From 645f7b299b8571d2a48d959cd301feb17010abd8 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 19 Oct 2024 10:50:29 +0200 Subject: efi_selftest: fix typo 'got languages' in HII test %s/got languages are/Available languages:/ Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Acked-by: Ilias Apalodimas --- lib/efi_selftest/efi_selftest_hii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c index f219c0120a3..c363df466dc 100644 --- a/lib/efi_selftest/efi_selftest_hii.c +++ b/lib/efi_selftest/efi_selftest_hii.c @@ -913,7 +913,7 @@ static int test_hii_string_get_languages(void) goto out; } - efi_st_printf("got languages are %s\n", languages); + efi_st_printf("Available languages: %s\n", languages); result = EFI_ST_SUCCESS; -- cgit v1.3.1 From e2f34f4d55b71d258b3b37b8e5f2fea75ce66e8f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 19 Oct 2024 11:03:56 +0200 Subject: efi_selftest: make HII test data static Variables that are only used locally in a module should not be exported. * Make the HII test data variables static. * Remove unused GUIDs. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- lib/efi_selftest/efi_selftest_hii_data.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/efi_selftest/efi_selftest_hii_data.c b/lib/efi_selftest/efi_selftest_hii_data.c index d19f0682afd..5fc890112b4 100644 --- a/lib/efi_selftest/efi_selftest_hii_data.c +++ b/lib/efi_selftest/efi_selftest_hii_data.c @@ -39,7 +39,7 @@ /* HII keyboard layout */ #define EFI_NULL_MODIFIER 0x0000 -u8 packagelist1[] = { +static u8 packagelist1[] = { // EFI_HII_PACKAGE_LIST_HEADER, length = 20 // SimpleFont, Font, GUID, Form, String, Image, DevicePath, // (74) (110) 20 (8) 78 (67) (8) @@ -262,7 +262,7 @@ u8 packagelist1[] = { EFI_HII_PACKAGE_END }; -u8 packagelist2[] = { +static u8 packagelist2[] = { // EFI_HII_PACKAGE_LIST_HEADER, length = 20 // SimpleFont, Font, GUID, KeyboardLayout, Form, End // (74) (122) 20 192 (8) 4 @@ -424,30 +424,10 @@ u8 packagelist2[] = { EFI_HII_PACKAGE_END // 1 }; -efi_guid_t packagelist_guid1 = - EFI_GUID(0x03abcd89, 0x03f4, 0x7044, - 0x81, 0xde, 0x99, 0xb1, 0x81, 0x20, 0xf7, 0x68); - -efi_guid_t packagelist_guid2 = - EFI_GUID(0x8685ded3, 0x1bce, 0x43f3, - 0xa2, 0x0c, 0xa3, 0x06, 0xec, 0x69, 0x72, 0xdd); - -efi_guid_t kb_layout_guid11 = +static efi_guid_t kb_layout_guid11 = EFI_GUID(0x8d40e495, 0xe2aa, 0x4c6f, 0x89, 0x70, 0x68, 0x85, 0x09, 0xee, 0xc7, 0xd2); -efi_guid_t kb_layout_guid12 = - EFI_GUID(0x2ae60b3e, 0xb9d6, 0x49d8, - 0x9a, 0x16, 0xc2, 0x48, 0xf1, 0xeb, 0xa8, 0xdb); - -efi_guid_t kb_layout_guid21 = - EFI_GUID(0xe0f56a1f, 0xdf6b, 0x4a7e, - 0xa3, 0x9a, 0xe7, 0xa5, 0x19, 0x15, 0x45, 0xd6); - -efi_guid_t kb_layout_guid22 = - EFI_GUID(0x47be6ac9, 0x54cc, 0x46f9, - 0xa2, 0x62, 0xd5, 0x3b, 0x25, 0x6a, 0x0c, 0x34); - -efi_guid_t package_guid = +static efi_guid_t package_guid = EFI_GUID(0x0387c95a, 0xd703, 0x2346, 0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8); -- cgit v1.3.1 From 1dd01ab1a4260363c49a36a1e4c28490b86f4407 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 19 Oct 2024 12:59:57 +0200 Subject: efi_loader: fix CONFIG_EFI_HTTP dependencies CONFIG_CMD_DNS and CONFIG_CMD_WGET depend on CONFIG_CMD_NET. CONFIG_CMD_NET depends on CONFIG_NET or CONFIG_NET_LWIP. We shall only enable CONFIG_EFI_HTTP if there is network support. We have to select CONFIG_CMD_NET. Fixes: d7d07a8b508b ("efi_loader: support boot from URI device path") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- lib/efi_loader/Kconfig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 69b2c9360d8..066f0ca0da7 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -545,6 +545,8 @@ config EFI_BOOTMGR config EFI_HTTP_BOOT bool "EFI HTTP Boot support" + depends on NET || NET_LWIP + select CMD_NET select CMD_DNS select CMD_WGET select BLKMAP -- cgit v1.3.1 From 4588ab997634a73ac2ac6b47ce8009152f59cace Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 24 Oct 2024 14:01:55 +0300 Subject: efi_loader: Simplify efi_free_pages() We currently call efi_free_pages() with a notify flag and explicitly update the efi memory map. That's not needed as lmb_free_flags() will do that for us if the LMB_NONOTIFY flag is removed Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_memory.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 9f3f0876997..d2f5d563f2a 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -521,7 +521,6 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) { u64 len; - uint flags; long status; efi_status_t ret; @@ -536,18 +535,17 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) return EFI_INVALID_PARAMETER; } - flags = LMB_NOOVERWRITE | LMB_NONOTIFY; len = (u64)pages << EFI_PAGE_SHIFT; + /* + * The 'memory' variable for sandbox holds a pointer which has already + * been mapped with map_sysmem() from efi_allocate_pages(). Convert + * it back to an address LMB understands + */ status = lmb_free_flags(map_to_sysmem((void *)(uintptr_t)memory), len, - flags); + LMB_NOOVERWRITE); if (status) return EFI_NOT_FOUND; - ret = efi_add_memory_map_pg(memory, pages, EFI_CONVENTIONAL_MEMORY, - false); - if (ret != EFI_SUCCESS) - return EFI_NOT_FOUND; - return ret; } -- cgit v1.3.1 From b63cb21221a4f032f9ae7491ff9ff7891a8d3e00 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Sat, 26 Oct 2024 10:37:32 +0300 Subject: efi_loader: Mark efi_bootmgr_release_uridp as static This is only used locally so make it static Suggested-by: Andy Shevchenko Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt Reviewed-by: Andy Shevchenko --- lib/efi_loader/efi_bootmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a3aa2b8d1b9..f9b5988a06e 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -385,7 +385,7 @@ err: * @ctx: event context * Return: status code */ -efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx) +static efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx) { efi_status_t ret = EFI_SUCCESS; efi_status_t ret2 = EFI_SUCCESS; -- cgit v1.3.1 From bfc30742b8e26a2d96d979c8cd076f82afab22a5 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Sat, 26 Oct 2024 10:43:17 +0300 Subject: efi_loader: Mark static function in dumpdtb A few functions are only used locally but miss the 'static' keyword. Add it and quiesce W=1 build wanrings Signed-off-by: Ilias Apalodimas --- lib/efi_loader/dtbdump.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/dtbdump.c b/lib/efi_loader/dtbdump.c index 9f1d8fb82cb..a3d59a2fd3b 100644 --- a/lib/efi_loader/dtbdump.c +++ b/lib/efi_loader/dtbdump.c @@ -225,7 +225,7 @@ static u32 f2h(fdt32_t val) * @systable: system table * Return: device tree or NULL */ -void *get_dtb(struct efi_system_table *systable) +static void *get_dtb(struct efi_system_table *systable) { void *dtb = NULL; efi_uintn_t i; @@ -246,7 +246,7 @@ void *get_dtb(struct efi_system_table *systable) * @pos: UTF-16 string * Return: pointer to first non-whitespace */ -u16 *skip_whitespace(u16 *pos) +static u16 *skip_whitespace(u16 *pos) { for (; *pos && *pos <= 0x20; ++pos) ; @@ -260,7 +260,7 @@ u16 *skip_whitespace(u16 *pos) * @keyword: keyword to be searched * Return: true fi @string starts with the keyword */ -bool starts_with(u16 *string, u16 *keyword) +static bool starts_with(u16 *string, u16 *keyword) { for (; *keyword; ++string, ++keyword) { if (*string != *keyword) @@ -272,7 +272,7 @@ bool starts_with(u16 *string, u16 *keyword) /** * do_help() - print help */ -void do_help(void) +static void do_help(void) { error(u"dump - print device-tree\r\n"); error(u"load - load device-tree from file\r\n"); @@ -332,7 +332,7 @@ open_file_system(struct efi_simple_file_system_protocol **file_system) * @filename: file name * Return: status code */ -efi_status_t do_load(u16 *filename) +static efi_status_t do_load(u16 *filename) { struct efi_dt_fixup_protocol *dt_fixup_prot; struct efi_simple_file_system_protocol *file_system; @@ -469,7 +469,7 @@ out: * @filename: file name * Return: status code */ -efi_status_t do_save(u16 *filename) +static efi_status_t do_save(u16 *filename) { struct efi_simple_file_system_protocol *file_system; efi_uintn_t dtb_size; -- cgit v1.3.1 From 6507ec20ba543103875a431b0897ea6cb9b1aaf5 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Sat, 26 Oct 2024 10:57:41 +0300 Subject: efi_loader: Mark static functions in smbiosdump Mark functions that are only used locally as static and quiesce W=1 warnings Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/smbiosdump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/smbiosdump.c b/lib/efi_loader/smbiosdump.c index 2f0b91a353d..d7f2ba30a95 100644 --- a/lib/efi_loader/smbiosdump.c +++ b/lib/efi_loader/smbiosdump.c @@ -289,7 +289,7 @@ static void *get_config_table(const efi_guid_t *guid) * @len: length of buffer * Return: checksum */ -u8 checksum(void *buf, int len) +static u8 checksum(void *buf, int len) { u8 ret = 0; @@ -304,7 +304,7 @@ u8 checksum(void *buf, int len) * * Return: status code */ -efi_status_t do_check(void) +static efi_status_t do_check(void) { struct smbios3_entry *smbios3_anchor; void *table, *table_end; @@ -401,7 +401,7 @@ efi_status_t do_check(void) * @buf: buffer to write * @size: size of the buffer */ -efi_status_t save_file(u16 *filename, void *buf, efi_uintn_t size) +static efi_status_t save_file(u16 *filename, void *buf, efi_uintn_t size) { efi_uintn_t ret; struct efi_simple_file_system_protocol *file_system; -- cgit v1.3.1 From 84b95e918942d0e29e3634d265694030f76faf5a Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Sat, 26 Oct 2024 11:00:49 +0300 Subject: efi_loader: Remove unused diskid That variable is defined and assigned a value in two functions but it's never used. Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_disk.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 93a9a5ac025..1f3de0a2339 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -561,11 +561,9 @@ static int efi_disk_create_raw(struct udevice *dev, efi_handle_t agent_handle) { struct efi_disk_obj *disk; struct blk_desc *desc; - int diskid; efi_status_t ret; desc = dev_get_uclass_plat(dev); - diskid = desc->devnum; ret = efi_disk_add_dev(NULL, NULL, desc, NULL, 0, &disk, agent_handle); @@ -608,7 +606,6 @@ static int efi_disk_create_part(struct udevice *dev, efi_handle_t agent_handle) struct disk_part *part_data; struct disk_partition *info; unsigned int part; - int diskid; struct efi_handler *handler; struct efi_device_path *dp_parent; struct efi_disk_obj *disk; @@ -618,7 +615,6 @@ static int efi_disk_create_part(struct udevice *dev, efi_handle_t agent_handle) return -1; desc = dev_get_uclass_plat(dev_get_parent(dev)); - diskid = desc->devnum; part_data = dev_get_uclass_plat(dev); part = part_data->partnum; -- cgit v1.3.1 From c8c10b83ef0a7a04ba40223c841f6f721d9a28a3 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Wed, 30 Oct 2024 22:40:59 +0200 Subject: efi_loader: Make tcg2_uninit() static This function is only used locally, so make it static and quiesce the W=1 warning Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_tcg2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 45f451ef6b6..866a529857e 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -789,7 +789,7 @@ static const struct efi_tcg2_protocol efi_tcg2_protocol = { /** * tcg2_uninit - remove the final event table and free efi memory on failures */ -void tcg2_uninit(void) +static void tcg2_uninit(void) { efi_status_t ret; -- cgit v1.3.1 From 7596d77bc1b6be838e38af3fb4e73dbd0a0a078e Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Wed, 30 Oct 2024 21:17:48 +0000 Subject: lib: efi_loader: Fix efi_dp_from_mem() calls The function expects an end address but is being called with an size instead. Fixes: 6422820ac3 ("efi_loader: split unrelated code from efi_bootmgr.c") Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas Signed-off-by: Moritz Fischer Reviewed-by: Patrick Wildt --- lib/efi_loader/efi_bootbin.c | 1 + lib/efi_loader/efi_device_path.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_bootbin.c b/lib/efi_loader/efi_bootbin.c index a87006b3c0e..bf38392fac3 100644 --- a/lib/efi_loader/efi_bootbin.c +++ b/lib/efi_loader/efi_bootbin.c @@ -137,6 +137,7 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) */ file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, (uintptr_t)source_buffer, + (uintptr_t)source_buffer + source_size); /* * Make sure that device for device_path exist diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 9de3b95d073..d7444588aa0 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -1073,7 +1073,8 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, efi_get_image_parameters(&image_addr, &image_size); dp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, - (uintptr_t)image_addr, image_size); + (uintptr_t)image_addr, + (uintptr_t)image_addr + image_size); } else if (IS_ENABLED(CONFIG_NETDEVICES) && !strcmp(dev, "Net")) { dp = efi_dp_from_eth(); } else if (!strcmp(dev, "Uart")) { -- cgit v1.3.1