1/* 2 * Misc ARM declarations 3 * 4 * Copyright (c) 2006 CodeSourcery. 5 * Written by Paul Brook 6 * 7 * This code is licensed under the LGPL. 8 * 9 */ 10 11#ifndef HW_ARM_H 12#define HW_ARM_H 13 14#include "exec/memory.h" 15#include "target-arm/cpu-qom.h" 16#include "hw/irq.h" 17#include "qemu/notify.h" 18 19typedef enum { 20 ARM_ENDIANNESS_UNKNOWN = 0, 21 ARM_ENDIANNESS_LE, 22 ARM_ENDIANNESS_BE8, 23 ARM_ENDIANNESS_BE32, 24} arm_endianness; 25 26/* armv7m.c */ 27DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq, 28 const char *kernel_filename, const char *cpu_model); 29 30/* 31 * struct used as a parameter of the arm_load_kernel machine init 32 * done notifier 33 */ 34typedef struct { 35 Notifier notifier; /* actual notifier */ 36 ARMCPU *cpu; /* handle to the first cpu object */ 37} ArmLoadKernelNotifier; 38 39/* arm_boot.c */ 40struct arm_boot_info { 41 uint64_t ram_size; 42 const char *kernel_filename; 43 const char *kernel_cmdline; 44 const char *initrd_filename; 45 const char *dtb_filename; 46 void *fdt; 47 int fdt_size; 48 hwaddr loader_start; 49 /* multicore boards that use the default secondary core boot functions 50 * need to put the address of the secondary boot code, the boot reg, 51 * and the GIC address in the next 3 values, respectively. boards that 52 * have their own boot functions can use these values as they want. 53 */ 54 hwaddr smp_loader_start; 55 hwaddr smp_bootreg_addr; 56 hwaddr gic_cpu_if_addr; 57 int nb_cpus; 58 int board_id; 59 /* ARM machines that support the ARM Security Extensions use this field to 60 * control whether Linux is booted as secure(true) or non-secure(false). 61 */ 62 bool secure_boot; 63 int (*atag_board)(const struct arm_boot_info *info, void *p); 64 /* multicore boards that use the default secondary core boot functions 65 * can ignore these two function calls. If the default functions won't 66 * work, then write_secondary_boot() should write a suitable blob of 67 * code mimicking the secondary CPU startup process used by the board's 68 * boot loader/boot ROM code, and secondary_cpu_reset_hook() should 69 * perform any necessary CPU reset handling and set the PC for the 70 * secondary CPUs to point at this boot blob. 71 */ 72 void (*write_secondary_boot)(ARMCPU *cpu, 73 const struct arm_boot_info *info); 74 void (*secondary_cpu_reset_hook)(ARMCPU *cpu, 75 const struct arm_boot_info *info); 76 /* if a board is able to create a dtb without a dtb file then it 77 * sets get_dtb. This will only be used if no dtb file is provided 78 * by the user. On success, sets *size to the length of the created 79 * dtb, and returns a pointer to it. (The caller must free this memory 80 * with g_free() when it has finished with it.) On failure, returns NULL. 81 */ 82 void *(*get_dtb)(const struct arm_boot_info *info, int *size); 83 /* if a board needs to be able to modify a device tree provided by 84 * the user it should implement this hook. 85 */ 86 void (*modify_dtb)(const struct arm_boot_info *info, void *fdt); 87 /* machine init done notifier executing arm_load_dtb */ 88 ArmLoadKernelNotifier load_kernel_notifier; 89 /* Used internally by arm_boot.c */ 90 int is_linux; 91 hwaddr initrd_start; 92 hwaddr initrd_size; 93 hwaddr entry; 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; 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); 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; 115 116 arm_endianness endianness; 117}; 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 */ 134void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); 135 136/* Write a secure board setup routine with a dummy handler for SMCs */ 137void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, 138 const struct arm_boot_info *info, 139 hwaddr mvbar_addr); 140 141/* Multiplication factor to convert from system clock ticks to qemu timer 142 ticks. */ 143extern int system_clock_scale; 144 145#endif /* HW_ARM_H */ 146