Merge tag 'v9.0.0-rc3'
[qemu/ar7.git] / include / hw / intc / riscv_aplic.h
blobde8532fbc3a34724f34ee7c256e87e257354d346
1 /*
2 * RISC-V APLIC (Advanced Platform Level Interrupt Controller) interface
4 * Copyright (c) 2021 Western Digital Corporation or its affiliates.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or later, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef HW_RISCV_APLIC_H
20 #define HW_RISCV_APLIC_H
22 #include "hw/sysbus.h"
23 #include "qom/object.h"
25 #define TYPE_RISCV_APLIC "riscv.aplic"
27 typedef struct RISCVAPLICState RISCVAPLICState;
28 DECLARE_INSTANCE_CHECKER(RISCVAPLICState, RISCV_APLIC, TYPE_RISCV_APLIC)
30 #define APLIC_MIN_SIZE 0x4000
31 #define APLIC_SIZE_ALIGN(__x) (((__x) + (APLIC_MIN_SIZE - 1)) & \
32 ~(APLIC_MIN_SIZE - 1))
33 #define APLIC_SIZE(__num_harts) (APLIC_MIN_SIZE + \
34 APLIC_SIZE_ALIGN(32 * (__num_harts)))
36 struct RISCVAPLICState {
37 /*< private >*/
38 SysBusDevice parent_obj;
39 qemu_irq *external_irqs;
41 /*< public >*/
42 MemoryRegion mmio;
43 uint32_t bitfield_words;
44 uint32_t domaincfg;
45 uint32_t mmsicfgaddr;
46 uint32_t mmsicfgaddrH;
47 uint32_t smsicfgaddr;
48 uint32_t smsicfgaddrH;
49 uint32_t genmsi;
50 uint32_t *sourcecfg;
51 uint32_t *state;
52 uint32_t *target;
53 uint32_t *idelivery;
54 uint32_t *iforce;
55 uint32_t *ithreshold;
57 /* topology */
58 #define QEMU_APLIC_MAX_CHILDREN 16
59 struct RISCVAPLICState *parent;
60 struct RISCVAPLICState *children[QEMU_APLIC_MAX_CHILDREN];
61 uint16_t num_children;
63 /* config */
64 uint32_t aperture_size;
65 uint32_t hartid_base;
66 uint32_t num_harts;
67 uint32_t iprio_mask;
68 uint32_t num_irqs;
69 bool msimode;
70 bool mmode;
73 void riscv_aplic_add_child(DeviceState *parent, DeviceState *child);
75 DeviceState *riscv_aplic_create(hwaddr addr, hwaddr size,
76 uint32_t hartid_base, uint32_t num_harts, uint32_t num_sources,
77 uint32_t iprio_bits, bool msimode, bool mmode, DeviceState *parent);
79 #endif