ia64/xen-unstable

view extras/mini-os/kernel.c @ 6685:549f4256ab3c

Remove control interface in kernels and domain builder.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 07 17:43:56 2005 +0000 (2005-09-07)
parents dd668f7527cb
children df1348e72390 cdfa7dd00c44
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 *
7 * Copyright (c) 2002-2003, K A Fraser & R Neugebauer
8 * Copyright (c) 2005, Grzegorz Milos, Intel Research Cambridge
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to
12 * deal in the Software without restriction, including without limitation the
13 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 * sell copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 */
29 #include <os.h>
30 #include <hypervisor.h>
31 #include <mm.h>
32 #include <events.h>
33 #include <time.h>
34 #include <types.h>
35 #include <lib.h>
37 /*
38 * Shared page for communicating with the hypervisor.
39 * Events flags go here, for example.
40 */
41 shared_info_t *HYPERVISOR_shared_info;
43 /*
44 * This structure contains start-of-day info, such as pagetable base pointer,
45 * address of the shared_info structure, and things like that.
46 */
47 union start_info_union start_info_union;
49 /*
50 * Just allocate the kernel stack here. SS:ESP is set up to point here
51 * in head.S.
52 */
53 char stack[8192];
56 /* Assembler interface fns in entry.S. */
57 void hypervisor_callback(void);
58 void failsafe_callback(void);
60 extern char shared_info[PAGE_SIZE];
62 static shared_info_t *map_shared_info(unsigned long pa)
63 {
64 if ( HYPERVISOR_update_va_mapping(
65 (unsigned long)shared_info, pa | 7, UVMF_INVLPG) )
66 {
67 printk("Failed to map shared_info!!\n");
68 *(int*)0=0;
69 }
70 return (shared_info_t *)shared_info;
71 }
74 /*
75 * INITIAL C ENTRY POINT.
76 */
77 void start_kernel(start_info_t *si)
78 {
79 static char hello[] = "Bootstrapping...\n";
80 int i;
81 (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello);
83 /* Copy the start_info struct to a globally-accessible area. */
84 memcpy(&start_info, si, sizeof(*si));
86 /* Grab the shared_info pointer and put it in a safe place. */
87 HYPERVISOR_shared_info = map_shared_info(start_info.shared_info);
89 /* Set up event and failsafe callback addresses. */
90 #ifdef __i386__
91 HYPERVISOR_set_callbacks(
92 __KERNEL_CS, (unsigned long)hypervisor_callback,
93 __KERNEL_CS, (unsigned long)failsafe_callback);
94 #else
95 HYPERVISOR_set_callbacks(
96 (unsigned long)hypervisor_callback,
97 (unsigned long)failsafe_callback, 0);
98 #endif
100 trap_init();
102 /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
103 __sti();
105 /* print out some useful information */
106 printk("Xen Minimal OS!\n");
107 printk("start_info: %p\n", si);
108 printk(" nr_pages: %lu", si->nr_pages);
109 printk(" shared_inf: %08lx\n", si->shared_info);
110 printk(" pt_base: %p", (void *)si->pt_base);
111 printk(" mod_start: 0x%lx\n", si->mod_start);
112 printk(" mod_len: %lu\n", si->mod_len);
113 printk(" flags: 0x%x\n", (unsigned int)si->flags);
114 printk(" cmd_line: %s\n",
115 si->cmd_line ? (const char *)si->cmd_line : "NULL");
118 /*
119 * If used for porting another OS, start here to figure out your
120 * guest os entry point. Otherwise continue below...
121 */
123 /* init memory management */
124 init_mm();
126 /* set up events */
127 init_events();
128 /* init time and timers */
129 init_time();
131 /* do nothing */
132 i = 0;
133 for ( ; ; )
134 {
135 // HYPERVISOR_yield();
136 block(100);
137 i++;
138 }
139 }
142 /*
143 * do_exit: This is called whenever an IRET fails in entry.S.
144 * This will generally be because an application has got itself into
145 * a really bad state (probably a bad CS or SS). It must be killed.
146 * Of course, minimal OS doesn't have applications :-)
147 */
149 void do_exit(void)
150 {
151 printk("do_exit called!\n");
152 for ( ;; ) HYPERVISOR_shutdown();
153 }