[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XenPPC] [PATCH] Rolled up bootargs simplification
Merge in Jimi's idea of handling the seperator phrase entirely in boot_of. Set and document clear precedence rules for boot argument processing. Support the same builtin command line format in the 32-bit xen binary as the 32-bit zImage binary does. Remove dead default_bootargs code. This patch has been in use by an internal IBM project for some time. It enables two important things: allowing developers and cluster administrators the option of overriding the bootargs supplied by firmware, and the ability to take a single gold master xen binary and customize its bootargs across a cluster with a simple and well-tested post-processing tool. Signed-off-by: Amos Waterland <apw@xxxxxxxxxx> --- b/xen/arch/powerpc/boot/arg32.c | 22 ++++++++++++++++++++++ xen/arch/powerpc/Makefile | 5 ++++- xen/arch/powerpc/boot/boot32.S | 5 +++++ xen/arch/powerpc/boot_of.c | 24 +++++++++++++++++++----- xen/arch/powerpc/ofd_fixup.c | 19 ------------------- xen/arch/powerpc/xen.lds.S | 4 ++++ 6 files changed, 54 insertions(+), 25 deletions(-) diff -r dbfb5fc0b9b2 xen/arch/powerpc/Makefile --- a/xen/arch/powerpc/Makefile Fri Sep 29 11:29:32 2006 -0400 +++ b/xen/arch/powerpc/Makefile Thu Sep 28 14:41:54 2006 -0400 @@ -130,7 +130,10 @@ boot32.o: boot/boot32.S $(CC) -m32 -Wa,-a32,-mppc64bridge \ -D__ASSEMBLY__ -D__BRIDGE64__ $(CFLAGS) -c $< -o $@ -$(TARGET): boot32.o $(TARGET).bin.o +arg32.o: boot/arg32.c + $(CC) -m32 -DCMDLINE="\"$(IMAGENAME) $(CMDLINE)\"" -c $< -o $@ + +$(TARGET): boot32.o arg32.o $(TARGET).bin.o $(CC) -m32 -N -Wl,-melf32ppclinux -static -nostdlib \ -Wl,-Ttext,$(boot32_link_base) -Wl,-Tdata,$(xen_link_base) \ $(CFLAGS) $^ -o $@ diff -r dbfb5fc0b9b2 xen/arch/powerpc/boot/boot32.S --- a/xen/arch/powerpc/boot/boot32.S Fri Sep 29 11:29:32 2006 -0400 +++ b/xen/arch/powerpc/boot/boot32.S Thu Sep 28 14:41:54 2006 -0400 @@ -36,6 +36,11 @@ _start: ## 51 12 00000000 00001000 ME Machine Check Enable _real_start: + # pass the builtin command line as argument to hype_init + li 7, 0 + oris 7, 7, builtin_cmdline@h + ori 7, 7, builtin_cmdline@l + # pass the original msr as argument to hype_init mfmsr 8 diff -r dbfb5fc0b9b2 xen/arch/powerpc/boot_of.c --- a/xen/arch/powerpc/boot_of.c Fri Sep 29 11:29:32 2006 -0400 +++ b/xen/arch/powerpc/boot_of.c Mon Oct 02 11:37:04 2006 -0400 @@ -40,11 +40,12 @@ static ulong of_vec; static ulong of_vec; static ulong of_msr; static int of_out; -static char bootargs[256]; #define COMMAND_LINE_SIZE 512 static char builtin_cmdline[COMMAND_LINE_SIZE] __attribute__((section("__builtin_cmdline"))) = CMDLINE; + +static char bootargs[COMMAND_LINE_SIZE]; extern struct ns16550_defaults ns16550; @@ -460,13 +461,24 @@ static void boot_of_probemem(multiboot_i } } -static void boot_of_bootargs(multiboot_info_t *mbi) +static void +boot_of_bootargs(multiboot_info_t *mbi, char *wrapper_builtin_cmdline) { int rc; - rc = of_getprop(bof_chosen, "bootargs", &bootargs, sizeof (bootargs)); - if (rc == OF_FAILURE || bootargs[0] == '\0') { + /* Boot argument precedence rules: + * 1. Arguments from 32-bit wrapper override all else + * 2. Builtin arguments in 64-bit image override firmware + * 3. Firmware is used if neither of the above exist + */ + if (wrapper_builtin_cmdline[0] != 0) { + strlcpy(bootargs, wrapper_builtin_cmdline, sizeof(bootargs)); + } else if (builtin_cmdline[0] != 0) { strlcpy(bootargs, builtin_cmdline, sizeof(bootargs)); + } else { + rc = of_getprop(bof_chosen, "bootargs", &bootargs, sizeof (bootargs)); + if (rc > sizeof (bootargs)) + of_panic("bootargs[] not big enough for /chosen/bootargs\n"); } mbi->flags |= MBI_CMDLINE; @@ -1023,6 +1035,8 @@ static void * __init boot_of_module(ulon mods[mod].mod_start, mods[mod].mod_end); p = strstr((char *)(ulong)mbi->cmdline, sepr); if (p != NULL) { + /* Xen proper should never know about the dom0 args. */ + *(char *)p = '\0'; p += sizeof (sepr) - 1; mods[mod].string = (u32)(ulong)p; of_printf("%s: dom0 mod string: %s\n", __func__, p); @@ -1197,7 +1211,7 @@ multiboot_info_t __init *boot_of_init( boot_of_fix_maple(); boot_of_probemem(&mbi); - boot_of_bootargs(&mbi); + boot_of_bootargs(&mbi, (char *)r7); oft = boot_of_module(r3, r4, &mbi); boot_of_cpus(); boot_of_serial(oft); diff -r dbfb5fc0b9b2 xen/arch/powerpc/ofd_fixup.c --- a/xen/arch/powerpc/ofd_fixup.c Fri Sep 29 11:29:32 2006 -0400 +++ b/xen/arch/powerpc/ofd_fixup.c Thu Sep 28 14:41:54 2006 -0400 @@ -244,12 +244,6 @@ static ofdn_t ofd_xics_props(void *m) } #endif -/* - * Good things you can stick here: - * init=/bin/bash ip=dhcp root=/dev/hda2 ide=nodma - */ -static char default_bootargs[] = ""; - static ofdn_t ofd_chosen_props(void *m, const char *cmdline) { ofdn_t n; @@ -257,7 +251,6 @@ static ofdn_t ofd_chosen_props(void *m, static const char path[] = "/chosen"; char bootargs[256]; int bsz; - int sz; int rm; n = ofd_node_find(m, path); @@ -270,18 +263,6 @@ static ofdn_t ofd_chosen_props(void *m, strcpy(bootargs, cmdline); bsz = strlen(bootargs) + 1; rm = sizeof (bootargs) - bsz; - - if (default_bootargs != NULL) { - sz = strlen(default_bootargs); - if (sz > rm) { - panic("default_bootargs is too big: 0x%x > 0x%x\n", - sz, rm); - } else if (sz > 0) { - memcpy(&bootargs[bsz - 1], default_bootargs, sz + 1); - bsz += sz; - rm -= sz; - } - } printk("DOM0 bootargs: %s\n", bootargs); ofd_prop_add(m, n, "bootargs", bootargs, bsz); diff -r dbfb5fc0b9b2 xen/arch/powerpc/xen.lds.S --- a/xen/arch/powerpc/xen.lds.S Fri Sep 29 11:29:32 2006 -0400 +++ b/xen/arch/powerpc/xen.lds.S Thu Sep 28 16:15:40 2006 -0400 @@ -179,6 +179,10 @@ SECTIONS } _edata = .; PROVIDE (edata = .); + /* When we are nested in a 32-bit wrapper, it's data section goes here. + Since its only data is a command line buffer, and we know its size, + we just advance the cursor by that size. */ + . = . + 512; __bss_start = .; .tocbss ALIGN(8) : { *(.tocbss)} .sbss : diff -r dbfb5fc0b9b2 xen/arch/powerpc/boot/arg32.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/arch/powerpc/boot/arg32.c Thu Sep 28 15:37:02 2006 -0400 @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2006 Jimi Xenidis <jimix@xxxxxxxxxxxxxx>, IBM Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define COMMAND_LINE_SIZE 512 +char builtin_cmdline[COMMAND_LINE_SIZE] + __attribute__((section("__builtin_cmdline"))) = CMDLINE; _______________________________________________ Xen-ppc-devel mailing list Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-ppc-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |