From patchwork Thu Sep 25 01:42:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37882 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CFF9320063 for ; Thu, 25 Sep 2014 01:44:53 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gi9sf737853lab.6 for ; Wed, 24 Sep 2014 18:44:52 -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=sH7hfwp+mzaPo8diuhlGLrV22CT5dWik5tlioI2WCzw=; b=Q424hx9sw52Zxv/iqENmhfJ+HVDC2NMaWVMGzoXlHrm114nX9mRJ2Grqtxf0VII3BB ucjg98tDwBKDUhmex79LBqXV8YYQyWdY2Q3FOIIcHia7ZJ9NSL6yJQ/oqWdqT/OUqR2q D1ppt5/JnHwRa7sKZy02uw2p3/gN9AovIAIK05V68RbUqAlhsJxY8/0fiyy17H3/Qe6F 06X65YebgcOqY1qcq3tMgkt51mqW/TRw2satI13qsV5sV5u2I6RzfApy5atpn+bENT7i MNAuVYPw5Dm5a58DfKWNUj45BelkY284cljiCsVqwj/uhRA5gZo5/B2r20i2k8acrYrJ P1hw== X-Gm-Message-State: ALoCoQklxJ1+V0Ai/JKJOV27tfrU6ioIVVMAEO2lBJilSdYSHh89YJfAkX2CtcvOtRlilji1TptA X-Received: by 10.112.89.8 with SMTP id bk8mr1568212lbb.6.1411609492690; Wed, 24 Sep 2014 18:44:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.9 with SMTP id o9ls191933lao.97.gmail; Wed, 24 Sep 2014 18:44:52 -0700 (PDT) X-Received: by 10.152.36.4 with SMTP id m4mr9859672laj.17.1411609492362; Wed, 24 Sep 2014 18:44:52 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by mx.google.com with ESMTPS id lf1si963571lac.65.2014.09.24.18.44.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Sep 2014 18:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id gb8so2181409lab.16 for ; Wed, 24 Sep 2014 18:44:52 -0700 (PDT) X-Received: by 10.152.197.35 with SMTP id ir3mr10135991lac.82.1411609492286; Wed, 24 Sep 2014 18:44:52 -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 of9csp678231lbb; Wed, 24 Sep 2014 18:44:51 -0700 (PDT) X-Received: by 10.140.20.105 with SMTP id 96mr15103543qgi.33.1411609490821; Wed, 24 Sep 2014 18:44:50 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id p2si1023815qat.60.2014.09.24.18.44.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 24 Sep 2014 18:44:50 -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 1XWy5B-00013H-Ej; Thu, 25 Sep 2014 01:42:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWy59-00010u-OO for xen-devel@lists.xen.org; Thu, 25 Sep 2014 01:42:55 +0000 Received: from [85.158.137.68:39247] by server-6.bemta-3.messagelabs.com id B2/06-29521-E1373245; Thu, 25 Sep 2014 01:42:54 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1411609372!8147562!1 X-Originating-IP: [209.85.213.182] 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 20469 invoked from network); 25 Sep 2014 01:42:53 -0000 Received: from mail-ig0-f182.google.com (HELO mail-ig0-f182.google.com) (209.85.213.182) by server-9.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 25 Sep 2014 01:42:53 -0000 Received: by mail-ig0-f182.google.com with SMTP id hn15so7583400igb.3 for ; Wed, 24 Sep 2014 18:42:52 -0700 (PDT) X-Received: by 10.42.121.146 with SMTP id j18mr14186935icr.48.1411609372280; Wed, 24 Sep 2014 18:42:52 -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 x9sm5829238igl.10.2014.09.24.18.42.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Sep 2014 18:42:51 -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: Wed, 24 Sep 2014 18:42:25 -0700 Message-Id: <1411609352-24549-8-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411609352-24549-1-git-send-email-roy.franz@linaro.org> References: <1411609352-24549-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5 V7 07/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.43 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 61e2198..07e9fc7 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -268,3 +268,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 d129035..24dba9b 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -61,6 +61,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); @@ -261,7 +262,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; @@ -287,10 +289,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 @@ -666,7 +666,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; @@ -704,14 +704,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 ) @@ -881,17 +881,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 ) @@ -958,15 +948,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);