From patchwork Wed Sep 10 00:51:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37177 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9154520566 for ; Wed, 10 Sep 2014 00:55:13 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf22110301iec.10 for ; Tue, 09 Sep 2014 17:55:13 -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=E3kcFfSE4KiVgjmypbKgRABeMNxkZpaTDtByU7JLg2o=; b=duPKz1CTam2yHMFlF2Px/9ZaQOGFNFD3NOpy/5TTqqZHVXgBmoiARKOifEcrqzM25Q GmjgU5pFBsrx1aGsMFx7FKCMxX0qk0sPwqsJqsHoxm8V3Q4qEBUvFsqECuygnKiQhJTf v0RdYu3gQDY+eIF44puiS4hFzHjfDhOMCoYyA0aqUPFFOQ4G0zZVgwIQBZyyFBZ8V5bn 2x7pW2x3+2A7chdisH55GKlsiQtiE47XH3v8+mtkCDxsIn0tikuRypsZcoQOl3+sShuK +f68pRMWLV8k+7MqrutJvlcGpJaK2V+656XRFeMPYrNPjJxgGFrCKerlqoPT2jf1pjHB DN8A== X-Gm-Message-State: ALoCoQlQveAkeLqwnzMybY8eVaC57/OXR8E/iHzmzaNPhSiYNKfeiZ+XcuhdMo1tidEaw1D2Cz2i X-Received: by 10.182.18.8 with SMTP id s8mr22538226obd.21.1410310513190; Tue, 09 Sep 2014 17:55:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.170 with SMTP id p39ls166221qgd.57.gmail; Tue, 09 Sep 2014 17:55:13 -0700 (PDT) X-Received: by 10.220.250.142 with SMTP id mo14mr18456177vcb.26.1410310513059; Tue, 09 Sep 2014 17:55:13 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id ry3si5850191vcb.27.2014.09.09.17.55.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 17:55:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hy10so4205156vcb.3 for ; Tue, 09 Sep 2014 17:55:13 -0700 (PDT) X-Received: by 10.220.59.138 with SMTP id l10mr186820vch.59.1410310512956; Tue, 09 Sep 2014 17:55:12 -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.221.45.67 with SMTP id uj3csp363945vcb; Tue, 9 Sep 2014 17:55:12 -0700 (PDT) X-Received: by 10.52.146.17 with SMTP id sy17mr28132041vdb.29.1410310512440; Tue, 09 Sep 2014 17:55:12 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ej9si5849143vcb.25.2014.09.09.17.55.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Sep 2014 17:55:12 -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 1XRW97-0006ED-9H; Wed, 10 Sep 2014 00:52:29 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XRW94-0006DA-PS for xen-devel@lists.xen.org; Wed, 10 Sep 2014 00:52:26 +0000 Received: from [85.158.143.35:63968] by server-1.bemta-4.messagelabs.com id 23/77-05872-AC0AF045; Wed, 10 Sep 2014 00:52:26 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-10.tower-21.messagelabs.com!1410310343!12733971!1 X-Originating-IP: [209.85.223.180] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13351 invoked from network); 10 Sep 2014 00:52:25 -0000 Received: from mail-ie0-f180.google.com (HELO mail-ie0-f180.google.com) (209.85.223.180) by server-10.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 10 Sep 2014 00:52:25 -0000 Received: by mail-ie0-f180.google.com with SMTP id rd18so3884480iec.11 for ; Tue, 09 Sep 2014 17:52:23 -0700 (PDT) X-Received: by 10.42.96.132 with SMTP id j4mr42327112icn.16.1410310343620; Tue, 09 Sep 2014 17:52:23 -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 dx10sm654825igb.4.2014.09.09.17.52.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Sep 2014 17:52:22 -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, 9 Sep 2014 17:51:56 -0700 Message-Id: <1410310325-4509-7-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410310325-4509-1-git-send-email-roy.franz@linaro.org> References: <1410310325-4509-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH V4 06/15] 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.220.172 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 --- xen/common/efi/boot.c | 41 +++++++++++------------------------------ xen/include/asm-x86/efi-boot.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index a33a8f6..fd9d382 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -53,6 +53,7 @@ static char *__init get_value(const struct file *cfg, const char *section, const char *item); static void __init split_value(char *s); static CHAR16 *__init s2w(union string *str); +static char *__init w2s(const union string *str); static bool_t __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, struct file *file); @@ -251,7 +252,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; @@ -277,10 +279,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 @@ -569,7 +569,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, info_size, gop_mode = ~0; EFI_HANDLE *handles = NULL; EFI_SHIM_LOCK_PROTOCOL *shim_lock; @@ -610,14 +610,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, &options); 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 ) @@ -786,19 +786,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_bs->FreePool(name.w); } - 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); - cols = rows = depth = 0; if ( !base_video ) { @@ -817,6 +804,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) } } + name.s = get_value(&cfg, section.s, "options"); + efi_arch_handle_cmdline(argc ? *argv : NULL, options, name.s); + efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size)); cfg.addr = 0; @@ -863,15 +853,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); diff --git a/xen/include/asm-x86/efi-boot.h b/xen/include/asm-x86/efi-boot.h index 3937955..d72b02b 100644 --- a/xen/include/asm-x86/efi-boot.h +++ b/xen/include/asm-x86/efi-boot.h @@ -607,3 +607,37 @@ static void __init efi_arch_cfg_file(EFI_FILE_HANDLE dir_handle, char *section) 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 below. + */ + mbi.boot_loader_name = (long)"EFI"; + mbi.mods_addr = (long)mb_modules; +}