Mini-os Xenbus
Minimal Xenbus implementation by Steven Smith replacing the old (broken)
implementation. The changeset also contains several bug fixes
including: BSS clearing, trap handler fix.
Signed-off-by Grzegorz Milos <[email protected]>
Keir could you apply?
Thanks.
extras/mini-os/Makefile +1 -2
@@ -41,8 +41,7 @@ links: [ -e include/xen ] || ln -sf ../../../xen/include/public include/xen - [ -e xenbus/xenstored.h ] || ln -sf ../../../tools/xenstore/xenstored.h xenbus/xenstored.h - + $(TARGET): links $(OBJS) $(LD) -N -T minios-$(TARGET_ARCH).lds $(OBJS) -o [email protected] gzip -f -9 -c [email protected] >[email protected]
extras/mini-os/console/console.c +5 -5
@@ -116,12 +116,12 @@ { (void )HYPERVISOR_console_io (CONSOLEIO_write,strlen (buf), buf);return ; + } else { +if (!console_initialised) + (void )HYPERVISOR_console_io (CONSOLEIO_write,strlen (buf), buf); + +console_print (buf,strlen (buf)); } - -if (!console_initialised) - (void )HYPERVISOR_console_io (CONSOLEIO_write,strlen (buf), buf); - -console_print (buf,strlen (buf)); }void printk (const char *fmt, ...)
extras/mini-os/console/xencons_ring.c +0 -2
@@ -10,7 +10,6 @@/* TODO - need to define BUG_ON for whole mini-os, need crash-dump as well */ -extern void do_exit (void );#define BUG_ON (_cond) do{if(_cond) do_exit();} while(0);static inline struct xencons_interface *xencons_interface (void )
@@ -29,7 +28,6 @@int sent =0 ;struct xencons_interface *intf =xencons_interface ();XENCONS_RING_IDX cons, prod; - cons = intf->out_cons; prod = intf->out_prod;mb ();
extras/mini-os/events.c +2 -2
@@ -74,9 +74,9 @@void unbind_evtchn (u32 port ) { -if (ev_actions[port].handler) +if (ev_actions[port].handler == default_handler)printk ("WARN: No handler for port %d when unbinding\n" , port); - ev_actions[port].handler =NULL ; + ev_actions[port].handler = default_handler; ev_actions[port].status |=EVS_DISABLED ; }
extras/mini-os/include/os.h +5 -0
@@ -9,6 +9,7 @@#define NULL 0 +#if __GNUC__ ==2 && __GNUC_MINOR__ <96 #define __builtin_expect (x, expected_value) (x)#endif
@@ -20,6 +21,10 @@#ifndef __ASSEMBLY__#include <types.h> #include <hypervisor.h> + +extern void do_exit (void ); +#define BUG do_exit +#endif #include <xen/xen.h>
extras/mini-os/include/wait.h +8 -0
@@ -66,6 +66,14 @@ } } +#define add_waiter (w, wq) do { \ + unsigned long flags; \ + local_irq_save(flags); \ + add_wait_queue(&wq, &w); \ + block(current); \ + local_irq_restore(flags); \ +} while (0) +#define wait_event (wq, condition) do{ \ unsigned long flags; \ if(condition) \
extras/mini-os/include/xenbus.h +4 -222
228 lines not on this page · raw message
extras/mini-os/kernel.c +23 -18
82 lines not on this page · raw message
extras/mini-os/minios-x86_32.lds +0 -9
@@ -21,15 +21,6 @@ _edata = .; /* End of data section */ - . = ALIGN(8192); /* init_task */ - .data.init_task : { *(.data.init_task) } - - . = ALIGN(4096); - .data.page_aligned : { *(.data.idt) } - - . = ALIGN(32); - .data.cacheline_aligned : { *(.data.cacheline_aligned) } - __bss_start = .; /* BSS */ .bss : { *(.bss)
extras/mini-os/mm.c +0 -1
@@ -51,7 +51,6 @@unsigned long *phys_to_machine_mapping;extern char *stack;extern char _text, _etext, _edata, _end; -extern void do_exit (void );extern void page_walk (unsigned long virt_addr);/*********************
extras/mini-os/sched.c +13 -16
@@ -65,6 +65,8 @@struct thread *idle_thread =NULL ;LIST_HEAD (exited_threads); +void idle_thread_fn (void *unused); +void dump_stack (struct thread *thread) {unsigned long *bottom = (unsigned long *)thread->stack +2048 ;
@@ -132,7 +134,7 @@xfree (thread); } } - next = idle_thread; + next = idle_thread;/* Thread list needs to be protected */ list_for_each (iterator, &idle_thread->thread_list) {
@@ -203,8 +205,13 @@set_runnable (thread);local_irq_save (flags); -if (idle_thread !=NULL ) +if (idle_thread !=NULL ) {list_add_tail (&thread->thread_list, &idle_thread->thread_list); + }else if (function != idle_thread_fn) + { +printk ("BUG: Not allowed to create thread before initialising scheduler.\n" ); +BUG (); + }local_irq_restore (flags);return thread;
@@ -282,19 +289,9 @@void init_sched (void ) { -printk ("Initialising scheduler\n" ); - +printk ("Initialising scheduler, idle_thread %p\n" , idle_thread); + idle_thread =create_thread ("Idle" , idle_thread_fn,NULL );INIT_LIST_HEAD (&idle_thread->thread_list); - - -/* create_thread("1", th_f1, (void *)0x1234); -create_thread("2", th_f1, (void *)0x1234); -create_thread("3", th_f1, (void *)0x1234); -create_thread("4", th_f1, (void *)0x1234); -create_thread("5", th_f1, (void *)0x1234); -create_thread("6", th_f1, (void *)0x1234); -create_thread("second", th_f2, NULL); -*/ -} - +} +
extras/mini-os/traps.c +18 -7
@@ -29,11 +29,18 @@void machine_check (void ); -extern void do_exit (void ); -void dump_regs (struct pt_regs *regs) { -printk ("FIXME: proper register dump (with the stack dump)\n" ); +printk ("EIP: %x, EFLAGS %x.\n" , regs->eip, regs->eflags); +printk ("EBX: %08x ECX: %08x EDX: %08x\n" , + regs->ebx, regs->ecx, regs->edx); +printk ("ESI: %08x EDI: %08x EBP: %08x EAX: %08x\n" , + regs->esi, regs->edi, regs->ebp, regs->eax); +printk ("DS: %04x ES: %04x orig_eax: %08x, eip: %08x\n" , + regs->xds, regs->xes, regs->orig_eax, regs->eip); +printk ("CS: %04x EFLAGS: %08x esp: %08x ss: %04x\n" , + regs->xcs, regs->eflags, regs->esp, regs->xss); + }
@@ -94,10 +101,14 @@ } -void do_page_fault (struct pt_regs *regs,unsigned long error_code, -unsigned long addr) -{ -printk ("Page fault at linear address %p\n" , addr); +#define read_cr2 () \ + (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2) + +void do_page_fault (struct pt_regs *regs,unsigned long error_code) +{ +unsigned long addr =read_cr2 (); +printk ("Page fault at linear address %p, regs %p, code %lx\n" , addr, regs, + error_code);dump_regs (regs);#ifdef __x86_64__/* FIXME: _PAGE_PSE */
extras/mini-os/x86_32.S +10 -35
67 lines not on this page · raw message
extras/mini-os/xenbus/xenbus.c new file +387 -0
387 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel