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=-12.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 7CB1AC2B9F4 for ; Mon, 28 Jun 2021 11:02:36 +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 BF8F661C6A for ; Mon, 28 Jun 2021 11:02:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF8F661C6A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de 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 AD43882DAD; Mon, 28 Jun 2021 13:02:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.net header.i=@gmx.net header.b="YDwOw2HO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0765482DAF; Mon, 28 Jun 2021 13:02:32 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 863F282DAA for ; Mon, 28 Jun 2021 13:02:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1624878146; bh=hEBgWUSc5ADPlEsNjQDUqZxn3czICSebAMoBUU+yaMc=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=YDwOw2HO3k9U9BRkeI1w370kmYijvylKagIuoNcPPXubCIeZMNlpopzNHpRZc0YcK FfuOe2gBIFpgecEcvkv0ZtproxmwA21BRW0iEToIB2+/8yecNT+7y+JYEWkhJjjWhw Et62iN5Wsx0cG9vvYS+SOFUygkCyVghc2IxhCmXk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([88.152.144.157]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MmlTC-1lYtsq1uNy-00jrB6; Mon, 28 Jun 2021 13:02:26 +0200 Subject: Re: [PATCH 5/7] Allow efi_loader header to be included always To: Simon Glass Cc: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Ilias Apalodimas , Tom Rini , U-Boot Mailing List , Alexander Graf References: <20210628014841.501036-1-sjg@chromium.org> <20210627194836.5.Ic5e3dd89c2f6c206590d6c192242a3d2b2b7aa06@changeid> From: Heinrich Schuchardt Message-ID: Date: Mon, 28 Jun 2021 13:02:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210627194836.5.Ic5e3dd89c2f6c206590d6c192242a3d2b2b7aa06@changeid> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:04sHaOC7SXfusrH2npulMX8GDOaFF4MsETvR1KXyD5iKOeuheK/ LEaorSigsMLL6+2QuAt9yFNHJPJi4u6flrDkxV01c3bYtQmKEB33IcIWwq5wd7VXZNxE4GW h05zbtcEenfbxw95BDadNkSd7lOgq5CqFDr8s4xNczASa0OPzFvK2T9HJIuViugubG7rvVU IcSoApqvqfHfrYv8WMSSw== X-UI-Out-Filterresults: notjunk:1;V03:K0:pKRMFPeIn+0=:QgP6sTsKKYr+FWx5lhUwRM NHrkDDFTjqHMRqnxkBcm7uOoSxpOvYARNq6VT4xWjgFJdpr09/rl3w+g8/RdbMBAk6HlNmDTn AoJJyFINmv12wrMLfm8mCe7vHlIlzMwVf46f+GdoMrSHsRsu9pBg47uGCjjA0XneWj1QcS52r T26TWw6VSjhc0uWqJGTUJJo4i6TfOJkHI3i8Y2DuHVIbEwWgSid6varmu9sAEoOtcs/kNWNOB lJ5TB2gm4/ASVEXkRTjq5PkvZ0IzMFpRQxTNXAjXwMsSyITtdgeupC3UxXyQPMhVdzvcwp6QI AzDhxHbPu5Grn+HN5Mq9XkTGU39XGSO8JnY9jyxmYejXuR20p33c0STYeM8mTWpy+cY/z5/q/ H384zMZ1hXBA+iDC0G/GraRhSKRx0xY+djC4zhZ2McUUaMGHNMLzYgL3QgmW2v7eXQRQkSmB5 HcFFoKq6HnC6qESv0tIaWQlQ5IKRbYRvK9wb30bTL+RSRonLpPC6wkjAVBGHfyHufFbTQmGG/ KH8vv/57TWeO6hUpym8sUVIjkbFGJ1THNjZTt3N+DMrzGKx/7r3xdvpMDFCdBuo/3p6tZ67zu ma2Osts+Mz0Yc7KTacZnej6ZKqNxPsxtv0gq9MXZieE5CgNfbLj0tUR06sD5QqcaueeyouHUG J5hF0QKGe2N5l+qBC7T6hwSDdng7faAbQAo6I0X6R5tS1xl8Izk6dgcKeADMOV0ywsI1WSUhh dOv0vyyhZNwWwLGWr6UDnKNXvJ0MnfupmqypvebQK/+v0rfsteIZ77S4rmYnBrJixUoPbxxAX HFu3BhGspoVUBG7ljgo4C2dJ5zs5QMDogbfMTU+mKgHEvI8deVBBgN4TU1+a086Ivt3gwpL44 JilLId8E5GRiaUoXETVEw0yMc78Hg6XQNNFQ/e26H3+6zfYQKSgo50fTtZbEheWXkRJTZ+HhJ 89KD53pIjBwNF+kpOmm1Ulm9kuLbbnuQChmXtSYwmEaOksIrrLZnZUI/L/ERHCtPpRGIZItGA BpcX5i9e9QPcwB5Q5Uv7QbUWxWrh7PNm59g8raQxO+rtURDeC2AZ250CFRct8atLRoYGrS+xQ zZcne+UY4PmSyBK0204ytv4gTKXTm71E4b0 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 On 6/28/21 3:48 AM, Simon Glass wrote: > 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. Collec= t > 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 Why are these includes not listed with the other includes? Please, move them up. Why should we have both "#include " and "struct blk_desc;"? I assume "struct blk_desc;" can be eliminated. Cf. e6f6f9e64882 ("common: Drop part.h from common header") Hiding "efi_status_t efi_add_runtime_mmio()" through "efi_status_t efi_launch_capsules()" behind "#if CONFIG_IS_ENABLED(EFI_LOADER)" contradicts the commit message. +CC Alex, reviewer EFI PAYLOAD Best regards Heinrich > > +#if CONFIG_IS_ENABLED(EFI_LOADER) > + > +/** > + * __efi_runtime_data - declares a non-const variable for EFI runtime s= ection > + * > + * 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 runn= ing. > + * > + * 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[] =3D { 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 reg= ion > + * 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 *pa= th, > + 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 o= ut */ > +#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_ob= j *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 *pa= th, > - 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_devic= e_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_devic= e_path *dp, > (((_dp)->type =3D=3D DEVICE_PATH_TYPE_##_type) && \ > ((_dp)->sub_type =3D=3D DEVICE_PATH_SUB_TYPE_##_subtype)) > > -/** > - * __efi_runtime_data - declares a non-const variable for EFI runtime s= ection > - * > - * 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 runn= ing. > - * > - * 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[] =3D { 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 reg= ion > - * 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 functionali= ty */ > > void __efi_runtime EFIAPI efi_reset_system( > @@ -926,34 +958,6 @@ efi_status_t efi_capsule_authenticate(const void *c= apsule, > > #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 o= ut */ > -#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. > * >