From patchwork Sat Jun 28 01:25:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 32651 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C1230200B9 for ; Sat, 28 Jun 2014 01:27:34 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id va2sf32859996obc.10 for ; Fri, 27 Jun 2014 18:27:34 -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=sur4I/jKK2bVr5lZhFxU1n8k0mUWwW+eGBUaPdZmJpM=; b=BtvIV7n2he3aLn8AOrM4mRwBUr8a1Q0g6HpyqLmfLUUUNEaPegg97eg34Tg7C9f8oC f8FfCGDa/G94joZLwLyifeVmNSw2osPPcIWiqBAp3JlPMEfTCxZNaeDO8wgWziZBcmRB y8bBzIt0qUr1y+eCY8V/IhrpOWwy5spT+6bTHiPLXTUDUii1aO6Nmzk4rcbiyQTZPisy E6NFe6omFSkXpXBw1P1YAybXQnlUWNL2SMtDXG+Aj4w1ZpLTly7Gs9/LAY7t8eMrKSqv j1PHlwtAkluOh+OkEAOo7H9HwT2Kxk94spHlOqlg4+F+lGD9ejEQ/a5r5zaJ4V52xGqN 3T/g== X-Gm-Message-State: ALoCoQnGdjJpOTjooysCUNFsxiiIO/rXXWdzdyYCooPBS6LStYrxRxcSPCID4aQNcY1ls5rGf3/+ X-Received: by 10.50.73.197 with SMTP id n5mr2761320igv.1.1403918854417; Fri, 27 Jun 2014 18:27:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.11 with SMTP id n11ls860553qge.11.gmail; Fri, 27 Jun 2014 18:27:34 -0700 (PDT) X-Received: by 10.220.92.193 with SMTP id s1mr22946910vcm.34.1403918854338; Fri, 27 Jun 2014 18:27:34 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id fa3si7205486vdc.63.2014.06.27.18.27.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 18:27:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so6051621veb.6 for ; Fri, 27 Jun 2014 18:27:34 -0700 (PDT) X-Received: by 10.52.26.237 with SMTP id o13mr19154284vdg.1.1403918854208; Fri, 27 Jun 2014 18:27:34 -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 tc5csp147851vcb; Fri, 27 Jun 2014 18:27:33 -0700 (PDT) X-Received: by 10.224.130.201 with SMTP id u9mr38744150qas.98.1403918853725; Fri, 27 Jun 2014 18:27:33 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id x2si15966111qai.74.2014.06.27.18.27.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Jun 2014 18:27:33 -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 1X0hP2-0007Ks-Bc; Sat, 28 Jun 2014 01:26:04 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X0hOz-0007Ix-K2 for xen-devel@lists.xen.org; Sat, 28 Jun 2014 01:26:02 +0000 Received: from [193.109.254.147:43197] by server-12.bemta-14.messagelabs.com id D9/88-32179-9A91EA35; Sat, 28 Jun 2014 01:26:01 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1403918758!14221377!1 X-Originating-IP: [209.85.220.46] 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 23143 invoked from network); 28 Jun 2014 01:25:59 -0000 Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 28 Jun 2014 01:25:59 -0000 Received: by mail-pa0-f46.google.com with SMTP id eu11so5379555pac.33 for ; Fri, 27 Jun 2014 18:25:58 -0700 (PDT) X-Received: by 10.68.94.225 with SMTP id df1mr34949688pbb.86.1403918757986; Fri, 27 Jun 2014 18:25:57 -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.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jun 2014 18:25:57 -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:27 +0100 Message-Id: <1403918735-30027-12-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 11/19] add read_config_file() function for XEN EFI config file 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.175 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: Move open-coded reading of the XEN EFI configuration file into a shared fuction read_config_file(). The open-coded version returned the dom0 kernel name in a global variable. This has been replaced by an explicit lookup of the dom0 kernel name after the initial processing of the config file has completed. Signed-off-by: Roy Franz --- xen/arch/x86/efi/boot.c | 49 +++------------------------------ xen/arch/x86/efi/efi-shared.c | 63 +++++++++++++++++++++++++++++++++++++++++++ xen/include/efi/efi-shared.h | 4 +++ 3 files changed, 70 insertions(+), 46 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 0583c6a..912b6de 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -514,53 +514,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( EFI_ERROR(status) ) gop = NULL; - /* Read and parse the config file. */ - if ( !cfg_file_name ) - { - CHAR16 *tail; + read_config_file(&dir_handle, &cfg, cfg_file_name, + §ion, file_name); - while ( (tail = point_tail(file_name)) != NULL ) - { - wstrcpy(tail, L".cfg"); - if ( read_file(dir_handle, file_name, &cfg) ) - break; - *tail = 0; - } - if ( !tail ) - blexit(L"No configuration file found."); - PrintStr(L"Using configuration file '"); - PrintStr(file_name); - PrintStr(L"'\r\n"); - } - else if ( !read_file(dir_handle, cfg_file_name, &cfg) ) - blexit(L"Configuration file not found."); - pre_parse(&cfg); - - if ( section.w ) - w2s(§ion); - else - section.s = get_value(&cfg, "global", "default"); - - for ( ; ; ) - { - name.s = get_value(&cfg, section.s, "kernel"); - if ( name.s ) - break; - name.s = get_value(&cfg, "global", "chain"); - if ( !name.s ) - break; - efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size)); - cfg.addr = 0; - if ( !read_file(dir_handle, s2w(&name), &cfg) ) - { - PrintStr(L"Chained configuration file '"); - PrintStr(name.w); - efi_bs->FreePool(name.w); - blexit(L"'not found."); - } - pre_parse(&cfg); - efi_bs->FreePool(name.w); - } + name.s = get_value(&cfg, section.s, "kernel"); if ( !name.s ) blexit(L"No Dom0 kernel image specified."); place_string(&mb_modules[mbi.mods_count].string, name.s); diff --git a/xen/arch/x86/efi/efi-shared.c b/xen/arch/x86/efi/efi-shared.c index 6abbc88..43601fe 100644 --- a/xen/arch/x86/efi/efi-shared.c +++ b/xen/arch/x86/efi/efi-shared.c @@ -200,6 +200,69 @@ char * __init truncate_string(char *s) return(NULL); } + + +void __init read_config_file(EFI_FILE_HANDLE *cfg_dir_handle, + struct file *cfg, CHAR16 *cfg_file_name, + union string *section, + CHAR16 *xen_file_name) +{ + + /* Read and parse the config file. */ + if ( !cfg_file_name ) + { + CHAR16 *tail; + + while ( (tail = point_tail(xen_file_name)) != NULL ) + { + wstrcpy(tail, L".cfg"); + if ( read_file(*cfg_dir_handle, xen_file_name, cfg) ) + break; + *tail = 0; + } + if ( !tail ) + blexit(L"No configuration file found."); + PrintStr(L"Using configuration file '"); + PrintStr(xen_file_name); + PrintStr(L"'\r\n"); + } + else if ( !read_file(*cfg_dir_handle, cfg_file_name, cfg) ) + blexit(L"Configuration file not found."); + pre_parse(cfg); + + if ( section->w ) + w2s(section); + else + section->s = get_value(cfg, "global", "default"); + + + for ( ; ; ) + { + union string dom0_kernel_name; + // RFRANZ_TODO - would like to get rid of this kernel lookup, + // but can't as it allows both kernel _and_ chain to be specified + // with kernel overriding chain. + // !! different sections.... + dom0_kernel_name.s = get_value(cfg, section->s, "kernel"); + if ( dom0_kernel_name.s ) + break; + dom0_kernel_name.s = get_value(cfg, "global", "chain"); + if ( !dom0_kernel_name.s ) + break; + efi_bs->FreePages(cfg->addr, PFN_UP(cfg->size)); + cfg->addr = 0; + if ( !read_file(*cfg_dir_handle, s2w(&dom0_kernel_name), cfg) ) + { + PrintStr(L"Chained configuration file '"); + PrintStr(dom0_kernel_name.w); + efi_bs->FreePool(dom0_kernel_name.w); + blexit(L"'not found."); + } + pre_parse(cfg); + efi_bs->FreePool(dom0_kernel_name.w); + } +} + EFI_FILE_HANDLE __init get_parent_handle(EFI_LOADED_IMAGE *loaded_image, CHAR16 **leaf) { diff --git a/xen/include/efi/efi-shared.h b/xen/include/efi/efi-shared.h index 98e9e89..a1028d1 100644 --- a/xen/include/efi/efi-shared.h +++ b/xen/include/efi/efi-shared.h @@ -57,4 +57,8 @@ void __init noreturn blexit(const CHAR16 *str); bool_t __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, struct file *file); char * __init truncate_string(char *s); +void __init read_config_file(EFI_FILE_HANDLE *cfg_dir_handle, + struct file *cfg, CHAR16 *cfg_file_name, + union string *section, + CHAR16 *xen_file_name); #endif