xref: /openbmc/qemu/include/hw/arm/armv7m.h (revision a969fe97)
1 /*
2  * ARMv7M CPU object
3  *
4  * Copyright (c) 2017 Linaro Ltd
5  * Written by Peter Maydell <peter.maydell@linaro.org>
6  *
7  * This code is licensed under the GPL version 2 or later.
8  */
9 
10 #ifndef HW_ARM_ARMV7M_H
11 #define HW_ARM_ARMV7M_H
12 
13 #include "hw/sysbus.h"
14 #include "hw/intc/armv7m_nvic.h"
15 #include "hw/misc/armv7m_ras.h"
16 #include "target/arm/idau.h"
17 #include "qom/object.h"
18 #include "hw/clock.h"
19 
20 #define TYPE_BITBAND "ARM-bitband-memory"
21 OBJECT_DECLARE_SIMPLE_TYPE(BitBandState, BITBAND)
22 
23 struct BitBandState {
24     /*< private >*/
25     SysBusDevice parent_obj;
26     /*< public >*/
27 
28     AddressSpace source_as;
29     MemoryRegion iomem;
30     uint32_t base;
31     MemoryRegion *source_memory;
32 };
33 
34 #define TYPE_ARMV7M "armv7m"
35 OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M)
36 
37 #define ARMV7M_NUM_BITBANDS 2
38 
39 /* ARMv7M container object.
40  * + Unnamed GPIO input lines: external IRQ lines for the NVIC
41  * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ.
42  *   If this GPIO is not wired up then the NVIC will default to performing
43  *   a qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET).
44  * + Property "cpu-type": CPU type to instantiate
45  * + Property "num-irq": number of external IRQ lines
46  * + Property "memory": MemoryRegion defining the physical address space
47  *   that CPU accesses see. (The NVIC, bitbanding and other CPU-internal
48  *   devices will be automatically layered on top of this view.)
49  * + Property "idau": IDAU interface (forwarded to CPU object)
50  * + Property "init-svtor": secure VTOR reset value (forwarded to CPU object)
51  * + Property "init-nsvtor": non-secure VTOR reset value (forwarded to CPU object)
52  * + Property "vfp": enable VFP (forwarded to CPU object)
53  * + Property "dsp": enable DSP (forwarded to CPU object)
54  * + Property "enable-bitband": expose bitbanded IO
55  * + Property "mpu-ns-regions": number of Non-Secure MPU regions (forwarded
56  *   to CPU object pmsav7-dregion property; default is whatever the default
57  *   for the CPU is)
58  * + Property "mpu-s-regions": number of Secure MPU regions (default is
59  *   whatever the default for the CPU is; must currently be set to the same
60  *   value as mpu-ns-regions if the CPU implements the Security Extension)
61  * + Clock input "refclk" is the external reference clock for the systick timers
62  * + Clock input "cpuclk" is the main CPU clock
63  */
64 struct ARMv7MState {
65     /*< private >*/
66     SysBusDevice parent_obj;
67     /*< public >*/
68     NVICState nvic;
69     BitBandState bitband[ARMV7M_NUM_BITBANDS];
70     ARMCPU *cpu;
71     ARMv7MRAS ras;
72     SysTickState systick[M_REG_NUM_BANKS];
73 
74     /* MemoryRegion we pass to the CPU, with our devices layered on
75      * top of the ones the board provides in board_memory.
76      */
77     MemoryRegion container;
78     /*
79      * MemoryRegion which passes the transaction to either the S or the
80      * NS systick device depending on the transaction attributes
81      */
82     MemoryRegion systickmem;
83     /*
84      * MemoryRegion which enforces the S/NS handling of the systick
85      * device NS alias region and passes the transaction to the
86      * NS systick device if appropriate.
87      */
88     MemoryRegion systick_ns_mem;
89     /* Ditto, for the sysregs region provided by the NVIC */
90     MemoryRegion sysreg_ns_mem;
91     /* MR providing default PPB behaviour */
92     MemoryRegion defaultmem;
93 
94     Clock *refclk;
95     Clock *cpuclk;
96 
97     /* Properties */
98     char *cpu_type;
99     /* MemoryRegion the board provides to us (with its devices, RAM, etc) */
100     MemoryRegion *board_memory;
101     Object *idau;
102     uint32_t init_svtor;
103     uint32_t init_nsvtor;
104     uint32_t mpu_ns_regions;
105     uint32_t mpu_s_regions;
106     bool enable_bitband;
107     bool start_powered_off;
108     bool vfp;
109     bool dsp;
110 };
111 
112 #endif
113