From 38671d4f1cd44c22e5485606034ed5f3be9f1211 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 11 Jul 2019 06:07:40 +0200 Subject: efi_loader: duplicate IMAGE_SUBSYSTEM_EFI_APPLICATION IMAGE_SUBSYSTEM_EFI_APPLICATION is already defined in include/asm-generic/pe.h which is included in include/pe.h. We should not define it twice. Signed-off-by: Heinrich Schuchardt --- include/pe.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/pe.h b/include/pe.h index 36e1908b7ea..c7aeb2dcb6f 100644 --- a/include/pe.h +++ b/include/pe.h @@ -48,7 +48,6 @@ typedef struct _IMAGE_DOS_HEADER { #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b -#define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 typedef struct _IMAGE_FILE_HEADER { uint16_t Machine; -- cgit v1.2.3 From a35c33c0dc9ef9d2ab44cf677ac17a359c79b019 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 11 Jul 2019 06:39:32 +0200 Subject: efi_loader: use predefined constants in crt0_*_efi.S We should use predefined constants instead of magic numbers. Move some constant definitions from include/pe.h to include/asm-generic/pe.h. Use these constants in crt0_*_efi.S. Signed-off-by: Heinrich Schuchardt --- include/asm-generic/pe.h | 16 ++++++++++++++++ include/pe.h | 15 --------------- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/asm-generic/pe.h b/include/asm-generic/pe.h index faae534e371..b247519a3d5 100644 --- a/include/asm-generic/pe.h +++ b/include/asm-generic/pe.h @@ -29,6 +29,22 @@ #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 +/* Machine types */ +#define IMAGE_FILE_MACHINE_I386 0x014c +#define IMAGE_FILE_MACHINE_ARM 0x01c0 +#define IMAGE_FILE_MACHINE_THUMB 0x01c2 +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 +#define IMAGE_FILE_MACHINE_AMD64 0x8664 +#define IMAGE_FILE_MACHINE_ARM64 0xaa64 +#define IMAGE_FILE_MACHINE_RISCV32 0x5032 +#define IMAGE_FILE_MACHINE_RISCV64 0x5064 + +/* Header magic constants */ +#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x010b +#define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x020b +#define IMAGE_DOS_SIGNATURE 0x5a4d /* MZ */ +#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */ + /* Subsystem type */ #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 diff --git a/include/pe.h b/include/pe.h index c7aeb2dcb6f..bff3b0aa7a6 100644 --- a/include/pe.h +++ b/include/pe.h @@ -34,21 +34,6 @@ typedef struct _IMAGE_DOS_HEADER { uint32_t e_lfanew; /* 3c: Offset to extended header */ } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; -#define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */ -#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */ - -#define IMAGE_FILE_MACHINE_I386 0x014c -#define IMAGE_FILE_MACHINE_ARM 0x01c0 -#define IMAGE_FILE_MACHINE_THUMB 0x01c2 -#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 -#define IMAGE_FILE_MACHINE_AMD64 0x8664 -#define IMAGE_FILE_MACHINE_ARM64 0xaa64 -#define IMAGE_FILE_MACHINE_RISCV32 0x5032 -#define IMAGE_FILE_MACHINE_RISCV64 0x5064 - -#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b -#define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b - typedef struct _IMAGE_FILE_HEADER { uint16_t Machine; uint16_t NumberOfSections; -- cgit v1.2.3 From b225c92fd0c0b09b99e2290c5e42708f9046a7a2 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Mon, 15 Jul 2019 12:00:39 +0100 Subject: efi_loader: Change return type of efi_add_memory_map() We currently have some inconsistent use of efi_add_memory_map() throughout the code. In particular the return value of efi_add_memory_map() is not interpreted the same way by various users in the codebase. This patch does the following: - Changes efi_add_memory_map() to return efi_status_t. - Adds a method description to efi_add_memory_map(). - Changes efi_add_memory_map() to return EFI_SUCCESS - Returns non-zero for error in efi_add_memory_map() - Updates efi_allocate_pages() to new efi_add_memory_map() - Updates efi_free_pages() to new efi_add_memory_map() - Updates efi_carve_out_dt_rsv() to new efi_add_memory_map() - Updates efi_add_runtime_mmio() to new efi_add_memory_map() Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map") Fixes: 74c16acce30b ("efi_loader: Don't allocate from memory holes") Suggested-by: Heinrich Schuchardt Cc: Alexander Graf Signed-off-by: Bryan O'Donoghue Reviewed-by: Heinrich Schuchardt --- include/efi_loader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index db4763fc9b7..6cc6a3835c9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -476,8 +476,8 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, efi_uintn_t *descriptor_size, uint32_t *descriptor_version); /* Adds a range into the EFI memory map */ -uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, - bool overlap_only_ram); +efi_status_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, + bool overlap_only_ram); /* Called by board init to initialize the EFI drivers */ efi_status_t efi_driver_init(void); /* Called by board init to initialize the EFI memory map */ -- cgit v1.2.3 From ade317a281652354cb3d86d40a8c012b32f28497 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Jul 2019 18:51:00 +0200 Subject: efi_loader: avoid alignment error In packed structures GUIDs are not aligned. Avoid a build error with GCC 9.1 by using const void * as argument for guidcmp(). Reported-by: Ramon Fried Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 6cc6a3835c9..5298ea7997f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -567,7 +567,7 @@ static inline void ascii2unicode(u16 *unicode, const char *ascii) *unicode = 0; } -static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) +static inline int guidcmp(const void *g1, const void *g2) { return memcmp(g1, g2, sizeof(efi_guid_t)); } -- cgit v1.2.3 From 317068b8b6b15ad38f7aa1019310e41764c80e5b Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Jul 2019 17:28:49 +0200 Subject: efi_loader: support unaligned u16 strings Allow unaligned u16 strings as arguments to u16_strdup() and u16_strlen(). Signed-off-by: Heinrich Schuchardt --- include/charset.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/charset.h b/include/charset.h index 4f7ae8fafdf..020f8a90df0 100644 --- a/include/charset.h +++ b/include/charset.h @@ -178,7 +178,7 @@ s32 utf_to_upper(const s32 code); * ReturnValue: number of non-zero words. * This is not the number of utf-16 letters! */ -size_t u16_strlen(const u16 *in); +size_t u16_strlen(const void *in); /** * u16_strlen - count non-zero words @@ -214,7 +214,7 @@ u16 *u16_strcpy(u16 *dest, const u16 *src); * @src: source buffer (null terminated) * Return: allocated new buffer on success, NULL on failure */ -u16 *u16_strdup(const u16 *src); +u16 *u16_strdup(const void *src); /** * utf16_to_utf8() - Convert an utf16 string to utf8 -- cgit v1.2.3