From patchwork Mon Sep 8 03:53:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 36931 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E55B20491 for ; Mon, 8 Sep 2014 03:56:06 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id r10sf1537625pdi.4 for ; Sun, 07 Sep 2014 20:56:05 -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=GgfX72pChKjXUyh3lhYT6LGarSDdxpfYHT4+5vPzy54=; b=aoKNvH9++/cOQN4+SD5muQVz9Lrxf0TI32u2HPPRlc/uDrmlgckJxU8Ad6irJdGD+S Tl8bI7R7oJ792ivwhZFwQASfHHIjwPDiq7MgB5le2UKhFmygRSByxtv7WKM/RVdSyWFk P/GTu/6Egu2s6LO8YnN/b58eDDBIaRKImI+i2NSIwRhwrmvSAKNH6IC/2fcX/VLS4w3S XbzIYIhsnBhZm8mSHhPuVamQZH7F0f8SFu8+dr+jbf9IOfROBRuPPwBBun3qhMGqnwQ3 3a4X/boGzLVEDufda6gF7QUDAWbLtFWAs+pc1Mp639cOOzFJ/gKzU9xR5O8iANee6h7V qjOA== X-Gm-Message-State: ALoCoQlq1+gidecGozACfyLbG5he3crr/iiU1H8+chcWarrG09qBKiAwpxd6nHpVP0rJft0wDBsD X-Received: by 10.66.163.41 with SMTP id yf9mr16270170pab.36.1410148565656; Sun, 07 Sep 2014 20:56:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.81 with SMTP id v75ls695081qge.9.gmail; Sun, 07 Sep 2014 20:56:05 -0700 (PDT) X-Received: by 10.52.253.39 with SMTP id zx7mr19385234vdc.2.1410148565546; Sun, 07 Sep 2014 20:56:05 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id sd10si4077106vdb.79.2014.09.07.20.56.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 07 Sep 2014 20:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id ik5so14461185vcb.7 for ; Sun, 07 Sep 2014 20:56:05 -0700 (PDT) X-Received: by 10.52.136.196 with SMTP id qc4mr19590402vdb.22.1410148565445; Sun, 07 Sep 2014 20:56:05 -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 uj3csp76440vcb; Sun, 7 Sep 2014 20:56:05 -0700 (PDT) X-Received: by 10.224.161.11 with SMTP id p11mr38232472qax.40.1410148564837; Sun, 07 Sep 2014 20:56:04 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i49si9669555qgd.114.2014.09.07.20.56.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 07 Sep 2014 20:56:04 -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 1XQq2A-0006yY-D0; Mon, 08 Sep 2014 03:54:30 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XQq27-0006wH-P8 for xen-devel@lists.xen.org; Mon, 08 Sep 2014 03:54:27 +0000 Received: from [85.158.143.35:64072] by server-2.bemta-4.messagelabs.com id 24/FE-04525-2782D045; Mon, 08 Sep 2014 03:54:26 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1410148464!12201744!1 X-Originating-IP: [209.85.220.45] 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 551 invoked from network); 8 Sep 2014 03:54:25 -0000 Received: from mail-pa0-f45.google.com (HELO mail-pa0-f45.google.com) (209.85.220.45) by server-11.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 8 Sep 2014 03:54:25 -0000 Received: by mail-pa0-f45.google.com with SMTP id rd3so1503437pab.18 for ; Sun, 07 Sep 2014 20:54:23 -0700 (PDT) X-Received: by 10.66.121.103 with SMTP id lj7mr42530043pab.80.1410148463834; Sun, 07 Sep 2014 20:54:23 -0700 (PDT) Received: from rfranz-i7.local (c-24-10-97-91.hsd1.ca.comcast.net. [24.10.97.91]) by mx.google.com with ESMTPSA id qy1sm7524053pbc.27.2014.09.07.20.54.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Sep 2014 20:54:23 -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: Sun, 7 Sep 2014 20:53:52 -0700 Message-Id: <1410148441-18684-7-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410148441-18684-1-git-send-email-roy.franz@linaro.org> References: <1410148441-18684-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org, linaro-uefi@lists.linaro.org Subject: [Xen-devel] [PATCH V3 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.176 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 | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 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 42b087e..dea9be3 100644 --- a/xen/include/asm-x86/efi-boot.h +++ b/xen/include/asm-x86/efi-boot.h @@ -606,3 +606,36 @@ 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; +}