ia64/xen-unstable

view extras/mini-os/kernel.c @ 795:3a4eb84cc402

bitkeeper revision 1.485 (3f81b19fL5Y4lVlRaEpJI9r_IZlDcw)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/rn212/xeno.mini
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Mon Oct 06 18:17:03 2003 +0000 (2003-10-06)
parents 34473973889b
children 71f9c171157e
line source
1 /******************************************************************************
2 * kernel.c
3 *
4 * Assorted crap goes here, including the initial C entry point, jumped at
5 * from head.S.
6 */
8 #include <os.h>
9 #include <hypervisor.h>
10 #include <mm.h>
11 #include <events.h>
12 #include <time.h>
13 #include <types.h>
14 #include <lib.h>
16 /*
17 * Shared page for communicating with the hypervisor.
18 * Events flags go here, for example.
19 */
20 shared_info_t *HYPERVISOR_shared_info;
22 /*
23 * This structure contains start-of-day info, such as pagetable base pointer,
24 * address of the shared_info structure, and things like that.
25 */
26 union start_info_union start_info_union;
28 /*
29 * Just allocate the kernel stack here. SS:ESP is set up to point here
30 * in head.S.
31 */
32 char stack[8192];
35 /* Assembler interface fns in entry.S. */
36 void hypervisor_callback(void);
37 void failsafe_callback(void);
39 /* default event handlers */
40 static void exit_handler(int ev, struct pt_regs *regs);
41 static void debug_handler(int ev, struct pt_regs *regs);
44 /*
45 * INITIAL C ENTRY POINT.
46 */
47 void start_kernel(start_info_t *si)
48 {
49 int i;
51 /* Copy the start_info struct to a globally-accessible area. */
52 memcpy(&start_info, si, sizeof(*si));
54 /* Grab the shared_info pointer and put it in a safe place. */
55 HYPERVISOR_shared_info = start_info.shared_info;
57 /* Set up event and failsafe callback addresses. */
58 HYPERVISOR_set_callbacks(
59 __KERNEL_CS, (unsigned long)hypervisor_callback,
60 __KERNEL_CS, (unsigned long)failsafe_callback);
63 trap_init();
66 /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
67 __sti();
69 /* print out some useful information */
70 printk("Xeno Minimal OS!\n");
71 printk("start_info: %p\n", si);
72 printk(" nr_pages: %lu", si->nr_pages);
73 printk(" shared_inf: %p\n", si->shared_info);
74 printk(" pt_base: %p", (void *)si->pt_base);
75 printk(" mod_start: 0x%lx\n", si->mod_start);
76 printk(" mod_len: %lu\n", si->mod_len);
77 printk(" net_rings: ");
78 for (i = 0; i < MAX_DOMAIN_VIFS; i++) {
79 printk(" %lx", si->net_rings[i]);
80 }; printk("\n");
81 printk(" blk_ring: 0x%lx\n", si->blk_ring);
82 printk(" dom_id: %d\n", si->dom_id);
83 printk(" flags: 0x%lx\n", si->flags);
84 printk(" cmd_line: %s\n", si->cmd_line ? (const char *)si->cmd_line : "NULL");
87 /*
88 * If used for porting another OS, start here to figure out your
89 * guest os entry point. Otherwise continue below...
90 */
92 /* init memory management */
93 init_mm();
95 /* set up events */
96 init_events();
98 /* install some handlers */
99 add_ev_action(EV_DIE, &exit_handler);
100 enable_ev_action(EV_DIE);
101 enable_hypervisor_event(EV_DIE);
103 add_ev_action(EV_DEBUG, &debug_handler);
104 enable_ev_action(EV_DEBUG);
105 enable_hypervisor_event(EV_DEBUG);
107 /* init time and timers */
108 init_time();
110 /* do nothing */
111 for ( ; ; ) HYPERVISOR_yield();
112 }
115 /*
116 * do_exit: This is called whenever an IRET fails in entry.S.
117 * This will generally be because an application has got itself into
118 * a really bad state (probably a bad CS or SS). It must be killed.
119 * Of course, minimal OS doesn't have applications :-)
120 */
122 void do_exit(void)
123 {
124 printk("do_exit called!\n");
125 for ( ;; ) ;
126 }
127 static void exit_handler(int ev, struct pt_regs *regs) {
128 do_exit();
129 }
131 /*
132 * a debug handler to print out some state from the guest
133 */
134 static void debug_handler(int ev, struct pt_regs *regs) {
135 dump_regs(regs);
136 }