mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
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 <xypron.glpk@gmx.de>
This commit is contained in:
parent
38671d4f1c
commit
a35c33c0dc
5 changed files with 29 additions and 31 deletions
|
@ -17,14 +17,13 @@
|
|||
*/
|
||||
.globl ImageBase
|
||||
ImageBase:
|
||||
.ascii "MZ"
|
||||
.short IMAGE_DOS_SIGNATURE /* 'MZ' */
|
||||
.skip 58 /* 'MZ' + pad + offset == 64 */
|
||||
.long pe_header - ImageBase /* Offset to the PE header */
|
||||
pe_header:
|
||||
.ascii "PE"
|
||||
.short 0
|
||||
.long IMAGE_NT_SIGNATURE /* 'PE' */
|
||||
coff_header:
|
||||
.short 0xaa64 /* AArch64 */
|
||||
.short IMAGE_FILE_MACHINE_ARM64 /* AArch64 */
|
||||
.short 2 /* nr_sections */
|
||||
.long 0 /* TimeDateStamp */
|
||||
.long 0 /* PointerToSymbolTable */
|
||||
|
@ -36,7 +35,7 @@ coff_header:
|
|||
IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
|
||||
IMAGE_FILE_DEBUG_STRIPPED)
|
||||
optional_header:
|
||||
.short 0x20b /* PE32+ format */
|
||||
.short IMAGE_NT_OPTIONAL_HDR64_MAGIC /* PE32+ format */
|
||||
.byte 0x02 /* MajorLinkerVersion */
|
||||
.byte 0x14 /* MinorLinkerVersion */
|
||||
.long _edata - _start /* SizeOfCode */
|
||||
|
|
|
@ -16,14 +16,13 @@
|
|||
*/
|
||||
.globl image_base
|
||||
image_base:
|
||||
.ascii "MZ"
|
||||
.short IMAGE_DOS_SIGNATURE /* 'MZ' */
|
||||
.skip 58 /* 'MZ' + pad + offset == 64 */
|
||||
.long pe_header - image_base /* Offset to the PE header */
|
||||
pe_header:
|
||||
.ascii "PE"
|
||||
.short 0
|
||||
.long IMAGE_NT_SIGNATURE /* 'PE' */
|
||||
coff_header:
|
||||
.short 0x1c2 /* Mixed ARM/Thumb */
|
||||
.short IMAGE_FILE_MACHINE_THUMB /* Mixed ARM/Thumb */
|
||||
.short 2 /* nr_sections */
|
||||
.long 0 /* TimeDateStamp */
|
||||
.long 0 /* PointerToSymbolTable */
|
||||
|
@ -36,7 +35,7 @@ coff_header:
|
|||
IMAGE_FILE_32BIT_MACHINE | \
|
||||
IMAGE_FILE_DEBUG_STRIPPED)
|
||||
optional_header:
|
||||
.short 0x10b /* PE32 format */
|
||||
.short IMAGE_NT_OPTIONAL_HDR32_MAGIC /* PE32 format */
|
||||
.byte 0x02 /* MajorLinkerVersion */
|
||||
.byte 0x14 /* MinorLinkerVersion */
|
||||
.long _edata - _start /* SizeOfCode */
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#define SIZE_LONG 8
|
||||
#define SAVE_LONG(reg, idx) sd reg, (idx*SIZE_LONG)(sp)
|
||||
#define LOAD_LONG(reg, idx) ld reg, (idx*SIZE_LONG)(sp)
|
||||
#define PE_MACHINE 0x5064
|
||||
#define PE_MACHINE IMAGE_FILE_MACHINE_RISCV64
|
||||
#else
|
||||
#define SIZE_LONG 4
|
||||
#define SAVE_LONG(reg, idx) sw reg, (idx*SIZE_LONG)(sp)
|
||||
#define LOAD_LONG(reg, idx) lw reg, (idx*SIZE_LONG)(sp)
|
||||
#define PE_MACHINE 0x5032
|
||||
#define PE_MACHINE IMAGE_FILE_MACHINE_RISCV32
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -30,12 +30,11 @@
|
|||
*/
|
||||
.globl ImageBase
|
||||
ImageBase:
|
||||
.ascii "MZ"
|
||||
.short IMAGE_DOS_SIGNATURE /* 'MZ' */
|
||||
.skip 58 /* 'MZ' + pad + offset == 64 */
|
||||
.long pe_header - ImageBase /* Offset to the PE header */
|
||||
pe_header:
|
||||
.ascii "PE"
|
||||
.short 0
|
||||
.long IMAGE_NT_SIGNATURE /* 'PE' */
|
||||
coff_header:
|
||||
.short PE_MACHINE /* RISC-V 64/32-bit */
|
||||
.short 2 /* nr_sections */
|
||||
|
@ -49,7 +48,7 @@ coff_header:
|
|||
IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
|
||||
IMAGE_FILE_DEBUG_STRIPPED)
|
||||
optional_header:
|
||||
.short 0x20b /* PE32+ format */
|
||||
.short IMAGE_NT_OPTIONAL_HDR64_MAGIC /* PE32+ format */
|
||||
.byte 0x02 /* MajorLinkerVersion */
|
||||
.byte 0x14 /* MinorLinkerVersion */
|
||||
.long _edata - _start /* SizeOfCode */
|
||||
|
|
|
@ -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
|
||||
|
|
15
include/pe.h
15
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;
|
||||
|
|
Loading…
Reference in a new issue