From patchwork Thu Sep 18 22:49:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37623 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B6C572054E for ; Thu, 18 Sep 2014 22:52:54 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e53sf1120988eek.6 for ; Thu, 18 Sep 2014 15:52:53 -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=U715Lp09EE8J7ZtDqpLO/o+21FdAzjEhmEGKESyYQ+Q=; b=bQehrRBVgjfecmkkcEXid6f8Ft0iEKN1VZLYtkeTln7XjVVrJOsc59xjZzhczo/7Ir +bXMmwkfqb1EAQ0MPb7JkkyTbm0U2Ez3A3nE1Efzkecjpuu/S5AYAlsfoG/LqculPHwt /nPz5GnZ7++yVQ8sV+kmVkhGBpAHnzNmYgbOAemkCen7OnaJ2AzV7OglNc3JQVAhzETk q6RCdWuv5S//bqMNOWAOZzRkYgBSrd2Mz0hwjQUQY9lrXMpasQjmg7N3nQWK5QF/NTeG cNYT5E6xOuLZVqX5TkOefV3PbNb5oXoVsg1iLIhjlPbG+u2ANA8lLEy69VEcOtZdMX0T TQ7g== X-Gm-Message-State: ALoCoQn0xoISrnte/85Voo4etqwuXPv0W70LjnotBkIOUNWc6jP+H0R9S0Ni2l9q+tG8UA41EdiK X-Received: by 10.112.163.104 with SMTP id yh8mr1209040lbb.5.1411080773814; Thu, 18 Sep 2014 15:52:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.169 with SMTP id k9ls280040laa.91.gmail; Thu, 18 Sep 2014 15:52:53 -0700 (PDT) X-Received: by 10.112.180.137 with SMTP id do9mr2492670lbc.63.1411080773341; Thu, 18 Sep 2014 15:52:53 -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 qi3si166510lbb.41.2014.09.18.15.52.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 15:52:53 -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 gi9so2103409lab.30 for ; Thu, 18 Sep 2014 15:52:52 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr2809323lac.44.1411080772812; Thu, 18 Sep 2014 15:52: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 of9csp843177lbb; Thu, 18 Sep 2014 15:52:52 -0700 (PDT) X-Received: by 10.220.127.84 with SMTP id f20mr1761139vcs.3.1411080770698; Thu, 18 Sep 2014 15:52:50 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id w18si41903vdj.103.2014.09.18.15.52.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 18 Sep 2014 15:52: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 1XUkWy-0006Kp-0U; Thu, 18 Sep 2014 22:50:28 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XUkWw-0006Jd-Ed for xen-devel@lists.xen.org; Thu, 18 Sep 2014 22:50:26 +0000 Received: from [193.109.254.147:17859] by server-4.bemta-14.messagelabs.com id B1/09-01677-1B16B145; Thu, 18 Sep 2014 22:50:25 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1411080622!16516442!1 X-Originating-IP: [209.85.220.42] 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 20916 invoked from network); 18 Sep 2014 22:50:24 -0000 Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by server-4.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 18 Sep 2014 22:50:24 -0000 Received: by mail-pa0-f42.google.com with SMTP id lj1so2503183pab.29 for ; Thu, 18 Sep 2014 15:50:22 -0700 (PDT) X-Received: by 10.68.230.102 with SMTP id sx6mr10661234pbc.0.1411080622552; Thu, 18 Sep 2014 15:50:22 -0700 (PDT) Received: from rfranz-t520.swisscom.com (70-35-38-154.static.wiline.com. [70.35.38.154]) by mx.google.com with ESMTPSA id ig4sm66332pbb.55.2014.09.18.15.50.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Sep 2014 15:50:21 -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: Thu, 18 Sep 2014 15:49:57 -0700 Message-Id: <1411080607-32365-7-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1411080607-32365-1-git-send-email-roy.franz@linaro.org> References: <1411080607-32365-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH V5 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.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/common/efi/boot.c | 37 +++++++++---------------------------- xen/include/asm-x86/efi-boot.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 58e3cbc..2f8dade 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); @@ -256,7 +257,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; @@ -282,10 +284,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 @@ -660,7 +660,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; @@ -701,14 +701,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 ) @@ -878,17 +878,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 ) @@ -955,15 +945,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 93498bb..6e9376a 100644 --- a/xen/include/asm-x86/efi-boot.h +++ b/xen/include/asm-x86/efi-boot.h @@ -279,3 +279,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; +}