From patchwork Tue Jul 22 00:43: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: 34016 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2B14420492 for ; Tue, 22 Jul 2014 00:46:22 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf55572051pdb.1 for ; Mon, 21 Jul 2014 17:46:21 -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=7ftfvMSXqy5hcUzDlYQ2W9nFveS6IMh6eoiZRTWYim0=; b=VM8d81nTZwibwEF5MI1lvIQ7CSQG5aB5MWauiI8H7CPDbBT/AMLmWxVJr1JOxBlTmQ D8w+oiRftJh6K8i7moNEhzt16l0rctIboOuxNLLFodobJ9qiHEYziwXpzmkLyXDl3iuH A/T0uIcl0J2UNKTrO314ffNZkPyiraWWcd/M3iHwhZBL8Z08kLOIi6A2gS7xWk9d8AxH 6QsKwjlpO78lCE8MAJEcvFfe1IW/6eU9I9R07qugVp//2fyqxEj3Kkj780t46IlTqkAL R/m/ykDtn5zMMKK4uQxH3YrVoA7xG8UiroA9PImC+aqKvHhQMRK6LVAaZoS5lhPdOxFA KqGQ== X-Gm-Message-State: ALoCoQk/QsOiHzXFqT0uj75k4kw3M5V9/xrc3zUAA/rcjVhYXLgNQuR7/IYY5QSbLBySyKb99XzI X-Received: by 10.68.107.33 with SMTP id gz1mr9177044pbb.5.1405989980990; Mon, 21 Jul 2014 17:46:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.36 with SMTP id k33ls2218227qgf.79.gmail; Mon, 21 Jul 2014 17:46:20 -0700 (PDT) X-Received: by 10.221.39.132 with SMTP id tm4mr7391158vcb.74.1405989980816; Mon, 21 Jul 2014 17:46:20 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id ke8si12848727vec.83.2014.07.21.17.46.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so13463032vcb.5 for ; Mon, 21 Jul 2014 17:46:20 -0700 (PDT) X-Received: by 10.52.244.138 with SMTP id xg10mr29457248vdc.40.1405989980680; Mon, 21 Jul 2014 17:46:20 -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 tc5csp154160vcb; Mon, 21 Jul 2014 17:46:20 -0700 (PDT) X-Received: by 10.42.123.204 with SMTP id t12mr17579366icr.19.1405989979162; Mon, 21 Jul 2014 17:46:19 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id uh4si32968980igc.6.2014.07.21.17.46.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:19 -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 1X9OBl-0000AG-7u; Tue, 22 Jul 2014 00:44:17 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9OBh-00008d-Rr for xen-devel@lists.xen.org; Tue, 22 Jul 2014 00:44:14 +0000 Received: from [85.158.139.211:6656] by server-5.bemta-5.messagelabs.com id D2/4A-09027-DD3BDC35; Tue, 22 Jul 2014 00:44:13 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-9.tower-206.messagelabs.com!1405989850!16750995!1 X-Originating-IP: [209.85.192.172] 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 6625 invoked from network); 22 Jul 2014 00:44:12 -0000 Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by server-9.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 22 Jul 2014 00:44:12 -0000 Received: by mail-pd0-f172.google.com with SMTP id ft15so10089077pdb.17 for ; Mon, 21 Jul 2014 17:44:10 -0700 (PDT) X-Received: by 10.68.143.100 with SMTP id sd4mr18189688pbb.76.1405989850235; Mon, 21 Jul 2014 17:44:10 -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.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jul 2014 17:44:09 -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:29 -0700 Message-Id: <1405989815-25236-7-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 06/12] 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.220.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: 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 | 116 ++++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 48 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 546ff1c..fa6aca4 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -510,6 +510,70 @@ char * __init truncate_string(char *s) return(NULL); } +bool_t __init read_config_file(EFI_FILE_HANDLE *cfg_dir_handle, + struct file *cfg, CHAR16 *cfg_file_name, + union string *section, + CHAR16 *xen_file_name) +{ + /* + * This allocation is internal to the EFI stub, so any address is + * fine. + */ + EFI_PHYSICAL_ADDRESS max = ~0; + + /* 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, max) ) + break; + *tail = 0; + } + if ( !tail ) + return 0; + PrintStr(L"Using configuration file '"); + PrintStr(xen_file_name); + PrintStr(L"'\r\n"); + } + else if ( !read_file(*cfg_dir_handle, cfg_file_name, cfg, max) ) + return 0; + pre_parse(cfg); + + if ( section->w ) + w2s(section); + else + section->s = get_value(cfg, "global", "default"); + + + for ( ; ; ) + { + union string dom0_kernel_name; + 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, max) ) + { + PrintStr(L"Chained configuration file '"); + PrintStr(dom0_kernel_name.w); + efi_bs->FreePool(dom0_kernel_name.w); + PrintStr(L"'not found."); + return 0; + } + pre_parse(cfg); + efi_bs->FreePool(dom0_kernel_name.w); + } + return 1; +} + static void __init edd_put_string(u8 *dst, size_t n, const char *src) { while ( n-- && *src ) @@ -722,8 +786,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) u64 efer; bool_t base_video = 0; bool_t load_ok = 0; - EFI_PHYSICAL_ADDRESS max_addr = min(1UL << (32 + PAGE_SHIFT), - HYPERVISOR_VIRT_END - DIRECTMAP_VIRT_START); efi_ih = ImageHandle; efi_bs = SystemTable->BootServices; @@ -855,53 +917,11 @@ 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; + if ( !read_config_file(&dir_handle, &cfg, cfg_file_name, §ion, + file_name) ) + blexit(L"Unable to read configuration file."); - while ( (tail = point_tail(file_name)) != NULL ) - { - wstrcpy(tail, L".cfg"); - if ( read_file(dir_handle, file_name, &cfg, max_addr) ) - 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, max_addr) ) - 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, max_addr) ) - { - 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);