summaryrefslogtreecommitdiff
path: root/kexec/arch/mips/kexec-elf-mips.c
diff options
context:
space:
mode:
authorMarcin Nowakowski <marcin.nowakowski@imgtec.com>2016-12-02 10:49:08 +0100
committerSimon Horman <horms@verge.net.au>2016-12-09 08:56:16 +0100
commitfecd481fbe6102dac2beb467a616401a0cb8ab2e (patch)
treed8c5da5d6fd719146b31093121560977c73d2a62 /kexec/arch/mips/kexec-elf-mips.c
parentb5f715e98eac3025273d64685b511a97f817100b (diff)
mips: move arch option parsing from elf loader to common arch code
At the moment only commandline handling is implemented and there is nothing elf-specific about it, so all of the commandline parsing logic can be moved to common arch code. getopt() options are moved to KEXEC_ARCH_OPTIONS macro (as many platforms currently do) to avoid unnecessary duplication. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/mips/kexec-elf-mips.c')
-rw-r--r--kexec/arch/mips/kexec-elf-mips.c43
1 files changed, 5 insertions, 38 deletions
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 8a6419a..7cb06f1 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -63,51 +63,18 @@ int elf_mips_probe(const char *buf, off_t len)
void elf_mips_usage(void)
{
- printf(" --command-line=STRING Set the kernel command line to "
- "STRING.\n"
- " --append=STRING Set the kernel command line to "
- "STRING.\n");
}
int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info)
{
struct mem_ehdr ehdr;
- const char *command_line;
- int command_line_len;
+ int command_line_len = 0;
char *crash_cmdline;
- int opt;
int result;
unsigned long cmdline_addr;
size_t i;
- /* See options.h if adding any more options. */
- static const struct option options[] = {
- KEXEC_ARCH_OPTIONS
- {"command-line", 1, 0, OPT_APPEND},
- {"append", 1, 0, OPT_APPEND},
- {0, 0, 0, 0},
- };
-
- static const char short_options[] = KEXEC_ARCH_OPT_STR "d";
-
- command_line = 0;
- while ((opt = getopt_long(argc, argv, short_options,
- options, 0)) != -1) {
- switch (opt) {
- default:
- /* Ignore core options */
- if (opt < OPT_ARCH_MAX) {
- break;
- }
- case OPT_APPEND:
- command_line = optarg;
- break;
- }
- }
-
- command_line_len = 0;
-
/* Need to append some command line parameters internally in case of
* taking crash dumps.
*/
@@ -136,8 +103,8 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
info->entry = (void *)virt_to_phys(ehdr.e_entry);
- if (command_line)
- command_line_len = strlen(command_line) + 1;
+ if (arch_options.command_line)
+ command_line_len = strlen(arch_options.command_line) + 1;
if (info->kexec_flags & KEXEC_ON_CRASH) {
result = load_crashdump_segments(info, crash_cmdline,
@@ -148,8 +115,8 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
}
}
- if (command_line)
- strncat(cmdline_buf, command_line, command_line_len);
+ if (arch_options.command_line)
+ strncat(cmdline_buf, arch_options.command_line, command_line_len);
if (crash_cmdline)
strncat(cmdline_buf, crash_cmdline,
sizeof(crash_cmdline) -