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.4 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 48CB1C48BC2 for ; Mon, 28 Jun 2021 01:49:59 +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 C132B6197F for ; Mon, 28 Jun 2021 01:49:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C132B6197F 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 AD0DF82D92; Mon, 28 Jun 2021 03:49:16 +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="g6BaiuO5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBDB082C8C; Mon, 28 Jun 2021 03:48:58 +0200 (CEST) Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) (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 BE35582CDE for ; Mon, 28 Jun 2021 03:48:50 +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-oi1-x234.google.com with SMTP id q10so20082787oij.5 for ; Sun, 27 Jun 2021 18:48:50 -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=nG2yalVXF+a+NsMkQAnfaxJEjsdPXvpfLamO/72Qmy0=; b=g6BaiuO51l2J6QIeagwxF3L/XIOX/UwfXOKJqtbaMn2pca7Vdi3gbB/UuOQC9RGP0B 4F+r+MzE+fCclW5CT5H5aLGPEyUNIIzvOLIxKhegrckpgVy/tmyblGCIJbrvEiGZ30GB +s92MMR8wvEiueN9hdG9lRUiE5YABMjjFHn7Y= 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=nG2yalVXF+a+NsMkQAnfaxJEjsdPXvpfLamO/72Qmy0=; b=qFTh2qtGFePBDfyuSr1/VDtaRvYGUvanoc5b2mrnYefBf05xTYA8Pd9P7VKkaKkv0a rqD4gvAu4MRmaRpSUJ4CGUfk1UX9Mz4mZs45VhgMb1bM8E+sUQwwigFviaGRMmZw2ECW jTFCWra3L9dPXbC+48+qINRJEn/fkeWpzAUmtWLqo99nxBVeIZVGKTTRsJrfLG5iej5P RxjUFTr0GTT6y6GNofjTbQXOCz/ibmkCX6R0ht4BrehlnnTktjN2MU8NuyXftLGRIFbj KBFhWdNwnPmpMhLyqBRfsmQ9jCygkXuZv5R/N/n2fD5uHDhJnXkgmWbox6QRL3rW9xfl S3Mg== X-Gm-Message-State: AOAM531VnokhLjVtIz3vAwIcBPWY6D5KcxNThDF8P0sqAhqGS0Icdq4S Sgkgu9DqJiBHsx8yxQTw3WwQCM6bv14Z2cHW X-Google-Smtp-Source: ABdhPJxFUbz8IJL6beJBEHCwOvU+LFLdno15qMITyGSjsDjZK4g7L4gUeEdI0MmorT0Xy7zu8RcP5g== X-Received: by 2002:aca:fc0a:: with SMTP id a10mr1866541oii.150.1624844929186; Sun, 27 Jun 2021 18:48:49 -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 t21sm3140962otd.35.2021.06.27.18.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jun 2021 18:48:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= , Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass Subject: [PATCH 5/7] Allow efi_loader header to be included always Date: Sun, 27 Jun 2021 19:48:39 -0600 Message-Id: <20210627194836.5.Ic5e3dd89c2f6c206590d6c192242a3d2b2b7aa06@changeid> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210628014841.501036-1-sjg@chromium.org> References: <20210628014841.501036-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. This header provides two different versions of various functions. 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. Signed-off-by: Simon Glass --- include/efi_loader.h | 186 ++++++++++++++++++++++--------------------- 1 file changed, 95 insertions(+), 91 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 0a9c82a257e..2d532c5ccbb 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -28,12 +28,104 @@ 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 +#if CONFIG_IS_ENABLED(EFI_LOADER) + +/** + * __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 +557,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 +570,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 +703,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 +764,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 +958,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