They are all coming from UEFI spec, Microsoft PE sepc, or IANA websites. Signed-off-by: Jiaxun Yang <jiaxun.y...@flygoat.com> --- boot/bootmeth_efi.c | 2 ++ include/asm-generic/pe.h | 2 ++ include/config_distro_bootcmd.h | 5 +++++ include/efi_default_filename.h | 2 ++ lib/efi_loader/efi_image_loader.c | 7 +++++++ lib/efi_loader/efi_runtime.c | 4 ++++ lib/efi_selftest/efi_selftest_miniapp_exception.c | 2 ++ 7 files changed, 24 insertions(+)
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index aebc5207fc01..b0207dac49c5 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -41,6 +41,8 @@ static int get_efi_pxe_arch(void) return 0x19; else if (IS_ENABLED(CONFIG_ARCH_RV64I)) return 0x1b; + else if (IS_ENABLED(CONFIG_ARCH_LA64)) + return 0x27; else if (IS_ENABLED(CONFIG_SANDBOX)) return 0; /* not used */ diff --git a/include/asm-generic/pe.h b/include/asm-generic/pe.h index cd5b6ad62bf0..fb93f2621715 100644 --- a/include/asm-generic/pe.h +++ b/include/asm-generic/pe.h @@ -38,6 +38,8 @@ #define IMAGE_FILE_MACHINE_ARM64 0xaa64 #define IMAGE_FILE_MACHINE_RISCV32 0x5032 #define IMAGE_FILE_MACHINE_RISCV64 0x5064 +#define IMAGE_FILE_MACHINE_LOONGARCH32 0x6232 +#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264 /* Header magic constants */ #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x010b diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 2a136b96a6d9..f8c3a4bb70ae 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -118,6 +118,8 @@ #define BOOTEFI_NAME "bootriscv32.efi" #elif defined(CONFIG_ARCH_RV64I) #define BOOTEFI_NAME "bootriscv64.efi" +#elif defined(CONFIG_ARCH_LA64) +#define BOOTEFI_NAME "bootloongarch64.efi" #endif #endif @@ -366,6 +368,9 @@ #elif defined(CONFIG_ARCH_RV64I) || ((defined(__riscv) && __riscv_xlen == 64)) #define BOOTENV_EFI_PXE_ARCH "0x1b" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000" +#elif defined(CONFIG_ARCH_LA64) || defined(__loongarch64) +#define BOOTENV_EFI_PXE_ARCH "0x27" +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00039:UNDI:003000" #elif defined(CONFIG_SANDBOX) # error "sandbox EFI support is only supported on ARM and x86" #else diff --git a/include/efi_default_filename.h b/include/efi_default_filename.h index 77932984b557..fac25039fd31 100644 --- a/include/efi_default_filename.h +++ b/include/efi_default_filename.h @@ -47,6 +47,8 @@ #define BOOTEFI_NAME "BOOTRISCV32.EFI" #elif defined(CONFIG_ARCH_RV64I) #define BOOTEFI_NAME "BOOTRISCV64.EFI" +#elif defined(CONFIG_ARCH_LA64) +#define BOOTEFI_NAME "BOOTLOONGARCH64.EFI" #else #error Unsupported UEFI architecture #endif diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 604243603289..cb0619f27e8a 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -50,6 +50,13 @@ static int machines[] = { #if defined(__riscv) && (__riscv_xlen == 64) IMAGE_FILE_MACHINE_RISCV64, #endif + +#if defined(__loongarch64) + IMAGE_FILE_MACHINE_LOONGARCH64, +#endif +#if defined(__loongarch32) + IMAGE_FILE_MACHINE_LOONGARCH32, +#endif 0 }; /** diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 011bcd04836d..45bdf45b5812 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -76,6 +76,10 @@ struct dyn_sym { #else #error unknown riscv target #endif +#elif defined(__loongarch__) +#define R_RELATIVE R_LARCH_RELATIVE +#define R_MASK 0xffffffffULL +#define IS_RELA 1 #else #error Need to add relocation awareness #endif diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c index f668cdac4ab2..1e500a5ccc35 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c @@ -35,6 +35,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, asm volatile (".word 0xffffffff\n"); #elif defined(CONFIG_X86) asm volatile (".word 0xffff\n"); +#elif defined(CONFIG_LOONGARCH) + asm volatile ("break 0xf\n"); #elif defined(CONFIG_SANDBOX) #if (HOST_ARCH == HOST_ARCH_ARM || HOST_ARCH == HOST_ARCH_AARCH64) asm volatile (".word 0xe7f7defb\n"); -- 2.43.0