From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0BBBC07E95 for ; Fri, 2 Jul 2021 19:08:16 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 581D16141C for ; Fri, 2 Jul 2021 19:08:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 581D16141C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2C5D682BF0; Fri, 2 Jul 2021 21:07:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="h0QxYkJo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B46D582ADF; Fri, 2 Jul 2021 21:06:49 +0200 (CEST) Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3A11C829E4 for ; Fri, 2 Jul 2021 21:06:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x330.google.com with SMTP id m6-20020a9d1d060000b029044e2d8e855eso11019721otm.8 for ; Fri, 02 Jul 2021 12:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aEPKYr7rqkKuzIMevPzo5zi5zzkPhxvhkP/G7iBDM20=; b=h0QxYkJoRc2JIkwos6DugsjrsmV9o78vwxZ0TOmZ5Yla4bwuWLzFaPwxQhfxJho/H6 2MZ9OFt254siyD0UszfnT8B6j4ORdc5mBgRsiZqr+k1LtnQPmus21KcopoFk4q/r8WjE AI8uPwcZufzeqEUAClHbgRXAgcBLczHHikXLE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=aEPKYr7rqkKuzIMevPzo5zi5zzkPhxvhkP/G7iBDM20=; b=Dn1sDf8ZTbwZslro9BKJjZfXLuAbEZE2K/VSdy20vFhdTn5VAPV+eQDEhk05VFcM4g FBbOVlE7j27DOYs5yxxe0L3TYLryjbNykgvYcXkPm6x9NdmSwK3CE+IOSPGoFzIzz26I shkrhQVKgAqghvD+8YjuEH8Qg6qmo5m0LWCAMcNjvJ/UcYPc361cXJTRtVcNz9PmTDyi /YK/6RAAVUgIgaYixXA/CJBu+G7509SvNMxYABvUxvbaNsHPVcszRhKHbRMY7uR+gIB9 97EjQiENUhPtO5qCAL/hgrNcajBquXbmtzkRsJ5Jae0oiObLhmLsiubhxuVIyxTSpYlC TkfA== X-Gm-Message-State: AOAM532ohhuStEwv68yNYY78hu/RDeDzP5JYq6dgpVO1r1l67CU9QjHF ks+mUSO/Xuxk+WX+BhbnS+oy922tzwMO/Yzp X-Google-Smtp-Source: ABdhPJzaW2IeQfbyxIyn04QaG9bYF4sYeds+vDbFlKebHZg/INVrklLLbk4uSsErKjPlqCt60J7Z0w== X-Received: by 2002:a9d:2032:: with SMTP id n47mr616269ota.173.1625252798567; Fri, 02 Jul 2021 12:06:38 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id v8sm772625oth.69.2021.07.02.12.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 12:06:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Mark Kettenis , Heinrich Schuchardt , Simon Glass Subject: [PATCH v2 5/9] Allow efi_loader header to be included always Date: Fri, 2 Jul 2021 12:36:16 -0600 Message-Id: <20210702183620.1542680-3-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210702183620.1542680-1-sjg@chromium.org> References: <20210702183620.1542680-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean It is bad practice to put function declarations behind an #ifdef since it makes it impossible to use IS_ENABLED() in the C code. The main reason for doing this is when an empty static inline function is desired when the feature is disabled. To this end, this header provides two different versions of various functions and macros. Collect them together in one place for clarity. Allow all the rest of the header to be included, regardless of the setting of EFI_LOADER. With the inclusion of blk.h the 'struct blk_desc' declaration is unnecessary. Drop it while we are here. Signed-off-by: Simon Glass --- Changes in v2: - Update commit message to be clearer - Drop 'struct blk_desc' - Move all header inclusions to the top include/efi_loader.h | 187 ++++++++++++++++++++++--------------------- 1 file changed, 94 insertions(+), 93 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 0a9c82a257e..6fb5696056c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -15,8 +15,8 @@ #include #include #include - -struct blk_desc; +#include +#include static inline int guidcmp(const void *g1, const void *g2) { @@ -28,11 +28,100 @@ static inline void *guidcpy(void *dst, const void *src) return memcpy(dst, src, sizeof(efi_guid_t)); } -/* No need for efi loader support in SPL */ #if CONFIG_IS_ENABLED(EFI_LOADER) -#include -#include +/** + * __efi_runtime_data - declares a non-const variable for EFI runtime section + * + * This macro indicates that a variable is non-const and should go into the + * EFI runtime section, and thus still be available when the OS is running. + * + * Only use on variables not declared const. + * + * Example: + * + * :: + * + * static __efi_runtime_data my_computed_table[256]; + */ +#define __efi_runtime_data __section(".data.efi_runtime") + +/** + * __efi_runtime_rodata - declares a read-only variable for EFI runtime section + * + * This macro indicates that a variable is read-only (const) and should go into + * the EFI runtime section, and thus still be available when the OS is running. + * + * Only use on variables also declared const. + * + * Example: + * + * :: + * + * static const __efi_runtime_rodata my_const_table[] = { 1, 2, 3 }; + */ +#define __efi_runtime_rodata __section(".rodata.efi_runtime") + +/** + * __efi_runtime - declares a function for EFI runtime section + * + * This macro indicates that a function should go into the EFI runtime section, + * and thus still be available when the OS is running. + * + * Example: + * + * :: + * + * static __efi_runtime compute_my_table(void); + */ +#define __efi_runtime __section(".text.efi_runtime") + +/* + * Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region + * to make it available at runtime + */ +efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len); + +/* + * Special case handler for error/abort that just tries to dtrt to get + * back to u-boot world + */ +void efi_restore_gd(void); +/* Call this to set the current device name */ +void efi_set_bootdev(const char *dev, const char *devnr, const char *path, + void *buffer, size_t buffer_size); +/* Called by networking code to memorize the dhcp ack package */ +void efi_net_set_dhcp_ack(void *pkt, int len); +/* Print information about all loaded images */ +void efi_print_image_infos(void *pc); + +/* Hook at initialization */ +efi_status_t efi_launch_capsules(void); + +#else /* CONFIG_IS_ENABLED(EFI_LOADER) */ + +/* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ +#define __efi_runtime_data +#define __efi_runtime_rodata +#define __efi_runtime +static inline efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) +{ + return EFI_SUCCESS; +} + +/* No loader configured, stub out EFI_ENTRY */ +static inline void efi_restore_gd(void) { } +static inline void efi_set_bootdev(const char *dev, const char *devnr, + const char *path, void *buffer, + size_t buffer_size) { } +static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } +static inline void efi_print_image_infos(void *pc) { } +static inline efi_status_t efi_launch_capsules(void) +{ + return EFI_SUCCESS; +} + +#endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ /* Maximum number of configuration tables */ #define EFI_MAX_CONFIGURATION_TABLES 16 @@ -465,8 +554,6 @@ efi_status_t efi_smbios_register(void); struct efi_simple_file_system_protocol * efi_fs_from_path(struct efi_device_path *fp); -/* Called by networking code to memorize the dhcp ack package */ -void efi_net_set_dhcp_ack(void *pkt, int len); /* Called by efi_set_watchdog_timer to reset the timer */ efi_status_t efi_set_watchdog(unsigned long timeout); @@ -480,14 +567,8 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, struct efi_loaded_image *loaded_image_info); /* Called once to store the pristine gd pointer */ void efi_save_gd(void); -/* Special case handler for error/abort that just tries to dtrt to get - * back to u-boot world */ -void efi_restore_gd(void); /* Call this to relocate the runtime section to an address space */ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); -/* Call this to set the current device name */ -void efi_set_bootdev(const char *dev, const char *devnr, const char *path, - void *buffer, size_t buffer_size); /* Add a new object to the object list. */ void efi_add_handle(efi_handle_t obj); /* Create handle */ @@ -619,8 +700,6 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path, struct efi_device_path *file_path, struct efi_loaded_image_obj **handle_ptr, struct efi_loaded_image **info_ptr); -/* Print information about all loaded images */ -void efi_print_image_infos(void *pc); #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER extern void *efi_bounce_buffer; @@ -682,62 +761,12 @@ ssize_t efi_dp_check_length(const struct efi_device_path *dp, (((_dp)->type == DEVICE_PATH_TYPE_##_type) && \ ((_dp)->sub_type == DEVICE_PATH_SUB_TYPE_##_subtype)) -/** - * __efi_runtime_data - declares a non-const variable for EFI runtime section - * - * This macro indicates that a variable is non-const and should go into the - * EFI runtime section, and thus still be available when the OS is running. - * - * Only use on variables not declared const. - * - * Example: - * - * :: - * - * static __efi_runtime_data my_computed_table[256]; - */ -#define __efi_runtime_data __section(".data.efi_runtime") - -/** - * __efi_runtime_rodata - declares a read-only variable for EFI runtime section - * - * This macro indicates that a variable is read-only (const) and should go into - * the EFI runtime section, and thus still be available when the OS is running. - * - * Only use on variables also declared const. - * - * Example: - * - * :: - * - * static const __efi_runtime_rodata my_const_table[] = { 1, 2, 3 }; - */ -#define __efi_runtime_rodata __section(".rodata.efi_runtime") - -/** - * __efi_runtime - declares a function for EFI runtime section - * - * This macro indicates that a function should go into the EFI runtime section, - * and thus still be available when the OS is running. - * - * Example: - * - * :: - * - * static __efi_runtime compute_my_table(void); - */ -#define __efi_runtime __section(".text.efi_runtime") - /* Indicate supported runtime services */ efi_status_t efi_init_runtime_supported(void); /* Update CRC32 in table header */ void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table); -/* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region - * to make it available at runtime */ -efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len); - /* Boards may provide the functions below to implement RTS functionality */ void __efi_runtime EFIAPI efi_reset_system( @@ -926,34 +955,6 @@ efi_status_t efi_capsule_authenticate(const void *capsule, #define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" -/* Hook at initialization */ -efi_status_t efi_launch_capsules(void); - -#else /* CONFIG_IS_ENABLED(EFI_LOADER) */ - -/* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ -#define __efi_runtime_data -#define __efi_runtime_rodata -#define __efi_runtime -static inline efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) -{ - return EFI_SUCCESS; -} - -/* No loader configured, stub out EFI_ENTRY */ -static inline void efi_restore_gd(void) { } -static inline void efi_set_bootdev(const char *dev, const char *devnr, - const char *path, void *buffer, - size_t buffer_size) { } -static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } -static inline void efi_print_image_infos(void *pc) { } -static inline efi_status_t efi_launch_capsules(void) -{ - return EFI_SUCCESS; -} - -#endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ - /** * Install the ESRT system table. * -- 2.32.0.93.g670b81a890-goog