Describes the meaning and value of the image header field. Suggested-by: Xiaotian Wu <wuxiaotian@xxxxxxxxxxx> Signed-off-by: Yanteng Si <siyanteng@xxxxxxxxxxx> --- Documentation/loongarch/booting.rst | 89 +++++++++++++++++++++++++++++ Documentation/loongarch/index.rst | 1 + 2 files changed, 90 insertions(+) create mode 100644 Documentation/loongarch/booting.rst diff --git a/Documentation/loongarch/booting.rst b/Documentation/loongarch/booting.rst new file mode 100644 index 000000000000..90456f713c48 --- /dev/null +++ b/Documentation/loongarch/booting.rst @@ -0,0 +1,89 @@ +.. SPDX-License-Identifier: GPL-2.0 + +==================== +启动 LoongArch Linux +==================== + +:Author: Yanteng Si <siyanteng@xxxxxxxxxxx> +:Date: 18 Nov 2022 + +BootLoader passing parameters to the kernel +=========================================== + +LoongArch supports ACPI and FDT. The information that needs to be +passed to the kernel are memmap, initrd, cmdline, fdt, etc. +On LoongArch machines, the BootLoader (EFISTUB/Grub) will pass three +valid parameters to the kernel, which are:: + + a0 = efi_boot + a1 = cmdline + a2 = systemtable + +where a1 is a pointer to cmdline, a2 contains the memmap, initrd, +fdt(opt) and other information that needs to be passed to the kernel. + +Boot image header in LoongArch Linux +==================================== + +The following 64-byte header is present in decompressed Linux +kernel image:: + + u32 MZ_MAGIC /* "MZ", MS-DOS header */ + u32 res0 = 0 /* reserved */ + u64 kernel_entry /* Kernel entry point */ + u64 _end - _text /* Kernel image effective size */ + u64 0 /* Kernel image load offset from start of RAM */ + u64 res1 = 0 /* reserved */ + u64 res2 = 0 /* reserved */ + u64 res3 = 0 /* reserved */ + u32 res4 = 0 /* reserved */ + u32 pe_header - _head /* Offset to the PE header */ + +Header notes +============ + +Currently, LoongArch has removed the "magic" field. + +According to the EFI specification, the PE/COFF image file header is +required at the beginning of the kernel image; the LoongArch kernel +supports the EFI stub, so the first two bytes of the kernel image header +are "MZ" magic characters, and 0x3c should point to the rest of the +PE/COFF file header, between which The kernel entry point, image +effectivesize, and image load offset layout are as follows:: + + +-----------------------------------------------+ + | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | + +-----------------------------------------------+ + 0x00: | MZ_MAGIC | res0 | + +-----------------------------------------------+ + 0x08: | kernel_entry | + +-----------------------------------------------+ + 0x10: | _end - _text | + +-----------------------------------------------+ + 0x18: | 0 | + +-----------------------------------------------+ + 0x20: | res1 | + +-----------------------------------------------+ + 0x28: | res2 | + +-----------------------------------------------+ + 0x30: | res3 | + +-----------------------------------------------+ + 0x38: | res4 | PE header | + +-----------------------------------------------+ + +All bit fields are in little endian: + + - MZ: Effective length of 2 bytes; + + - kernel entry point: leaving 6 bytes blank in front, starting + from 0x8, with a effective length of 8 bytes; + + - kernel image effective size: Immediately following the kernel + entry point, with a effective length of 8 bytes, this field is + required for the bootloader; + + - kernel image load offset: Immediately following the kernel + image effective size, with a effective length of 8 bytes; + + - Offset to the PE header: leaving 28 bytes blank in front, + starting from 0x3c, with a effective length of 4 bytes. diff --git a/Documentation/loongarch/index.rst b/Documentation/loongarch/index.rst index aaba648db907..df0174d6d227 100644 --- a/Documentation/loongarch/index.rst +++ b/Documentation/loongarch/index.rst @@ -10,6 +10,7 @@ LoongArch Architecture introduction irq-chip-model + booting features -- 2.31.1