From: Roy Franz <roy.franz@linaro.org>
To: xen-devel@lists.xen.org, ian.campbell@citrix.com,
stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com,
keir@xen.org
Cc: Roy Franz <roy.franz@linaro.org>,
fu.wei@linaro.org, linaro-uefi@lists.linaro.org
Subject: [PATCH V2 07/12] create handle_cmdline() function
Date: Mon, 21 Jul 2014 17:43:30 -0700 [thread overview]
Message-ID: <1405989815-25236-8-git-send-email-roy.franz@linaro.org> (raw)
In-Reply-To: <1405989815-25236-1-git-send-email-roy.franz@linaro.org>
Create handle_cmdline() function in preparation for sharing to allow x86 and
ARM architectures to share the command line processing.
Signed-off-by: Roy Franz <roy.franz@linaro.org>
---
xen/arch/x86/efi/boot.c | 127 +++++++++++++++++++++++++++++-------------------
1 file changed, 77 insertions(+), 50 deletions(-)
diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c
index fa6aca4..2ef86d1 100644
--- a/xen/arch/x86/efi/boot.c
+++ b/xen/arch/x86/efi/boot.c
@@ -744,6 +744,74 @@ static void __init relocate_image(unsigned long delta)
}
}
+
+bool_t __init handle_cmdline(EFI_LOADED_IMAGE *loaded_image,
+ CHAR16 **cfg_file_name, bool_t *base_video,
+ CHAR16 **image_name, CHAR16 **section_name)
+{
+
+ unsigned int i, argc;
+ CHAR16 **argv;
+
+
+ if ( !cfg_file_name || !base_video || !image_name )
+ {
+ PrintStr(L"Invalid args to handle_cmdline\r\n");
+ return 0;
+ }
+
+ argc = get_argv(0, NULL, loaded_image->LoadOptions,
+ loaded_image->LoadOptionsSize);
+ if ( argc > 0 &&
+ efi_bs->AllocatePool(EfiLoaderData,
+ (argc + 1) * sizeof(*argv) +
+ loaded_image->LoadOptionsSize,
+ (void **)&argv) == EFI_SUCCESS )
+ get_argv(argc, argv, loaded_image->LoadOptions,
+ loaded_image->LoadOptionsSize);
+ else
+ argc = 0;
+
+ for ( i = 1; i < argc; ++i )
+ {
+ CHAR16 *ptr = argv[i];
+
+ if ( !ptr )
+ break;
+ if ( *ptr == L'/' || *ptr == L'-' )
+ {
+ if ( wstrcmp(ptr + 1, L"basevideo") == 0 )
+ *base_video = 1;
+ else if ( wstrncmp(ptr + 1, L"cfg=", 4) == 0 )
+ *cfg_file_name = ptr + 5;
+ else if ( i + 1 < argc && wstrcmp(ptr + 1, L"cfg") == 0 )
+ *cfg_file_name = argv[++i];
+ else if ( wstrcmp(ptr + 1, L"help") == 0 ||
+ (ptr[1] == L'?' && !ptr[2]) )
+ {
+ PrintStr(L"Xen EFI Loader options:\r\n");
+ PrintStr(L"-basevideo retain current video mode\r\n");
+ PrintStr(L"-cfg=<file> specify configuration file\r\n");
+ PrintStr(L"-help, -? display this help\r\n");
+ return 0;
+ }
+ else
+ {
+ PrintStr(L"WARNING: Unknown command line option '");
+ PrintStr(ptr);
+ PrintStr(L"' ignored\r\n");
+ }
+ }
+ else
+ *section_name = ptr;
+ }
+
+ if ( argc )
+ *image_name = *argv;
+
+ return 1;
+}
+
extern const s32 __trampoline_rel_start[], __trampoline_rel_stop[];
extern const s32 __trampoline_seg_start[], __trampoline_seg_stop[];
@@ -773,8 +841,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID;
EFI_LOADED_IMAGE *loaded_image;
EFI_STATUS status;
- unsigned int i, argc;
- CHAR16 **argv, *file_name, *cfg_file_name = NULL;
+ unsigned int i;
+ CHAR16 *file_name = NULL, *cfg_file_name = NULL, *image_name = NULL;
+ CHAR16 *section_name = NULL;
UINTN cols, rows, depth, size, map_key, info_size, gop_mode = ~0;
EFI_HANDLE *handles = NULL;
EFI_SHIM_LOCK_PROTOCOL *shim_lock;
@@ -814,53 +883,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
/* Get the file system interface. */
dir_handle = get_parent_handle(loaded_image, &file_name);
- if ( !dir_handle )
- blexit(L"EFI get_parent_handle failed.");
+ if ( !handle_cmdline(loaded_image, &cfg_file_name, &base_video, &image_name,
+ §ion_name) )
+ blexit(NULL);
- argc = get_argv(0, NULL, loaded_image->LoadOptions,
- loaded_image->LoadOptionsSize);
- if ( argc > 0 &&
- efi_bs->AllocatePool(EfiLoaderData,
- (argc + 1) * sizeof(*argv) +
- loaded_image->LoadOptionsSize,
- (void **)&argv) == EFI_SUCCESS )
- get_argv(argc, argv, loaded_image->LoadOptions,
- loaded_image->LoadOptionsSize);
- else
- argc = 0;
- for ( i = 1; i < argc; ++i )
- {
- CHAR16 *ptr = argv[i];
-
- if ( !ptr )
- break;
- if ( *ptr == L'/' || *ptr == L'-' )
- {
- if ( wstrcmp(ptr + 1, L"basevideo") == 0 )
- base_video = 1;
- else if ( wstrncmp(ptr + 1, L"cfg=", 4) == 0 )
- cfg_file_name = ptr + 5;
- else if ( i + 1 < argc && wstrcmp(ptr + 1, L"cfg") == 0 )
- cfg_file_name = argv[++i];
- else if ( wstrcmp(ptr + 1, L"help") == 0 ||
- (ptr[1] == L'?' && !ptr[2]) )
- {
- PrintStr(L"Xen EFI Loader options:\r\n");
- PrintStr(L"-basevideo retain current video mode\r\n");
- PrintStr(L"-cfg=<file> specify configuration file\r\n");
- PrintStr(L"-help, -? display this help\r\n");
- blexit(NULL);
- }
- else
- {
- PrintStr(L"WARNING: Unknown command line option '");
- PrintStr(ptr);
- PrintStr(L"' ignored\r\n");
- }
- }
- else
- section.w = ptr;
- }
+ section.w = section_name;
if ( !base_video )
{
@@ -976,9 +1003,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
if ( name.s )
place_string(&mbi.cmdline, name.s);
/* Insert image name last, as it gets prefixed to the other options. */
- if ( argc )
+ if ( image_name )
{
- name.w = *argv;
+ name.w = image_name;
w2s(&name);
}
else
--
2.0.0
next prev parent reply other threads:[~2014-07-22 0:43 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 0:43 [PATCH V2 00/12] arm64 EFI stub Roy Franz
2014-07-22 0:43 ` [PATCH V2 01/12] Create efi-shared.[ch], and move string functions Roy Franz
2014-07-23 16:31 ` Jan Beulich
2014-07-28 15:41 ` Ian Campbell
2014-07-28 15:52 ` Jan Beulich
2014-07-28 15:56 ` Ian Campbell
2014-07-28 16:00 ` Jan Beulich
2014-07-28 16:04 ` Ian Campbell
2014-07-28 16:10 ` Jan Beulich
2014-08-06 23:55 ` Roy Franz
2014-08-07 6:17 ` Jan Beulich
2014-08-09 0:27 ` Roy Franz
2014-08-06 23:42 ` Roy Franz
2014-07-22 0:43 ` [PATCH V2 02/12] rename printErrMsg to PrintErrMesgExit Roy Franz
2014-07-23 16:33 ` Jan Beulich
2014-07-22 0:43 ` [PATCH V2 03/12] Refactor get_parent_handle for sharing Roy Franz
2014-07-23 16:37 ` Jan Beulich
2014-07-22 0:43 ` [PATCH V2 04/12] Refactor read_file() so it can be shared Roy Franz
2014-07-24 7:09 ` Jan Beulich
2014-08-06 18:38 ` Roy Franz
2014-08-07 6:20 ` Jan Beulich
2014-08-07 17:26 ` Roy Franz
2014-07-22 0:43 ` [PATCH V2 05/12] replace split_value() with truncate_string() Roy Franz
2014-07-24 7:19 ` Jan Beulich
2014-08-06 22:37 ` Roy Franz
2014-08-07 6:24 ` Jan Beulich
2014-08-18 23:38 ` Roy Franz
2014-08-19 12:56 ` Jan Beulich
2014-07-22 0:43 ` [PATCH V2 06/12] add read_config_file() function for XEN EFI config file Roy Franz
2014-07-24 7:32 ` Jan Beulich
2014-08-06 22:42 ` Roy Franz
2014-07-22 0:43 ` Roy Franz [this message]
2014-07-24 7:36 ` [PATCH V2 07/12] create handle_cmdline() function Jan Beulich
2014-07-28 15:44 ` Ian Campbell
2014-07-28 15:57 ` Jan Beulich
2014-07-22 0:43 ` [PATCH V2 08/12] Refactor get_argv() for sharing Roy Franz
2014-07-24 7:38 ` Jan Beulich
2014-07-22 0:43 ` [PATCH V2 09/12] Move shared EFI functions to efi-shared.c Roy Franz
2014-07-22 0:43 ` [PATCH V2 10/12] add arm64 cache flushing code from linux Roy Franz
2014-07-28 15:53 ` Ian Campbell
2014-07-28 16:24 ` Ian Campbell
2014-07-22 0:43 ` [PATCH V2 11/12] Add fdt_create_empty_tree() function Roy Franz
2014-07-22 16:36 ` [Linaro-uefi] " Julien Grall
2014-07-22 17:12 ` Roy Franz
2014-07-22 17:15 ` Julien Grall
2014-07-23 9:58 ` Ian Campbell
2014-07-23 16:15 ` Roy Franz
2014-07-22 0:43 ` [PATCH V2 12/12] Add EFI stub for arm64 Roy Franz
2014-07-29 9:46 ` Ian Campbell
2014-07-28 15:30 ` [PATCH V2 00/12] arm64 EFI stub Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405989815-25236-8-git-send-email-roy.franz@linaro.org \
--to=roy.franz@linaro.org \
--cc=fu.wei@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=linaro-uefi@lists.linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).