ia64/xen-unstable
changeset 11597:d913017a5c66
[MINIOS] Added a new file arc/x86/setup.c and moved some x86 specific
initialization stuff from kernel.c there. Two new functions are added
to handle this.
Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
initialization stuff from kernel.c there. Two new functions are added
to handle this.
Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
author | kfraser@localhost.localdomain |
---|---|
date | Sat Sep 23 14:00:38 2006 +0100 (2006-09-23) |
parents | 5c58df8c7885 |
children | 6d7bba6443ef |
files | extras/mini-os/arch/x86/setup.c extras/mini-os/include/x86/os.h extras/mini-os/kernel.c |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/extras/mini-os/arch/x86/setup.c Sat Sep 23 14:00:38 2006 +0100 1.3 @@ -0,0 +1,108 @@ 1.4 +/****************************************************************************** 1.5 + * common.c 1.6 + * 1.7 + * Common stuff special to x86 goes here. 1.8 + * 1.9 + * Copyright (c) 2002-2003, K A Fraser & R Neugebauer 1.10 + * Copyright (c) 2005, Grzegorz Milos, Intel Research Cambridge 1.11 + * 1.12 + * Permission is hereby granted, free of charge, to any person obtaining a copy 1.13 + * of this software and associated documentation files (the "Software"), to 1.14 + * deal in the Software without restriction, including without limitation the 1.15 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 1.16 + * sell copies of the Software, and to permit persons to whom the Software is 1.17 + * furnished to do so, subject to the following conditions: 1.18 + * 1.19 + * The above copyright notice and this permission notice shall be included in 1.20 + * all copies or substantial portions of the Software. 1.21 + * 1.22 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.23 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.24 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1.25 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1.26 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1.27 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 1.28 + * DEALINGS IN THE SOFTWARE. 1.29 + * 1.30 + */ 1.31 + 1.32 +#include <os.h> 1.33 + 1.34 + 1.35 +/* 1.36 + * Shared page for communicating with the hypervisor. 1.37 + * Events flags go here, for example. 1.38 + */ 1.39 +shared_info_t *HYPERVISOR_shared_info; 1.40 + 1.41 +/* 1.42 + * This structure contains start-of-day info, such as pagetable base pointer, 1.43 + * address of the shared_info structure, and things like that. 1.44 + */ 1.45 +union start_info_union start_info_union; 1.46 + 1.47 +/* 1.48 + * Just allocate the kernel stack here. SS:ESP is set up to point here 1.49 + * in head.S. 1.50 + */ 1.51 +char stack[8192]; 1.52 + 1.53 +extern char shared_info[PAGE_SIZE]; 1.54 + 1.55 +/* Assembler interface fns in entry.S. */ 1.56 +void hypervisor_callback(void); 1.57 +void failsafe_callback(void); 1.58 + 1.59 +#if !defined(CONFIG_X86_PAE) 1.60 +#define __pte(x) ((pte_t) { (x) } ) 1.61 +#else 1.62 +#define __pte(x) ({ unsigned long long _x = (x); \ 1.63 + ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); }) 1.64 +#endif 1.65 + 1.66 +static 1.67 +shared_info_t *map_shared_info(unsigned long pa) 1.68 +{ 1.69 + if ( HYPERVISOR_update_va_mapping( 1.70 + (unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG) ) 1.71 + { 1.72 + printk("Failed to map shared_info!!\n"); 1.73 + do_exit(); 1.74 + } 1.75 + return (shared_info_t *)shared_info; 1.76 +} 1.77 + 1.78 +void 1.79 +arch_init(start_info_t *si) 1.80 +{ 1.81 + /* Copy the start_info struct to a globally-accessible area. */ 1.82 + /* WARN: don't do printk before here, it uses information from 1.83 + shared_info. Use xprintk instead. */ 1.84 + memcpy(&start_info, si, sizeof(*si)); 1.85 + 1.86 + /* set up minimal memory infos */ 1.87 + phys_to_machine_mapping = (unsigned long *)start_info.mfn_list; 1.88 + 1.89 + /* Grab the shared_info pointer and put it in a safe place. */ 1.90 + HYPERVISOR_shared_info = map_shared_info(start_info.shared_info); 1.91 + 1.92 + /* Set up event and failsafe callback addresses. */ 1.93 +#ifdef __i386__ 1.94 + HYPERVISOR_set_callbacks( 1.95 + __KERNEL_CS, (unsigned long)hypervisor_callback, 1.96 + __KERNEL_CS, (unsigned long)failsafe_callback); 1.97 +#else 1.98 + HYPERVISOR_set_callbacks( 1.99 + (unsigned long)hypervisor_callback, 1.100 + (unsigned long)failsafe_callback, 0); 1.101 +#endif 1.102 + 1.103 +} 1.104 + 1.105 +void 1.106 +arch_print_info(void) 1.107 +{ 1.108 + printk(" stack: %p-%p\n", stack, stack + 8192); 1.109 +} 1.110 + 1.111 +
2.1 --- a/extras/mini-os/include/x86/os.h Sat Sep 23 13:57:55 2006 +0100 2.2 +++ b/extras/mini-os/include/x86/os.h Sat Sep 23 14:00:38 2006 +0100 2.3 @@ -61,6 +61,11 @@ extern shared_info_t *HYPERVISOR_shared_ 2.4 2.5 void trap_init(void); 2.6 2.7 +void arch_init(start_info_t *si); 2.8 +void arch_print_info(void); 2.9 + 2.10 + 2.11 + 2.12 2.13 2.14 /*
3.1 --- a/extras/mini-os/kernel.c Sat Sep 23 13:57:55 2006 +0100 3.2 +++ b/extras/mini-os/kernel.c Sat Sep 23 14:00:38 2006 +0100 3.3 @@ -39,49 +39,6 @@ 3.4 #include <xen/features.h> 3.5 #include <xen/version.h> 3.6 3.7 -/* 3.8 - * Shared page for communicating with the hypervisor. 3.9 - * Events flags go here, for example. 3.10 - */ 3.11 -shared_info_t *HYPERVISOR_shared_info; 3.12 - 3.13 -/* 3.14 - * This structure contains start-of-day info, such as pagetable base pointer, 3.15 - * address of the shared_info structure, and things like that. 3.16 - */ 3.17 -union start_info_union start_info_union; 3.18 - 3.19 -/* 3.20 - * Just allocate the kernel stack here. SS:ESP is set up to point here 3.21 - * in head.S. 3.22 - */ 3.23 -char stack[8192]; 3.24 - 3.25 - 3.26 -/* Assembler interface fns in entry.S. */ 3.27 -void hypervisor_callback(void); 3.28 -void failsafe_callback(void); 3.29 - 3.30 -extern char shared_info[PAGE_SIZE]; 3.31 - 3.32 -#if !defined(CONFIG_X86_PAE) 3.33 -#define __pte(x) ((pte_t) { (x) } ) 3.34 -#else 3.35 -#define __pte(x) ({ unsigned long long _x = (x); \ 3.36 - ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); }) 3.37 -#endif 3.38 - 3.39 -static shared_info_t *map_shared_info(unsigned long pa) 3.40 -{ 3.41 - if ( HYPERVISOR_update_va_mapping( 3.42 - (unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG) ) 3.43 - { 3.44 - printk("Failed to map shared_info!!\n"); 3.45 - do_exit(); 3.46 - } 3.47 - return (shared_info_t *)shared_info; 3.48 -} 3.49 - 3.50 3.51 u8 xen_features[XENFEAT_NR_SUBMAPS * 32]; 3.52 3.53 @@ -126,27 +83,8 @@ void start_kernel(start_info_t *si) 3.54 3.55 (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello); 3.56 3.57 - /* Copy the start_info struct to a globally-accessible area. */ 3.58 - /* WARN: don't do printk before here, it uses information from 3.59 - shared_info. Use xprintk instead. */ 3.60 - memcpy(&start_info, si, sizeof(*si)); 3.61 - 3.62 - /* set up minimal memory infos */ 3.63 - phys_to_machine_mapping = (unsigned long *)start_info.mfn_list; 3.64 - 3.65 - /* Grab the shared_info pointer and put it in a safe place. */ 3.66 - HYPERVISOR_shared_info = map_shared_info(start_info.shared_info); 3.67 + arch_init(si); 3.68 3.69 - /* Set up event and failsafe callback addresses. */ 3.70 -#ifdef __i386__ 3.71 - HYPERVISOR_set_callbacks( 3.72 - __KERNEL_CS, (unsigned long)hypervisor_callback, 3.73 - __KERNEL_CS, (unsigned long)failsafe_callback); 3.74 -#else 3.75 - HYPERVISOR_set_callbacks( 3.76 - (unsigned long)hypervisor_callback, 3.77 - (unsigned long)failsafe_callback, 0); 3.78 -#endif 3.79 trap_init(); 3.80 3.81 /* ENABLE EVENT DELIVERY. This is disabled at start of day. */ 3.82 @@ -163,7 +101,8 @@ void start_kernel(start_info_t *si) 3.83 printk(" flags: 0x%x\n", (unsigned int)si->flags); 3.84 printk(" cmd_line: %s\n", 3.85 si->cmd_line ? (const char *)si->cmd_line : "NULL"); 3.86 - printk(" stack: %p-%p\n", stack, stack + 8192); 3.87 + 3.88 + arch_print_info(); 3.89 3.90 setup_xen_features(); 3.91