qemu/include/hw/arm/arm.h
<<
>>
Prefs
   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 ARM_MISC_H
  12#define ARM_MISC_H 1
  13
  14#include "exec/memory.h"
  15#include "target-arm/cpu-qom.h"
  16#include "hw/irq.h"
  17#include "qemu/notify.h"
  18#include "cpu.h"
  19
  20typedef enum {
  21    ARM_ENDIANNESS_UNKNOWN = 0,
  22    ARM_ENDIANNESS_LE,
  23    ARM_ENDIANNESS_BE8,
  24    ARM_ENDIANNESS_BE32,
  25} arm_endianness;
  26
  27/* armv7m.c */
  28DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
  29                      const char *kernel_filename, const char *cpu_model);
  30
  31/*
  32 * struct used as a parameter of the arm_load_kernel machine init
  33 * done notifier
  34 */
  35typedef struct {
  36    Notifier notifier; /* actual notifier */
  37    ARMCPU *cpu; /* handle to the first cpu object */
  38} ArmLoadKernelNotifier;
  39
  40/* arm_boot.c */
  41struct arm_boot_info {
  42    uint64_t ram_size;
  43    const char *kernel_filename;
  44    const char *kernel_cmdline;
  45    const char *initrd_filename;
  46    const char *dtb_filename;
  47    void *fdt;
  48    int fdt_size;
  49    hwaddr loader_start;
  50    /* multicore boards that use the default secondary core boot functions
  51     * need to put the address of the secondary boot code, the boot reg,
  52     * and the GIC address in the next 3 values, respectively. boards that
  53     * have their own boot functions can use these values as they want.
  54     */
  55    hwaddr smp_loader_start;
  56    hwaddr smp_bootreg_addr;
  57    hwaddr gic_cpu_if_addr;
  58    int nb_cpus;
  59    int board_id;
  60    /* ARM machines that support the ARM Security Extensions use this field to
  61     * control whether Linux is booted as secure(true) or non-secure(false).
  62     */
  63    bool secure_boot;
  64    int (*atag_board)(const struct arm_boot_info *info, void *p);
  65    /* multicore boards that use the default secondary core boot functions
  66     * can ignore these two function calls. If the default functions won't
  67     * work, then write_secondary_boot() should write a suitable blob of
  68     * code mimicking the secondary CPU startup process used by the board's
  69     * boot loader/boot ROM code, and secondary_cpu_reset_hook() should
  70     * perform any necessary CPU reset handling and set the PC for the
  71     * secondary CPUs to point at this boot blob.
  72     */
  73    void (*write_secondary_boot)(ARMCPU *cpu,
  74                                 const struct arm_boot_info *info);
  75    void (*secondary_cpu_reset_hook)(ARMCPU *cpu,
  76                                     const struct arm_boot_info *info);
  77    /* if a board is able to create a dtb without a dtb file then it
  78     * sets get_dtb. This will only be used if no dtb file is provided
  79     * by the user. On success, sets *size to the length of the created
  80     * dtb, and returns a pointer to it. (The caller must free this memory
  81     * with g_free() when it has finished with it.) On failure, returns NULL.
  82     */
  83    void *(*get_dtb)(const struct arm_boot_info *info, int *size);
  84    /* if a board needs to be able to modify a device tree provided by
  85     * the user it should implement this hook.
  86     */
  87    void (*modify_dtb)(const struct arm_boot_info *info, void *fdt);
  88    /* machine init done notifier executing arm_load_dtb */
  89    ArmLoadKernelNotifier load_kernel_notifier;
  90    /* Used internally by arm_boot.c */
  91    int is_linux;
  92    hwaddr initrd_start;
  93    hwaddr initrd_size;
  94    hwaddr entry;
  95
  96    /* Boot firmware has been loaded, typically at address 0, with -bios or
  97     * -pflash. It also implies that fw_cfg_find() will succeed.
  98     */
  99    bool firmware_loaded;
 100
 101    /* Address at which board specific loader/setup code exists. If enabled,
 102     * this code-blob will run before anything else. It must return to the
 103     * caller via the link register. There is no stack set up. Enabled by
 104     * defining write_board_setup, which is responsible for loading the blob
 105     * to the specified address.
 106     */
 107    hwaddr board_setup_addr;
 108    void (*write_board_setup)(ARMCPU *cpu,
 109                              const struct arm_boot_info *info);
 110
 111    /* If set, the board specific loader/setup blob will be run from secure
 112     * mode, regardless of secure_boot. The blob becomes responsible for
 113     * changing to non-secure state if implementing a non-secure boot
 114     */
 115    bool secure_board_setup;
 116
 117    arm_endianness endianness;
 118};
 119
 120/**
 121 * arm_load_kernel - Loads memory with everything needed to boot
 122 *
 123 * @cpu: handle to the first CPU object
 124 * @info: handle to the boot info struct
 125 * Registers a machine init done notifier that copies to memory
 126 * everything needed to boot, depending on machine and user options:
 127 * kernel image, boot loaders, initrd, dtb. Also registers the CPU
 128 * reset handler.
 129 *
 130 * In case the machine file supports the platform bus device and its
 131 * dynamically instantiable sysbus devices, this function must be called
 132 * before sysbus-fdt arm_register_platform_bus_fdt_creator. Indeed the
 133 * machine init done notifiers are called in registration reverse order.
 134 */
 135void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info);
 136
 137/* Write a secure board setup routine with a dummy handler for SMCs */
 138void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
 139                                            const struct arm_boot_info *info,
 140                                            hwaddr mvbar_addr);
 141
 142/* Multiplication factor to convert from system clock ticks to qemu timer
 143   ticks.  */
 144extern int system_clock_scale;
 145
 146#endif /* !ARM_MISC_H */
 147