From patchwork Sat Jun 28 01:25:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 32658 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C00E8200B9 for ; Sat, 28 Jun 2014 01:27:58 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id eu11sf24376862pac.10 for ; Fri, 27 Jun 2014 18:27:58 -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=9WcGFpisQntVFTHqmqA9Ia/hdJ4Zc5dp41ZXhjDM3U0=; b=S47ML9clokTbju3LXimqymvdc8u52eDpGJT++IPDrJ2EAt3HBPdMGayxwDUTDrXgkB U3vop1GQE8wOPPEOMGpxxKwYEhqqLZEsL1w3dD1lE4Cu5N/7c8u7Ye7PBbSdzjMIdAaD daHIFHfif8FRhXNWA5YvnDuTx+ljZ4LSjPITXc5Ef6h+MdhSuF3oIEkDlESuoMHNMPyt uqr9CP04vF2TRL/n0nOwnHCagOjysgoFd/lXa/2YE2Wrn9Yi2Xe3b79KHHTlkI5tXTfo 6rc8eevUSWasqblHqqsXfmcFQMeQfqK++MO7JS6O74v/PNz7aQh6Mg6H4594oG4cEXtc KKLw== X-Gm-Message-State: ALoCoQks6DPV8GaaIV2T++Z2wfvpAKGBIkxiXRB8aFwoH8zLwrBA+xtWYISkXJ4d2P1dD8x+RBbG X-Received: by 10.67.30.71 with SMTP id kc7mr13807290pad.39.1403918878037; Fri, 27 Jun 2014 18:27:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.50 with SMTP id i47ls802360qgd.38.gmail; Fri, 27 Jun 2014 18:27:57 -0700 (PDT) X-Received: by 10.58.229.162 with SMTP id sr2mr22538902vec.15.1403918877905; Fri, 27 Jun 2014 18:27:57 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id b5si7215608vdj.25.2014.06.27.18.27.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 18:27:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.174 as permitted sender) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jx11so6106767veb.19 for ; Fri, 27 Jun 2014 18:27:57 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr23102916vcb.28.1403918877758; Fri, 27 Jun 2014 18:27:57 -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 tc5csp147870vcb; Fri, 27 Jun 2014 18:27:57 -0700 (PDT) X-Received: by 10.140.27.23 with SMTP id 23mr36692841qgw.94.1403918877350; Fri, 27 Jun 2014 18:27:57 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id h6si15972405qcm.9.2014.06.27.18.27.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Jun 2014 18:27:57 -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 1X0hP3-0007NB-J7; Sat, 28 Jun 2014 01:26:05 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X0hP1-0007K3-LS for xen-devel@lists.xen.org; Sat, 28 Jun 2014 01:26:03 +0000 Received: from [85.158.139.211:34745] by server-12.bemta-5.messagelabs.com id 6A/46-27841-AA91EA35; Sat, 28 Jun 2014 01:26:02 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1403918760!7183738!1 X-Originating-IP: [209.85.192.175] 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 21265 invoked from network); 28 Jun 2014 01:26:02 -0000 Received: from mail-pd0-f175.google.com (HELO mail-pd0-f175.google.com) (209.85.192.175) by server-10.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 28 Jun 2014 01:26:02 -0000 Received: by mail-pd0-f175.google.com with SMTP id v10so5109388pde.6 for ; Fri, 27 Jun 2014 18:26:00 -0700 (PDT) X-Received: by 10.67.23.227 with SMTP id id3mr34430545pad.45.1403918760548; Fri, 27 Jun 2014 18:26:00 -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 eh4sm16637918pbc.79.2014.06.27.18.25.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jun 2014 18:26:00 -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: Sat, 28 Jun 2014 02:25:29 +0100 Message-Id: <1403918735-30027-14-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1403918735-30027-1-git-send-email-roy.franz@linaro.org> References: <1403918735-30027-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org, linaro-uefi@lists.linaro.org Subject: [Xen-devel] [PATCH RFC 13/19] 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.128.174 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 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 6ee3c1f..49e0c15 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -118,7 +118,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; @@ -144,10 +145,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 @@ -348,7 +348,8 @@ static void __init relocate_image(unsigned long delta) void __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; @@ -362,14 +363,14 @@ void __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; @@ -445,6 +446,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) unsigned int i; CHAR16 *file_name, *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; @@ -487,7 +489,13 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) &cfg_file_name, &base_video, &image_name, - §ion_name); + §ion_name, + &cmdline.w); + + if (cmdline.w) + { + place_string(&mbi.cmdline, w2s(&cmdline)); + } section.w = section_name;