arm/boot: split load_dtb() from arm_load_kernel()
load_dtb() depends on arm_load_kernel() to figure out place
in RAM where it should be loaded, but it's not required for
arm_load_kernel() to work. Sometimes it's neccesary for
devices added with -device/device_add to be enumerated in
DTB as well, which's lead to [1] and surrounding commits to
add 2 more machine_done notifiers with non obvious ordering
to make dynamic sysbus devices initialization happen in
the right order.
However instead of moving whole arm_load_kernel() in to
machine_done, it's sufficient to move only load_dtb() into
virt_machine_done() notifier and remove ArmLoadKernelNotifier/
/PlatformBusFDTNotifierParams notifiers, which saves us ~90LOC
and simplifies code flow quite a bit.
Later would allow to consolidate DTB generation within one
function for 'mach-virt' board and make it reentrant so it
could generate updated DTB in device hotplug secenarios.
While at it rename load_dtb() to arm_load_dtb() since it's
public now.
Add additional field skip_dtb_autoload to struct arm_boot_info
to allow manual DTB load later in mach-virt and to avoid touching
all other boards to explicitly call arm_load_dtb().
1) (ac9d32e hw/arm/boot: arm_load_kernel implemented as a machine init done notifier)
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Message-id: 1525691524-32265-4-git-send-email-imammedo@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
a3fc839635
commit
3b77f6c353
5 changed files with 94 additions and 185 deletions
|
|
@ -39,15 +39,6 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
|
|||
*/
|
||||
void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size);
|
||||
|
||||
/*
|
||||
* struct used as a parameter of the arm_load_kernel machine init
|
||||
* done notifier
|
||||
*/
|
||||
typedef struct {
|
||||
Notifier notifier; /* actual notifier */
|
||||
ARMCPU *cpu; /* handle to the first cpu object */
|
||||
} ArmLoadKernelNotifier;
|
||||
|
||||
/* arm_boot.c */
|
||||
struct arm_boot_info {
|
||||
uint64_t ram_size;
|
||||
|
|
@ -56,6 +47,13 @@ struct arm_boot_info {
|
|||
const char *initrd_filename;
|
||||
const char *dtb_filename;
|
||||
hwaddr loader_start;
|
||||
hwaddr dtb_start;
|
||||
hwaddr dtb_limit;
|
||||
/* If set to True, arm_load_kernel() will not load DTB.
|
||||
* It allows board to load DTB manually later.
|
||||
* (default: False)
|
||||
*/
|
||||
bool skip_dtb_autoload;
|
||||
/* multicore boards that use the default secondary core boot functions
|
||||
* need to put the address of the secondary boot code, the boot reg,
|
||||
* and the GIC address in the next 3 values, respectively. boards that
|
||||
|
|
@ -94,8 +92,6 @@ struct arm_boot_info {
|
|||
* the user it should implement this hook.
|
||||
*/
|
||||
void (*modify_dtb)(const struct arm_boot_info *info, void *fdt);
|
||||
/* machine init done notifier executing arm_load_dtb */
|
||||
ArmLoadKernelNotifier load_kernel_notifier;
|
||||
/* Used internally by arm_boot.c */
|
||||
int is_linux;
|
||||
hwaddr initrd_start;
|
||||
|
|
@ -143,6 +139,33 @@ struct arm_boot_info {
|
|||
*/
|
||||
void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info);
|
||||
|
||||
AddressSpace *arm_boot_address_space(ARMCPU *cpu,
|
||||
const struct arm_boot_info *info);
|
||||
|
||||
/**
|
||||
* arm_load_dtb() - load a device tree binary image into memory
|
||||
* @addr: the address to load the image at
|
||||
* @binfo: struct describing the boot environment
|
||||
* @addr_limit: upper limit of the available memory area at @addr
|
||||
* @as: address space to load image to
|
||||
*
|
||||
* Load a device tree supplied by the machine or by the user with the
|
||||
* '-dtb' command line option, and put it at offset @addr in target
|
||||
* memory.
|
||||
*
|
||||
* If @addr_limit contains a meaningful value (i.e., it is strictly greater
|
||||
* than @addr), the device tree is only loaded if its size does not exceed
|
||||
* the limit.
|
||||
*
|
||||
* Returns: the size of the device tree image on success,
|
||||
* 0 if the image size exceeds the limit,
|
||||
* -1 on errors.
|
||||
*
|
||||
* Note: Must not be called unless have_dtb(binfo) is true.
|
||||
*/
|
||||
int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
|
||||
hwaddr addr_limit, AddressSpace *as);
|
||||
|
||||
/* Write a secure board setup routine with a dummy handler for SMCs */
|
||||
void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
|
||||
const struct arm_boot_info *info,
|
||||
|
|
|
|||
|
|
@ -24,37 +24,14 @@
|
|||
#ifndef HW_ARM_SYSBUS_FDT_H
|
||||
#define HW_ARM_SYSBUS_FDT_H
|
||||
|
||||
#include "hw/arm/arm.h"
|
||||
#include "qemu-common.h"
|
||||
#include "hw/sysbus.h"
|
||||
|
||||
/*
|
||||
* struct that contains dimensioning parameters of the platform bus
|
||||
*/
|
||||
typedef struct {
|
||||
hwaddr platform_bus_base; /* start address of the bus */
|
||||
hwaddr platform_bus_size; /* size of the bus */
|
||||
int platform_bus_first_irq; /* first hwirq assigned to the bus */
|
||||
int platform_bus_num_irqs; /* number of hwirq assigned to the bus */
|
||||
} ARMPlatformBusSystemParams;
|
||||
|
||||
/*
|
||||
* struct that contains all relevant info to build the fdt nodes of
|
||||
* platform bus and attached dynamic sysbus devices
|
||||
* in the future might be augmented with additional info
|
||||
* such as PHY, CLK handles ...
|
||||
*/
|
||||
typedef struct {
|
||||
const ARMPlatformBusSystemParams *system_params;
|
||||
struct arm_boot_info *binfo;
|
||||
const char *intc; /* parent interrupt controller name */
|
||||
} ARMPlatformBusFDTParams;
|
||||
#include "exec/hwaddr.h"
|
||||
|
||||
/**
|
||||
* arm_register_platform_bus_fdt_creator - register a machine init done
|
||||
* notifier that creates the device tree nodes of the platform bus and
|
||||
* associated dynamic sysbus devices
|
||||
* platform_bus_add_all_fdt_nodes - create all the platform bus nodes
|
||||
*
|
||||
* builds the parent platform bus node and all the nodes of dynamic
|
||||
* sysbus devices attached to it.
|
||||
*/
|
||||
void arm_register_platform_bus_fdt_creator(ARMPlatformBusFDTParams *fdt_params);
|
||||
|
||||
void platform_bus_add_all_fdt_nodes(void *fdt, const char *intc, hwaddr addr,
|
||||
hwaddr bus_size, int irq_start);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue