aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTim Bird <tim.bird@am.sony.com>2008-08-12 15:52:36 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-15 10:10:37 -0400
commit516cbf3730c49739629d66313b20bdc50c98aa2c (patch)
tree07d481c928cb95e3db5de1cfa6062c572153706a /arch
parentb635acec48bcaa9183fcbf4e3955616b0d4119b5 (diff)
x86, bootup: add built-in kernel command line for x86 (v2)
Allow x86 to support a built-in kernel command line. The built-in command line can override the one provided by the boot loader, for those cases where the boot loader is broken or it is difficult to change the command line in the the boot loader. H. Peter Anvin wrote: > Ingo Molnar wrote: >> Best would be to make it really apparent in the code that nothing >> changes if this config option is not set. Preferably there should be >> no extra code at all in that case. >> > > I would like to see this: [...Nested ifdefs...] OK. This version changes absolutely nothing if CONFIG_CMDLINE_BOOL is not set (the default). Also, no space is appended even when CONFIG_CMDLINE_BOOL is set, but the builtin string is empty. This is less sloppy all the way around, IMHO. Note that I use the same option names as on other arches for this feature. [ mingo@elte.hu: build fix ] Signed-off-by: Tim Bird <tim.bird@am.sony.com> Cc: Matt Mackall <mpm@selenic.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/Kconfig45
-rw-r--r--arch/x86/kernel/setup.c16
2 files changed, 61 insertions, 0 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ac2fb0641a0..fbcb79bbafd 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1392,6 +1392,51 @@ config COMPAT_VDSO
1392 1392
1393 If unsure, say Y. 1393 If unsure, say Y.
1394 1394
1395config CMDLINE_BOOL
1396 bool "Built-in kernel command line"
1397 default n
1398 help
1399 Allow for specifying boot arguments to the kernel at
1400 build time. On some systems (e.g. embedded ones), it is
1401 necessary or convenient to provide some or all of the
1402 kernel boot arguments with the kernel itself (that is,
1403 to not rely on the boot loader to provide them.)
1404
1405 To compile command line arguments into the kernel,
1406 set this option to 'Y', then fill in the
1407 the boot arguments in CONFIG_CMDLINE.
1408
1409 Systems with fully functional boot loaders (i.e. non-embedded)
1410 should leave this option set to 'N'.
1411
1412config CMDLINE
1413 string "Built-in kernel command string"
1414 depends on CMDLINE_BOOL
1415 default ""
1416 help
1417 Enter arguments here that should be compiled into the kernel
1418 image and used at boot time. If the boot loader provides a
1419 command line at boot time, it is appended to this string to
1420 form the full kernel command line, when the system boots.
1421
1422 However, you can use the CONFIG_CMDLINE_OVERRIDE option to
1423 change this behavior.
1424
1425 In most cases, the command line (whether built-in or provided
1426 by the boot loader) should specify the device for the root
1427 file system.
1428
1429config CMDLINE_OVERRIDE
1430 bool "Built-in command line overrides boot loader arguments"
1431 default n
1432 depends on CMDLINE_BOOL
1433 help
1434 Set this option to 'Y' to have the kernel ignore the boot loader
1435 command line, and use ONLY the built-in command line.
1436
1437 This is used to work around broken boot loaders. This should
1438 be set to 'N' under normal conditions.
1439
1395endmenu 1440endmenu
1396 1441
1397config ARCH_ENABLE_MEMORY_HOTPLUG 1442config ARCH_ENABLE_MEMORY_HOTPLUG
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 68b48e3fbcb..2f31cddd27b 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -223,6 +223,9 @@ unsigned long saved_video_mode;
223#define RAMDISK_LOAD_FLAG 0x4000 223#define RAMDISK_LOAD_FLAG 0x4000
224 224
225static char __initdata command_line[COMMAND_LINE_SIZE]; 225static char __initdata command_line[COMMAND_LINE_SIZE];
226#ifdef CONFIG_CMDLINE_BOOL
227static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
228#endif
226 229
227#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) 230#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
228struct edd edd; 231struct edd edd;
@@ -673,6 +676,19 @@ void __init setup_arch(char **cmdline_p)
673 bss_resource.start = virt_to_phys(&__bss_start); 676 bss_resource.start = virt_to_phys(&__bss_start);
674 bss_resource.end = virt_to_phys(&__bss_stop)-1; 677 bss_resource.end = virt_to_phys(&__bss_stop)-1;
675 678
679#ifdef CONFIG_CMDLINE_BOOL
680#ifdef CONFIG_CMDLINE_OVERRIDE
681 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
682#else
683 if (builtin_cmdline[0]) {
684 /* append boot loader cmdline to builtin */
685 strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
686 strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
687 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
688 }
689#endif
690#endif
691
676 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); 692 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
677 *cmdline_p = command_line; 693 *cmdline_p = command_line;
678 694