From patchwork Sun Dec 30 14:16:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 154614 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10014480ljp; Sun, 30 Dec 2018 06:17:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/UQnz96GiwzPXB3hg/oF3LRdczEYsQSMsEDcaLzvAhCqZY3n+7PpgRmz3G6tDukpOu3hZVT X-Received: by 2002:a50:b536:: with SMTP id y51mr28580047edd.201.1546179464169; Sun, 30 Dec 2018 06:17:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546179464; cv=none; d=google.com; s=arc-20160816; b=DQwPWM2OEkVrscL/TbbOCbwYg6tZvxB3w/nNeJLl07N1QgDk0l4xOCSNFBnDYhYNSR 09WqMoFtktlNJd7SzDpCxS7GuVGLzFGH6bfF1++N5IyKcQHHiBASHVULrdxTHv1A0lKZ +KdL3No7pv5KaLnXgOEuNqbfUEIHabDAwsGVn4LeuxryL/DJvDkZ+8dupiUqFC5KwEDh 8qqM/xftt4+8oaNDMFzZ32UzX76XH1/y6tT3X2YbELQ7UGkVtKMu8D0Rd0lz7nqN4FPi 7NURb2Y7aNNyRstXfFZleQfHuitBLgrcWcR7wrVvJ9TCmiXFP+9lT9pOCQ4p/bk0spqV Lnjw== 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; bh=YWu5Ubt5LUXmEVnAVaG3zxhDLBnxAhh7h31HxIMfDjc=; b=quhQSD++7DuIsKiYSJyMYbi/NEK/w6Hgi3bqRflzGvNprg0YL3QlnR+A7ef1aWHDo1 jOC7xxyihsrkiEuLU4OxOYal1poiHrmA9UNhT1uu3SwdVIbYGoKKDjCO6f79T//LYnAE 3d4/ZXqKjCV3BRzfsivkF2cA/stj+QUu2v/AgQLlMPbuW3EUJPLewnrkjC1Lhs1l67dr urK0AYLHe+CjgYM2TniSvCIj52tCihPlvmZRKmmkh4opORtKaBu3kmPSBJaNZjwwiH1U lDWiAww8Vm3kmqFZYmA1JefJ5ypD0yHmdEoAa8qEnOMR9HSDqJ3LuSmU8oAQpog73YD2 lixQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id o2-v6si3629030ejx.251.2018.12.30.06.17.43; Sun, 30 Dec 2018 06:17:44 -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; 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 Received: by lists.denx.de (Postfix, from userid 105) id 27963C21E68; Sun, 30 Dec 2018 14:17:40 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2 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 85AD1C21C51; Sun, 30 Dec 2018 14:17:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5607EC21C51; Sun, 30 Dec 2018 14:17:36 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id E3C2DC21BE5 for ; Sun, 30 Dec 2018 14:17:35 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.159.3]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MfjJY-1h0cvo3sAe-00N8s4; Sun, 30 Dec 2018 15:17:33 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 30 Dec 2018 15:16:55 +0100 Message-Id: <20181230141655.27361-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-Provags-ID: V03:K1:njqDV6HHS1dnnRQjQDQWZXvbe2Shx9rgjikQmeD07VjFBSkiOlP OrNg8p7DqT3Q8D3nb8vsscgaFDSbSbNu+nugs+71o5tE7x17B6FaRTXZZnNmUMmAeh8agkb pLujMS7198HwyOaYl1Vbhzv2VPhzVTozwbeTyr+z3GzFIpVTu8Z+ogxZAkEh+przMlL8Ijt 6hz38++B00zeT8/fuR53g== X-UI-Out-Filterresults: notjunk:1; V03:K0:jFX36ABPCv0=:h2JTtA7H0d3MIve6QFEcd1 utbz/Q1JGiHPMarTSVMJXRV6h/Ads0sex4jpCqZGY6dnUYRT1h+Uvy7VqRRWTs/hpOEn0v/aj SCLdnXrSb2LrBKMwOWfiKk0C6x5zXy7pveSpCFIHuk0ATypSq2e6kh7h6VBLmWAbiR0bf5Cq5 QIqt2J2qBbTV07wweR7/Dtfnon2Gx9XuBSdMSRFeObEGsl1RX3TMsWHUQJIpstUT3xDXx0gFl KLUcAvd1BG8YrmhGvLupTbqcCzyx/uN5HbCu3BqScK1Y4fyLqbR8lVHJfCvrp8Nr5Uc/BFHIh RSx8CWTIVAAOK0knd7ajORt68SknW+W+m3wmr1Fce26NEhtUA8J18CiL/tPrk+OCWkelqgynC cUHl/4JPzsuQbmuXWRCS69tOT3pZxr2C08l2Gkv9ezq9omqfUMgFivpdgf2Df6WQa+kJ6daob MM7Qcxzc7Bf7OYsF3tKfCMaFdioPSYdX/ZOc4Rh7J6VqOfgTjEWiiL+P+uIqLhQLifDFgJLgO W1d2inmgVAZqR1DFVici0rp8dE1SrQHl3Yxx34IS8c72olsOhqEOnz3AOvd8TEyRxhKWb7jG3 QbT3GX8A40UiL7MID/BnnprCXd00uKNBnkSsVY0P+AEDc3aWp+0USoYUzkMRck4itbkFeVBZ0 XkNvSX+D7kYMKrADUGZarBW8zXeAwhgvrTmYsQwmrii9QxDa0R6Z1sftSKBM7rnxzqyEI5SkL Spikn6T0hvpllRf+uVaFB3DNjmZn9wZvbYP6HO9ZFxAm8GJlrbFcq98SBbQUW0dOUvbmf4L4S wh3FvkHcda8HYeWpCcrZWzWpAt7yRUPNrhMydvBuMAzVSLart8JSKLea1o52sst6NPOqbbQIB 8PYrARhy3jSP66E/AqkLFJxjc9+oW1l844EmVFJdPsGF/zEW2azq9Hzb0kYcFc Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 1/1] 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" From: AKASHI Takahiro 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 Remove lines deactivated by #if 1 #else Reviewed-by: Heinrich Schuchardt --- v2 Remove lines deactivated by #if 1 #else Remove unused #define OBJ_LIST_NOT_INITIALIZED from cmd/bootefi.c Correct copyright lines (moving lines to another file does not establish any new copyright) --- cmd/bootefi.c | 77 ---------------------------------- include/efi_loader.h | 2 + lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_setup.c | 86 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 77 deletions(-) create mode 100644 lib/efi_loader/efi_setup.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index cc0f2923dc..356849dca3 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -28,86 +28,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 53f08161ab..6323686f9d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -244,6 +244,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 6703435947..a7bba58d41 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -28,6 +28,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 0000000000..8266d06c2e --- /dev/null +++ b/lib/efi_loader/efi_setup.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI setup code + * + * Copyright (c) 2016-2018 Alexander Graf et al. + */ + +#include +#include + +#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; +}