From patchwork Tue Dec 18 05:02:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154053 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3276278ljp; Mon, 17 Dec 2018 20:59:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/WOKC9yDPS1l/hKuR1q44k/6owNeY20lq73hHiRlktZOT/EoG790JQOAl6Giv8C8asdCw+s X-Received: by 2002:a50:9665:: with SMTP id y92mr14658473eda.282.1545109194479; Mon, 17 Dec 2018 20:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109194; cv=none; d=google.com; s=arc-20160816; b=d9is0wqGeGlHwz9mT1k631+D6BdKOkDD7ao59PpW3aB4emYAKOjdlaALhbSov8eKvm JxFadDvIBqgI4RU1DzfGRdUDe7c3DPzUnd7nfDO5nxz6JvTgJt8QRZdhF0sECu16OkFu aSH9yy1SR85OZ9BhaYTehIx1zE3KXpegd8E3SDDIZpeAfK+YjlnVcB/y9ZSRhsm0dEQt PJzWYiyZ1+ZLUjetDJCEo+afKpazXkoSp16dBsOkHqlyDLN5LVf3mw27n8ZSO3xD0aU3 CuMQAE2CzGp12WOAveHa1hZNe1QL9gyorCkh4187VIYMpGIWVawHYxAPMfJawhWNpWYS nQAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from:dkim-signature; bh=Ja6fTW8ckNOBA/e5r2Dp+Qw1VgY4LdYbzajtCAYn1U8=; b=eNOH5UG+dLu6iad0vnVLjZho0ihFln+VJCTS3BfFRPPb5DbI03lqvYjKqnCOeWd0CN I4ywYQ6wGkoY6HD6K+KkJ8CI5hdlX4Av3BAedqTAQQzVynsTKA6lti18103Mod/IxojT TYRNws3GAVVFABP/5yE5/i/pTiVr7MGzDV1M6hFM0ebrruV5uwPe503AonzZVPBx6zgv te49RRm2/m6WB6xGKyjWkB1xYlke/EMlcrUGslsdhDY1MvtuJ+PSYKARWuizsnuckytI PXmY6BklfEwiKhpoH34Luk5jB5KzK+Tf65fPatYySAdRPbUtsvbmPtihzuG8P9wpDOWU zyJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IzEf6nqB; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id b11si2528491edj.393.2018.12.17.20.59.54; Mon, 17 Dec 2018 20:59:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IzEf6nqB; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 05A1AC22088; Tue, 18 Dec 2018 04:59:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 55F08C21F69; Tue, 18 Dec 2018 04:59:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3955AC21DFA; Tue, 18 Dec 2018 04:59:02 +0000 (UTC) Received: from mail-yw1-f66.google.com (mail-yw1-f66.google.com [209.85.161.66]) by lists.denx.de (Postfix) with ESMTPS id A61E0C21E89 for ; Tue, 18 Dec 2018 04:59:01 +0000 (UTC) Received: by mail-yw1-f66.google.com with SMTP id d190so6159820ywd.12 for ; Mon, 17 Dec 2018 20:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M4vPgdUA3TdHtWr4dZBlAzrWM3InIsjyTg+vou1psts=; b=IzEf6nqB/OqGVBvefWrhBvffUwgbJZAD9IkQ00/oo/C1nLoNooacRheFe/MixTvoKJ sUidwmKEc29Nn1A7UgSsKMY2m6ZLqFZ7g3rYkxxxQtray0MQs6UfT7MP/JcZ34IfL1o+ NWdkG8AaNJAkYHDJVTOJ1tzGZb0Y+qt+sLjC4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M4vPgdUA3TdHtWr4dZBlAzrWM3InIsjyTg+vou1psts=; b=YnAkGHLcIVoeSdnkInRHgyPgMWUfFjpFjCu1pWFchjvignsbVQNSk23CxoYLkt0PGG r2oljb9WaP2mGaqHkkPmWBAu0DM/BPA4PzEGkKm9xdHtT1U89v/XJnMSb6RWctE+AcUi 6rPd0Uc7pt2gPzVhxsxLbLQj4wq1DnoSFsVrKEMwmeGiw351hKkIdfYz98QZdR9LZtJI FG8KBaHO846DO1kAst5KtvOe7Q013yjHc+1Jl8KKwZAbjKyX5qdCbI10xotoFTI6vtWB OsCuaR+7FfD5N7yQytQMbP67dDCBeKw1kew3ajC1qjSCVQop3Io6Qvfum1zqaNLvGj5Z ozrw== X-Gm-Message-State: AA+aEWZPZTn9VEqMQjjaWMLt7als4xUXLvnRZ3HiVDVgJvsLMVf71EGm QJ4JC4Oox23xqr8oZJK2fGNChg== X-Received: by 2002:a81:2916:: with SMTP id p22mr16221611ywp.176.1545109140338; Mon, 17 Dec 2018 20:59:00 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 131sm4986144ywn.88.2018.12.17.20.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:58:59 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:15 +0900 Message-Id: <20181218050215.20062-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] efi_loader: move efi_init_obj_list() to a new efi_setup.c X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The function, efi_init_obj_list(), can be shared in different pseudo efi applications, like bootefi/bootmgr as well as my efishell. Moreover, it will be utilized to extend efi initialization, for example, my "removable disk support" patch and "capsule-on-disk support" patch in the future. So with this patch, it will be moved to a new file, efi_setup.c, under lib/efi_loader and exported, making no changes in functionality. Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 75 ------------------------- include/efi_loader.h | 2 + lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_setup.c | 112 +++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 75 deletions(-) create mode 100644 lib/efi_loader/efi_setup.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 38679ffc56a9..7012d72ab50d 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -30,84 +30,9 @@ DECLARE_GLOBAL_DATA_PTR; #define OBJ_LIST_NOT_INITIALIZED 1 -static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; - static struct efi_device_path *bootefi_image_path; static struct efi_device_path *bootefi_device_path; -/* Initialize and populate EFI object list */ -efi_status_t efi_init_obj_list(void) -{ - efi_status_t ret = EFI_SUCCESS; - - /* - * On the ARM architecture gd is mapped to a fixed register (r9 or x18). - * As this register may be overwritten by an EFI payload we save it here - * and restore it on every callback entered. - */ - efi_save_gd(); - - /* Initialize once only */ - if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) - return efi_obj_list_initialized; - - /* Initialize system table */ - ret = efi_initialize_system_table(); - if (ret != EFI_SUCCESS) - goto out; - - /* Initialize root node */ - ret = efi_root_node_register(); - if (ret != EFI_SUCCESS) - goto out; - - /* Initialize EFI driver uclass */ - ret = efi_driver_init(); - if (ret != EFI_SUCCESS) - goto out; - - ret = efi_console_register(); - if (ret != EFI_SUCCESS) - goto out; -#ifdef CONFIG_PARTITIONS - ret = efi_disk_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO) - ret = efi_gop_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#ifdef CONFIG_NET - ret = efi_net_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#ifdef CONFIG_GENERATE_ACPI_TABLE - ret = efi_acpi_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#ifdef CONFIG_GENERATE_SMBIOS_TABLE - ret = efi_smbios_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif - ret = efi_watchdog_register(); - if (ret != EFI_SUCCESS) - goto out; - - /* Initialize EFI runtime services */ - ret = efi_reset_system_init(); - if (ret != EFI_SUCCESS) - goto out; - -out: - efi_obj_list_initialized = ret; - return ret; -} - /* * Allow unaligned memory access. * diff --git a/include/efi_loader.h b/include/efi_loader.h index 16633d6da0d5..dd68cfce5c65 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -252,6 +252,8 @@ extern struct list_head efi_obj_list; /* List of all events */ extern struct list_head efi_events; +/* Initialize efi execution environment */ +efi_status_t efi_init_obj_list(void); /* Called by bootefi to initialize root node */ efi_status_t efi_root_node_register(void); /* Called by bootefi to initialize runtime */ diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 26b999bf7c51..3ba539314aee 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -29,6 +29,7 @@ obj-y += efi_image_loader.o obj-y += efi_memory.o obj-y += efi_root_node.o obj-y += efi_runtime.o +obj-y += efi_setup.o obj-y += efi_unicode_collation.o obj-y += efi_variable.o obj-y += efi_watchdog.o diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c new file mode 100644 index 000000000000..215c163380ee --- /dev/null +++ b/lib/efi_loader/efi_setup.c @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI setup code + * + * Copyright (c) 2016 Alexander Graf + * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited + */ + +#if 1 /* TODO: cleanup */ +#include +#include +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_ARMV7_NONSEC +#include +#include +#endif +#endif + +DECLARE_GLOBAL_DATA_PTR; + +#define OBJ_LIST_NOT_INITIALIZED 1 + +static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; + +/* Initialize and populate EFI object list */ +efi_status_t efi_init_obj_list(void) +{ + efi_status_t ret = EFI_SUCCESS; + + /* + * On the ARM architecture gd is mapped to a fixed register (r9 or x18). + * As this register may be overwritten by an EFI payload we save it here + * and restore it on every callback entered. + */ + efi_save_gd(); + + /* Initialize once only */ + if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) + return efi_obj_list_initialized; + + /* Initialize system table */ + ret = efi_initialize_system_table(); + if (ret != EFI_SUCCESS) + goto out; + + /* Initialize root node */ + ret = efi_root_node_register(); + if (ret != EFI_SUCCESS) + goto out; + + /* Initialize EFI driver uclass */ + ret = efi_driver_init(); + if (ret != EFI_SUCCESS) + goto out; + + ret = efi_console_register(); + if (ret != EFI_SUCCESS) + goto out; +#ifdef CONFIG_PARTITIONS + ret = efi_disk_register(); + if (ret != EFI_SUCCESS) + goto out; +#endif +#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO) + ret = efi_gop_register(); + if (ret != EFI_SUCCESS) + goto out; +#endif +#ifdef CONFIG_NET + ret = efi_net_register(); + if (ret != EFI_SUCCESS) + goto out; +#endif +#ifdef CONFIG_GENERATE_ACPI_TABLE + ret = efi_acpi_register(); + if (ret != EFI_SUCCESS) + goto out; +#endif +#ifdef CONFIG_GENERATE_SMBIOS_TABLE + ret = efi_smbios_register(); + if (ret != EFI_SUCCESS) + goto out; +#endif + ret = efi_watchdog_register(); + if (ret != EFI_SUCCESS) + goto out; + + /* Initialize EFI runtime services */ + ret = efi_reset_system_init(); + if (ret != EFI_SUCCESS) + goto out; + +out: + efi_obj_list_initialized = ret; + return ret; +}