-
Notifications
You must be signed in to change notification settings - Fork 6
부트로더
DEWH edited this page Jul 19, 2019
·
2 revisions
refer 1: Raspberry PI 2 부트 과정
refer 2: 커널 이미지 덤프 분석
refer 3: Linux Kernel Image Header - arm64
refer 4: vmlinux.lds.S
refer 5: ARM64 페이지 테이블 -2- (매핑)
refer 6: PINE A64 보드로 알아보는 64-bit ARM Linux
linux-insides: 영어
linux-insides: 한글
linux-5.1.15\Documentation\arm64\booting.txt
The Image must be placed text_offset bytes from a 2MB aligned base address anywhere in usable system RAM and called there.
이미지는 사용 가능한 시스템 RAM에 2MB 정렬 기본 주소의 text_offset 바이트에 배치하고 거기에서 호출해야 합니다.
2MB - 0x20-0000 - (하위 21 bits..)
The region between the 2 MB aligned base address and the start of the image has no special significance to the kernel, and may be used for other purposes.
2 MB 정렬 기본 주소와 이미지 시작 사이의 영역은 커널에 특별한 의미가 없으므로 다른 용도로 사용될 수 있습니다.
At least image_size bytes from the start of the image must be free for use by the kernel.
이미지의 시작 부분에서 적어도 image_size 바이트는 커널이 사용하기 위해 자유로 워야합니다.
NOTE: versions prior to v4.6 cannot make use of memory below the physical offset of the Image so it is recommended that the Image be placed as close as possible to the start of system RAM.
v4.6 이전 버전에서는 이미지의 물리적 오프셋보다 메모리를 사용할 수 없으므로 시스템 RAM의 시작 부분에 가능한 한 가깝게 이미지를 배치하는 것이 좋습니다.
Reference: arm64/booting.txt
- Setup and initialise the RAM (필수)
- Setup the device tree (필수)
- Decompress the kernel image (선택)
- Call the kernel image (필수)
부트로더는 최소 위에 나열된 기능을 수행해야한다.
커널 이미지(Image file)은 아래와 같은 헤더를 포함하고 있다.
The decompressed kernel image contains a 64-byte header as follows:
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) */
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 정렬된 베이스 주소는 가능한 DRAM의 시작 주소에 가까워야 한다.
(v4.6 이전 버전은 이미지의 물리적 오프셋 아래에 있는 메모리를 사용할 수 없으므로
이미지를 시스템 RAM 시작에 최대한 가깝게 배치하는 것이 좋다.)
1 - 2MB 정렬된 베이스 주소가 물리 메모리의 어느 곳이나 가능하다.
Bits 4-63: Reserved.
_head:
...
add x13, x18, #0x16
b stext
#else
b stext // branch to kernel start, magic
.long 0 // reserved
#endif
le64sym _kernel_offset_le // Image load offset from start of RAM, little-endian
le64sym _kernel_size_le // Effective size of kernel image, little-endian
le64sym _kernel_flags_le // Informative flags, little-endian
.quad 0 // reserved
.quad 0 // reserved
.quad 0 // reserved
.ascii ARM64_IMAGE_MAGIC // Magic number
- 커널 이미지는 환경에 따라 로딩되는 물리 주소가 다를 수 있다.
- PC-relative 어드레싱 방식을 사용하여 relocation에 상관없이 작동할 수 있다.