From patchwork Wed Sep 24 05:03:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37781 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 533B020792 for ; Wed, 24 Sep 2014 05:05:10 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf3531718eek.5 for ; Tue, 23 Sep 2014 22:05:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=7oVv6iJuJSckI339t5HU0YwGP+Xg37v+arbQjG6i9oE=; b=TarCszXySGqzZjH2ljemBb8T+T4pLdQ1aRcjhyszW1VuQMoanotLeq9oVZX6l2GCke Mj6ENznJYh9U8ENQYyOqnvUJgUcJ/ZrlqmbxK+4ZN8dWwJ/z4tP42cEszK88TkqQCqhX 6g2DHSm6jqGi3wtpyYA1NDVVw25INQ+0428+nuICsJiFC9RiDfLM5C+mIIbsCaIET2By VmLMpGZETOrSio9cBuPzSw9dYyjxJXPfuzzvtOUpvDNzDvHMxw4UPvmKtMnCNKQIzeGw 99CoqaTYrl/a8JW1zfgiOAN715nx1m8AMSpLqT1gIZPx9RegTG8WZuk5LhX/J48rC3Xb 2o1g== X-Gm-Message-State: ALoCoQku+xMSvbR3x1edGHp5EwE80t/vBmXPG4k1d/e/43h4hZXIbNU6XKhvBw1iTF0Qt31OYIBT X-Received: by 10.112.89.8 with SMTP id bk8mr625629lbb.6.1411535109289; Tue, 23 Sep 2014 22:05:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.69 with SMTP id u5ls118597lal.100.gmail; Tue, 23 Sep 2014 22:05:09 -0700 (PDT) X-Received: by 10.112.63.104 with SMTP id f8mr3520829lbs.91.1411535109153; Tue, 23 Sep 2014 22:05:09 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by mx.google.com with ESMTPS id g1si21277711lam.75.2014.09.23.22.05.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 22:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id ty20so10116008lab.9 for ; Tue, 23 Sep 2014 22:05:09 -0700 (PDT) X-Received: by 10.112.4.33 with SMTP id h1mr3508459lbh.67.1411535109029; Tue, 23 Sep 2014 22:05:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp526209lbb; Tue, 23 Sep 2014 22:05:05 -0700 (PDT) X-Received: by 10.224.36.4 with SMTP id r4mr2278287qad.69.1411535103630; Tue, 23 Sep 2014 22:05:03 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ma9si14971112qcb.22.2014.09.23.22.05.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 23 Sep 2014 22:05:03 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWejq-0006HR-7L; Wed, 24 Sep 2014 05:03:38 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWejp-0006H8-FB for xen-devel@lists.xen.org; Wed, 24 Sep 2014 05:03:37 +0000 Received: from [85.158.143.35:56474] by server-3.bemta-4.messagelabs.com id 1E/FF-06192-8A052245; Wed, 24 Sep 2014 05:03:36 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-2.tower-21.messagelabs.com!1411535014!4760724!1 X-Originating-IP: [209.85.223.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13493 invoked from network); 24 Sep 2014 05:03:35 -0000 Received: from mail-ie0-f172.google.com (HELO mail-ie0-f172.google.com) (209.85.223.172) by server-2.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 24 Sep 2014 05:03:35 -0000 Received: by mail-ie0-f172.google.com with SMTP id rp18so8974951iec.3 for ; Tue, 23 Sep 2014 22:03:34 -0700 (PDT) X-Received: by 10.50.152.105 with SMTP id ux9mr9348175igb.15.1411535014139; Tue, 23 Sep 2014 22:03:34 -0700 (PDT) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id ig9sm3477662igb.13.2014.09.23.22.03.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Sep 2014 22:03:33 -0700 (PDT) From: Roy Franz To: xen-devel@lists.xen.org, ian.campbell@citrix.com, stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com, keir@xen.org Date: Tue, 23 Sep 2014 22:03:04 -0700 Message-Id: <1411534992-27443-7-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411534992-27443-1-git-send-email-roy.franz@linaro.org> References: <1411534992-27443-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5 V6 06/14] Add efi_arch_handle_cmdline() for processing commandline X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Add arch function for processing the Xen commandline and updating internal structures. Signed-off-by: Roy Franz Acked-by: Jan Beulich --- xen/arch/x86/efi/efi-boot.h | 34 ++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 37 +++++++++---------------------------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 049e5f3..633a498 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -271,3 +271,37 @@ static void __init efi_arch_cfg_file_late(EFI_FILE_HANDLE dir_handle, char *sect efi_bs->FreePool(name.w); } } + +static void __init efi_arch_handle_cmdline(CHAR16 *image_name, + CHAR16 *cmdline_options, + char *cfgfile_options) +{ + union string name; + + if ( cmdline_options ) + { + name.w = cmdline_options; + w2s(&name); + place_string(&mbi.cmdline, name.s); + } + if ( cfgfile_options ) + place_string(&mbi.cmdline, cfgfile_options); + /* Insert image name last, as it gets prefixed to the other options. */ + if ( image_name ) + { + name.w = image_name; + w2s(&name); + } + else + name.s = "xen"; + place_string(&mbi.cmdline, name.s); + + if ( mbi.cmdline ) + mbi.flags |= MBI_CMDLINE; + /* + * These must not be initialized statically, since the value must + * not get relocated when processing base relocations later. + */ + mbi.boot_loader_name = (long)"EFI"; + mbi.mods_addr = (long)mb_modules; +} diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 0b096a6..639280b 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -58,6 +58,7 @@ static char *get_value(const struct file *cfg, const char *section, const char *item); static void split_value(char *s); static CHAR16 *s2w(union string *str); +static char *w2s(const union string *str); static bool_t read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, struct file *file); @@ -258,7 +259,8 @@ static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode) } static unsigned int __init get_argv(unsigned int argc, CHAR16 **argv, - CHAR16 *cmdline, UINTN cmdsize) + CHAR16 *cmdline, UINTN cmdsize, + CHAR16 **options) { CHAR16 *ptr = (CHAR16 *)(argv + argc + 1), *prev = NULL; bool_t prev_sep = TRUE; @@ -284,10 +286,8 @@ static unsigned int __init get_argv(unsigned int argc, CHAR16 **argv, ++argc; else if ( prev && wstrcmp(prev, L"--") == 0 ) { - union string rest = { .w = cmdline }; - - --argv; - place_string(&mbi.cmdline, w2s(&rest)); + if ( options ) + *options = cmdline; break; } else @@ -662,7 +662,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; unsigned int i, argc; - CHAR16 **argv, *file_name, *cfg_file_name = NULL; + CHAR16 **argv, *file_name, *cfg_file_name = NULL, *options = NULL; UINTN cols, rows, depth, size, map_key, info_size, gop_mode = ~0; EFI_HANDLE *handles = NULL; EFI_SHIM_LOCK_PROTOCOL *shim_lock; @@ -700,14 +700,14 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) dir_handle = get_parent_handle(loaded_image, &file_name); argc = get_argv(0, NULL, loaded_image->LoadOptions, - loaded_image->LoadOptionsSize); + loaded_image->LoadOptionsSize, NULL); 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); + loaded_image->LoadOptionsSize, &options); else argc = 0; for ( i = 1; i < argc; ++i ) @@ -877,17 +877,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) } name.s = get_value(&cfg, section.s, "options"); - if ( name.s ) - place_string(&mbi.cmdline, name.s); - /* Insert image name last, as it gets prefixed to the other options. */ - if ( argc ) - { - name.w = *argv; - w2s(&name); - } - else - name.s = "xen"; - place_string(&mbi.cmdline, name.s); + efi_arch_handle_cmdline(argc ? *argv : NULL, options, name.s); cols = rows = depth = 0; if ( !base_video ) @@ -954,15 +944,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) } } - if ( mbi.cmdline ) - mbi.flags |= MBI_CMDLINE; - /* - * These must not be initialized statically, since the value must - * not get relocated when processing base relocations below. - */ - mbi.boot_loader_name = (long)"EFI"; - mbi.mods_addr = (long)mb_modules; - /* Collect EDD info. */ BUILD_BUG_ON(offsetof(struct edd_info, edd_device_params) != EDDEXTSIZE); BUILD_BUG_ON(sizeof(struct edd_device_params) != EDDPARMSIZE);