]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
riscv: Fix efi header for RV32
authorAtish Patra <atish.patra@wdc.com>
Tue, 13 Oct 2020 19:23:31 +0000 (12:23 -0700)
committerAndes <uboot@andestech.com>
Mon, 14 Dec 2020 07:16:54 +0000 (15:16 +0800)
RV32 should use PE32 format instead of PE32+ as the efi header format.
This requires following changes
1. A different header magic value
2. An additional parameter known as BaseOfData. Currently, it is set to
   zero in absence of any usage.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
arch/riscv/lib/crt0_riscv_efi.S

index 87fe1e56f9063c393b02a556425f9314ddb2f4fb..4aaa49ad07775f82837486eb9113d1f2a08e49a3 100644 (file)
 #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     IMAGE_FILE_MACHINE_RISCV64
+#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR64_MAGIC
 #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     IMAGE_FILE_MACHINE_RISCV32
+#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR32_MAGIC
 #endif
 
 
@@ -48,7 +50,7 @@ coff_header:
                 IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
                 IMAGE_FILE_DEBUG_STRIPPED)
 optional_header:
-       .short  IMAGE_NT_OPTIONAL_HDR64_MAGIC   /* PE32+ format */
+       .short  PE_MAGIC                        /* PE32+ format */
        .byte   0x02                            /* MajorLinkerVersion */
        .byte   0x14                            /* MinorLinkerVersion */
        .long   _edata - _start                 /* SizeOfCode */
@@ -56,6 +58,9 @@ optional_header:
        .long   0                               /* SizeOfUninitializedData */
        .long   _start - ImageBase              /* AddressOfEntryPoint */
        .long   _start - ImageBase              /* BaseOfCode */
+#if __riscv_xlen == 32
+       .long   0                               /* BaseOfData */
+#endif
 
 extra_header_fields:
        .quad   0                               /* ImageBase */