187ecb68bSpbrook /* 287ecb68bSpbrook * Misc ARM declarations 387ecb68bSpbrook * 487ecb68bSpbrook * Copyright (c) 2006 CodeSourcery. 587ecb68bSpbrook * Written by Paul Brook 687ecb68bSpbrook * 78e31bf38SMatthew Fernandez * This code is licensed under the LGPL. 887ecb68bSpbrook * 987ecb68bSpbrook */ 1087ecb68bSpbrook 11121d0712SMarkus Armbruster #ifndef HW_ARM_H 12121d0712SMarkus Armbruster #define HW_ARM_H 1387ecb68bSpbrook 14022c62cbSPaolo Bonzini #include "exec/memory.h" 15*fcf5ef2aSThomas Huth #include "target/arm/cpu-qom.h" 165202ef94SIgor Mammedov #include "hw/irq.h" 17ac9d32e3SEric Auger #include "qemu/notify.h" 187d6f78cfSAvi Kivity 199776f636SPeter Crosthwaite typedef enum { 209776f636SPeter Crosthwaite ARM_ENDIANNESS_UNKNOWN = 0, 219776f636SPeter Crosthwaite ARM_ENDIANNESS_LE, 229776f636SPeter Crosthwaite ARM_ENDIANNESS_BE8, 239776f636SPeter Crosthwaite ARM_ENDIANNESS_BE32, 249776f636SPeter Crosthwaite } arm_endianness; 259776f636SPeter Crosthwaite 2687ecb68bSpbrook /* armv7m.c */ 2720c59c38SMichael Davidsaver DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq, 2887ecb68bSpbrook const char *kernel_filename, const char *cpu_model); 2987ecb68bSpbrook 30ac9d32e3SEric Auger /* 31ac9d32e3SEric Auger * struct used as a parameter of the arm_load_kernel machine init 32ac9d32e3SEric Auger * done notifier 33ac9d32e3SEric Auger */ 34ac9d32e3SEric Auger typedef struct { 35ac9d32e3SEric Auger Notifier notifier; /* actual notifier */ 36ac9d32e3SEric Auger ARMCPU *cpu; /* handle to the first cpu object */ 37ac9d32e3SEric Auger } ArmLoadKernelNotifier; 38ac9d32e3SEric Auger 3987ecb68bSpbrook /* arm_boot.c */ 40f93eb9ffSbalrog struct arm_boot_info { 41de841deaSPeter Maydell uint64_t ram_size; 42f93eb9ffSbalrog const char *kernel_filename; 43f93eb9ffSbalrog const char *kernel_cmdline; 44f93eb9ffSbalrog const char *initrd_filename; 45412beee6SGrant Likely const char *dtb_filename; 46a8170e5eSAvi Kivity hwaddr loader_start; 479d5ba9bfSMark Langsdorf /* multicore boards that use the default secondary core boot functions 489d5ba9bfSMark Langsdorf * need to put the address of the secondary boot code, the boot reg, 499d5ba9bfSMark Langsdorf * and the GIC address in the next 3 values, respectively. boards that 509d5ba9bfSMark Langsdorf * have their own boot functions can use these values as they want. 519d5ba9bfSMark Langsdorf */ 52a8170e5eSAvi Kivity hwaddr smp_loader_start; 53a8170e5eSAvi Kivity hwaddr smp_bootreg_addr; 54a8170e5eSAvi Kivity hwaddr gic_cpu_if_addr; 55f93eb9ffSbalrog int nb_cpus; 56f93eb9ffSbalrog int board_id; 57c8e829b7SGreg Bellows /* ARM machines that support the ARM Security Extensions use this field to 58c8e829b7SGreg Bellows * control whether Linux is booted as secure(true) or non-secure(false). 59c8e829b7SGreg Bellows */ 60c8e829b7SGreg Bellows bool secure_boot; 61462a8bc6SStefan Weil int (*atag_board)(const struct arm_boot_info *info, void *p); 629d5ba9bfSMark Langsdorf /* multicore boards that use the default secondary core boot functions 639d5ba9bfSMark Langsdorf * can ignore these two function calls. If the default functions won't 649d5ba9bfSMark Langsdorf * work, then write_secondary_boot() should write a suitable blob of 659b574c29SAndreas Färber * code mimicking the secondary CPU startup process used by the board's 669d5ba9bfSMark Langsdorf * boot loader/boot ROM code, and secondary_cpu_reset_hook() should 679b574c29SAndreas Färber * perform any necessary CPU reset handling and set the PC for the 689d5ba9bfSMark Langsdorf * secondary CPUs to point at this boot blob. 699d5ba9bfSMark Langsdorf */ 709543b0cdSAndreas Färber void (*write_secondary_boot)(ARMCPU *cpu, 719d5ba9bfSMark Langsdorf const struct arm_boot_info *info); 725d309320SAndreas Färber void (*secondary_cpu_reset_hook)(ARMCPU *cpu, 739d5ba9bfSMark Langsdorf const struct arm_boot_info *info); 740fb79851SJohn Rigby /* if a board is able to create a dtb without a dtb file then it 750fb79851SJohn Rigby * sets get_dtb. This will only be used if no dtb file is provided 760fb79851SJohn Rigby * by the user. On success, sets *size to the length of the created 770fb79851SJohn Rigby * dtb, and returns a pointer to it. (The caller must free this memory 780fb79851SJohn Rigby * with g_free() when it has finished with it.) On failure, returns NULL. 790fb79851SJohn Rigby */ 800fb79851SJohn Rigby void *(*get_dtb)(const struct arm_boot_info *info, int *size); 813b1cceb8SPeter Maydell /* if a board needs to be able to modify a device tree provided by 823b1cceb8SPeter Maydell * the user it should implement this hook. 833b1cceb8SPeter Maydell */ 843b1cceb8SPeter Maydell void (*modify_dtb)(const struct arm_boot_info *info, void *fdt); 85ac9d32e3SEric Auger /* machine init done notifier executing arm_load_dtb */ 86ac9d32e3SEric Auger ArmLoadKernelNotifier load_kernel_notifier; 87f2d74978SPaul Brook /* Used internally by arm_boot.c */ 88f2d74978SPaul Brook int is_linux; 89fc53b7d4SPeter Maydell hwaddr initrd_start; 90a8170e5eSAvi Kivity hwaddr initrd_size; 91a8170e5eSAvi Kivity hwaddr entry; 9207abe45cSLaszlo Ersek 9307abe45cSLaszlo Ersek /* Boot firmware has been loaded, typically at address 0, with -bios or 9407abe45cSLaszlo Ersek * -pflash. It also implies that fw_cfg_find() will succeed. 9507abe45cSLaszlo Ersek */ 9607abe45cSLaszlo Ersek bool firmware_loaded; 9710b8ec73SPeter Crosthwaite 9810b8ec73SPeter Crosthwaite /* Address at which board specific loader/setup code exists. If enabled, 9910b8ec73SPeter Crosthwaite * this code-blob will run before anything else. It must return to the 10010b8ec73SPeter Crosthwaite * caller via the link register. There is no stack set up. Enabled by 10110b8ec73SPeter Crosthwaite * defining write_board_setup, which is responsible for loading the blob 10210b8ec73SPeter Crosthwaite * to the specified address. 10310b8ec73SPeter Crosthwaite */ 10410b8ec73SPeter Crosthwaite hwaddr board_setup_addr; 10510b8ec73SPeter Crosthwaite void (*write_board_setup)(ARMCPU *cpu, 10610b8ec73SPeter Crosthwaite const struct arm_boot_info *info); 107baf6b681SPeter Crosthwaite 108baf6b681SPeter Crosthwaite /* If set, the board specific loader/setup blob will be run from secure 109baf6b681SPeter Crosthwaite * mode, regardless of secure_boot. The blob becomes responsible for 110baf6b681SPeter Crosthwaite * changing to non-secure state if implementing a non-secure boot 111baf6b681SPeter Crosthwaite */ 112baf6b681SPeter Crosthwaite bool secure_board_setup; 1139776f636SPeter Crosthwaite 1149776f636SPeter Crosthwaite arm_endianness endianness; 115f93eb9ffSbalrog }; 116ac9d32e3SEric Auger 117ac9d32e3SEric Auger /** 118ac9d32e3SEric Auger * arm_load_kernel - Loads memory with everything needed to boot 119ac9d32e3SEric Auger * 120ac9d32e3SEric Auger * @cpu: handle to the first CPU object 121ac9d32e3SEric Auger * @info: handle to the boot info struct 122ac9d32e3SEric Auger * Registers a machine init done notifier that copies to memory 123ac9d32e3SEric Auger * everything needed to boot, depending on machine and user options: 124ac9d32e3SEric Auger * kernel image, boot loaders, initrd, dtb. Also registers the CPU 125ac9d32e3SEric Auger * reset handler. 126ac9d32e3SEric Auger * 127ac9d32e3SEric Auger * In case the machine file supports the platform bus device and its 128ac9d32e3SEric Auger * dynamically instantiable sysbus devices, this function must be called 129ac9d32e3SEric Auger * before sysbus-fdt arm_register_platform_bus_fdt_creator. Indeed the 130ac9d32e3SEric Auger * machine init done notifiers are called in registration reverse order. 131ac9d32e3SEric Auger */ 1323aaa8dfaSAndreas Färber void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); 13387ecb68bSpbrook 134716536a9SAndrew Baumann /* Write a secure board setup routine with a dummy handler for SMCs */ 135716536a9SAndrew Baumann void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, 136716536a9SAndrew Baumann const struct arm_boot_info *info, 137716536a9SAndrew Baumann hwaddr mvbar_addr); 138716536a9SAndrew Baumann 13979383c9cSblueswir1 /* Multiplication factor to convert from system clock ticks to qemu timer 14079383c9cSblueswir1 ticks. */ 1417ee930d0Sblueswir1 extern int system_clock_scale; 14287ecb68bSpbrook 143121d0712SMarkus Armbruster #endif /* HW_ARM_H */ 144