blob: f919c3861bf4b11313a66a01b166f9402dc90c78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# U-boot
U-boot is a bootloader, not a firmware standard like UEFI.
## U-boot boot methods
### U-Boot's own boot protocol
- Loads a flat binary or uImage
- Passes device tree in X0 (or R2 on 32-bit)
- No UEFI involved at all
### U-Boot as UEFI firmware
- U-boot builded with CONFIG_EFI_LOADER
- Loads and runs 3efi PE32+ applications
- Bastion kernel should work perfectly
### booti/bootm commands
- Loads Linux-format Image with header
- Passes device tree pointer
### Modify u-boot to run bastion kernel
Worst case
## Easiest method
is using u-boot as uefi loader
For it i need to build u-boot with CONFIG_EFI_LOADER.
U-boot provides the same EFI_SYSTEM_TABLE, EFI_BOOT_SERVICES, GOP, memory map and ExitBootServices() that real UEFI firmware does.
A lot of ARM Linux platforms use it - they run GRUB(grubaa64.efi) from u-boot and then run kernel.
## Not-easiest method
Use u-boot's own boot proto
Here's how it works:
- The kernel is loaded as a flat bin (or a uImage wrapper)
- CPU is en EL2 or EL1, MMU off, caches off
- X0 = physical address of the device tree blof (FDT)
- No memory map - we need to parse dt's /memory node
- No framebuffer setup - we need to configure it from dt
- No ExitBootServices - u-boot is already gone when we get control
### Kernel image format
U-boot expects same as Linux's Image format - a flat binary with 64-byte header:
```
// ARM64 Image header (at offset 0 of the binary)
struct arm64_image_header {
uint32_t code0; // Executable code (branch instruction)
uint32_t code1; // Executable code
uint64_t text_offset; // Image load offset from start of RAM
uint64_t image_size; // Effective image size (0 = unknown)
uint64_t flags; // Kernel flags
uint64_t res2; // Reserved
uint64_t res3; // Reserved
uint64_t res4; // Reserved
uint32_t magic; // Magic: 0x644D5241 ("ARM\x64")
uint32_t res5; // Reserved (used for PE offset if EFI stub)
};
```
# Current state
Bastion kernel supports only UEFI boot loading and not support own u-boot protos
|