direct-io.hg

view extras/mini-os/kernel.c @ 11356:af7c87d42bc6

[XEN][POWERPC] Fix PHDR issues with large .data.percpu sections

This patch tells the link to only create one PHDR and place all sections
in it, also removing an unrequired mapping for the .data.percpu section.

This avoids the "Not enough room for program headers (allocated 2, need 3)"

Booted on a JS20.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Thu Aug 17 07:10:57 2006 -0400 (2006-08-17)
parents bbea54da02b5
children d913017a5c66
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>
42 /*
43 * Shared page for communicating with the hypervisor.
44 * Events flags go here, for example.
45 */
46 shared_info_t *HYPERVISOR_shared_info;
48 /*
49 * This structure contains start-of-day info, such as pagetable base pointer,
50 * address of the shared_info structure, and things like that.
51 */
52 union start_info_union start_info_union;
54 /*
55 * Just allocate the kernel stack here. SS:ESP is set up to point here
56 * in head.S.
57 */
58 char stack[8192];
61 /* Assembler interface fns in entry.S. */
62 void hypervisor_callback(void);
63 void failsafe_callback(void);
65 extern char shared_info[PAGE_SIZE];
67 #if !defined(CONFIG_X86_PAE)
68 #define __pte(x) ((pte_t) { (x) } )
69 #else
70 #define __pte(x) ({ unsigned long long _x = (x); \
71 ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
72 #endif
74 static shared_info_t *map_shared_info(unsigned long pa)
75 {
76 if ( HYPERVISOR_update_va_mapping(
77 (unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG) )
78 {
79 printk("Failed to map shared_info!!\n");
80 do_exit();
81 }
82 return (shared_info_t *)shared_info;
83 }
86 u8 xen_features[XENFEAT_NR_SUBMAPS * 32];
88 void setup_xen_features(void)
89 {
90 xen_feature_info_t fi;
91 int i, j;
93 for (i = 0; i < XENFEAT_NR_SUBMAPS; i++)
94 {
95 fi.submap_idx = i;
96 if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0)
97 break;
99 for (j=0; j<32; j++)
100 xen_features[i*32+j] = !!(fi.submap & 1<<j);
101 }
102 }
104 void test_xenbus(void);
106 void xenbus_tester(void *p)
107 {
108 printk("Xenbus tests disabled, because of a Xend bug.\n");
109 /* test_xenbus(); */
110 }
112 /* This should be overridden by the application we are linked against. */
113 __attribute__((weak)) int app_main(start_info_t *si)
114 {
115 printk("Dummy main: start_info=%p\n", si);
116 create_thread("xenbus_tester", xenbus_tester, si);
117 return 0;
118 }
120 /*
121 * INITIAL C ENTRY POINT.
122 */
123 void start_kernel(start_info_t *si)
124 {
125 static char hello[] = "Bootstrapping...\n";
127 (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello);
129 /* Copy the start_info struct to a globally-accessible area. */
130 /* WARN: don't do printk before here, it uses information from
131 shared_info. Use xprintk instead. */
132 memcpy(&start_info, si, sizeof(*si));
134 /* set up minimal memory infos */
135 phys_to_machine_mapping = (unsigned long *)start_info.mfn_list;
137 /* Grab the shared_info pointer and put it in a safe place. */
138 HYPERVISOR_shared_info = map_shared_info(start_info.shared_info);
140 /* Set up event and failsafe callback addresses. */
141 #ifdef __i386__
142 HYPERVISOR_set_callbacks(
143 __KERNEL_CS, (unsigned long)hypervisor_callback,
144 __KERNEL_CS, (unsigned long)failsafe_callback);
145 #else
146 HYPERVISOR_set_callbacks(
147 (unsigned long)hypervisor_callback,
148 (unsigned long)failsafe_callback, 0);
149 #endif
150 trap_init();
152 /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
153 __sti();
155 /* print out some useful information */
156 printk("Xen Minimal OS!\n");
157 printk("start_info: %p\n", si);
158 printk(" nr_pages: %lu", si->nr_pages);
159 printk(" shared_inf: %08lx\n", si->shared_info);
160 printk(" pt_base: %p", (void *)si->pt_base);
161 printk(" mod_start: 0x%lx\n", si->mod_start);
162 printk(" mod_len: %lu\n", si->mod_len);
163 printk(" flags: 0x%x\n", (unsigned int)si->flags);
164 printk(" cmd_line: %s\n",
165 si->cmd_line ? (const char *)si->cmd_line : "NULL");
166 printk(" stack: %p-%p\n", stack, stack + 8192);
168 setup_xen_features();
170 /* Init memory management. */
171 init_mm();
173 /* Set up events. */
174 init_events();
176 /* Init time and timers. */
177 init_time();
179 /* Init the console driver. */
180 init_console();
182 /* Init grant tables */
183 init_gnttab();
185 /* Init scheduler. */
186 init_sched();
188 /* Init XenBus */
189 init_xenbus();
191 /* Call (possibly overridden) app_main() */
192 app_main(&start_info);
194 /* Everything initialised, start idle thread */
195 run_idle_thread();
196 }
199 /*
200 * do_exit: This is called whenever an IRET fails in entry.S.
201 * This will generally be because an application has got itself into
202 * a really bad state (probably a bad CS or SS). It must be killed.
203 * Of course, minimal OS doesn't have applications :-)
204 */
206 void do_exit(void)
207 {
208 printk("Do_exit called!\n");
209 for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
210 }