Skip to contentSkip to conversation

Mini-os console

PATCH New Grzegorz Milos 1 participant 1 message Mar 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Mini-os console

The patch implements console for Mini-os.
It also fixes 2 bugs:
a) in initialising new page table frames
b) in initialising idle thread.

Could you apply Keir?

Thanks
Gregor

extras/mini-os/Makefile +1 -1
diff -r c445d4a0dd76 -r 0cd76c3fa05b extras/mini-os/Makefile
@@ -32,7 +32,7 @@
 OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
-#OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
+OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
 										   
 HDRS := $(wildcard include/*.h)
 HDRS += $(wildcard include/xen/*.h)
extras/mini-os/events.c +3 -2
diff -r c445d4a0dd76 -r 0cd76c3fa05b extras/mini-os/events.c
@@ -21,6 +21,7 @@
 #include <hypervisor.h>
 #include <events.h>
 #include <lib.h>
+
 
 static ev_action_t ev_actions[NR_EVS];
 void default_handler(int port, struct pt_regs *regs);
@@ -58,7 +59,7 @@
 
 int bind_evtchn( u32 port, void (*handler)(int, struct pt_regs *) )
 {
- 	if(ev_actions[port].handler)
+ 	if(ev_actions[port].handler != default_handler)
         printk("WARN: Handler for port %d already registered, replacing\n",
 				port);
 
@@ -73,7 +74,7 @@
 
 void unbind_evtchn( u32 port )
 {
-	if (!ev_actions[port].handler)
+	if (ev_actions[port].handler)
 		printk("WARN: No handler for port %d when unbinding\n", port);
 	ev_actions[port].handler = NULL;
 	ev_actions[port].status |= EVS_DISABLED;
extras/mini-os/include/lib.h +1 -4
diff -r c445d4a0dd76 -r 0cd76c3fa05b extras/mini-os/include/lib.h
@@ -56,13 +56,10 @@
 #define _LIB_H_
 
 #include <stdarg.h>
-
+#include <console.h>
 
 /* printing */
-#define printk  printf
-#define kprintf printf
 #define _p(_x) ((void *)(unsigned long)(_x))
-void printf(const char *fmt, ...);
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 int snprintf(char * buf, size_t size, const char *fmt, ...);
extras/mini-os/kernel.c +8 -2
diff -r c445d4a0dd76 -r 0cd76c3fa05b extras/mini-os/kernel.c
@@ -76,6 +76,8 @@
 }
 
 
+extern void init_console(void);
+
 /*
  * INITIAL C ENTRY POINT.
  */
@@ -127,15 +129,19 @@
 
     /* set up events */
     init_events();
+    
     /* init time and timers */
     init_time();
-    
+
+    /* init the console driver */
+    init_console();
+
     /* init scheduler */
     init_sched();
 
     /* init xenbus */
     xs_init();
-    
+   
     /* Everything initialised, start idle thread */
     run_idle_thread();
 }
extras/mini-os/lib/printf.c +0 -13
diff -r c445d4a0dd76 -r 0cd76c3fa05b extras/mini-os/lib/printf.c
@@ -556,19 +556,6 @@
     return i;
 }
 
-
-void printf(const char *fmt, ...)
-{
-    static char   buf[1024];
-    va_list       args;
-    
-    va_start(args, fmt);
-    (void)vsnprintf(buf, sizeof(buf), fmt, args);
-    va_end(args);        
-   
-    (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
-}
-
 /**
  * vsscanf - Unformat a buffer into a list of arguments
  * @buf:	input buffer
extras/mini-os/mm.c +4 -0
diff -r c445d4a0dd76 -r 0cd76c3fa05b extras/mini-os/mm.c
@@ -380,6 +380,10 @@
            "prev_l_mfn=%lx, offset=%lx\n", 
            level, *pt_pfn, prev_l_mfn, offset);
 
+    /* We need to clear the page, otherwise we might fail to map it
+       as a page table page */
+    memset((unsigned long*)pfn_to_virt(*pt_pfn), 0, PAGE_SIZE);  
+ 
     if (level == L1_FRAME)
     {
          prot_e = L1_PROT;
extras/mini-os/sched.c +2 -2
diff -r c445d4a0dd76 -r 0cd76c3fa05b extras/mini-os/sched.c
@@ -46,6 +46,7 @@
 #include <sched.h>
 #include <semaphore.h>
 
+
 #ifdef SCHED_DEBUG
 #define DEBUG(_f, _a...) \
     printk("MINI_OS(file=sched.c, line=%d) " _f "\n", __LINE__, ## _a)
@@ -61,7 +62,7 @@
 #define clear_runnable(_thread) (_thread->flags &= ~RUNNABLE_FLAG)
 
 
-struct thread *idle_thread;
+struct thread *idle_thread = NULL;
 LIST_HEAD(exited_threads);
 
 void dump_stack(struct thread *thread)
@@ -225,7 +226,6 @@
     for(;;)
     {
         schedule();
-        printk("Blocking the domain\n"); 
         block_domain(10000);
     }
 }
extras/mini-os/console/console.c new file +149 -0

149 lines not on this page · raw message

extras/mini-os/console/xencons_ring.c new file +104 -0

104 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel