Add qemu 2.4.0
[kvmfornfv.git] / qemu / include / hw / arm / arm.h
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 "hw/irq.h"
16 #include "qemu/notify.h"
17 #include "cpu.h"
18
19 /* armv7m.c */
20 qemu_irq *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
21                       const char *kernel_filename, const char *cpu_model);
22
23 /*
24  * struct used as a parameter of the arm_load_kernel machine init
25  * done notifier
26  */
27 typedef struct {
28     Notifier notifier; /* actual notifier */
29     ARMCPU *cpu; /* handle to the first cpu object */
30 } ArmLoadKernelNotifier;
31
32 /* arm_boot.c */
33 struct arm_boot_info {
34     uint64_t ram_size;
35     const char *kernel_filename;
36     const char *kernel_cmdline;
37     const char *initrd_filename;
38     const char *dtb_filename;
39     hwaddr loader_start;
40     /* multicore boards that use the default secondary core boot functions
41      * need to put the address of the secondary boot code, the boot reg,
42      * and the GIC address in the next 3 values, respectively. boards that
43      * have their own boot functions can use these values as they want.
44      */
45     hwaddr smp_loader_start;
46     hwaddr smp_bootreg_addr;
47     hwaddr gic_cpu_if_addr;
48     int nb_cpus;
49     int board_id;
50     /* ARM machines that support the ARM Security Extensions use this field to
51      * control whether Linux is booted as secure(true) or non-secure(false).
52      */
53     bool secure_boot;
54     int (*atag_board)(const struct arm_boot_info *info, void *p);
55     /* multicore boards that use the default secondary core boot functions
56      * can ignore these two function calls. If the default functions won't
57      * work, then write_secondary_boot() should write a suitable blob of
58      * code mimicking the secondary CPU startup process used by the board's
59      * boot loader/boot ROM code, and secondary_cpu_reset_hook() should
60      * perform any necessary CPU reset handling and set the PC for the
61      * secondary CPUs to point at this boot blob.
62      */
63     void (*write_secondary_boot)(ARMCPU *cpu,
64                                  const struct arm_boot_info *info);
65     void (*secondary_cpu_reset_hook)(ARMCPU *cpu,
66                                      const struct arm_boot_info *info);
67     /* if a board is able to create a dtb without a dtb file then it
68      * sets get_dtb. This will only be used if no dtb file is provided
69      * by the user. On success, sets *size to the length of the created
70      * dtb, and returns a pointer to it. (The caller must free this memory
71      * with g_free() when it has finished with it.) On failure, returns NULL.
72      */
73     void *(*get_dtb)(const struct arm_boot_info *info, int *size);
74     /* if a board needs to be able to modify a device tree provided by
75      * the user it should implement this hook.
76      */
77     void (*modify_dtb)(const struct arm_boot_info *info, void *fdt);
78     /* machine init done notifier executing arm_load_dtb */
79     ArmLoadKernelNotifier load_kernel_notifier;
80     /* Used internally by arm_boot.c */
81     int is_linux;
82     hwaddr initrd_start;
83     hwaddr initrd_size;
84     hwaddr entry;
85
86     /* Boot firmware has been loaded, typically at address 0, with -bios or
87      * -pflash. It also implies that fw_cfg_find() will succeed.
88      */
89     bool firmware_loaded;
90 };
91
92 /**
93  * arm_load_kernel - Loads memory with everything needed to boot
94  *
95  * @cpu: handle to the first CPU object
96  * @info: handle to the boot info struct
97  * Registers a machine init done notifier that copies to memory
98  * everything needed to boot, depending on machine and user options:
99  * kernel image, boot loaders, initrd, dtb. Also registers the CPU
100  * reset handler.
101  *
102  * In case the machine file supports the platform bus device and its
103  * dynamically instantiable sysbus devices, this function must be called
104  * before sysbus-fdt arm_register_platform_bus_fdt_creator. Indeed the
105  * machine init done notifiers are called in registration reverse order.
106  */
107 void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info);
108
109 /* Multiplication factor to convert from system clock ticks to qemu timer
110    ticks.  */
111 extern int system_clock_scale;
112
113 #endif /* !ARM_MISC_H */