ia64/xen-unstable

view extras/mini-os/kernel.c @ 12327:eea9247ad5a0

[XENOPROF] Oprofile user level samples for passive domains are being lost.
The number of of lost samples is most significant when dom0 is idle.

From: joserenato.santos@hp.com
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Nov 09 11:47:42 2006 +0000 (2006-11-09)
parents d913017a5c66
children 0839db0aa611
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>
36 #include <sched.h>
37 #include <xenbus.h>
38 #include <gnttab.h>
39 #include <xen/features.h>
40 #include <xen/version.h>
43 u8 xen_features[XENFEAT_NR_SUBMAPS * 32];
45 void setup_xen_features(void)
46 {
47 xen_feature_info_t fi;
48 int i, j;
50 for (i = 0; i < XENFEAT_NR_SUBMAPS; i++)
51 {
52 fi.submap_idx = i;
53 if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0)
54 break;
56 for (j=0; j<32; j++)
57 xen_features[i*32+j] = !!(fi.submap & 1<<j);
58 }
59 }
61 void test_xenbus(void);
63 void xenbus_tester(void *p)
64 {
65 printk("Xenbus tests disabled, because of a Xend bug.\n");
66 /* test_xenbus(); */
67 }
69 /* This should be overridden by the application we are linked against. */
70 __attribute__((weak)) int app_main(start_info_t *si)
71 {
72 printk("Dummy main: start_info=%p\n", si);
73 create_thread("xenbus_tester", xenbus_tester, si);
74 return 0;
75 }
77 /*
78 * INITIAL C ENTRY POINT.
79 */
80 void start_kernel(start_info_t *si)
81 {
82 static char hello[] = "Bootstrapping...\n";
84 (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello);
86 arch_init(si);
88 trap_init();
90 /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
91 __sti();
93 /* print out some useful information */
94 printk("Xen Minimal OS!\n");
95 printk("start_info: %p\n", si);
96 printk(" nr_pages: %lu", si->nr_pages);
97 printk(" shared_inf: %08lx\n", si->shared_info);
98 printk(" pt_base: %p", (void *)si->pt_base);
99 printk(" mod_start: 0x%lx\n", si->mod_start);
100 printk(" mod_len: %lu\n", si->mod_len);
101 printk(" flags: 0x%x\n", (unsigned int)si->flags);
102 printk(" cmd_line: %s\n",
103 si->cmd_line ? (const char *)si->cmd_line : "NULL");
105 arch_print_info();
107 setup_xen_features();
109 /* Init memory management. */
110 init_mm();
112 /* Set up events. */
113 init_events();
115 /* Init time and timers. */
116 init_time();
118 /* Init the console driver. */
119 init_console();
121 /* Init grant tables */
122 init_gnttab();
124 /* Init scheduler. */
125 init_sched();
127 /* Init XenBus */
128 init_xenbus();
130 /* Call (possibly overridden) app_main() */
131 app_main(&start_info);
133 /* Everything initialised, start idle thread */
134 run_idle_thread();
135 }
138 /*
139 * do_exit: This is called whenever an IRET fails in entry.S.
140 * This will generally be because an application has got itself into
141 * a really bad state (probably a bad CS or SS). It must be killed.
142 * Of course, minimal OS doesn't have applications :-)
143 */
145 void do_exit(void)
146 {
147 printk("Do_exit called!\n");
148 for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
149 }