Documentation: riscv: Add early boot document
[linux-2.6-block.git] / Documentation / riscv / boot-image-header.rst
CommitLineData
638b642f
MCC
1=================================
2Boot image header in RISC-V Linux
3=================================
0f327f2a 4
638b642f
MCC
5:Author: Atish Patra <atish.patra@wdc.com>
6:Date: 20 May 2019
0f327f2a
AP
7
8This document only describes the boot image header details for RISC-V Linux.
0f327f2a 9
638b642f 10The following 64-byte header is present in decompressed Linux kernel image::
0f327f2a
AP
11
12 u32 code0; /* Executable code */
638b642f 13 u32 code1; /* Executable code */
0f327f2a
AP
14 u64 text_offset; /* Image load offset, little endian */
15 u64 image_size; /* Effective Image size, little endian */
16 u64 flags; /* kernel flags, little endian */
17 u32 version; /* Version of this header */
638b642f
MCC
18 u32 res1 = 0; /* Reserved */
19 u64 res2 = 0; /* Reserved */
0f327f2a 20 u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" */
185271a1 21 u32 magic2 = 0x05435352; /* Magic number 2, little endian, "RSC\x05" */
1d5c17e4 22 u32 res3; /* Reserved for PE COFF offset */
0f327f2a
AP
23
24This header format is compliant with PE/COFF header and largely inspired from
25ARM64 header. Thus, both ARM64 & RISC-V header can be combined into one common
26header in future.
27
638b642f
MCC
28Notes
29=====
30
0f327f2a
AP
31- This header can also be reused to support EFI stub for RISC-V in future. EFI
32 specification needs PE/COFF image header in the beginning of the kernel image
33 in order to load it as an EFI application. In order to support EFI stub,
1d5c17e4 34 code0 should be replaced with "MZ" magic string and res3(at offset 0x3c) should
0f327f2a
AP
35 point to the rest of the PE/COFF header.
36
638b642f
MCC
37- version field indicate header version number
38
39 ========== =============
40 Bits 0:15 Minor version
41 Bits 16:31 Major version
42 ========== =============
0f327f2a
AP
43
44 This preserves compatibility across newer and older version of the header.
474efecb 45 The current version is defined as 0.2.
0f327f2a 46
474efecb
PW
47- The "magic" field is deprecated as of version 0.2. In a future
48 release, it may be removed. This originally should have matched up
49 with the ARM64 header "magic" field, but unfortunately does not.
50 The "magic2" field replaces it, matching up with the ARM64 header.
0f327f2a 51
474efecb 52- In current header, the flags field has only one field.
638b642f
MCC
53
54 ===== ====================================
55 Bit 0 Kernel endianness. 1 if BE, 0 if LE.
56 ===== ====================================
0f327f2a
AP
57
58- Image size is mandatory for boot loader to load kernel image. Booting will
59 fail otherwise.