From patchwork Tue Jul 22 00:43:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 34021 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B793520492 for ; Tue, 22 Jul 2014 00:46:48 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf60892125pab.4 for ; Mon, 21 Jul 2014 17:46:48 -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=MzXEi4Jehjuyiz+l6liqs9PZaX7/lL7sTOZRI+Rwqw0=; b=m+M+p42ig05dJKuT0aE2PcMDEKbXLIHkBSRctQKmd4HOgoZzosy7wBxOd/SvkMvgc2 f1KDJnRq87CO9kHCh53EOYmOZDLqPgHVlhcaKSghEbhZheAx9g6HRtP+ug4UYMVqsl+k HxfmVna9nBoGhzqf9XdOHCfi4N5IFrU4uYA1xMQTnabcdllkG3AKM+W6hhn9hs8O+oh7 KMZI2yRvEJPV+TxMN5M9HbAf1ZmmPJpvq/JC4QD+aHNs9o/1Yni5ZTJIXEbTYUfasKq2 tCMXxOCerMPHJbAvkRhrUG+m8yULgCm7peoR3ymJ50+jyZFkd8+e1jOazRL3f88GKiGq ysNw== X-Gm-Message-State: ALoCoQlnqdSEJraWxBeDLTJNL/K/ixLQCsqGbprozIDENCbjWBzN6Bn217xMaDi1lD2GRNRKRwZU X-Received: by 10.68.241.39 with SMTP id wf7mr3762183pbc.0.1405990008030; Mon, 21 Jul 2014 17:46:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.85 with SMTP id s79ls2185008qgd.77.gmail; Mon, 21 Jul 2014 17:46:47 -0700 (PDT) X-Received: by 10.221.41.135 with SMTP id tu7mr7624815vcb.70.1405990007828; Mon, 21 Jul 2014 17:46:47 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id yw1si12837444vdb.44.2014.07.21.17.46.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so13434114vcb.11 for ; Mon, 21 Jul 2014 17:46:47 -0700 (PDT) X-Received: by 10.220.44.141 with SMTP id a13mr7349297vcf.71.1405990007752; Mon, 21 Jul 2014 17:46:47 -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.37.5 with SMTP id tc5csp154192vcb; Mon, 21 Jul 2014 17:46:47 -0700 (PDT) X-Received: by 10.42.50.82 with SMTP id z18mr17116311icf.47.1405990007076; Mon, 21 Jul 2014 17:46:47 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id t6si32953238igr.26.2014.07.21.17.46.46 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:47 -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 1X9OBm-0000Ap-1C; Tue, 22 Jul 2014 00:44:18 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9OBk-00009v-Iy for xen-devel@lists.xen.org; Tue, 22 Jul 2014 00:44:16 +0000 Received: from [85.158.143.35:7543] by server-3.bemta-4.messagelabs.com id 26/6C-09960-FD3BDC35; Tue, 22 Jul 2014 00:44:15 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-10.tower-21.messagelabs.com!1405989853!19164178!1 X-Originating-IP: [209.85.192.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 32249 invoked from network); 22 Jul 2014 00:44:14 -0000 Received: from mail-pd0-f180.google.com (HELO mail-pd0-f180.google.com) (209.85.192.180) by server-10.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Jul 2014 00:44:14 -0000 Received: by mail-pd0-f180.google.com with SMTP id y13so10165243pdi.39 for ; Mon, 21 Jul 2014 17:44:13 -0700 (PDT) X-Received: by 10.68.65.36 with SMTP id u4mr7784115pbs.127.1405989853094; Mon, 21 Jul 2014 17:44:13 -0700 (PDT) Received: from rfranz-t520.local (c-24-10-97-91.hsd1.ca.comcast.net. [24.10.97.91]) by mx.google.com with ESMTPSA id fl3sm15417298pbc.35.2014.07.21.17.44.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jul 2014 17:44:12 -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: Mon, 21 Jul 2014 17:43:31 -0700 Message-Id: <1405989815-25236-9-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1405989815-25236-1-git-send-email-roy.franz@linaro.org> References: <1405989815-25236-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org, linaro-uefi@lists.linaro.org Subject: [Xen-devel] [PATCH V2 08/12] Refactor get_argv() for sharing 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.180 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: Refactor get_argv() to prepare for sharing by removing direct updating of the multiboot structures. The remaining command line is now returned in an argument rather than being directly updated by the get_argv() function. Signed-off-by: Roy Franz --- xen/arch/x86/efi/boot.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 2ef86d1..edbdb8a 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -175,7 +175,8 @@ static void __init place_string(u32 *addr, const char *s) } static unsigned int __init get_argv(unsigned int argc, CHAR16 **argv, - CHAR16 *cmdline, UINTN cmdsize) + CHAR16 *cmdline, UINTN cmdsize, + CHAR16 **cmdline_remain) { CHAR16 *ptr = (CHAR16 *)(argv + argc + 1), *prev = NULL; bool_t prev_sep = TRUE; @@ -201,10 +202,9 @@ 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 (**cmdline_remain) + *cmdline_remain = cmdline; break; } else @@ -747,7 +747,8 @@ static void __init relocate_image(unsigned long delta) bool_t __init handle_cmdline(EFI_LOADED_IMAGE *loaded_image, CHAR16 **cfg_file_name, bool_t *base_video, - CHAR16 **image_name, CHAR16 **section_name) + CHAR16 **image_name, CHAR16 **section_name, + CHAR16 **cmdline_remain) { unsigned int i, argc; @@ -761,14 +762,14 @@ bool_t __init handle_cmdline(EFI_LOADED_IMAGE *loaded_image, } 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, cmdline_remain); else argc = 0; @@ -844,6 +845,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) unsigned int i; CHAR16 *file_name = NULL, *cfg_file_name = NULL, *image_name = NULL; CHAR16 *section_name = NULL; + union string cmdline = { NULL }; UINTN cols, rows, depth, size, map_key, info_size, gop_mode = ~0; EFI_HANDLE *handles = NULL; EFI_SHIM_LOCK_PROTOCOL *shim_lock; @@ -884,9 +886,12 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) dir_handle = get_parent_handle(loaded_image, &file_name); if ( !handle_cmdline(loaded_image, &cfg_file_name, &base_video, &image_name, - §ion_name) ) + §ion_name, &cmdline.w) ) blexit(NULL); + if (cmdline.w) + place_string(&mbi.cmdline, w2s(&cmdline)); + section.w = section_name; if ( !base_video )