2 * ARM Generic/Distributed Interrupt Controller
4 * Copyright (c) 2006-2007 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licensed under the GPL.
10 /* This file contains implementation code for the RealView EB interrupt
11 * controller, MPCore distributed interrupt controller and ARMv7-M
12 * Nested Vectored Interrupt Controller.
13 * It is compiled in two ways:
14 * (1) as a standalone file to produce a sysbus device which is a GIC
15 * that can be used on the realview board and as one of the builtin
16 * private peripherals for the ARM MP CPUs (11MPCore, A9, etc)
17 * (2) by being directly #included into armv7m_nvic.c to produce the
21 #include "qemu/osdep.h"
23 #include "hw/sysbus.h"
24 #include "gic_internal.h"
25 #include "qapi/error.h"
26 #include "hw/core/cpu.h"
28 #include "qemu/module.h"
30 #include "sysemu/kvm.h"
32 /* #define DEBUG_GIC */
35 #define DEBUG_GIC_GATE 1
37 #define DEBUG_GIC_GATE 0
40 #define DPRINTF(fmt, ...) do { \
41 if (DEBUG_GIC_GATE) { \
42 fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \
46 static const uint8_t gic_id_11mpcore
[] = {
47 0x00, 0x00, 0x00, 0x00, 0x90, 0x13, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1
50 static const uint8_t gic_id_gicv1
[] = {
51 0x04, 0x00, 0x00, 0x00, 0x90, 0xb3, 0x1b, 0x00, 0x0d, 0xf0, 0x05, 0xb1
54 static const uint8_t gic_id_gicv2
[] = {
55 0x04, 0x00, 0x00, 0x00, 0x90, 0xb4, 0x2b, 0x00, 0x0d, 0xf0, 0x05, 0xb1
58 static inline int gic_get_current_cpu(GICState
*s
)
61 return current_cpu
->cpu_index
;
66 static inline int gic_get_current_vcpu(GICState
*s
)
68 return gic_get_current_cpu(s
) + GIC_NCPU
;
71 /* Return true if this GIC config has interrupt groups, which is
72 * true if we're a GICv2, or a GICv1 with the security extensions.
74 static inline bool gic_has_groups(GICState
*s
)
76 return s
->revision
== 2 || s
->security_extn
;
79 static inline bool gic_cpu_ns_access(GICState
*s
, int cpu
, MemTxAttrs attrs
)
81 return !gic_is_vcpu(cpu
) && s
->security_extn
&& !attrs
.secure
;
84 static inline void gic_get_best_irq(GICState
*s
, int cpu
,
85 int *best_irq
, int *best_prio
, int *group
)
93 for (irq
= 0; irq
< s
->num_irq
; irq
++) {
94 if (GIC_DIST_TEST_ENABLED(irq
, cm
) && gic_test_pending(s
, irq
, cm
) &&
95 (!GIC_DIST_TEST_ACTIVE(irq
, cm
)) &&
96 (irq
< GIC_INTERNAL
|| GIC_DIST_TARGET(irq
) & cm
)) {
97 if (GIC_DIST_GET_PRIORITY(irq
, cpu
) < *best_prio
) {
98 *best_prio
= GIC_DIST_GET_PRIORITY(irq
, cpu
);
104 if (*best_irq
< 1023) {
105 *group
= GIC_DIST_TEST_GROUP(*best_irq
, cm
);
109 static inline void gic_get_best_virq(GICState
*s
, int cpu
,
110 int *best_irq
, int *best_prio
, int *group
)
117 for (lr_idx
= 0; lr_idx
< s
->num_lrs
; lr_idx
++) {
118 uint32_t lr_entry
= s
->h_lr
[lr_idx
][cpu
];
119 int state
= GICH_LR_STATE(lr_entry
);
121 if (state
== GICH_LR_STATE_PENDING
) {
122 int prio
= GICH_LR_PRIORITY(lr_entry
);
124 if (prio
< *best_prio
) {
126 *best_irq
= GICH_LR_VIRT_ID(lr_entry
);
127 *group
= GICH_LR_GROUP(lr_entry
);
133 /* Return true if IRQ signaling is enabled for the given cpu and at least one
134 * of the given groups:
135 * - in the non-virt case, the distributor must be enabled for one of the
137 * - in the virt case, the virtual interface must be enabled.
138 * - in all cases, the (v)CPU interface must be enabled for one of the given
141 static inline bool gic_irq_signaling_enabled(GICState
*s
, int cpu
, bool virt
,
144 if (!virt
&& !(s
->ctlr
& group_mask
)) {
148 if (virt
&& !(s
->h_hcr
[cpu
] & R_GICH_HCR_EN_MASK
)) {
152 if (!(s
->cpu_ctlr
[cpu
] & group_mask
)) {
159 /* TODO: Many places that call this routine could be optimized. */
160 /* Update interrupt status after enabled or pending bits have been changed. */
161 static inline void gic_update_internal(GICState
*s
, bool virt
)
165 int irq_level
, fiq_level
;
168 qemu_irq
*irq_lines
= virt
? s
->parent_virq
: s
->parent_irq
;
169 qemu_irq
*fiq_lines
= virt
? s
->parent_vfiq
: s
->parent_fiq
;
171 for (cpu
= 0; cpu
< s
->num_cpu
; cpu
++) {
172 cpu_iface
= virt
? (cpu
+ GIC_NCPU
) : cpu
;
174 s
->current_pending
[cpu_iface
] = 1023;
175 if (!gic_irq_signaling_enabled(s
, cpu
, virt
,
176 GICD_CTLR_EN_GRP0
| GICD_CTLR_EN_GRP1
)) {
177 qemu_irq_lower(irq_lines
[cpu
]);
178 qemu_irq_lower(fiq_lines
[cpu
]);
183 gic_get_best_virq(s
, cpu
, &best_irq
, &best_prio
, &group
);
185 gic_get_best_irq(s
, cpu
, &best_irq
, &best_prio
, &group
);
188 if (best_irq
!= 1023) {
189 trace_gic_update_bestirq(virt
? "vcpu" : "cpu", cpu
,
191 s
->priority_mask
[cpu_iface
],
192 s
->running_priority
[cpu_iface
]);
195 irq_level
= fiq_level
= 0;
197 if (best_prio
< s
->priority_mask
[cpu_iface
]) {
198 s
->current_pending
[cpu_iface
] = best_irq
;
199 if (best_prio
< s
->running_priority
[cpu_iface
]) {
200 if (gic_irq_signaling_enabled(s
, cpu
, virt
, 1 << group
)) {
202 s
->cpu_ctlr
[cpu_iface
] & GICC_CTLR_FIQ_EN
) {
203 DPRINTF("Raised pending FIQ %d (cpu %d)\n",
204 best_irq
, cpu_iface
);
206 trace_gic_update_set_irq(cpu
, virt
? "vfiq" : "fiq",
209 DPRINTF("Raised pending IRQ %d (cpu %d)\n",
210 best_irq
, cpu_iface
);
212 trace_gic_update_set_irq(cpu
, virt
? "virq" : "irq",
219 qemu_set_irq(irq_lines
[cpu
], irq_level
);
220 qemu_set_irq(fiq_lines
[cpu
], fiq_level
);
224 static void gic_update(GICState
*s
)
226 gic_update_internal(s
, false);
229 /* Return true if this LR is empty, i.e. the corresponding bit
232 static inline bool gic_lr_entry_is_free(uint32_t entry
)
234 return (GICH_LR_STATE(entry
) == GICH_LR_STATE_INVALID
)
235 && (GICH_LR_HW(entry
) || !GICH_LR_EOI(entry
));
238 /* Return true if this LR should trigger an EOI maintenance interrupt, i.e. the
239 * corrsponding bit in EISR is set.
241 static inline bool gic_lr_entry_is_eoi(uint32_t entry
)
243 return (GICH_LR_STATE(entry
) == GICH_LR_STATE_INVALID
)
244 && !GICH_LR_HW(entry
) && GICH_LR_EOI(entry
);
247 static inline void gic_extract_lr_info(GICState
*s
, int cpu
,
248 int *num_eoi
, int *num_valid
, int *num_pending
)
256 for (lr_idx
= 0; lr_idx
< s
->num_lrs
; lr_idx
++) {
257 uint32_t *entry
= &s
->h_lr
[lr_idx
][cpu
];
259 if (gic_lr_entry_is_eoi(*entry
)) {
263 if (GICH_LR_STATE(*entry
) != GICH_LR_STATE_INVALID
) {
267 if (GICH_LR_STATE(*entry
) == GICH_LR_STATE_PENDING
) {
273 static void gic_compute_misr(GICState
*s
, int cpu
)
276 int vcpu
= cpu
+ GIC_NCPU
;
278 int num_eoi
, num_valid
, num_pending
;
280 gic_extract_lr_info(s
, cpu
, &num_eoi
, &num_valid
, &num_pending
);
284 value
|= R_GICH_MISR_EOI_MASK
;
287 /* U: true if only 0 or 1 LR entry is valid */
288 if ((s
->h_hcr
[cpu
] & R_GICH_HCR_UIE_MASK
) && (num_valid
< 2)) {
289 value
|= R_GICH_MISR_U_MASK
;
292 /* LRENP: EOICount is not 0 */
293 if ((s
->h_hcr
[cpu
] & R_GICH_HCR_LRENPIE_MASK
) &&
294 ((s
->h_hcr
[cpu
] & R_GICH_HCR_EOICount_MASK
) != 0)) {
295 value
|= R_GICH_MISR_LRENP_MASK
;
298 /* NP: no pending interrupts */
299 if ((s
->h_hcr
[cpu
] & R_GICH_HCR_NPIE_MASK
) && (num_pending
== 0)) {
300 value
|= R_GICH_MISR_NP_MASK
;
303 /* VGrp0E: group0 virq signaling enabled */
304 if ((s
->h_hcr
[cpu
] & R_GICH_HCR_VGRP0EIE_MASK
) &&
305 (s
->cpu_ctlr
[vcpu
] & GICC_CTLR_EN_GRP0
)) {
306 value
|= R_GICH_MISR_VGrp0E_MASK
;
309 /* VGrp0D: group0 virq signaling disabled */
310 if ((s
->h_hcr
[cpu
] & R_GICH_HCR_VGRP0DIE_MASK
) &&
311 !(s
->cpu_ctlr
[vcpu
] & GICC_CTLR_EN_GRP0
)) {
312 value
|= R_GICH_MISR_VGrp0D_MASK
;
315 /* VGrp1E: group1 virq signaling enabled */
316 if ((s
->h_hcr
[cpu
] & R_GICH_HCR_VGRP1EIE_MASK
) &&
317 (s
->cpu_ctlr
[vcpu
] & GICC_CTLR_EN_GRP1
)) {
318 value
|= R_GICH_MISR_VGrp1E_MASK
;
321 /* VGrp1D: group1 virq signaling disabled */
322 if ((s
->h_hcr
[cpu
] & R_GICH_HCR_VGRP1DIE_MASK
) &&
323 !(s
->cpu_ctlr
[vcpu
] & GICC_CTLR_EN_GRP1
)) {
324 value
|= R_GICH_MISR_VGrp1D_MASK
;
327 s
->h_misr
[cpu
] = value
;
330 static void gic_update_maintenance(GICState
*s
)
335 for (cpu
= 0; cpu
< s
->num_cpu
; cpu
++) {
336 gic_compute_misr(s
, cpu
);
337 maint_level
= (s
->h_hcr
[cpu
] & R_GICH_HCR_EN_MASK
) && s
->h_misr
[cpu
];
339 trace_gic_update_maintenance_irq(cpu
, maint_level
);
340 qemu_set_irq(s
->maintenance_irq
[cpu
], maint_level
);
344 static void gic_update_virt(GICState
*s
)
346 gic_update_internal(s
, true);
347 gic_update_maintenance(s
);
350 static void gic_set_irq_11mpcore(GICState
*s
, int irq
, int level
,
354 GIC_DIST_SET_LEVEL(irq
, cm
);
355 if (GIC_DIST_TEST_EDGE_TRIGGER(irq
) || GIC_DIST_TEST_ENABLED(irq
, cm
)) {
356 DPRINTF("Set %d pending mask %x\n", irq
, target
);
357 GIC_DIST_SET_PENDING(irq
, target
);
360 GIC_DIST_CLEAR_LEVEL(irq
, cm
);
364 static void gic_set_irq_generic(GICState
*s
, int irq
, int level
,
368 GIC_DIST_SET_LEVEL(irq
, cm
);
369 DPRINTF("Set %d pending mask %x\n", irq
, target
);
370 if (GIC_DIST_TEST_EDGE_TRIGGER(irq
)) {
371 GIC_DIST_SET_PENDING(irq
, target
);
374 GIC_DIST_CLEAR_LEVEL(irq
, cm
);
378 /* Process a change in an external IRQ input. */
379 static void gic_set_irq(void *opaque
, int irq
, int level
)
381 /* Meaning of the 'irq' parameter:
382 * [0..N-1] : external interrupts
383 * [N..N+31] : PPI (internal) interrupts for CPU 0
384 * [N+32..N+63] : PPI (internal interrupts for CPU 1
387 GICState
*s
= (GICState
*)opaque
;
389 if (irq
< (s
->num_irq
- GIC_INTERNAL
)) {
390 /* The first external input line is internal interrupt 32. */
393 target
= GIC_DIST_TARGET(irq
);
396 irq
-= (s
->num_irq
- GIC_INTERNAL
);
397 cpu
= irq
/ GIC_INTERNAL
;
403 assert(irq
>= GIC_NR_SGIS
);
405 if (level
== GIC_DIST_TEST_LEVEL(irq
, cm
)) {
409 if (s
->revision
== REV_11MPCORE
) {
410 gic_set_irq_11mpcore(s
, irq
, level
, cm
, target
);
412 gic_set_irq_generic(s
, irq
, level
, cm
, target
);
414 trace_gic_set_irq(irq
, level
, cm
, target
);
419 static uint16_t gic_get_current_pending_irq(GICState
*s
, int cpu
,
422 uint16_t pending_irq
= s
->current_pending
[cpu
];
424 if (pending_irq
< GIC_MAXIRQ
&& gic_has_groups(s
)) {
425 int group
= gic_test_group(s
, pending_irq
, cpu
);
427 /* On a GIC without the security extensions, reading this register
428 * behaves in the same way as a secure access to a GIC with them.
430 bool secure
= !gic_cpu_ns_access(s
, cpu
, attrs
);
432 if (group
== 0 && !secure
) {
433 /* Group0 interrupts hidden from Non-secure access */
436 if (group
== 1 && secure
&& !(s
->cpu_ctlr
[cpu
] & GICC_CTLR_ACK_CTL
)) {
437 /* Group1 interrupts only seen by Secure access if
446 static int gic_get_group_priority(GICState
*s
, int cpu
, int irq
)
448 /* Return the group priority of the specified interrupt
449 * (which is the top bits of its priority, with the number
450 * of bits masked determined by the applicable binary point register).
455 if (gic_has_groups(s
) &&
456 !(s
->cpu_ctlr
[cpu
] & GICC_CTLR_CBPR
) &&
457 gic_test_group(s
, irq
, cpu
)) {
458 bpr
= s
->abpr
[cpu
] - 1;
464 /* a BPR of 0 means the group priority bits are [7:1];
465 * a BPR of 1 means they are [7:2], and so on down to
466 * a BPR of 7 meaning no group priority bits at all.
468 mask
= ~0U << ((bpr
& 7) + 1);
470 return gic_get_priority(s
, irq
, cpu
) & mask
;
473 static void gic_activate_irq(GICState
*s
, int cpu
, int irq
)
475 /* Set the appropriate Active Priority Register bit for this IRQ,
476 * and update the running priority.
478 int prio
= gic_get_group_priority(s
, cpu
, irq
);
479 int min_bpr
= gic_is_vcpu(cpu
) ? GIC_VIRT_MIN_BPR
: GIC_MIN_BPR
;
480 int preemption_level
= prio
>> (min_bpr
+ 1);
481 int regno
= preemption_level
/ 32;
482 int bitno
= preemption_level
% 32;
483 uint32_t *papr
= NULL
;
485 if (gic_is_vcpu(cpu
)) {
487 papr
= &s
->h_apr
[gic_get_vcpu_real_id(cpu
)];
488 } else if (gic_has_groups(s
) && gic_test_group(s
, irq
, cpu
)) {
489 papr
= &s
->nsapr
[regno
][cpu
];
491 papr
= &s
->apr
[regno
][cpu
];
494 *papr
|= (1 << bitno
);
496 s
->running_priority
[cpu
] = prio
;
497 gic_set_active(s
, irq
, cpu
);
500 static int gic_get_prio_from_apr_bits(GICState
*s
, int cpu
)
502 /* Recalculate the current running priority for this CPU based
503 * on the set bits in the Active Priority Registers.
507 if (gic_is_vcpu(cpu
)) {
508 uint32_t apr
= s
->h_apr
[gic_get_vcpu_real_id(cpu
)];
510 return ctz32(apr
) << (GIC_VIRT_MIN_BPR
+ 1);
516 for (i
= 0; i
< GIC_NR_APRS
; i
++) {
517 uint32_t apr
= s
->apr
[i
][cpu
] | s
->nsapr
[i
][cpu
];
521 return (i
* 32 + ctz32(apr
)) << (GIC_MIN_BPR
+ 1);
526 static void gic_drop_prio(GICState
*s
, int cpu
, int group
)
528 /* Drop the priority of the currently active interrupt in the
531 * Note that we can guarantee (because of the requirement to nest
532 * GICC_IAR reads [which activate an interrupt and raise priority]
533 * with GICC_EOIR writes [which drop the priority for the interrupt])
534 * that the interrupt we're being called for is the highest priority
535 * active interrupt, meaning that it has the lowest set bit in the
538 * If the guest does not honour the ordering constraints then the
539 * behaviour of the GIC is UNPREDICTABLE, which for us means that
540 * the values of the APR registers might become incorrect and the
541 * running priority will be wrong, so interrupts that should preempt
542 * might not do so, and interrupts that should not preempt might do so.
544 if (gic_is_vcpu(cpu
)) {
545 int rcpu
= gic_get_vcpu_real_id(cpu
);
547 if (s
->h_apr
[rcpu
]) {
548 /* Clear lowest set bit */
549 s
->h_apr
[rcpu
] &= s
->h_apr
[rcpu
] - 1;
554 for (i
= 0; i
< GIC_NR_APRS
; i
++) {
555 uint32_t *papr
= group
? &s
->nsapr
[i
][cpu
] : &s
->apr
[i
][cpu
];
559 /* Clear lowest set bit */
565 s
->running_priority
[cpu
] = gic_get_prio_from_apr_bits(s
, cpu
);
568 static inline uint32_t gic_clear_pending_sgi(GICState
*s
, int irq
, int cpu
)
573 if (!gic_is_vcpu(cpu
)) {
574 /* Lookup the source CPU for the SGI and clear this in the
575 * sgi_pending map. Return the src and clear the overall pending
576 * state on this CPU if the SGI is not pending from any CPUs.
578 assert(s
->sgi_pending
[irq
][cpu
] != 0);
579 src
= ctz32(s
->sgi_pending
[irq
][cpu
]);
580 s
->sgi_pending
[irq
][cpu
] &= ~(1 << src
);
581 if (s
->sgi_pending
[irq
][cpu
] == 0) {
582 gic_clear_pending(s
, irq
, cpu
);
584 ret
= irq
| ((src
& 0x7) << 10);
586 uint32_t *lr_entry
= gic_get_lr_entry(s
, irq
, cpu
);
587 src
= GICH_LR_CPUID(*lr_entry
);
589 gic_clear_pending(s
, irq
, cpu
);
590 ret
= irq
| (src
<< 10);
596 uint32_t gic_acknowledge_irq(GICState
*s
, int cpu
, MemTxAttrs attrs
)
600 /* gic_get_current_pending_irq() will return 1022 or 1023 appropriately
601 * for the case where this GIC supports grouping and the pending interrupt
602 * is in the wrong group.
604 irq
= gic_get_current_pending_irq(s
, cpu
, attrs
);
605 trace_gic_acknowledge_irq(gic_is_vcpu(cpu
) ? "vcpu" : "cpu",
606 gic_get_vcpu_real_id(cpu
), irq
);
608 if (irq
>= GIC_MAXIRQ
) {
609 DPRINTF("ACK, no pending interrupt or it is hidden: %d\n", irq
);
613 if (gic_get_priority(s
, irq
, cpu
) >= s
->running_priority
[cpu
]) {
614 DPRINTF("ACK, pending interrupt (%d) has insufficient priority\n", irq
);
618 gic_activate_irq(s
, cpu
, irq
);
620 if (s
->revision
== REV_11MPCORE
) {
621 /* Clear pending flags for both level and edge triggered interrupts.
622 * Level triggered IRQs will be reasserted once they become inactive.
624 gic_clear_pending(s
, irq
, cpu
);
627 if (irq
< GIC_NR_SGIS
) {
628 ret
= gic_clear_pending_sgi(s
, irq
, cpu
);
630 gic_clear_pending(s
, irq
, cpu
);
635 if (gic_is_vcpu(cpu
)) {
640 DPRINTF("ACK %d\n", irq
);
644 static uint32_t gic_fullprio_mask(GICState
*s
, int cpu
)
647 * Return a mask word which clears the unimplemented priority
648 * bits from a priority value for an interrupt. (Not to be
649 * confused with the group priority, whose mask depends on BPR.)
653 if (gic_is_vcpu(cpu
)) {
654 priBits
= GIC_VIRT_MAX_GROUP_PRIO_BITS
;
656 priBits
= s
->n_prio_bits
;
658 return ~0U << (8 - priBits
);
661 void gic_dist_set_priority(GICState
*s
, int cpu
, int irq
, uint8_t val
,
664 if (s
->security_extn
&& !attrs
.secure
) {
665 if (!GIC_DIST_TEST_GROUP(irq
, (1 << cpu
))) {
666 return; /* Ignore Non-secure access of Group0 IRQ */
668 val
= 0x80 | (val
>> 1); /* Non-secure view */
671 val
&= gic_fullprio_mask(s
, cpu
);
673 if (irq
< GIC_INTERNAL
) {
674 s
->priority1
[irq
][cpu
] = val
;
676 s
->priority2
[(irq
) - GIC_INTERNAL
] = val
;
680 static uint32_t gic_dist_get_priority(GICState
*s
, int cpu
, int irq
,
683 uint32_t prio
= GIC_DIST_GET_PRIORITY(irq
, cpu
);
685 if (s
->security_extn
&& !attrs
.secure
) {
686 if (!GIC_DIST_TEST_GROUP(irq
, (1 << cpu
))) {
687 return 0; /* Non-secure access cannot read priority of Group0 IRQ */
689 prio
= (prio
<< 1) & 0xff; /* Non-secure view */
691 return prio
& gic_fullprio_mask(s
, cpu
);
694 static void gic_set_priority_mask(GICState
*s
, int cpu
, uint8_t pmask
,
697 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
698 if (s
->priority_mask
[cpu
] & 0x80) {
699 /* Priority Mask in upper half */
700 pmask
= 0x80 | (pmask
>> 1);
702 /* Non-secure write ignored if priority mask is in lower half */
706 s
->priority_mask
[cpu
] = pmask
& gic_fullprio_mask(s
, cpu
);
709 static uint32_t gic_get_priority_mask(GICState
*s
, int cpu
, MemTxAttrs attrs
)
711 uint32_t pmask
= s
->priority_mask
[cpu
];
713 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
715 /* Priority Mask in upper half, return Non-secure view */
716 pmask
= (pmask
<< 1) & 0xff;
718 /* Priority Mask in lower half, RAZ */
725 static uint32_t gic_get_cpu_control(GICState
*s
, int cpu
, MemTxAttrs attrs
)
727 uint32_t ret
= s
->cpu_ctlr
[cpu
];
729 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
730 /* Construct the NS banked view of GICC_CTLR from the correct
731 * bits of the S banked view. We don't need to move the bypass
732 * control bits because we don't implement that (IMPDEF) part
733 * of the GIC architecture.
735 ret
= (ret
& (GICC_CTLR_EN_GRP1
| GICC_CTLR_EOIMODE_NS
)) >> 1;
740 static void gic_set_cpu_control(GICState
*s
, int cpu
, uint32_t value
,
745 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
746 /* The NS view can only write certain bits in the register;
747 * the rest are unchanged
749 mask
= GICC_CTLR_EN_GRP1
;
750 if (s
->revision
== 2) {
751 mask
|= GICC_CTLR_EOIMODE_NS
;
753 s
->cpu_ctlr
[cpu
] &= ~mask
;
754 s
->cpu_ctlr
[cpu
] |= (value
<< 1) & mask
;
756 if (s
->revision
== 2) {
757 mask
= s
->security_extn
? GICC_CTLR_V2_S_MASK
: GICC_CTLR_V2_MASK
;
759 mask
= s
->security_extn
? GICC_CTLR_V1_S_MASK
: GICC_CTLR_V1_MASK
;
761 s
->cpu_ctlr
[cpu
] = value
& mask
;
763 DPRINTF("CPU Interface %d: Group0 Interrupts %sabled, "
764 "Group1 Interrupts %sabled\n", cpu
,
765 (s
->cpu_ctlr
[cpu
] & GICC_CTLR_EN_GRP0
) ? "En" : "Dis",
766 (s
->cpu_ctlr
[cpu
] & GICC_CTLR_EN_GRP1
) ? "En" : "Dis");
769 static uint8_t gic_get_running_priority(GICState
*s
, int cpu
, MemTxAttrs attrs
)
771 if ((s
->revision
!= REV_11MPCORE
) && (s
->running_priority
[cpu
] > 0xff)) {
776 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
777 if (s
->running_priority
[cpu
] & 0x80) {
778 /* Running priority in upper half of range: return the Non-secure
779 * view of the priority.
781 return s
->running_priority
[cpu
] << 1;
783 /* Running priority in lower half of range: RAZ */
787 return s
->running_priority
[cpu
];
791 /* Return true if we should split priority drop and interrupt deactivation,
792 * ie whether the relevant EOIMode bit is set.
794 static bool gic_eoi_split(GICState
*s
, int cpu
, MemTxAttrs attrs
)
796 if (s
->revision
!= 2) {
797 /* Before GICv2 prio-drop and deactivate are not separable */
800 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
801 return s
->cpu_ctlr
[cpu
] & GICC_CTLR_EOIMODE_NS
;
803 return s
->cpu_ctlr
[cpu
] & GICC_CTLR_EOIMODE
;
806 static void gic_deactivate_irq(GICState
*s
, int cpu
, int irq
, MemTxAttrs attrs
)
810 if (irq
>= GIC_MAXIRQ
|| (!gic_is_vcpu(cpu
) && irq
>= s
->num_irq
)) {
812 * This handles two cases:
813 * 1. If software writes the ID of a spurious interrupt [ie 1023]
814 * to the GICC_DIR, the GIC ignores that write.
815 * 2. If software writes the number of a non-existent interrupt
816 * this must be a subcase of "value written is not an active interrupt"
817 * and so this is UNPREDICTABLE. We choose to ignore it. For vCPUs,
818 * all IRQs potentially exist, so this limit does not apply.
823 if (!gic_eoi_split(s
, cpu
, attrs
)) {
824 /* This is UNPREDICTABLE; we choose to ignore it */
825 qemu_log_mask(LOG_GUEST_ERROR
,
826 "gic_deactivate_irq: GICC_DIR write when EOIMode clear");
830 if (gic_is_vcpu(cpu
) && !gic_virq_is_valid(s
, irq
, cpu
)) {
831 /* This vIRQ does not have an LR entry which is either active or
832 * pending and active. Increment EOICount and ignore the write.
834 int rcpu
= gic_get_vcpu_real_id(cpu
);
835 s
->h_hcr
[rcpu
] += 1 << R_GICH_HCR_EOICount_SHIFT
;
837 /* Update the virtual interface in case a maintenance interrupt should
844 group
= gic_has_groups(s
) && gic_test_group(s
, irq
, cpu
);
846 if (gic_cpu_ns_access(s
, cpu
, attrs
) && !group
) {
847 DPRINTF("Non-secure DI for Group0 interrupt %d ignored\n", irq
);
851 gic_clear_active(s
, irq
, cpu
);
854 static void gic_complete_irq(GICState
*s
, int cpu
, int irq
, MemTxAttrs attrs
)
859 DPRINTF("EOI %d\n", irq
);
860 if (gic_is_vcpu(cpu
)) {
861 /* The call to gic_prio_drop() will clear a bit in GICH_APR iff the
862 * running prio is < 0x100.
864 bool prio_drop
= s
->running_priority
[cpu
] < 0x100;
866 if (irq
>= GIC_MAXIRQ
) {
867 /* Ignore spurious interrupt */
871 gic_drop_prio(s
, cpu
, 0);
873 if (!gic_eoi_split(s
, cpu
, attrs
)) {
874 bool valid
= gic_virq_is_valid(s
, irq
, cpu
);
875 if (prio_drop
&& !valid
) {
876 /* We are in a situation where:
877 * - V_CTRL.EOIMode is false (no EOI split),
878 * - The call to gic_drop_prio() cleared a bit in GICH_APR,
879 * - This vIRQ does not have an LR entry which is either
880 * active or pending and active.
881 * In that case, we must increment EOICount.
883 int rcpu
= gic_get_vcpu_real_id(cpu
);
884 s
->h_hcr
[rcpu
] += 1 << R_GICH_HCR_EOICount_SHIFT
;
886 gic_clear_active(s
, irq
, cpu
);
894 if (irq
>= s
->num_irq
) {
895 /* This handles two cases:
896 * 1. If software writes the ID of a spurious interrupt [ie 1023]
897 * to the GICC_EOIR, the GIC ignores that write.
898 * 2. If software writes the number of a non-existent interrupt
899 * this must be a subcase of "value written does not match the last
900 * valid interrupt value read from the Interrupt Acknowledge
901 * register" and so this is UNPREDICTABLE. We choose to ignore it.
905 if (s
->running_priority
[cpu
] == 0x100) {
906 return; /* No active IRQ. */
909 if (s
->revision
== REV_11MPCORE
) {
910 /* Mark level triggered interrupts as pending if they are still
912 if (!GIC_DIST_TEST_EDGE_TRIGGER(irq
) && GIC_DIST_TEST_ENABLED(irq
, cm
)
913 && GIC_DIST_TEST_LEVEL(irq
, cm
)
914 && (GIC_DIST_TARGET(irq
) & cm
) != 0) {
915 DPRINTF("Set %d pending mask %x\n", irq
, cm
);
916 GIC_DIST_SET_PENDING(irq
, cm
);
920 group
= gic_has_groups(s
) && gic_test_group(s
, irq
, cpu
);
922 if (gic_cpu_ns_access(s
, cpu
, attrs
) && !group
) {
923 DPRINTF("Non-secure EOI for Group0 interrupt %d ignored\n", irq
);
927 /* Secure EOI with GICC_CTLR.AckCtl == 0 when the IRQ is a Group 1
928 * interrupt is UNPREDICTABLE. We choose to handle it as if AckCtl == 1,
929 * i.e. go ahead and complete the irq anyway.
932 gic_drop_prio(s
, cpu
, group
);
934 /* In GICv2 the guest can choose to split priority-drop and deactivate */
935 if (!gic_eoi_split(s
, cpu
, attrs
)) {
936 gic_clear_active(s
, irq
, cpu
);
941 static uint32_t gic_dist_readb(void *opaque
, hwaddr offset
, MemTxAttrs attrs
)
943 GICState
*s
= (GICState
*)opaque
;
951 cpu
= gic_get_current_cpu(s
);
953 if (offset
< 0x100) {
954 if (offset
== 0) { /* GICD_CTLR */
955 if (s
->security_extn
&& !attrs
.secure
) {
956 /* The NS bank of this register is just an alias of the
957 * EnableGrp1 bit in the S bank version.
959 return extract32(s
->ctlr
, 1, 1);
965 /* Interrupt Controller Type Register */
966 return ((s
->num_irq
/ 32) - 1)
967 | ((s
->num_cpu
- 1) << 5)
968 | (s
->security_extn
<< 10);
971 if (offset
>= 0x80) {
972 /* Interrupt Group Registers: these RAZ/WI if this is an NS
973 * access to a GIC with the security extensions, or if the GIC
974 * doesn't have groups at all.
977 if (!(s
->security_extn
&& !attrs
.secure
) && gic_has_groups(s
)) {
978 /* Every byte offset holds 8 group status bits */
979 irq
= (offset
- 0x080) * 8;
980 if (irq
>= s
->num_irq
) {
983 for (i
= 0; i
< 8; i
++) {
984 if (GIC_DIST_TEST_GROUP(irq
+ i
, cm
)) {
992 } else if (offset
< 0x200) {
993 /* Interrupt Set/Clear Enable. */
995 irq
= (offset
- 0x100) * 8;
997 irq
= (offset
- 0x180) * 8;
998 if (irq
>= s
->num_irq
)
1001 for (i
= 0; i
< 8; i
++) {
1002 if (s
->security_extn
&& !attrs
.secure
&&
1003 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1004 continue; /* Ignore Non-secure access of Group0 IRQ */
1007 if (GIC_DIST_TEST_ENABLED(irq
+ i
, cm
)) {
1011 } else if (offset
< 0x300) {
1012 /* Interrupt Set/Clear Pending. */
1014 irq
= (offset
- 0x200) * 8;
1016 irq
= (offset
- 0x280) * 8;
1017 if (irq
>= s
->num_irq
)
1020 mask
= (irq
< GIC_INTERNAL
) ? cm
: ALL_CPU_MASK
;
1021 for (i
= 0; i
< 8; i
++) {
1022 if (s
->security_extn
&& !attrs
.secure
&&
1023 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1024 continue; /* Ignore Non-secure access of Group0 IRQ */
1027 if (gic_test_pending(s
, irq
+ i
, mask
)) {
1031 } else if (offset
< 0x400) {
1032 /* Interrupt Set/Clear Active. */
1033 if (offset
< 0x380) {
1034 irq
= (offset
- 0x300) * 8;
1035 } else if (s
->revision
== 2) {
1036 irq
= (offset
- 0x380) * 8;
1041 if (irq
>= s
->num_irq
)
1044 mask
= (irq
< GIC_INTERNAL
) ? cm
: ALL_CPU_MASK
;
1045 for (i
= 0; i
< 8; i
++) {
1046 if (s
->security_extn
&& !attrs
.secure
&&
1047 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1048 continue; /* Ignore Non-secure access of Group0 IRQ */
1051 if (GIC_DIST_TEST_ACTIVE(irq
+ i
, mask
)) {
1055 } else if (offset
< 0x800) {
1056 /* Interrupt Priority. */
1057 irq
= (offset
- 0x400);
1058 if (irq
>= s
->num_irq
)
1060 res
= gic_dist_get_priority(s
, cpu
, irq
, attrs
);
1061 } else if (offset
< 0xc00) {
1062 /* Interrupt CPU Target. */
1063 if (s
->num_cpu
== 1 && s
->revision
!= REV_11MPCORE
) {
1064 /* For uniprocessor GICs these RAZ/WI */
1067 irq
= (offset
- 0x800);
1068 if (irq
>= s
->num_irq
) {
1071 if (irq
< 29 && s
->revision
== REV_11MPCORE
) {
1073 } else if (irq
< GIC_INTERNAL
) {
1076 res
= GIC_DIST_TARGET(irq
);
1079 } else if (offset
< 0xf00) {
1080 /* Interrupt Configuration. */
1081 irq
= (offset
- 0xc00) * 4;
1082 if (irq
>= s
->num_irq
)
1085 for (i
= 0; i
< 4; i
++) {
1086 if (s
->security_extn
&& !attrs
.secure
&&
1087 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1088 continue; /* Ignore Non-secure access of Group0 IRQ */
1091 if (GIC_DIST_TEST_MODEL(irq
+ i
)) {
1092 res
|= (1 << (i
* 2));
1094 if (GIC_DIST_TEST_EDGE_TRIGGER(irq
+ i
)) {
1095 res
|= (2 << (i
* 2));
1098 } else if (offset
< 0xf10) {
1100 } else if (offset
< 0xf30) {
1101 if (s
->revision
== REV_11MPCORE
) {
1105 if (offset
< 0xf20) {
1106 /* GICD_CPENDSGIRn */
1107 irq
= (offset
- 0xf10);
1109 irq
= (offset
- 0xf20);
1110 /* GICD_SPENDSGIRn */
1113 if (s
->security_extn
&& !attrs
.secure
&&
1114 !GIC_DIST_TEST_GROUP(irq
, 1 << cpu
)) {
1115 res
= 0; /* Ignore Non-secure access of Group0 IRQ */
1117 res
= s
->sgi_pending
[irq
][cpu
];
1119 } else if (offset
< 0xfd0) {
1121 } else if (offset
< 0x1000) {
1125 switch (s
->revision
) {
1127 res
= gic_id_11mpcore
[(offset
- 0xfd0) >> 2];
1130 res
= gic_id_gicv1
[(offset
- 0xfd0) >> 2];
1133 res
= gic_id_gicv2
[(offset
- 0xfd0) >> 2];
1140 g_assert_not_reached();
1144 qemu_log_mask(LOG_GUEST_ERROR
,
1145 "gic_dist_readb: Bad offset %x\n", (int)offset
);
1149 static MemTxResult
gic_dist_read(void *opaque
, hwaddr offset
, uint64_t *data
,
1150 unsigned size
, MemTxAttrs attrs
)
1154 *data
= gic_dist_readb(opaque
, offset
, attrs
);
1157 *data
= gic_dist_readb(opaque
, offset
, attrs
);
1158 *data
|= gic_dist_readb(opaque
, offset
+ 1, attrs
) << 8;
1161 *data
= gic_dist_readb(opaque
, offset
, attrs
);
1162 *data
|= gic_dist_readb(opaque
, offset
+ 1, attrs
) << 8;
1163 *data
|= gic_dist_readb(opaque
, offset
+ 2, attrs
) << 16;
1164 *data
|= gic_dist_readb(opaque
, offset
+ 3, attrs
) << 24;
1170 trace_gic_dist_read(offset
, size
, *data
);
1174 static void gic_dist_writeb(void *opaque
, hwaddr offset
,
1175 uint32_t value
, MemTxAttrs attrs
)
1177 GICState
*s
= (GICState
*)opaque
;
1182 cpu
= gic_get_current_cpu(s
);
1183 if (offset
< 0x100) {
1185 if (s
->security_extn
&& !attrs
.secure
) {
1186 /* NS version is just an alias of the S version's bit 1 */
1187 s
->ctlr
= deposit32(s
->ctlr
, 1, 1, value
);
1188 } else if (gic_has_groups(s
)) {
1189 s
->ctlr
= value
& (GICD_CTLR_EN_GRP0
| GICD_CTLR_EN_GRP1
);
1191 s
->ctlr
= value
& GICD_CTLR_EN_GRP0
;
1193 DPRINTF("Distributor: Group0 %sabled; Group 1 %sabled\n",
1194 s
->ctlr
& GICD_CTLR_EN_GRP0
? "En" : "Dis",
1195 s
->ctlr
& GICD_CTLR_EN_GRP1
? "En" : "Dis");
1196 } else if (offset
< 4) {
1198 } else if (offset
>= 0x80) {
1199 /* Interrupt Group Registers: RAZ/WI for NS access to secure
1200 * GIC, or for GICs without groups.
1202 if (!(s
->security_extn
&& !attrs
.secure
) && gic_has_groups(s
)) {
1203 /* Every byte offset holds 8 group status bits */
1204 irq
= (offset
- 0x80) * 8;
1205 if (irq
>= s
->num_irq
) {
1208 for (i
= 0; i
< 8; i
++) {
1209 /* Group bits are banked for private interrupts */
1210 int cm
= (irq
< GIC_INTERNAL
) ? (1 << cpu
) : ALL_CPU_MASK
;
1211 if (value
& (1 << i
)) {
1212 /* Group1 (Non-secure) */
1213 GIC_DIST_SET_GROUP(irq
+ i
, cm
);
1215 /* Group0 (Secure) */
1216 GIC_DIST_CLEAR_GROUP(irq
+ i
, cm
);
1223 } else if (offset
< 0x180) {
1224 /* Interrupt Set Enable. */
1225 irq
= (offset
- 0x100) * 8;
1226 if (irq
>= s
->num_irq
)
1228 if (irq
< GIC_NR_SGIS
) {
1232 for (i
= 0; i
< 8; i
++) {
1233 if (value
& (1 << i
)) {
1235 (irq
< GIC_INTERNAL
) ? (1 << cpu
)
1236 : GIC_DIST_TARGET(irq
+ i
);
1237 int cm
= (irq
< GIC_INTERNAL
) ? (1 << cpu
) : ALL_CPU_MASK
;
1239 if (s
->security_extn
&& !attrs
.secure
&&
1240 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1241 continue; /* Ignore Non-secure access of Group0 IRQ */
1244 if (!GIC_DIST_TEST_ENABLED(irq
+ i
, cm
)) {
1245 DPRINTF("Enabled IRQ %d\n", irq
+ i
);
1246 trace_gic_enable_irq(irq
+ i
);
1248 GIC_DIST_SET_ENABLED(irq
+ i
, cm
);
1249 /* If a raised level triggered IRQ enabled then mark
1251 if (GIC_DIST_TEST_LEVEL(irq
+ i
, mask
)
1252 && !GIC_DIST_TEST_EDGE_TRIGGER(irq
+ i
)) {
1253 DPRINTF("Set %d pending mask %x\n", irq
+ i
, mask
);
1254 GIC_DIST_SET_PENDING(irq
+ i
, mask
);
1258 } else if (offset
< 0x200) {
1259 /* Interrupt Clear Enable. */
1260 irq
= (offset
- 0x180) * 8;
1261 if (irq
>= s
->num_irq
)
1263 if (irq
< GIC_NR_SGIS
) {
1267 for (i
= 0; i
< 8; i
++) {
1268 if (value
& (1 << i
)) {
1269 int cm
= (irq
< GIC_INTERNAL
) ? (1 << cpu
) : ALL_CPU_MASK
;
1271 if (s
->security_extn
&& !attrs
.secure
&&
1272 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1273 continue; /* Ignore Non-secure access of Group0 IRQ */
1276 if (GIC_DIST_TEST_ENABLED(irq
+ i
, cm
)) {
1277 DPRINTF("Disabled IRQ %d\n", irq
+ i
);
1278 trace_gic_disable_irq(irq
+ i
);
1280 GIC_DIST_CLEAR_ENABLED(irq
+ i
, cm
);
1283 } else if (offset
< 0x280) {
1284 /* Interrupt Set Pending. */
1285 irq
= (offset
- 0x200) * 8;
1286 if (irq
>= s
->num_irq
)
1288 if (irq
< GIC_NR_SGIS
) {
1292 for (i
= 0; i
< 8; i
++) {
1293 if (value
& (1 << i
)) {
1294 if (s
->security_extn
&& !attrs
.secure
&&
1295 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1296 continue; /* Ignore Non-secure access of Group0 IRQ */
1299 GIC_DIST_SET_PENDING(irq
+ i
, GIC_DIST_TARGET(irq
+ i
));
1302 } else if (offset
< 0x300) {
1303 /* Interrupt Clear Pending. */
1304 irq
= (offset
- 0x280) * 8;
1305 if (irq
>= s
->num_irq
)
1307 if (irq
< GIC_NR_SGIS
) {
1311 for (i
= 0; i
< 8; i
++) {
1312 if (s
->security_extn
&& !attrs
.secure
&&
1313 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1314 continue; /* Ignore Non-secure access of Group0 IRQ */
1317 /* ??? This currently clears the pending bit for all CPUs, even
1318 for per-CPU interrupts. It's unclear whether this is the
1320 if (value
& (1 << i
)) {
1321 GIC_DIST_CLEAR_PENDING(irq
+ i
, ALL_CPU_MASK
);
1324 } else if (offset
< 0x380) {
1325 /* Interrupt Set Active. */
1326 if (s
->revision
!= 2) {
1330 irq
= (offset
- 0x300) * 8;
1331 if (irq
>= s
->num_irq
) {
1335 /* This register is banked per-cpu for PPIs */
1336 int cm
= irq
< GIC_INTERNAL
? (1 << cpu
) : ALL_CPU_MASK
;
1338 for (i
= 0; i
< 8; i
++) {
1339 if (s
->security_extn
&& !attrs
.secure
&&
1340 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1341 continue; /* Ignore Non-secure access of Group0 IRQ */
1344 if (value
& (1 << i
)) {
1345 GIC_DIST_SET_ACTIVE(irq
+ i
, cm
);
1348 } else if (offset
< 0x400) {
1349 /* Interrupt Clear Active. */
1350 if (s
->revision
!= 2) {
1354 irq
= (offset
- 0x380) * 8;
1355 if (irq
>= s
->num_irq
) {
1359 /* This register is banked per-cpu for PPIs */
1360 int cm
= irq
< GIC_INTERNAL
? (1 << cpu
) : ALL_CPU_MASK
;
1362 for (i
= 0; i
< 8; i
++) {
1363 if (s
->security_extn
&& !attrs
.secure
&&
1364 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1365 continue; /* Ignore Non-secure access of Group0 IRQ */
1368 if (value
& (1 << i
)) {
1369 GIC_DIST_CLEAR_ACTIVE(irq
+ i
, cm
);
1372 } else if (offset
< 0x800) {
1373 /* Interrupt Priority. */
1374 irq
= (offset
- 0x400);
1375 if (irq
>= s
->num_irq
)
1377 gic_dist_set_priority(s
, cpu
, irq
, value
, attrs
);
1378 } else if (offset
< 0xc00) {
1379 /* Interrupt CPU Target. RAZ/WI on uniprocessor GICs, with the
1380 * annoying exception of the 11MPCore's GIC.
1382 if (s
->num_cpu
!= 1 || s
->revision
== REV_11MPCORE
) {
1383 irq
= (offset
- 0x800);
1384 if (irq
>= s
->num_irq
) {
1387 if (irq
< 29 && s
->revision
== REV_11MPCORE
) {
1389 } else if (irq
< GIC_INTERNAL
) {
1390 value
= ALL_CPU_MASK
;
1392 s
->irq_target
[irq
] = value
& ALL_CPU_MASK
;
1394 } else if (offset
< 0xf00) {
1395 /* Interrupt Configuration. */
1396 irq
= (offset
- 0xc00) * 4;
1397 if (irq
>= s
->num_irq
)
1399 if (irq
< GIC_NR_SGIS
)
1401 for (i
= 0; i
< 4; i
++) {
1402 if (s
->security_extn
&& !attrs
.secure
&&
1403 !GIC_DIST_TEST_GROUP(irq
+ i
, 1 << cpu
)) {
1404 continue; /* Ignore Non-secure access of Group0 IRQ */
1407 if (s
->revision
== REV_11MPCORE
) {
1408 if (value
& (1 << (i
* 2))) {
1409 GIC_DIST_SET_MODEL(irq
+ i
);
1411 GIC_DIST_CLEAR_MODEL(irq
+ i
);
1414 if (value
& (2 << (i
* 2))) {
1415 GIC_DIST_SET_EDGE_TRIGGER(irq
+ i
);
1417 GIC_DIST_CLEAR_EDGE_TRIGGER(irq
+ i
);
1420 } else if (offset
< 0xf10) {
1421 /* 0xf00 is only handled for 32-bit writes. */
1423 } else if (offset
< 0xf20) {
1424 /* GICD_CPENDSGIRn */
1425 if (s
->revision
== REV_11MPCORE
) {
1428 irq
= (offset
- 0xf10);
1430 if (!s
->security_extn
|| attrs
.secure
||
1431 GIC_DIST_TEST_GROUP(irq
, 1 << cpu
)) {
1432 s
->sgi_pending
[irq
][cpu
] &= ~value
;
1433 if (s
->sgi_pending
[irq
][cpu
] == 0) {
1434 GIC_DIST_CLEAR_PENDING(irq
, 1 << cpu
);
1437 } else if (offset
< 0xf30) {
1438 /* GICD_SPENDSGIRn */
1439 if (s
->revision
== REV_11MPCORE
) {
1442 irq
= (offset
- 0xf20);
1444 if (!s
->security_extn
|| attrs
.secure
||
1445 GIC_DIST_TEST_GROUP(irq
, 1 << cpu
)) {
1446 GIC_DIST_SET_PENDING(irq
, 1 << cpu
);
1447 s
->sgi_pending
[irq
][cpu
] |= value
;
1455 qemu_log_mask(LOG_GUEST_ERROR
,
1456 "gic_dist_writeb: Bad offset %x\n", (int)offset
);
1459 static void gic_dist_writew(void *opaque
, hwaddr offset
,
1460 uint32_t value
, MemTxAttrs attrs
)
1462 gic_dist_writeb(opaque
, offset
, value
& 0xff, attrs
);
1463 gic_dist_writeb(opaque
, offset
+ 1, value
>> 8, attrs
);
1466 static void gic_dist_writel(void *opaque
, hwaddr offset
,
1467 uint32_t value
, MemTxAttrs attrs
)
1469 GICState
*s
= (GICState
*)opaque
;
1470 if (offset
== 0xf00) {
1476 cpu
= gic_get_current_cpu(s
);
1477 irq
= value
& 0x3ff;
1478 switch ((value
>> 24) & 3) {
1480 mask
= (value
>> 16) & ALL_CPU_MASK
;
1483 mask
= ALL_CPU_MASK
^ (1 << cpu
);
1489 DPRINTF("Bad Soft Int target filter\n");
1490 mask
= ALL_CPU_MASK
;
1493 GIC_DIST_SET_PENDING(irq
, mask
);
1494 target_cpu
= ctz32(mask
);
1495 while (target_cpu
< GIC_NCPU
) {
1496 s
->sgi_pending
[irq
][target_cpu
] |= (1 << cpu
);
1497 mask
&= ~(1 << target_cpu
);
1498 target_cpu
= ctz32(mask
);
1503 gic_dist_writew(opaque
, offset
, value
& 0xffff, attrs
);
1504 gic_dist_writew(opaque
, offset
+ 2, value
>> 16, attrs
);
1507 static MemTxResult
gic_dist_write(void *opaque
, hwaddr offset
, uint64_t data
,
1508 unsigned size
, MemTxAttrs attrs
)
1510 trace_gic_dist_write(offset
, size
, data
);
1514 gic_dist_writeb(opaque
, offset
, data
, attrs
);
1517 gic_dist_writew(opaque
, offset
, data
, attrs
);
1520 gic_dist_writel(opaque
, offset
, data
, attrs
);
1527 static inline uint32_t gic_apr_ns_view(GICState
*s
, int cpu
, int regno
)
1529 /* Return the Nonsecure view of GICC_APR<regno>. This is the
1530 * second half of GICC_NSAPR.
1532 switch (GIC_MIN_BPR
) {
1535 return s
->nsapr
[regno
+ 2][cpu
];
1540 return s
->nsapr
[regno
+ 1][cpu
];
1545 return extract32(s
->nsapr
[0][cpu
], 16, 16);
1550 return extract32(s
->nsapr
[0][cpu
], 8, 8);
1554 g_assert_not_reached();
1559 static inline void gic_apr_write_ns_view(GICState
*s
, int cpu
, int regno
,
1562 /* Write the Nonsecure view of GICC_APR<regno>. */
1563 switch (GIC_MIN_BPR
) {
1566 s
->nsapr
[regno
+ 2][cpu
] = value
;
1571 s
->nsapr
[regno
+ 1][cpu
] = value
;
1576 s
->nsapr
[0][cpu
] = deposit32(s
->nsapr
[0][cpu
], 16, 16, value
);
1581 s
->nsapr
[0][cpu
] = deposit32(s
->nsapr
[0][cpu
], 8, 8, value
);
1585 g_assert_not_reached();
1589 static MemTxResult
gic_cpu_read(GICState
*s
, int cpu
, int offset
,
1590 uint64_t *data
, MemTxAttrs attrs
)
1593 case 0x00: /* Control */
1594 *data
= gic_get_cpu_control(s
, cpu
, attrs
);
1596 case 0x04: /* Priority mask */
1597 *data
= gic_get_priority_mask(s
, cpu
, attrs
);
1599 case 0x08: /* Binary Point */
1600 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
1601 if (s
->cpu_ctlr
[cpu
] & GICC_CTLR_CBPR
) {
1602 /* NS view of BPR when CBPR is 1 */
1603 *data
= MIN(s
->bpr
[cpu
] + 1, 7);
1605 /* BPR is banked. Non-secure copy stored in ABPR. */
1606 *data
= s
->abpr
[cpu
];
1609 *data
= s
->bpr
[cpu
];
1612 case 0x0c: /* Acknowledge */
1613 *data
= gic_acknowledge_irq(s
, cpu
, attrs
);
1615 case 0x14: /* Running Priority */
1616 *data
= gic_get_running_priority(s
, cpu
, attrs
);
1618 case 0x18: /* Highest Pending Interrupt */
1619 *data
= gic_get_current_pending_irq(s
, cpu
, attrs
);
1621 case 0x1c: /* Aliased Binary Point */
1622 /* GIC v2, no security: ABPR
1623 * GIC v1, no security: not implemented (RAZ/WI)
1624 * With security extensions, secure access: ABPR (alias of NS BPR)
1625 * With security extensions, nonsecure access: RAZ/WI
1627 if (!gic_has_groups(s
) || (gic_cpu_ns_access(s
, cpu
, attrs
))) {
1630 *data
= s
->abpr
[cpu
];
1633 case 0xd0: case 0xd4: case 0xd8: case 0xdc:
1635 int regno
= (offset
- 0xd0) / 4;
1636 int nr_aprs
= gic_is_vcpu(cpu
) ? GIC_VIRT_NR_APRS
: GIC_NR_APRS
;
1638 if (regno
>= nr_aprs
|| s
->revision
!= 2) {
1640 } else if (gic_is_vcpu(cpu
)) {
1641 *data
= s
->h_apr
[gic_get_vcpu_real_id(cpu
)];
1642 } else if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
1643 /* NS view of GICC_APR<n> is the top half of GIC_NSAPR<n> */
1644 *data
= gic_apr_ns_view(s
, regno
, cpu
);
1646 *data
= s
->apr
[regno
][cpu
];
1650 case 0xe0: case 0xe4: case 0xe8: case 0xec:
1652 int regno
= (offset
- 0xe0) / 4;
1654 if (regno
>= GIC_NR_APRS
|| s
->revision
!= 2 || !gic_has_groups(s
) ||
1655 gic_cpu_ns_access(s
, cpu
, attrs
) || gic_is_vcpu(cpu
)) {
1658 *data
= s
->nsapr
[regno
][cpu
];
1663 qemu_log_mask(LOG_GUEST_ERROR
,
1664 "gic_cpu_read: Bad offset %x\n", (int)offset
);
1669 trace_gic_cpu_read(gic_is_vcpu(cpu
) ? "vcpu" : "cpu",
1670 gic_get_vcpu_real_id(cpu
), offset
, *data
);
1674 static MemTxResult
gic_cpu_write(GICState
*s
, int cpu
, int offset
,
1675 uint32_t value
, MemTxAttrs attrs
)
1677 trace_gic_cpu_write(gic_is_vcpu(cpu
) ? "vcpu" : "cpu",
1678 gic_get_vcpu_real_id(cpu
), offset
, value
);
1681 case 0x00: /* Control */
1682 gic_set_cpu_control(s
, cpu
, value
, attrs
);
1684 case 0x04: /* Priority mask */
1685 gic_set_priority_mask(s
, cpu
, value
, attrs
);
1687 case 0x08: /* Binary Point */
1688 if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
1689 if (s
->cpu_ctlr
[cpu
] & GICC_CTLR_CBPR
) {
1690 /* WI when CBPR is 1 */
1693 s
->abpr
[cpu
] = MAX(value
& 0x7, GIC_MIN_ABPR
);
1696 int min_bpr
= gic_is_vcpu(cpu
) ? GIC_VIRT_MIN_BPR
: GIC_MIN_BPR
;
1697 s
->bpr
[cpu
] = MAX(value
& 0x7, min_bpr
);
1700 case 0x10: /* End Of Interrupt */
1701 gic_complete_irq(s
, cpu
, value
& 0x3ff, attrs
);
1703 case 0x1c: /* Aliased Binary Point */
1704 if (!gic_has_groups(s
) || (gic_cpu_ns_access(s
, cpu
, attrs
))) {
1705 /* unimplemented, or NS access: RAZ/WI */
1708 s
->abpr
[cpu
] = MAX(value
& 0x7, GIC_MIN_ABPR
);
1711 case 0xd0: case 0xd4: case 0xd8: case 0xdc:
1713 int regno
= (offset
- 0xd0) / 4;
1714 int nr_aprs
= gic_is_vcpu(cpu
) ? GIC_VIRT_NR_APRS
: GIC_NR_APRS
;
1716 if (regno
>= nr_aprs
|| s
->revision
!= 2) {
1719 if (gic_is_vcpu(cpu
)) {
1720 s
->h_apr
[gic_get_vcpu_real_id(cpu
)] = value
;
1721 } else if (gic_cpu_ns_access(s
, cpu
, attrs
)) {
1722 /* NS view of GICC_APR<n> is the top half of GIC_NSAPR<n> */
1723 gic_apr_write_ns_view(s
, regno
, cpu
, value
);
1725 s
->apr
[regno
][cpu
] = value
;
1729 case 0xe0: case 0xe4: case 0xe8: case 0xec:
1731 int regno
= (offset
- 0xe0) / 4;
1733 if (regno
>= GIC_NR_APRS
|| s
->revision
!= 2) {
1736 if (gic_is_vcpu(cpu
)) {
1739 if (!gic_has_groups(s
) || (gic_cpu_ns_access(s
, cpu
, attrs
))) {
1742 s
->nsapr
[regno
][cpu
] = value
;
1747 gic_deactivate_irq(s
, cpu
, value
& 0x3ff, attrs
);
1750 qemu_log_mask(LOG_GUEST_ERROR
,
1751 "gic_cpu_write: Bad offset %x\n", (int)offset
);
1755 if (gic_is_vcpu(cpu
)) {
1764 /* Wrappers to read/write the GIC CPU interface for the current CPU */
1765 static MemTxResult
gic_thiscpu_read(void *opaque
, hwaddr addr
, uint64_t *data
,
1766 unsigned size
, MemTxAttrs attrs
)
1768 GICState
*s
= (GICState
*)opaque
;
1769 return gic_cpu_read(s
, gic_get_current_cpu(s
), addr
, data
, attrs
);
1772 static MemTxResult
gic_thiscpu_write(void *opaque
, hwaddr addr
,
1773 uint64_t value
, unsigned size
,
1776 GICState
*s
= (GICState
*)opaque
;
1777 return gic_cpu_write(s
, gic_get_current_cpu(s
), addr
, value
, attrs
);
1780 /* Wrappers to read/write the GIC CPU interface for a specific CPU.
1781 * These just decode the opaque pointer into GICState* + cpu id.
1783 static MemTxResult
gic_do_cpu_read(void *opaque
, hwaddr addr
, uint64_t *data
,
1784 unsigned size
, MemTxAttrs attrs
)
1786 GICState
**backref
= (GICState
**)opaque
;
1787 GICState
*s
= *backref
;
1788 int id
= (backref
- s
->backref
);
1789 return gic_cpu_read(s
, id
, addr
, data
, attrs
);
1792 static MemTxResult
gic_do_cpu_write(void *opaque
, hwaddr addr
,
1793 uint64_t value
, unsigned size
,
1796 GICState
**backref
= (GICState
**)opaque
;
1797 GICState
*s
= *backref
;
1798 int id
= (backref
- s
->backref
);
1799 return gic_cpu_write(s
, id
, addr
, value
, attrs
);
1802 static MemTxResult
gic_thisvcpu_read(void *opaque
, hwaddr addr
, uint64_t *data
,
1803 unsigned size
, MemTxAttrs attrs
)
1805 GICState
*s
= (GICState
*)opaque
;
1807 return gic_cpu_read(s
, gic_get_current_vcpu(s
), addr
, data
, attrs
);
1810 static MemTxResult
gic_thisvcpu_write(void *opaque
, hwaddr addr
,
1811 uint64_t value
, unsigned size
,
1814 GICState
*s
= (GICState
*)opaque
;
1816 return gic_cpu_write(s
, gic_get_current_vcpu(s
), addr
, value
, attrs
);
1819 static uint32_t gic_compute_eisr(GICState
*s
, int cpu
, int lr_start
)
1824 for (lr_idx
= lr_start
; lr_idx
< s
->num_lrs
; lr_idx
++) {
1825 uint32_t *entry
= &s
->h_lr
[lr_idx
][cpu
];
1826 ret
= deposit32(ret
, lr_idx
- lr_start
, 1,
1827 gic_lr_entry_is_eoi(*entry
));
1833 static uint32_t gic_compute_elrsr(GICState
*s
, int cpu
, int lr_start
)
1838 for (lr_idx
= lr_start
; lr_idx
< s
->num_lrs
; lr_idx
++) {
1839 uint32_t *entry
= &s
->h_lr
[lr_idx
][cpu
];
1840 ret
= deposit32(ret
, lr_idx
- lr_start
, 1,
1841 gic_lr_entry_is_free(*entry
));
1847 static void gic_vmcr_write(GICState
*s
, uint32_t value
, MemTxAttrs attrs
)
1849 int vcpu
= gic_get_current_vcpu(s
);
1855 ctlr
= FIELD_EX32(value
, GICH_VMCR
, VMCCtlr
);
1856 abpr
= FIELD_EX32(value
, GICH_VMCR
, VMABP
);
1857 bpr
= FIELD_EX32(value
, GICH_VMCR
, VMBP
);
1858 prio_mask
= FIELD_EX32(value
, GICH_VMCR
, VMPriMask
) << 3;
1860 gic_set_cpu_control(s
, vcpu
, ctlr
, attrs
);
1861 s
->abpr
[vcpu
] = MAX(abpr
, GIC_VIRT_MIN_ABPR
);
1862 s
->bpr
[vcpu
] = MAX(bpr
, GIC_VIRT_MIN_BPR
);
1863 gic_set_priority_mask(s
, vcpu
, prio_mask
, attrs
);
1866 static MemTxResult
gic_hyp_read(void *opaque
, int cpu
, hwaddr addr
,
1867 uint64_t *data
, MemTxAttrs attrs
)
1869 GICState
*s
= ARM_GIC(opaque
);
1870 int vcpu
= cpu
+ GIC_NCPU
;
1873 case A_GICH_HCR
: /* Hypervisor Control */
1874 *data
= s
->h_hcr
[cpu
];
1877 case A_GICH_VTR
: /* VGIC Type */
1878 *data
= FIELD_DP32(0, GICH_VTR
, ListRegs
, s
->num_lrs
- 1);
1879 *data
= FIELD_DP32(*data
, GICH_VTR
, PREbits
,
1880 GIC_VIRT_MAX_GROUP_PRIO_BITS
- 1);
1881 *data
= FIELD_DP32(*data
, GICH_VTR
, PRIbits
,
1882 (7 - GIC_VIRT_MIN_BPR
) - 1);
1885 case A_GICH_VMCR
: /* Virtual Machine Control */
1886 *data
= FIELD_DP32(0, GICH_VMCR
, VMCCtlr
,
1887 extract32(s
->cpu_ctlr
[vcpu
], 0, 10));
1888 *data
= FIELD_DP32(*data
, GICH_VMCR
, VMABP
, s
->abpr
[vcpu
]);
1889 *data
= FIELD_DP32(*data
, GICH_VMCR
, VMBP
, s
->bpr
[vcpu
]);
1890 *data
= FIELD_DP32(*data
, GICH_VMCR
, VMPriMask
,
1891 extract32(s
->priority_mask
[vcpu
], 3, 5));
1894 case A_GICH_MISR
: /* Maintenance Interrupt Status */
1895 *data
= s
->h_misr
[cpu
];
1898 case A_GICH_EISR0
: /* End of Interrupt Status 0 and 1 */
1900 *data
= gic_compute_eisr(s
, cpu
, (addr
- A_GICH_EISR0
) * 8);
1903 case A_GICH_ELRSR0
: /* Empty List Status 0 and 1 */
1905 *data
= gic_compute_elrsr(s
, cpu
, (addr
- A_GICH_ELRSR0
) * 8);
1908 case A_GICH_APR
: /* Active Priorities */
1909 *data
= s
->h_apr
[cpu
];
1912 case A_GICH_LR0
... A_GICH_LR63
: /* List Registers */
1914 int lr_idx
= (addr
- A_GICH_LR0
) / 4;
1916 if (lr_idx
> s
->num_lrs
) {
1919 *data
= s
->h_lr
[lr_idx
][cpu
];
1925 qemu_log_mask(LOG_GUEST_ERROR
,
1926 "gic_hyp_read: Bad offset %" HWADDR_PRIx
"\n", addr
);
1930 trace_gic_hyp_read(addr
, *data
);
1934 static MemTxResult
gic_hyp_write(void *opaque
, int cpu
, hwaddr addr
,
1935 uint64_t value
, MemTxAttrs attrs
)
1937 GICState
*s
= ARM_GIC(opaque
);
1938 int vcpu
= cpu
+ GIC_NCPU
;
1940 trace_gic_hyp_write(addr
, value
);
1943 case A_GICH_HCR
: /* Hypervisor Control */
1944 s
->h_hcr
[cpu
] = value
& GICH_HCR_MASK
;
1947 case A_GICH_VMCR
: /* Virtual Machine Control */
1948 gic_vmcr_write(s
, value
, attrs
);
1951 case A_GICH_APR
: /* Active Priorities */
1952 s
->h_apr
[cpu
] = value
;
1953 s
->running_priority
[vcpu
] = gic_get_prio_from_apr_bits(s
, vcpu
);
1956 case A_GICH_LR0
... A_GICH_LR63
: /* List Registers */
1958 int lr_idx
= (addr
- A_GICH_LR0
) / 4;
1960 if (lr_idx
> s
->num_lrs
) {
1964 s
->h_lr
[lr_idx
][cpu
] = value
& GICH_LR_MASK
;
1965 trace_gic_lr_entry(cpu
, lr_idx
, s
->h_lr
[lr_idx
][cpu
]);
1970 qemu_log_mask(LOG_GUEST_ERROR
,
1971 "gic_hyp_write: Bad offset %" HWADDR_PRIx
"\n", addr
);
1979 static MemTxResult
gic_thiscpu_hyp_read(void *opaque
, hwaddr addr
, uint64_t *data
,
1980 unsigned size
, MemTxAttrs attrs
)
1982 GICState
*s
= (GICState
*)opaque
;
1984 return gic_hyp_read(s
, gic_get_current_cpu(s
), addr
, data
, attrs
);
1987 static MemTxResult
gic_thiscpu_hyp_write(void *opaque
, hwaddr addr
,
1988 uint64_t value
, unsigned size
,
1991 GICState
*s
= (GICState
*)opaque
;
1993 return gic_hyp_write(s
, gic_get_current_cpu(s
), addr
, value
, attrs
);
1996 static MemTxResult
gic_do_hyp_read(void *opaque
, hwaddr addr
, uint64_t *data
,
1997 unsigned size
, MemTxAttrs attrs
)
1999 GICState
**backref
= (GICState
**)opaque
;
2000 GICState
*s
= *backref
;
2001 int id
= (backref
- s
->backref
);
2003 return gic_hyp_read(s
, id
, addr
, data
, attrs
);
2006 static MemTxResult
gic_do_hyp_write(void *opaque
, hwaddr addr
,
2007 uint64_t value
, unsigned size
,
2010 GICState
**backref
= (GICState
**)opaque
;
2011 GICState
*s
= *backref
;
2012 int id
= (backref
- s
->backref
);
2014 return gic_hyp_write(s
, id
+ GIC_NCPU
, addr
, value
, attrs
);
2018 static const MemoryRegionOps gic_ops
[2] = {
2020 .read_with_attrs
= gic_dist_read
,
2021 .write_with_attrs
= gic_dist_write
,
2022 .endianness
= DEVICE_NATIVE_ENDIAN
,
2025 .read_with_attrs
= gic_thiscpu_read
,
2026 .write_with_attrs
= gic_thiscpu_write
,
2027 .endianness
= DEVICE_NATIVE_ENDIAN
,
2031 static const MemoryRegionOps gic_cpu_ops
= {
2032 .read_with_attrs
= gic_do_cpu_read
,
2033 .write_with_attrs
= gic_do_cpu_write
,
2034 .endianness
= DEVICE_NATIVE_ENDIAN
,
2037 static const MemoryRegionOps gic_virt_ops
[2] = {
2039 .read_with_attrs
= gic_thiscpu_hyp_read
,
2040 .write_with_attrs
= gic_thiscpu_hyp_write
,
2041 .endianness
= DEVICE_NATIVE_ENDIAN
,
2044 .read_with_attrs
= gic_thisvcpu_read
,
2045 .write_with_attrs
= gic_thisvcpu_write
,
2046 .endianness
= DEVICE_NATIVE_ENDIAN
,
2050 static const MemoryRegionOps gic_viface_ops
= {
2051 .read_with_attrs
= gic_do_hyp_read
,
2052 .write_with_attrs
= gic_do_hyp_write
,
2053 .endianness
= DEVICE_NATIVE_ENDIAN
,
2056 static void arm_gic_realize(DeviceState
*dev
, Error
**errp
)
2058 /* Device instance realize function for the GIC sysbus device */
2060 GICState
*s
= ARM_GIC(dev
);
2061 SysBusDevice
*sbd
= SYS_BUS_DEVICE(dev
);
2062 ARMGICClass
*agc
= ARM_GIC_GET_CLASS(s
);
2063 Error
*local_err
= NULL
;
2065 agc
->parent_realize(dev
, &local_err
);
2067 error_propagate(errp
, local_err
);
2071 if (kvm_enabled() && !kvm_arm_supports_user_irq()) {
2072 error_setg(errp
, "KVM with user space irqchip only works when the "
2073 "host kernel supports KVM_CAP_ARM_USER_IRQ");
2077 if (s
->n_prio_bits
> GIC_MAX_PRIORITY_BITS
||
2078 (s
->virt_extn
? s
->n_prio_bits
< GIC_VIRT_MAX_GROUP_PRIO_BITS
:
2079 s
->n_prio_bits
< GIC_MIN_PRIORITY_BITS
)) {
2080 error_setg(errp
, "num-priority-bits cannot be greater than %d"
2081 " or less than %d", GIC_MAX_PRIORITY_BITS
,
2082 s
->virt_extn
? GIC_VIRT_MAX_GROUP_PRIO_BITS
:
2083 GIC_MIN_PRIORITY_BITS
);
2087 /* This creates distributor, main CPU interface (s->cpuiomem[0]) and if
2088 * enabled, virtualization extensions related interfaces (main virtual
2089 * interface (s->vifaceiomem[0]) and virtual CPU interface).
2091 gic_init_irqs_and_mmio(s
, gic_set_irq
, gic_ops
, gic_virt_ops
);
2093 /* Extra core-specific regions for the CPU interfaces. This is
2094 * necessary for "franken-GIC" implementations, for example on
2096 * NB that the memory region size of 0x100 applies for the 11MPCore
2097 * and also cores following the GIC v1 spec (ie A9).
2098 * GIC v2 defines a larger memory region (0x1000) so this will need
2099 * to be extended when we implement A15.
2101 for (i
= 0; i
< s
->num_cpu
; i
++) {
2103 memory_region_init_io(&s
->cpuiomem
[i
+1], OBJECT(s
), &gic_cpu_ops
,
2104 &s
->backref
[i
], "gic_cpu", 0x100);
2105 sysbus_init_mmio(sbd
, &s
->cpuiomem
[i
+1]);
2108 /* Extra core-specific regions for virtual interfaces. This is required by
2109 * the GICv2 specification.
2112 for (i
= 0; i
< s
->num_cpu
; i
++) {
2113 memory_region_init_io(&s
->vifaceiomem
[i
+ 1], OBJECT(s
),
2114 &gic_viface_ops
, &s
->backref
[i
],
2115 "gic_viface", 0x200);
2116 sysbus_init_mmio(sbd
, &s
->vifaceiomem
[i
+ 1]);
2122 static void arm_gic_class_init(ObjectClass
*klass
, void *data
)
2124 DeviceClass
*dc
= DEVICE_CLASS(klass
);
2125 ARMGICClass
*agc
= ARM_GIC_CLASS(klass
);
2127 device_class_set_parent_realize(dc
, arm_gic_realize
, &agc
->parent_realize
);
2130 static const TypeInfo arm_gic_info
= {
2131 .name
= TYPE_ARM_GIC
,
2132 .parent
= TYPE_ARM_GIC_COMMON
,
2133 .instance_size
= sizeof(GICState
),
2134 .class_init
= arm_gic_class_init
,
2135 .class_size
= sizeof(ARMGICClass
),
2138 static void arm_gic_register_types(void)
2140 type_register_static(&arm_gic_info
);
2143 type_init(arm_gic_register_types
)