]>
Commit | Line | Data |
---|---|---|
87ecb68b | 1 | /* |
12ec8bd5 | 2 | * ARM kernel loader. |
87ecb68b PB |
3 | * |
4 | * Copyright (c) 2006 CodeSourcery. | |
5 | * Written by Paul Brook | |
6 | * | |
8e31bf38 | 7 | * This code is licensed under the LGPL. |
87ecb68b PB |
8 | * |
9 | */ | |
10 | ||
12ec8bd5 PM |
11 | #ifndef HW_ARM_BOOT_H |
12 | #define HW_ARM_BOOT_H | |
87ecb68b | 13 | |
fcf5ef2a | 14 | #include "target/arm/cpu-qom.h" |
ac9d32e3 | 15 | #include "qemu/notify.h" |
7d6f78cf | 16 | |
9776f636 PC |
17 | typedef enum { |
18 | ARM_ENDIANNESS_UNKNOWN = 0, | |
19 | ARM_ENDIANNESS_LE, | |
20 | ARM_ENDIANNESS_BE8, | |
21 | ARM_ENDIANNESS_BE32, | |
22 | } arm_endianness; | |
23 | ||
3651c285 PM |
24 | /** |
25 | * armv7m_load_kernel: | |
26 | * @cpu: CPU | |
27 | * @kernel_filename: file to load | |
28 | * @mem_size: mem_size: maximum image size to load | |
29 | * | |
30 | * Load the guest image for an ARMv7M system. This must be called by | |
38d81daf PM |
31 | * any ARMv7M board. (This is necessary to ensure that the CPU resets |
32 | * correctly on system reset, as well as for kernel loading.) | |
3651c285 PM |
33 | */ |
34 | void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size); | |
87ecb68b PB |
35 | |
36 | /* arm_boot.c */ | |
f93eb9ff | 37 | struct arm_boot_info { |
de841dea | 38 | uint64_t ram_size; |
f93eb9ff AZ |
39 | const char *kernel_filename; |
40 | const char *kernel_cmdline; | |
41 | const char *initrd_filename; | |
412beee6 | 42 | const char *dtb_filename; |
a8170e5e | 43 | hwaddr loader_start; |
3b77f6c3 IM |
44 | hwaddr dtb_start; |
45 | hwaddr dtb_limit; | |
46 | /* If set to True, arm_load_kernel() will not load DTB. | |
47 | * It allows board to load DTB manually later. | |
48 | * (default: False) | |
49 | */ | |
50 | bool skip_dtb_autoload; | |
9d5ba9bf ML |
51 | /* multicore boards that use the default secondary core boot functions |
52 | * need to put the address of the secondary boot code, the boot reg, | |
53 | * and the GIC address in the next 3 values, respectively. boards that | |
54 | * have their own boot functions can use these values as they want. | |
55 | */ | |
a8170e5e AK |
56 | hwaddr smp_loader_start; |
57 | hwaddr smp_bootreg_addr; | |
58 | hwaddr gic_cpu_if_addr; | |
f93eb9ff AZ |
59 | int nb_cpus; |
60 | int board_id; | |
c8e829b7 GB |
61 | /* ARM machines that support the ARM Security Extensions use this field to |
62 | * control whether Linux is booted as secure(true) or non-secure(false). | |
63 | */ | |
64 | bool secure_boot; | |
462a8bc6 | 65 | int (*atag_board)(const struct arm_boot_info *info, void *p); |
9d5ba9bf ML |
66 | /* multicore boards that use the default secondary core boot functions |
67 | * can ignore these two function calls. If the default functions won't | |
68 | * work, then write_secondary_boot() should write a suitable blob of | |
9b574c29 | 69 | * code mimicking the secondary CPU startup process used by the board's |
9d5ba9bf | 70 | * boot loader/boot ROM code, and secondary_cpu_reset_hook() should |
9b574c29 | 71 | * perform any necessary CPU reset handling and set the PC for the |
9d5ba9bf ML |
72 | * secondary CPUs to point at this boot blob. |
73 | */ | |
9543b0cd | 74 | void (*write_secondary_boot)(ARMCPU *cpu, |
9d5ba9bf | 75 | const struct arm_boot_info *info); |
5d309320 | 76 | void (*secondary_cpu_reset_hook)(ARMCPU *cpu, |
9d5ba9bf | 77 | const struct arm_boot_info *info); |
0fb79851 JR |
78 | /* if a board is able to create a dtb without a dtb file then it |
79 | * sets get_dtb. This will only be used if no dtb file is provided | |
80 | * by the user. On success, sets *size to the length of the created | |
81 | * dtb, and returns a pointer to it. (The caller must free this memory | |
82 | * with g_free() when it has finished with it.) On failure, returns NULL. | |
83 | */ | |
84 | void *(*get_dtb)(const struct arm_boot_info *info, int *size); | |
3b1cceb8 PM |
85 | /* if a board needs to be able to modify a device tree provided by |
86 | * the user it should implement this hook. | |
87 | */ | |
88 | void (*modify_dtb)(const struct arm_boot_info *info, void *fdt); | |
f2d74978 PB |
89 | /* Used internally by arm_boot.c */ |
90 | int is_linux; | |
fc53b7d4 | 91 | hwaddr initrd_start; |
a8170e5e AK |
92 | hwaddr initrd_size; |
93 | hwaddr entry; | |
07abe45c LE |
94 | |
95 | /* Boot firmware has been loaded, typically at address 0, with -bios or | |
96 | * -pflash. It also implies that fw_cfg_find() will succeed. | |
97 | */ | |
98 | bool firmware_loaded; | |
10b8ec73 PC |
99 | |
100 | /* Address at which board specific loader/setup code exists. If enabled, | |
101 | * this code-blob will run before anything else. It must return to the | |
102 | * caller via the link register. There is no stack set up. Enabled by | |
103 | * defining write_board_setup, which is responsible for loading the blob | |
104 | * to the specified address. | |
105 | */ | |
106 | hwaddr board_setup_addr; | |
107 | void (*write_board_setup)(ARMCPU *cpu, | |
108 | const struct arm_boot_info *info); | |
baf6b681 PC |
109 | |
110 | /* If set, the board specific loader/setup blob will be run from secure | |
111 | * mode, regardless of secure_boot. The blob becomes responsible for | |
112 | * changing to non-secure state if implementing a non-secure boot | |
113 | */ | |
114 | bool secure_board_setup; | |
9776f636 PC |
115 | |
116 | arm_endianness endianness; | |
f93eb9ff | 117 | }; |
ac9d32e3 EA |
118 | |
119 | /** | |
120 | * arm_load_kernel - Loads memory with everything needed to boot | |
121 | * | |
122 | * @cpu: handle to the first CPU object | |
123 | * @info: handle to the boot info struct | |
124 | * Registers a machine init done notifier that copies to memory | |
125 | * everything needed to boot, depending on machine and user options: | |
126 | * kernel image, boot loaders, initrd, dtb. Also registers the CPU | |
127 | * reset handler. | |
128 | * | |
129 | * In case the machine file supports the platform bus device and its | |
130 | * dynamically instantiable sysbus devices, this function must be called | |
131 | * before sysbus-fdt arm_register_platform_bus_fdt_creator. Indeed the | |
132 | * machine init done notifiers are called in registration reverse order. | |
133 | */ | |
3aaa8dfa | 134 | void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); |
87ecb68b | 135 | |
3b77f6c3 IM |
136 | AddressSpace *arm_boot_address_space(ARMCPU *cpu, |
137 | const struct arm_boot_info *info); | |
138 | ||
139 | /** | |
140 | * arm_load_dtb() - load a device tree binary image into memory | |
141 | * @addr: the address to load the image at | |
142 | * @binfo: struct describing the boot environment | |
143 | * @addr_limit: upper limit of the available memory area at @addr | |
144 | * @as: address space to load image to | |
145 | * | |
146 | * Load a device tree supplied by the machine or by the user with the | |
147 | * '-dtb' command line option, and put it at offset @addr in target | |
148 | * memory. | |
149 | * | |
150 | * If @addr_limit contains a meaningful value (i.e., it is strictly greater | |
151 | * than @addr), the device tree is only loaded if its size does not exceed | |
152 | * the limit. | |
153 | * | |
154 | * Returns: the size of the device tree image on success, | |
155 | * 0 if the image size exceeds the limit, | |
156 | * -1 on errors. | |
157 | * | |
158 | * Note: Must not be called unless have_dtb(binfo) is true. | |
159 | */ | |
160 | int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | |
161 | hwaddr addr_limit, AddressSpace *as); | |
162 | ||
716536a9 AB |
163 | /* Write a secure board setup routine with a dummy handler for SMCs */ |
164 | void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, | |
165 | const struct arm_boot_info *info, | |
166 | hwaddr mvbar_addr); | |
167 | ||
12ec8bd5 | 168 | #endif /* HW_ARM_BOOT_H */ |