Lines Matching +full:cs +full:- +full:1
24 static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio, bool nmi) in irqbetter() argument
33 if (prio != cs->hppi.prio) { in irqbetter()
34 return prio < cs->hppi.prio; in irqbetter()
38 * The same priority IRQ with non-maskable property should signal to in irqbetter()
41 if (nmi != cs->hppi.nmi) { in irqbetter()
49 if (irq <= cs->hppi.irq) { in irqbetter()
59 * of 32), and return a 32-bit integer which has a bit set for each in gicd_int_pending()
63 * + the PENDING latch is set OR it is level triggered and the input is 1 in gicd_int_pending()
67 * Conveniently we can bulk-calculate this with bitwise operations. in gicd_int_pending()
70 uint32_t pending = *gic_bmp_ptr32(s->pending, irq); in gicd_int_pending()
71 uint32_t edge_trigger = *gic_bmp_ptr32(s->edge_trigger, irq); in gicd_int_pending()
72 uint32_t level = *gic_bmp_ptr32(s->level, irq); in gicd_int_pending()
73 uint32_t group = *gic_bmp_ptr32(s->group, irq); in gicd_int_pending()
74 uint32_t grpmod = *gic_bmp_ptr32(s->grpmod, irq); in gicd_int_pending()
75 uint32_t enable = *gic_bmp_ptr32(s->enabled, irq); in gicd_int_pending()
76 uint32_t active = *gic_bmp_ptr32(s->active, irq); in gicd_int_pending()
82 if (s->gicd_ctlr & GICD_CTLR_DS) { in gicd_int_pending()
87 if (s->gicd_ctlr & GICD_CTLR_EN_GRP1NS) { in gicd_int_pending()
90 if (s->gicd_ctlr & GICD_CTLR_EN_GRP1S) { in gicd_int_pending()
93 if (s->gicd_ctlr & GICD_CTLR_EN_GRP0) { in gicd_int_pending()
101 static uint32_t gicr_int_pending(GICv3CPUState *cs) in gicr_int_pending() argument
104 * and return a 32-bit integer which has a bit set for each interrupt in gicr_int_pending()
108 * + the PENDING latch is set OR it is level triggered and the input is 1 in gicr_int_pending()
112 * Conveniently we can bulk-calculate this with bitwise operations. in gicr_int_pending()
116 pend = cs->gicr_ipendr0 | (~cs->edge_trigger & cs->level); in gicr_int_pending()
117 pend &= cs->gicr_ienabler0; in gicr_int_pending()
118 pend &= ~cs->gicr_iactiver0; in gicr_int_pending()
120 if (cs->gic->gicd_ctlr & GICD_CTLR_DS) { in gicr_int_pending()
123 grpmod = cs->gicr_igrpmodr0; in gicr_int_pending()
127 if (cs->gic->gicd_ctlr & GICD_CTLR_EN_GRP1NS) { in gicr_int_pending()
128 grpmask |= cs->gicr_igroupr0; in gicr_int_pending()
130 if (cs->gic->gicd_ctlr & GICD_CTLR_EN_GRP1S) { in gicr_int_pending()
131 grpmask |= (~cs->gicr_igroupr0 & grpmod); in gicr_int_pending()
133 if (cs->gic->gicd_ctlr & GICD_CTLR_EN_GRP0) { in gicr_int_pending()
134 grpmask |= (~cs->gicr_igroupr0 & ~grpmod); in gicr_int_pending()
141 static bool gicv3_get_priority(GICv3CPUState *cs, bool is_redist, int irq, in gicv3_get_priority() argument
147 nmi = extract32(cs->gicr_inmir0, irq, 1); in gicv3_get_priority()
149 nmi = *gic_bmp_ptr32(cs->gic->nmi, irq); in gicv3_get_priority()
150 nmi = nmi & (1 << (irq & 0x1f)); in gicv3_get_priority()
154 /* DS = 0 & Non-secure NMI */ in gicv3_get_priority()
155 if (!(cs->gic->gicd_ctlr & GICD_CTLR_DS) && in gicv3_get_priority()
156 ((is_redist && extract32(cs->gicr_igroupr0, irq, 1)) || in gicv3_get_priority()
157 (!is_redist && gicv3_gicd_group_test(cs->gic, irq)))) { in gicv3_get_priority()
167 *prio = cs->gicr_ipriorityr[irq]; in gicv3_get_priority()
169 *prio = cs->gic->gicd_ipriority[irq]; in gicv3_get_priority()
178 static void gicv3_redist_update_noirqset(GICv3CPUState *cs) in gicv3_redist_update_noirqset() argument
192 pend = gicr_int_pending(cs); in gicv3_redist_update_noirqset()
196 if (!(pend & (1 << i))) { in gicv3_redist_update_noirqset()
199 nmi = gicv3_get_priority(cs, true, i, &prio); in gicv3_redist_update_noirqset()
200 if (irqbetter(cs, i, prio, nmi)) { in gicv3_redist_update_noirqset()
201 cs->hppi.irq = i; in gicv3_redist_update_noirqset()
202 cs->hppi.prio = prio; in gicv3_redist_update_noirqset()
203 cs->hppi.nmi = nmi; in gicv3_redist_update_noirqset()
210 cs->hppi.grp = gicv3_irq_group(cs->gic, cs, cs->hppi.irq); in gicv3_redist_update_noirqset()
213 if ((cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) && cs->gic->lpi_enable && in gicv3_redist_update_noirqset()
214 (cs->gic->gicd_ctlr & GICD_CTLR_EN_GRP1NS) && in gicv3_redist_update_noirqset()
215 (cs->hpplpi.prio != 0xff)) { in gicv3_redist_update_noirqset()
216 if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio, cs->hpplpi.nmi)) { in gicv3_redist_update_noirqset()
217 cs->hppi.irq = cs->hpplpi.irq; in gicv3_redist_update_noirqset()
218 cs->hppi.prio = cs->hpplpi.prio; in gicv3_redist_update_noirqset()
219 cs->hppi.nmi = cs->hpplpi.nmi; in gicv3_redist_update_noirqset()
220 cs->hppi.grp = cs->hpplpi.grp; in gicv3_redist_update_noirqset()
236 if (!seenbetter && cs->hppi.prio != 0xff && in gicv3_redist_update_noirqset()
237 (cs->hppi.irq < GIC_INTERNAL || in gicv3_redist_update_noirqset()
238 cs->hppi.irq >= GICV3_LPI_INTID_START)) { in gicv3_redist_update_noirqset()
239 gicv3_full_update_noirqset(cs->gic); in gicv3_redist_update_noirqset()
247 void gicv3_redist_update(GICv3CPUState *cs) in gicv3_redist_update() argument
249 gicv3_redist_update_noirqset(cs); in gicv3_redist_update()
250 gicv3_cpuif_update(cs); in gicv3_redist_update()
267 for (i = 0; i < s->num_cpu; i++) { in gicv3_update_noirqset()
268 s->cpu[i].seenbetter = false; in gicv3_update_noirqset()
273 GICv3CPUState *cs; in gicv3_update_noirqset() local
280 if (!(pend & (1 << (i & 0x1f)))) { in gicv3_update_noirqset()
283 cs = s->gicd_irouter_target[i]; in gicv3_update_noirqset()
284 if (!cs) { in gicv3_update_noirqset()
290 nmi = gicv3_get_priority(cs, false, i, &prio); in gicv3_update_noirqset()
291 if (irqbetter(cs, i, prio, nmi)) { in gicv3_update_noirqset()
292 cs->hppi.irq = i; in gicv3_update_noirqset()
293 cs->hppi.prio = prio; in gicv3_update_noirqset()
294 cs->hppi.nmi = nmi; in gicv3_update_noirqset()
295 cs->seenbetter = true; in gicv3_update_noirqset()
310 for (i = 0; i < s->num_cpu; i++) { in gicv3_update_noirqset()
311 GICv3CPUState *cs = &s->cpu[i]; in gicv3_update_noirqset() local
313 if (cs->seenbetter) { in gicv3_update_noirqset()
314 cs->hppi.grp = gicv3_irq_group(cs->gic, cs, cs->hppi.irq); in gicv3_update_noirqset()
317 if (!cs->seenbetter && cs->hppi.prio != 0xff && in gicv3_update_noirqset()
318 cs->hppi.irq >= start && cs->hppi.irq < start + len) { in gicv3_update_noirqset()
330 for (i = 0; i < s->num_cpu; i++) { in gicv3_update()
331 gicv3_cpuif_update(&s->cpu[i]); in gicv3_update()
342 for (i = 0; i < s->num_cpu; i++) { in gicv3_full_update_noirqset()
343 s->cpu[i].hppi.prio = 0xff; in gicv3_full_update_noirqset()
344 s->cpu[i].hppi.nmi = false; in gicv3_full_update_noirqset()
352 gicv3_update_noirqset(s, GIC_INTERNAL, s->num_irq - GIC_INTERNAL); in gicv3_full_update_noirqset()
354 for (i = 0; i < s->num_cpu; i++) { in gicv3_full_update_noirqset()
355 gicv3_redist_update_noirqset(&s->cpu[i]); in gicv3_full_update_noirqset()
367 for (i = 0; i < s->num_cpu; i++) { in gicv3_full_update()
368 gicv3_cpuif_update(&s->cpu[i]); in gicv3_full_update()
376 * [0..N-1] : external interrupts in gicv3_set_irq()
378 * [N+32..N+63] : PPI (internal interrupts for CPU 1 in gicv3_set_irq()
383 if (irq < (s->num_irq - GIC_INTERNAL)) { in gicv3_set_irq()
387 /* per-cpu interrupt (PPI) */ in gicv3_set_irq()
390 irq -= (s->num_irq - GIC_INTERNAL); in gicv3_set_irq()
393 assert(cpu < s->num_cpu); in gicv3_set_irq()
398 gicv3_redist_set_irq(&s->cpu[cpu], irq, level); in gicv3_set_irq()
408 for (i = 0; i < s->num_cpu; i++) { in arm_gicv3_post_load()
409 gicv3_redist_update_lpi_only(&s->cpu[i]); in arm_gicv3_post_load()
421 .valid.min_access_size = 1,
423 .impl.min_access_size = 1,
430 .valid.min_access_size = 1,
432 .impl.min_access_size = 1,
444 agc->parent_realize(dev, &local_err); in arm_gic_realize()
461 agcc->post_load = arm_gicv3_post_load; in arm_gicv3_class_init()
462 device_class_set_parent_realize(dc, arm_gic_realize, &agc->parent_realize); in arm_gicv3_class_init()