[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [POWERPC][XEN] Use multiboot2 data structures when present.
# HG changeset patch # User Hollis Blanchard <hollisb@xxxxxxxxxx> # Date 1185833445 18000 # Node ID 553f64e4f6efb0482490324a8e7cd99d3a9a653d # Parent a94bf8086002290270f3e6c6a464986462ba8809 [POWERPC][XEN] Use multiboot2 data structures when present. Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx> --- xen/arch/powerpc/Makefile | 1 xen/arch/powerpc/boot_of.c | 180 ++++++------------------------------------ xen/arch/powerpc/exceptions.h | 3 xen/arch/powerpc/memory.c | 3 xen/arch/powerpc/oftree.h | 4 xen/arch/powerpc/setup.c | 155 ++++++++++++++++++++++-------------- xen/include/asm-powerpc/mm.h | 1 7 files changed, 125 insertions(+), 222 deletions(-) diff -r a94bf8086002 -r 553f64e4f6ef xen/arch/powerpc/Makefile --- a/xen/arch/powerpc/Makefile Mon Jul 30 13:50:14 2007 -0500 +++ b/xen/arch/powerpc/Makefile Mon Jul 30 17:10:45 2007 -0500 @@ -27,6 +27,7 @@ obj-y += mm.o obj-y += mm.o obj-y += mpic.o obj-y += mpic_init.o +obj-y += multiboot2.o obj-y += numa.o obj-y += of-devtree.o obj-y += of-devwalk.o diff -r a94bf8086002 -r 553f64e4f6ef xen/arch/powerpc/boot_of.c --- a/xen/arch/powerpc/boot_of.c Mon Jul 30 13:50:14 2007 -0500 +++ b/xen/arch/powerpc/boot_of.c Mon Jul 30 17:10:45 2007 -0500 @@ -22,7 +22,6 @@ #include <xen/config.h> #include <xen/init.h> #include <xen/lib.h> -#include <xen/multiboot.h> #include <xen/version.h> #include <xen/spinlock.h> #include <xen/serial.h> @@ -30,6 +29,7 @@ #include <xen/sched.h> #include <asm/page.h> #include <asm/io.h> +#include <asm/boot.h> #include "exceptions.h" #include "of-devtree.h" #include "oftree.h" @@ -54,7 +54,6 @@ static ulong eomem; #define MEM_AVAILABLE_PAGES ((32 << 20) >> PAGE_SHIFT) static DECLARE_BITMAP(mem_available_pages, MEM_AVAILABLE_PAGES); -extern char builtin_cmdline[]; extern struct ns16550_defaults ns16550; #undef OF_DEBUG @@ -648,23 +647,6 @@ static ulong boot_of_mem_init(void) return 0; } -static void boot_of_bootargs(multiboot_info_t *mbi) -{ - int rc; - - if (builtin_cmdline[0] == '\0') { - rc = of_getprop(bof_chosen, "bootargs", builtin_cmdline, - CONFIG_CMDLINE_SIZE); - if (rc > CONFIG_CMDLINE_SIZE) - of_panic("bootargs[] not big enough for /chosen/bootargs\n"); - } - - mbi->flags |= MBI_CMDLINE; - mbi->cmdline = (ulong)builtin_cmdline; - - of_printf("bootargs = %s\n", builtin_cmdline); -} - static int save_props(void *m, ofdn_t n, int pkg) { int ret; @@ -933,8 +915,8 @@ static void __init boot_of_fix_maple(voi } } } - -static int __init boot_of_serial(void *oft) + +void __init boot_of_serial(void *oft) { int n; int p; @@ -1014,11 +996,9 @@ static int __init boot_of_serial(void *o __func__, ns16550.irq); ns16550.irq = 0; } - - return 1; -} - -static int __init boot_of_rtas(module_t *mod, multiboot_info_t *mbi) +} + +static int __init boot_of_rtas(void) { int rtas_node; int rtas_instance; @@ -1065,14 +1045,13 @@ static int __init boot_of_rtas(module_t rtas_end = mem + size; rtas_msr = of_msr; - mod->mod_start = rtas_base; - mod->mod_end = rtas_end; return 1; } -static void * __init boot_of_devtree(module_t *mod, multiboot_info_t *mbi) +void __init *boot_of_devtree(void) { void *oft; + ulong oft_sz = 48 * PAGE_SIZE; ulong alloc_sz = 32 << 10; /* 32KiB should be plenty */ ulong sz; @@ -1100,108 +1079,9 @@ static void * __init boot_of_devtree(mod ofd_walk(oft, __func__, OFD_ROOT, /* add_hype_props */ NULL, 2); - mod->mod_start = (ulong)oft; - mod->mod_end = ALIGN_UP(mod->mod_start + sz, PAGE_SIZE); - - if (mod->mod_end -mod->mod_start > alloc_sz) - of_panic("Could not fit all devtree module in 0x%lx of memory\n", - alloc_sz); - - of_printf("%s: devtree mod @ 0x%016x - 0x%016x\n", __func__, - mod->mod_start, mod->mod_end); - - return oft; -} - -static void * __init boot_of_module(ulong r3, ulong r4, multiboot_info_t *mbi) -{ - static module_t mods[4]; - ulong mod0_start; - ulong mod0_size; - static const char * sepr[] = {" -- ", " || "}; - int sepr_index; - extern char dom0_start[] __attribute__ ((weak)); - extern char dom0_size[] __attribute__ ((weak)); - const char *p = NULL; - int mod; - void *oft; - - if ((r3 > 0) && (r4 > 0)) { - /* was it handed to us in registers ? */ - mod0_start = r3; - mod0_size = r4; - of_printf("%s: Dom0 was loaded and found using r3/r4:" - "0x%lx[size 0x%lx]\n", - __func__, mod0_start, mod0_size); - } else { - /* see if it is in the boot params */ - p = strstr((char *)((ulong)mbi->cmdline), "dom0_start="); - if ( p != NULL) { - p += 11; - mod0_start = simple_strtoul(p, NULL, 0); - - p = strstr((char *)((ulong)mbi->cmdline), "dom0_size="); - p += 10; - mod0_size = simple_strtoul(p, NULL, 0); - of_printf("%s: Dom0 was loaded and found using cmdline:" - "0x%lx[size 0x%lx]\n", - __func__, mod0_start, mod0_size); - } else if ( ((ulong)dom0_start != 0) && ((ulong)dom0_size != 0) ) { - /* was it linked in ? */ - - mod0_start = (ulong)dom0_start; - mod0_size = (ulong)dom0_size; - of_printf("%s: Dom0 is linked in: 0x%lx[size 0x%lx]\n", - __func__, mod0_start, mod0_size); - } else { - mod0_start = (ulong)_end; - mod0_size = 0; - of_printf("%s: FYI Dom0 is unknown, will be caught later\n", - __func__); - } - } - - if (mod0_size > 0) { - const char *c = (const char *)mod0_start; - - of_printf("mod0: %o %c %c %c\n", c[0], c[1], c[2], c[3]); - } - - mod = 0; - mods[mod].mod_start = mod0_start; - mods[mod].mod_end = mod0_start + mod0_size; - - of_printf("%s: dom0 mod @ 0x%016x[0x%x]\n", __func__, - mods[mod].mod_start, mods[mod].mod_end); - - /* look for delimiter: "--" or "||" */ - for (sepr_index = 0; sepr_index < ARRAY_SIZE(sepr); sepr_index++){ - p = strstr((char *)(ulong)mbi->cmdline, sepr[sepr_index]); - if (p != NULL) - break; - } - - if (p != NULL) { - /* Xen proper should never know about the dom0 args. */ - *(char *)p = '\0'; - p += strlen(sepr[sepr_index]); - mods[mod].string = (u32)(ulong)p; - of_printf("%s: dom0 mod string: %s\n", __func__, p); - } - - ++mod; - if (boot_of_rtas(&mods[mod], mbi)) - ++mod; - - oft = boot_of_devtree(&mods[mod], mbi); - if (oft == NULL) - of_panic("%s: boot_of_devtree failed\n", __func__); - - ++mod; - - mbi->flags |= MBI_MODULES; - mbi->mods_count = mod; - mbi->mods_addr = (u32)mods; + oftree = (ulong)oft; + oftree = (ulong)oft + oft_sz; + oftree_len = oft_sz; return oft; } @@ -1327,15 +1207,19 @@ static int __init boot_of_cpus(void) return 1; } -multiboot_info_t __init *boot_of_init( - ulong r3, ulong r4, ulong vec, ulong r6, ulong r7, ulong orig_msr) -{ - static multiboot_info_t mbi; - void *oft; +void __init boot_of_init(ulong vec, ulong orig_msr) +{ int r; of_vec = vec; of_msr = orig_msr; + + if (is_kernel(vec)) { + of_panic("Hmm.. OF[0x%lx] seems to have stepped on our image " + "that ranges: %p .. %p.\n", + vec, _start, _end); + } + of_printf("%s: _start %p _end %p\n", __func__, _start, _end); bof_chosen = of_finddevice("/chosen"); of_getprop(bof_chosen, "stdout", &of_out, sizeof (of_out)); @@ -1346,32 +1230,20 @@ multiboot_info_t __init *boot_of_init( xen_compile_by(), xen_compile_domain(), xen_compiler(), xen_compile_date()); - of_printf("%s args: 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n" - "boot msr: 0x%lx\n", - __func__, - r3, r4, vec, r6, r7, orig_msr); - - if (is_kernel(vec)) { - of_panic("Hmm.. OF[0x%lx] seems to have stepped on our image " - "that ranges: %p .. %p.\n", - vec, _start, _end); - } - of_printf("%s: _start %p _end %p 0x%lx\n", __func__, _start, _end, r6); - boot_of_fix_maple(); r = boot_of_mem_init(); if (r == 0) of_panic("failure to initialize memory allocator"); - boot_of_bootargs(&mbi); - oft = boot_of_module(r3, r4, &mbi); + + boot_of_rtas(); boot_of_cpus(); - boot_of_serial(oft); - +} + +void __init boot_of_finish(void) +{ /* end of OF */ of_printf("Quiescing Open Firmware ...\n"); of_call("quiesce", 0, 0, NULL); - - return &mbi; } /* diff -r a94bf8086002 -r 553f64e4f6ef xen/arch/powerpc/exceptions.h --- a/xen/arch/powerpc/exceptions.h Mon Jul 30 13:50:14 2007 -0500 +++ b/xen/arch/powerpc/exceptions.h Mon Jul 30 17:10:45 2007 -0500 @@ -33,9 +33,6 @@ extern void ack_APIC_irq(void); extern void ack_APIC_irq(void); extern int ioapic_guest_read(unsigned long physbase, unsigned int reg, u32 *pval); extern int ioapic_guest_write(unsigned long physbase, unsigned int reg, u32 val); -extern void __start_xen_ppc( - ulong r3, ulong r4, ulong r5, ulong r6, ulong r7, ulong orig_msr); -extern multiboot_info_t *boot_of_init(ulong r3, ulong r4, ulong vec, ulong r6, ulong r7, ulong orig_msr); extern void do_timer(struct cpu_user_regs *regs); extern void do_dec(struct cpu_user_regs *regs); diff -r a94bf8086002 -r 553f64e4f6ef xen/arch/powerpc/memory.c --- a/xen/arch/powerpc/memory.c Mon Jul 30 13:50:14 2007 -0500 +++ b/xen/arch/powerpc/memory.c Mon Jul 30 17:10:45 2007 -0500 @@ -21,6 +21,7 @@ #include <xen/sched.h> #include <xen/mm.h> #include <xen/numa.h> +#include <asm/boot.h> #include "of-devtree.h" #include "oftree.h" #include "rtas.h" @@ -116,7 +117,7 @@ static void ofd_walk_mem(void *m, walk_m } } -void memory_init(module_t *mod, int mcount) +void memory_init(void) { ulong eomem; ulong bitmap_start = ~0UL; diff -r a94bf8086002 -r 553f64e4f6ef xen/arch/powerpc/oftree.h --- a/xen/arch/powerpc/oftree.h Mon Jul 30 13:50:14 2007 -0500 +++ b/xen/arch/powerpc/oftree.h Mon Jul 30 17:10:45 2007 -0500 @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (C) IBM Corp. 2005 + * Copyright IBM Corp. 2005 * * Authors: Jimi Xenidis <jimix@xxxxxxxxxxxxxx> */ @@ -35,6 +35,4 @@ extern int firmware_image_start[0]; extern int firmware_image_start[0]; extern int firmware_image_size[0]; -extern void memory_init(module_t *mod, int mcount); - #endif /* #ifndef _OFTREE_H */ diff -r a94bf8086002 -r 553f64e4f6ef xen/arch/powerpc/setup.c --- a/xen/arch/powerpc/setup.c Mon Jul 30 13:50:14 2007 -0500 +++ b/xen/arch/powerpc/setup.c Mon Jul 30 17:10:45 2007 -0500 @@ -25,7 +25,7 @@ #include <xen/lib.h> #include <xen/cpumask.h> #include <xen/sched.h> -#include <xen/multiboot.h> +#include <xen/multiboot2.h> #include <xen/serial.h> #include <xen/softirq.h> #include <xen/console.h> @@ -48,6 +48,7 @@ #include <asm/delay.h> #include <asm/percpu.h> #include <asm/io.h> +#include <asm/boot.h> #include "exceptions.h" #include "of-devtree.h" #include "oftree.h" @@ -78,6 +79,17 @@ ulong oftree; ulong oftree; ulong oftree_len; ulong oftree_end; + +/* linked-in dom0: */ +extern char dom0_start[] __attribute__ ((weak)); +extern char dom0_size[] __attribute__ ((weak)); + +char *xen_cmdline; +char *dom0_cmdline; +ulong dom0_addr; +ulong dom0_len; +ulong initrd_start; +ulong initrd_len; uint cpu_hard_id[NR_CPUS] __initdata; cpumask_t cpu_present_map; @@ -286,21 +298,15 @@ void secondary_cpu_init(int cpuid, unsig panic("should never get here\n"); } -static void __init __start_xen(multiboot_info_t *mbi) -{ - char *cmdline; - module_t *mod = (module_t *)((ulong)mbi->mods_addr); - ulong dom0_start, dom0_len; - ulong initrd_start, initrd_len; - +static void __init __start_xen(void) +{ memcpy(0, exception_vectors, exception_vectors_end - exception_vectors); synchronize_caches(0, exception_vectors_end - exception_vectors); ticks_per_usec = timebase_freq / 1000000ULL; /* Parse the command-line options. */ - if ((mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0)) - cmdline_parse(__va((ulong)mbi->cmdline)); + cmdline_parse(xen_cmdline); /* we need to be able to identify this CPU early on */ init_boot_cpu(); @@ -313,32 +319,20 @@ static void __init __start_xen(multiboot serial_init_preirq(); init_console(); - /* let synchronize until we really get going */ - console_start_sync(); - - /* Check that we have at least one Multiboot module. */ - if (!(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0)) { - panic("FATAL ERROR: Require at least one Multiboot module.\n"); - } - - /* OF dev tree is the last module */ - oftree = mod[mbi->mods_count-1].mod_start; - oftree_end = mod[mbi->mods_count-1].mod_end; - oftree_len = oftree_end - oftree; - - /* remove it from consideration */ - mod[mbi->mods_count-1].mod_start = 0; - mod[mbi->mods_count-1].mod_end = 0; - --mbi->mods_count; - - if (rtas_entry) { - rtas_init((void *)oftree); - /* remove rtas module from consideration */ - mod[mbi->mods_count-1].mod_start = 0; - mod[mbi->mods_count-1].mod_end = 0; - --mbi->mods_count; - } - memory_init(mod, mbi->mods_count); + console_start_sync(); /* Stay synchronous for early debugging. */ + + rtas_init((void *)oftree); + + memory_init(); + + printk("xen_cmdline: %016lx\n", (ulong)xen_cmdline); + printk("dom0_cmdline: %016lx\n", (ulong)dom0_cmdline); + printk("dom0_addr: %016lx\n", (ulong)dom0_addr); + printk("dom0_len: %016lx\n", (ulong)dom0_len); + printk("initrd_start: %016lx\n", (ulong)initrd_start); + printk("initrd_len: %016lx\n", (ulong)initrd_len); + + printk("dom0: %016llx\n", *(unsigned long long *)dom0_addr); #ifdef OF_DEBUG key_ofdump(0); @@ -382,30 +376,22 @@ static void __init __start_xen(multiboot dom0->is_privileged = 1; - cmdline = (char *)(mod[0].string ? __va((ulong)mod[0].string) : NULL); - /* scrub_heap_pages() requires IRQs enabled, and we're post IRQ setup... */ local_irq_enable(); /* Scrub RAM that is still free and so may go to an unprivileged domain. */ scrub_heap_pages(); - dom0_start = mod[0].mod_start; - dom0_len = mod[0].mod_end - mod[0].mod_start; - if (mbi->mods_count > 1) { - initrd_start = mod[1].mod_start; - initrd_len = mod[1].mod_end - mod[1].mod_start; - } else { - initrd_start = 0; - initrd_len = 0; - } - if (construct_dom0(dom0, dom0_start, dom0_len, + if ((dom0_addr == 0) || (dom0_len == 0)) + panic("No domain 0 found.\n"); + + if (construct_dom0(dom0, dom0_addr, dom0_len, initrd_start, initrd_len, - cmdline) != 0) { + dom0_cmdline) != 0) { panic("Could not set up DOM0 guest OS\n"); } - init_xenheap_pages(ALIGN_UP(dom0_start, PAGE_SIZE), - ALIGN_DOWN(dom0_start + dom0_len, PAGE_SIZE)); + init_xenheap_pages(ALIGN_UP(dom0_addr, PAGE_SIZE), + ALIGN_DOWN(dom0_addr + dom0_len, PAGE_SIZE)); if (initrd_start) init_xenheap_pages(ALIGN_UP(initrd_start, PAGE_SIZE), ALIGN_DOWN(initrd_start + initrd_len, PAGE_SIZE)); @@ -426,25 +412,74 @@ static void __init __start_xen(multiboot startup_cpu_idle_loop(); } +static void ofd_bootargs(void) +{ + static const char *sepr[] = {" -- ", " || "}; + char *p; + ofdn_t chosen; + int sepr_index; + int rc; + + if (builtin_cmdline[0] == '\0') { + chosen = ofd_node_find((void *)oftree, "/chosen"); + rc = ofd_getprop((void *)oftree, chosen, "bootargs", builtin_cmdline, + CONFIG_CMDLINE_SIZE); + } + + /* look for delimiter: "--" or "||" */ + for (sepr_index = 0; sepr_index < ARRAY_SIZE(sepr); sepr_index++){ + p = strstr(builtin_cmdline, sepr[sepr_index]); + if (p != NULL) { + /* Xen proper should never know about the dom0 args. */ + *p = '\0'; + p += strlen(sepr[sepr_index]); + dom0_cmdline = p; + break; + } + } + + xen_cmdline = builtin_cmdline; +} + +void __init __start_xen_ppc(ulong, ulong, ulong, ulong, ulong, ulong); void __init __start_xen_ppc( ulong r3, ulong r4, ulong r5, ulong r6, ulong r7, ulong orig_msr) { - multiboot_info_t *mbi = NULL; - /* clear bss */ memset(__bss_start, 0, (ulong)_end - (ulong)__bss_start); - if (r5 > 0) { - /* we were booted by OpenFirmware */ - mbi = boot_of_init(r3, r4, r5, r6, r7, orig_msr); - + if (r5) { + /* We came from Open Firmware. */ + boot_of_init(r5, orig_msr); + oftree = (ulong)boot_of_devtree(); /* Copy the device tree. */ + /* Use the device tree to find the Xen console. */ + boot_of_serial((void *)oftree); + boot_of_finish(); /* End firmware. */ } else { - /* booted by someone else that hopefully has a trap handler */ + /* XXX handle flat device tree here */ __builtin_trap(); } - __start_xen(mbi); - + ofd_bootargs(); + + if (r3 == MB2_BOOTLOADER_MAGIC) { + /* Get dom0 info from multiboot structures. */ + parse_multiboot(r4); + } + + if ((dom0_len == 0) && r3 && r4) { + /* Maybe dom0's location handed to us in registers. */ + dom0_addr = r3; + dom0_len = r4; + } + + if (dom0_len == 0) { + /* Dom0 had better be built in. */ + dom0_addr = (ulong)dom0_start; + dom0_len = (ulong)dom0_size; + } + + __start_xen(); } extern void arch_get_xen_caps(xen_capabilities_info_t *info); diff -r a94bf8086002 -r 553f64e4f6ef xen/include/asm-powerpc/mm.h --- a/xen/include/asm-powerpc/mm.h Mon Jul 30 13:50:14 2007 -0500 +++ b/xen/include/asm-powerpc/mm.h Mon Jul 30 17:10:45 2007 -0500 @@ -35,7 +35,6 @@ #define memguard_unguard_range(_p,_l) ((void)0) extern unsigned long xenheap_phys_end; -extern int boot_of_mem_avail(int pos, ulong *start, ulong *end); /* * Per-page-frame information. _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |