diff options
author | Pawel Moll <pawel.moll@arm.com> | 2012-03-25 22:20:51 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-03-25 22:20:51 -0400 |
commit | 026cee0086fe1df4cf74691cf273062cc769617d (patch) | |
tree | 22735ecd2132de4570fbad81e5716f7fee3448d5 /init/main.c | |
parent | 8b8252813dee8e8cd453bb219731c36b268c69a7 (diff) |
params: <level>_initcall-like kernel parameters
This patch adds a set of macros that can be used to declare
kernel parameters to be parsed _before_ initcalls at a chosen
level are executed. We rename the now-unused "flags" field of
struct kernel_param as the level. It's signed, for when we
use this for early params as well, in future.
Linker macro collating init calls had to be modified in order
to add additional symbols between levels that are later used
by the init code to split the calls into blocks.
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/init/main.c b/init/main.c index c24805c824b9..439715858ba0 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -400,7 +400,7 @@ static int __init do_early_param(char *param, char *val) | |||
400 | 400 | ||
401 | void __init parse_early_options(char *cmdline) | 401 | void __init parse_early_options(char *cmdline) |
402 | { | 402 | { |
403 | parse_args("early options", cmdline, NULL, 0, do_early_param); | 403 | parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param); |
404 | } | 404 | } |
405 | 405 | ||
406 | /* Arch code calls this early on, or if not, just before other parsing. */ | 406 | /* Arch code calls this early on, or if not, just before other parsing. */ |
@@ -503,7 +503,7 @@ asmlinkage void __init start_kernel(void) | |||
503 | parse_early_param(); | 503 | parse_early_param(); |
504 | parse_args("Booting kernel", static_command_line, __start___param, | 504 | parse_args("Booting kernel", static_command_line, __start___param, |
505 | __stop___param - __start___param, | 505 | __stop___param - __start___param, |
506 | &unknown_bootoption); | 506 | 0, 0, &unknown_bootoption); |
507 | 507 | ||
508 | jump_label_init(); | 508 | jump_label_init(); |
509 | 509 | ||
@@ -699,16 +699,69 @@ int __init_or_module do_one_initcall(initcall_t fn) | |||
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[]; | 702 | extern initcall_t __initcall_start[]; |
703 | extern initcall_t __initcall0_start[]; | ||
704 | extern initcall_t __initcall1_start[]; | ||
705 | extern initcall_t __initcall2_start[]; | ||
706 | extern initcall_t __initcall3_start[]; | ||
707 | extern initcall_t __initcall4_start[]; | ||
708 | extern initcall_t __initcall5_start[]; | ||
709 | extern initcall_t __initcall6_start[]; | ||
710 | extern initcall_t __initcall7_start[]; | ||
711 | extern initcall_t __initcall_end[]; | ||
712 | |||
713 | static initcall_t *initcall_levels[] __initdata = { | ||
714 | __initcall0_start, | ||
715 | __initcall1_start, | ||
716 | __initcall2_start, | ||
717 | __initcall3_start, | ||
718 | __initcall4_start, | ||
719 | __initcall5_start, | ||
720 | __initcall6_start, | ||
721 | __initcall7_start, | ||
722 | __initcall_end, | ||
723 | }; | ||
724 | |||
725 | static char *initcall_level_names[] __initdata = { | ||
726 | "early parameters", | ||
727 | "core parameters", | ||
728 | "postcore parameters", | ||
729 | "arch parameters", | ||
730 | "subsys parameters", | ||
731 | "fs parameters", | ||
732 | "device parameters", | ||
733 | "late parameters", | ||
734 | }; | ||
735 | |||
736 | static int __init ignore_unknown_bootoption(char *param, char *val) | ||
737 | { | ||
738 | return 0; | ||
739 | } | ||
703 | 740 | ||
704 | static void __init do_initcalls(void) | 741 | static void __init do_initcall_level(int level) |
705 | { | 742 | { |
743 | extern const struct kernel_param __start___param[], __stop___param[]; | ||
706 | initcall_t *fn; | 744 | initcall_t *fn; |
707 | 745 | ||
708 | for (fn = __early_initcall_end; fn < __initcall_end; fn++) | 746 | strcpy(static_command_line, saved_command_line); |
747 | parse_args(initcall_level_names[level], | ||
748 | static_command_line, __start___param, | ||
749 | __stop___param - __start___param, | ||
750 | level, level, | ||
751 | ignore_unknown_bootoption); | ||
752 | |||
753 | for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) | ||
709 | do_one_initcall(*fn); | 754 | do_one_initcall(*fn); |
710 | } | 755 | } |
711 | 756 | ||
757 | static void __init do_initcalls(void) | ||
758 | { | ||
759 | int level; | ||
760 | |||
761 | for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) | ||
762 | do_initcall_level(level); | ||
763 | } | ||
764 | |||
712 | /* | 765 | /* |
713 | * Ok, the machine is now initialized. None of the devices | 766 | * Ok, the machine is now initialized. None of the devices |
714 | * have been touched yet, but the CPU subsystem is up and | 767 | * have been touched yet, but the CPU subsystem is up and |
@@ -732,7 +785,7 @@ static void __init do_pre_smp_initcalls(void) | |||
732 | { | 785 | { |
733 | initcall_t *fn; | 786 | initcall_t *fn; |
734 | 787 | ||
735 | for (fn = __initcall_start; fn < __early_initcall_end; fn++) | 788 | for (fn = __initcall_start; fn < __initcall0_start; fn++) |
736 | do_one_initcall(*fn); | 789 | do_one_initcall(*fn); |
737 | } | 790 | } |
738 | 791 | ||