一、kernel header定义:
======aarch64 kernel header========
u32 code0; /* Executable code */
u32 code1; /* Executable code */
u64 text_offset; /* Image load offset, little endian */
u64 image_size; /* Effective Image size, little endian */
u64 flags; /* kernel flags, little endian */
u64 res2 = 0; /* reserved */
u64 res3 = 0; /* reserved */
u64 res4 = 0; /* reserved */
u32 magic = 0x644d5241; /* Magic number, little endian, "ARM\x64" */
u32 res5; /* reserved (used for PE COFF offset) */
====================================
//TEXT_OFFSET是kernel镜像在内存中的偏移量。
注意事项:
Header notes:
As of v3.17, all fields are little endian unless stated otherwise.
code0/code1 are responsible for branching to stext.
when booting through EFI, code0/code1 are initially skipped. res5 is an offset to the PE header and the PE header has the EFI entry point (efi_stub_entry). When the stub has done its work, it jumps to code0 to resume the normal boot process.
Prior to v3.17, the endianness of text_offset was not specified. In these cases image_size is zero and text_offset is 0x80000 in the endianness of the kernel. Where image_size is non-zero image_size is little-endian and must be respected. Where image_size is zero, text_offset can be assumed to be 0x80000.
The flags field (introduced in v3.17) is a little-endian 64-bit field composed as follows:
Bit 0
Kernel endianness. 1 if BE, 0 if LE.
Bit 1-2
Kernel Page size.
- 0 - Unspecified.
- 1 - 4K
- 2 - 16K
- 3 - 64K
Bit 3
Kernel physical placement
0
2MB aligned base should be as close as possible to the base of DRAM, since memory below it is not accessible via the linear mapping
1
2MB aligned base may be anywhere in physical memory
Bits 4-63
Reserved.
参考:https://github.com/torvalds/linux/blob/ff1176468d368232b684f75e82563369208bc371/Documentation/arm64/booting.rst