diff options
-rw-r--r-- | arch/arm/cpu/armv8/fwcall.c | 11 | ||||
-rw-r--r-- | arch/arm/mach-bcm283x/reset.c | 11 | ||||
-rw-r--r-- | cmd/bootefi.c | 9 | ||||
-rw-r--r-- | disk/part_efi.c | 9 | ||||
-rw-r--r-- | include/efi.h | 3 | ||||
-rw-r--r-- | include/pe.h | 3 | ||||
-rw-r--r-- | lib/efi_loader/efi_image_loader.c | 14 | ||||
-rw-r--r-- | lib/efi_loader/efi_runtime.c | 4 | ||||
-rw-r--r-- | scripts/Makefile.lib | 10 |
9 files changed, 54 insertions, 20 deletions
diff --git a/arch/arm/cpu/armv8/fwcall.c b/arch/arm/cpu/armv8/fwcall.c index c5aa41a0e6..0ba3dad8cc 100644 --- a/arch/arm/cpu/armv8/fwcall.c +++ b/arch/arm/cpu/armv8/fwcall.c @@ -143,15 +143,12 @@ void __efi_runtime EFIAPI efi_reset_system( efi_status_t reset_status, unsigned long data_size, void *reset_data) { - switch (reset_type) { - case EFI_RESET_COLD: - case EFI_RESET_WARM: - case EFI_RESET_PLATFORM_SPECIFIC: + if (reset_type == EFI_RESET_COLD || + reset_type == EFI_RESET_WARM || + reset_type == EFI_RESET_PLATFORM_SPECIFIC) { psci_system_reset(); - break; - case EFI_RESET_SHUTDOWN: + } else if (reset_type == EFI_RESET_SHUTDOWN) { psci_system_off(); - break; } while (1) { } diff --git a/arch/arm/mach-bcm283x/reset.c b/arch/arm/mach-bcm283x/reset.c index f8a17755e3..7712d4664c 100644 --- a/arch/arm/mach-bcm283x/reset.c +++ b/arch/arm/mach-bcm283x/reset.c @@ -59,13 +59,11 @@ void __efi_runtime EFIAPI efi_reset_system( { u32 val; - switch (reset_type) { - case EFI_RESET_COLD: - case EFI_RESET_WARM: - case EFI_RESET_PLATFORM_SPECIFIC: + if (reset_type == EFI_RESET_COLD || + reset_type == EFI_RESET_WARM || + reset_type == EFI_RESET_PLATFORM_SPECIFIC) { reset_cpu(0); - break; - case EFI_RESET_SHUTDOWN: + } else if (reset_type == EFI_RESET_SHUTDOWN) { /* * We set the watchdog hard reset bit here to distinguish this reset * from the normal (full) reset. bootcode.bin will not reboot after a @@ -76,7 +74,6 @@ void __efi_runtime EFIAPI efi_reset_system( val |= BCM2835_WDOG_RSTS_RASPBERRYPI_HALT; writel(val, &wdog_regs->rsts); reset_cpu(0); - break; } while (1) { } diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 707d159bac..f55a40dc84 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -263,6 +263,7 @@ static efi_status_t do_bootefi_exec(void *efi, { struct efi_loaded_image loaded_image_info = {}; struct efi_object loaded_image_info_obj = {}; + struct efi_object mem_obj = {}; struct efi_device_path *memdp = NULL; efi_status_t ret; @@ -279,6 +280,12 @@ static efi_status_t do_bootefi_exec(void *efi, /* actual addresses filled in after efi_load_pe() */ memdp = efi_dp_from_mem(0, 0, 0); device_path = image_path = memdp; + efi_add_handle(&mem_obj); + + ret = efi_add_protocol(mem_obj.handle, &efi_guid_device_path, + device_path); + if (ret != EFI_SUCCESS) + goto exit; } else { assert(device_path && image_path); } @@ -343,6 +350,8 @@ static efi_status_t do_bootefi_exec(void *efi, exit: /* image has returned, loaded-image obj goes *poof*: */ list_del(&loaded_image_info_obj.link); + if (mem_obj.handle) + list_del(&mem_obj.link); return ret; } diff --git a/disk/part_efi.c b/disk/part_efi.c index 5c1039f013..2945892a24 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -23,6 +23,11 @@ DECLARE_GLOBAL_DATA_PTR; +/* + * GUID for basic data partions. + */ +static const efi_guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID; + #ifdef CONFIG_HAVE_BLOCK_DEVICE /** * efi_crc32() - EFI version of crc32 function @@ -502,12 +507,12 @@ int gpt_fill_pte(struct blk_desc *dev_desc, } else { /* default partition type GUID */ memcpy(bin_type_guid, - &PARTITION_BASIC_DATA_GUID, 16); + &partition_basic_data_guid, 16); } #else /* partition type GUID */ memcpy(gpt_e[i].partition_type_guid.b, - &PARTITION_BASIC_DATA_GUID, 16); + &partition_basic_data_guid, 16); #endif #if CONFIG_IS_ENABLED(PARTITION_UUIDS) diff --git a/include/efi.h b/include/efi.h index 98bddbac1a..e30a3c51c6 100644 --- a/include/efi.h +++ b/include/efi.h @@ -89,12 +89,11 @@ typedef u64 efi_virtual_addr_t; typedef void *efi_handle_t; #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ - ((efi_guid_t) \ {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \ ((a) >> 24) & 0xff, \ (b) & 0xff, ((b) >> 8) & 0xff, \ (c) & 0xff, ((c) >> 8) & 0xff, \ - (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } }) + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } } /* Generic EFI table header */ struct efi_table_hdr { diff --git a/include/pe.h b/include/pe.h index d73eb142cb..36e1908b7e 100644 --- a/include/pe.h +++ b/include/pe.h @@ -201,10 +201,13 @@ typedef struct _IMAGE_RELOCATION #define IMAGE_REL_BASED_MIPS_JMPADDR 5 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */ #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */ +#define IMAGE_REL_BASED_RISCV_HI20 5 /* yes, 5 too */ #define IMAGE_REL_BASED_SECTION 6 #define IMAGE_REL_BASED_REL 7 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */ #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */ +#define IMAGE_REL_BASED_RISCV_LOW12I 7 /* yes, 7 too */ +#define IMAGE_REL_BASED_RISCV_LOW12S 8 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */ #define IMAGE_REL_BASED_DIR64 10 diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 3cffe9ef46..ecdb77e5b6 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -126,6 +126,20 @@ static efi_status_t efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel, case IMAGE_REL_BASED_DIR64: *x64 += (uint64_t)delta; break; +#ifdef __riscv + case IMAGE_REL_BASED_RISCV_HI20: + *x32 = ((*x32 & 0xfffff000) + (uint32_t)delta) | + (*x32 & 0x00000fff); + break; + case IMAGE_REL_BASED_RISCV_LOW12I: + case IMAGE_REL_BASED_RISCV_LOW12S: + /* We know that we're 4k aligned */ + if (delta & 0xfff) { + printf("Unsupported reloc offset\n"); + return EFI_LOAD_ERROR; + } + break; +#endif default: printf("Unknown Relocation off %x type %x\n", offset, type); diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 65f2bcf140..4874eb602f 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -28,6 +28,10 @@ static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void); static efi_status_t __efi_runtime EFIAPI efi_device_error(void); static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void); +/* + * TODO(sjg@chromium.org): These defines and structs should come from the elf + * header for each arch (or a generic header) rather than being repeated here. + */ #if defined(CONFIG_ARM64) #define R_RELATIVE 1027 #define R_MASK 0xffffffffULL diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 2a7d73432d..f8c3fff1d1 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -385,8 +385,14 @@ cmd_efi_ld = $(LD) -nostdlib -znocombreloc -T $(EFI_LDS_PATH) -shared \ EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS) -$(obj)/%_efi.so: $(obj)/%.o arch/$(ARCH)/lib/$(EFI_CRT0) \ - arch/$(ARCH)/lib/$(EFI_RELOC) +$(obj)/efi_crt0.o: $(srctree)/arch/$(ARCH)/lib/$(EFI_CRT0:.o=.S) + $(call if_changed_dep,as_o_S) + +$(obj)/efi_reloc.o: $(srctree)/arch/$(ARCH)/lib/$(EFI_RELOC:.o=.c) $(recordmcount_source) FORCE + $(call cmd,force_checksrc) + $(call if_changed_rule,cc_o_c) + +$(obj)/%_efi.so: $(obj)/%.o $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(call cmd,efi_ld) # ACPI |