Back to home page

OSCL-LXR

 
 

    


0001 =================================
0002 Boot image header in RISC-V Linux
0003 =================================
0004 
0005 :Author: Atish Patra <atish.patra@wdc.com>
0006 :Date:   20 May 2019
0007 
0008 This document only describes the boot image header details for RISC-V Linux.
0009 
0010 TODO:
0011   Write a complete booting guide.
0012 
0013 The following 64-byte header is present in decompressed Linux kernel image::
0014 
0015         u32 code0;                /* Executable code */
0016         u32 code1;                /* Executable code */
0017         u64 text_offset;          /* Image load offset, little endian */
0018         u64 image_size;           /* Effective Image size, little endian */
0019         u64 flags;                /* kernel flags, little endian */
0020         u32 version;              /* Version of this header */
0021         u32 res1 = 0;             /* Reserved */
0022         u64 res2 = 0;             /* Reserved */
0023         u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" */
0024         u32 magic2 = 0x05435352;  /* Magic number 2, little endian, "RSC\x05" */
0025         u32 res3;                 /* Reserved for PE COFF offset */
0026 
0027 This header format is compliant with PE/COFF header and largely inspired from
0028 ARM64 header. Thus, both ARM64 & RISC-V header can be combined into one common
0029 header in future.
0030 
0031 Notes
0032 =====
0033 
0034 - This header can also be reused to support EFI stub for RISC-V in future. EFI
0035   specification needs PE/COFF image header in the beginning of the kernel image
0036   in order to load it as an EFI application. In order to support EFI stub,
0037   code0 should be replaced with "MZ" magic string and res3(at offset 0x3c) should
0038   point to the rest of the PE/COFF header.
0039 
0040 - version field indicate header version number
0041 
0042         ==========  =============
0043         Bits 0:15   Minor version
0044         Bits 16:31  Major version
0045         ==========  =============
0046 
0047   This preserves compatibility across newer and older version of the header.
0048   The current version is defined as 0.2.
0049 
0050 - The "magic" field is deprecated as of version 0.2.  In a future
0051   release, it may be removed.  This originally should have matched up
0052   with the ARM64 header "magic" field, but unfortunately does not.
0053   The "magic2" field replaces it, matching up with the ARM64 header.
0054 
0055 - In current header, the flags field has only one field.
0056 
0057         =====  ====================================
0058         Bit 0  Kernel endianness. 1 if BE, 0 if LE.
0059         =====  ====================================
0060 
0061 - Image size is mandatory for boot loader to load kernel image. Booting will
0062   fail otherwise.