2 * Misc ARM declarations
4 * Copyright (c) 2006 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licensed under the LGPL.
14 #include "exec/memory.h"
15 #include "target/arm/cpu-qom.h"
17 #include "qemu/notify.h"
20 ARM_ENDIANNESS_UNKNOWN
= 0,
29 * @kernel_filename: file to load
30 * @mem_size: mem_size: maximum image size to load
32 * Load the guest image for an ARMv7M system. This must be called by
33 * any ARMv7M board. (This is necessary to ensure that the CPU resets
34 * correctly on system reset, as well as for kernel loading.)
36 void armv7m_load_kernel(ARMCPU
*cpu
, const char *kernel_filename
, int mem_size
);
39 struct arm_boot_info
{
41 const char *kernel_filename
;
42 const char *kernel_cmdline
;
43 const char *initrd_filename
;
44 const char *dtb_filename
;
48 /* If set to True, arm_load_kernel() will not load DTB.
49 * It allows board to load DTB manually later.
52 bool skip_dtb_autoload
;
53 /* multicore boards that use the default secondary core boot functions
54 * need to put the address of the secondary boot code, the boot reg,
55 * and the GIC address in the next 3 values, respectively. boards that
56 * have their own boot functions can use these values as they want.
58 hwaddr smp_loader_start
;
59 hwaddr smp_bootreg_addr
;
60 hwaddr gic_cpu_if_addr
;
63 /* ARM machines that support the ARM Security Extensions use this field to
64 * control whether Linux is booted as secure(true) or non-secure(false).
67 int (*atag_board
)(const struct arm_boot_info
*info
, void *p
);
68 /* multicore boards that use the default secondary core boot functions
69 * can ignore these two function calls. If the default functions won't
70 * work, then write_secondary_boot() should write a suitable blob of
71 * code mimicking the secondary CPU startup process used by the board's
72 * boot loader/boot ROM code, and secondary_cpu_reset_hook() should
73 * perform any necessary CPU reset handling and set the PC for the
74 * secondary CPUs to point at this boot blob.
76 void (*write_secondary_boot
)(ARMCPU
*cpu
,
77 const struct arm_boot_info
*info
);
78 void (*secondary_cpu_reset_hook
)(ARMCPU
*cpu
,
79 const struct arm_boot_info
*info
);
80 /* if a board is able to create a dtb without a dtb file then it
81 * sets get_dtb. This will only be used if no dtb file is provided
82 * by the user. On success, sets *size to the length of the created
83 * dtb, and returns a pointer to it. (The caller must free this memory
84 * with g_free() when it has finished with it.) On failure, returns NULL.
86 void *(*get_dtb
)(const struct arm_boot_info
*info
, int *size
);
87 /* if a board needs to be able to modify a device tree provided by
88 * the user it should implement this hook.
90 void (*modify_dtb
)(const struct arm_boot_info
*info
, void *fdt
);
91 /* Used internally by arm_boot.c */
97 /* Boot firmware has been loaded, typically at address 0, with -bios or
98 * -pflash. It also implies that fw_cfg_find() will succeed.
100 bool firmware_loaded
;
102 /* Address at which board specific loader/setup code exists. If enabled,
103 * this code-blob will run before anything else. It must return to the
104 * caller via the link register. There is no stack set up. Enabled by
105 * defining write_board_setup, which is responsible for loading the blob
106 * to the specified address.
108 hwaddr board_setup_addr
;
109 void (*write_board_setup
)(ARMCPU
*cpu
,
110 const struct arm_boot_info
*info
);
112 /* If set, the board specific loader/setup blob will be run from secure
113 * mode, regardless of secure_boot. The blob becomes responsible for
114 * changing to non-secure state if implementing a non-secure boot
116 bool secure_board_setup
;
118 arm_endianness endianness
;
122 * arm_load_kernel - Loads memory with everything needed to boot
124 * @cpu: handle to the first CPU object
125 * @info: handle to the boot info struct
126 * Registers a machine init done notifier that copies to memory
127 * everything needed to boot, depending on machine and user options:
128 * kernel image, boot loaders, initrd, dtb. Also registers the CPU
131 * In case the machine file supports the platform bus device and its
132 * dynamically instantiable sysbus devices, this function must be called
133 * before sysbus-fdt arm_register_platform_bus_fdt_creator. Indeed the
134 * machine init done notifiers are called in registration reverse order.
136 void arm_load_kernel(ARMCPU
*cpu
, struct arm_boot_info
*info
);
138 AddressSpace
*arm_boot_address_space(ARMCPU
*cpu
,
139 const struct arm_boot_info
*info
);
142 * arm_load_dtb() - load a device tree binary image into memory
143 * @addr: the address to load the image at
144 * @binfo: struct describing the boot environment
145 * @addr_limit: upper limit of the available memory area at @addr
146 * @as: address space to load image to
148 * Load a device tree supplied by the machine or by the user with the
149 * '-dtb' command line option, and put it at offset @addr in target
152 * If @addr_limit contains a meaningful value (i.e., it is strictly greater
153 * than @addr), the device tree is only loaded if its size does not exceed
156 * Returns: the size of the device tree image on success,
157 * 0 if the image size exceeds the limit,
160 * Note: Must not be called unless have_dtb(binfo) is true.
162 int arm_load_dtb(hwaddr addr
, const struct arm_boot_info
*binfo
,
163 hwaddr addr_limit
, AddressSpace
*as
);
165 /* Write a secure board setup routine with a dummy handler for SMCs */
166 void arm_write_secure_board_setup_dummy_smc(ARMCPU
*cpu
,
167 const struct arm_boot_info
*info
,
170 /* Multiplication factor to convert from system clock ticks to qemu timer
172 extern int system_clock_scale
;
174 #endif /* HW_ARM_H */