[PATCH 6/7] MIPS: Define MIPS EFI related bits everywhere

Ilias Apalodimas ilias.apalodimas at linaro.org
Tue Jun 11 15:52:14 CEST 2024


On Fri, 17 May 2024 at 19:33, Jiaxun Yang <jiaxun.yang at flygoat.com> wrote:
>
> Various file names, instruction defines, magic numbers
> related to MIPS's EFI implementation.
>
> PE magic numbers are from winnt.h, DHCP numbers are
> from IANA page, boot file names are from other
> implementations.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com>
> ---
>  include/asm-generic/pe.h                          |  5 +++++
>  include/config_distro_bootcmd.h                   |  6 ++++++
>  include/efi_default_filename.h                    |  8 ++++++++
>  include/elf.h                                     |  8 ++++++++
>  lib/efi_loader/efi_image_loader.c                 | 17 +++++++++++++++++
>  lib/efi_selftest/efi_selftest_miniapp_exception.c |  2 ++
>  6 files changed, 46 insertions(+)
>
> diff --git a/include/asm-generic/pe.h b/include/asm-generic/pe.h
> index cd5b6ad62bf0..42c4cbedbc95 100644
> --- a/include/asm-generic/pe.h
> +++ b/include/asm-generic/pe.h
> @@ -31,6 +31,11 @@
>
>  /* Machine types */
>  #define IMAGE_FILE_MACHINE_I386                        0x014c
> +#define IMAGE_FILE_MACHINE_R3000_BE            0x0160
> +#define IMAGE_FILE_MACHINE_R3000               0x0162
> +#define IMAGE_FILE_MACHINE_R4000_BE            0x0164
> +#define IMAGE_FILE_MACHINE_R4000               0x0166
> +#define IMAGE_FILE_MACHINE_R10000              0x0168
>  #define IMAGE_FILE_MACHINE_ARM                 0x01c0
>  #define IMAGE_FILE_MACHINE_THUMB               0x01c2
>  #define IMAGE_FILE_MACHINE_ARMNT               0x01c4
> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> index 2a136b96a6d9..9e03d10acec5 100644
> --- a/include/config_distro_bootcmd.h
> +++ b/include/config_distro_bootcmd.h
> @@ -366,6 +366,12 @@
>  #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_CPU_MIPS32) || ((defined(__mips) && __mips == 32))
> +#define BOOTENV_EFI_PXE_ARCH "0x21"
> +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00033:UNDI:003000"
> +#elif defined(CONFIG_CPU_MIPS64) || ((defined(__mips) && __mips == 64))
> +#define BOOTENV_EFI_PXE_ARCH "0x22"
> +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00034: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..eb94a54514bc 100644
> --- a/include/efi_default_filename.h
> +++ b/include/efi_default_filename.h
> @@ -47,6 +47,14 @@
>  #define BOOTEFI_NAME "BOOTRISCV32.EFI"
>  #elif defined(CONFIG_ARCH_RV64I)
>  #define BOOTEFI_NAME "BOOTRISCV64.EFI"
> +#elif defined(CONFIG_CPU_MIPS32) && defined(CONFIG_SYS_BIG_ENDIAN)
> +#define BOOTEFI_NAME "BOOTMIPS.EFI"
> +#elif defined(CONFIG_CPU_MIPS32) && defined(CONFIG_SYS_LITTLE_ENDIAN)
> +#define BOOTEFI_NAME "BOOTMIPSEL.EFI"
> +#elif defined(CONFIG_CPU_MIPS64) && defined(CONFIG_SYS_BIG_ENDIAN)
> +#define BOOTEFI_NAME "BOOTMIPS64.EFI"
> +#elif defined(CONFIG_CPU_MIPS64) && defined(CONFIG_SYS_LITTLE_ENDIAN)
> +#define BOOTEFI_NAME "BOOTMIPS64EL.EFI"
>  #else
>  #error Unsupported UEFI architecture
>  #endif
> diff --git a/include/elf.h b/include/elf.h
> index a4ba74d8abeb..95de6ffbce31 100644
> --- a/include/elf.h
> +++ b/include/elf.h
> @@ -545,6 +545,9 @@ typedef struct {
>  #define DT_LOPROC      0x70000000      /* reserved range for processor */
>  #define DT_HIPROC      0x7fffffff      /* specific dynamic array tags */
>
> +/* MIPS */
> +#define DT_MIPS_LOCAL_GOTNO    0x7000000a      /* Number of local got entries */
> +
>  /* Dynamic Tag Flags - d_un.d_val */
>  #define DF_ORIGIN      0x01            /* Object may use DF_ORIGIN */
>  #define DF_SYMBOLIC    0x02            /* Symbol resolutions starts here */
> @@ -699,6 +702,11 @@ unsigned long elf_hash(const unsigned char *name);
>  #define R_RISCV_64             2
>  #define R_RISCV_RELATIVE       3
>
> +/* MIPS Relocations */
> +#define R_MIPS_NONE            0
> +#define R_MIPS_REL32           3
> +#define R_MIPS_64              18
> +
>  #ifndef __ASSEMBLY__
>  int valid_elf_image(unsigned long addr);
>  unsigned long load_elf64_image_phdr(unsigned long addr);
> diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
> index cedc4d822fe7..8df469851851 100644
> --- a/lib/efi_loader/efi_image_loader.c
> +++ b/lib/efi_loader/efi_image_loader.c
> @@ -51,6 +51,23 @@ static int machines[] = {
>         IMAGE_FILE_MACHINE_RISCV64,
>  #endif
>
> +#if defined(__mips__) && (__mips == 32) && defined(__BIG_ENDIAN)
> +       IMAGE_FILE_MACHINE_R3000_BE,
> +#endif
> +
> +#if defined(__mips__) && (__mips == 32) && defined(__LITTLE_ENDIAN)
> +       IMAGE_FILE_MACHINE_R3000,
> +#endif
> +
> +#if defined(__mips__) && (__mips == 64) && defined(__BIG_ENDIAN)
> +       IMAGE_FILE_MACHINE_R4000_BE,
> +#endif
> +
> +#if defined(__mips__) && (__mips == 64) && defined(__LITTLE_ENDIAN)
> +       IMAGE_FILE_MACHINE_R4000,
> +       IMAGE_FILE_MACHINE_R10000,
> +#endif
> +
>         0 };
>
>  /**
> diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c
> index f668cdac4ab2..f3b4ee926f8f 100644
> --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c
> +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c
> @@ -33,6 +33,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
>         asm volatile (".word 0xe7f7defb\n");
>  #elif defined(CONFIG_RISCV)
>         asm volatile (".word 0xffffffff\n");
> +#elif defined(CONFIG_MIPS)
> +       asm volatile ("break 0xf\n");
>  #elif defined(CONFIG_X86)
>         asm volatile (".word 0xffff\n");
>  #elif defined(CONFIG_SANDBOX)
>
> --
> 2.34.1
>
Acked-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>


More information about the U-Boot mailing list