Lines Matching full:aplic
51 MALLOC_DEFINE(M_APLIC, "RISC-V VMM APLIC", "RISC-V AIA APLIC");
103 struct aplic { struct
113 aplic_handle_sourcecfg(struct aplic *aplic, int i, bool write, uint64_t *val) in aplic_handle_sourcecfg() argument
117 if (i <= 0 || i > aplic->nirqs) in aplic_handle_sourcecfg()
120 mtx_lock_spin(&aplic->mtx); in aplic_handle_sourcecfg()
121 irq = &aplic->irqs[i]; in aplic_handle_sourcecfg()
126 mtx_unlock_spin(&aplic->mtx); in aplic_handle_sourcecfg()
132 aplic_set_enabled(struct aplic *aplic, bool write, uint64_t *val, bool enabled) in aplic_set_enabled() argument
143 if (i <= 0 || i > aplic->nirqs) in aplic_set_enabled()
146 irq = &aplic->irqs[i]; in aplic_set_enabled()
148 mtx_lock_spin(&aplic->mtx); in aplic_set_enabled()
153 mtx_unlock_spin(&aplic->mtx); in aplic_set_enabled()
159 aplic_handle_target(struct aplic *aplic, int i, bool write, uint64_t *val) in aplic_handle_target() argument
163 mtx_lock_spin(&aplic->mtx); in aplic_handle_target()
164 irq = &aplic->irqs[i]; in aplic_handle_target()
170 mtx_unlock_spin(&aplic->mtx); in aplic_handle_target()
176 aplic_handle_idc_claimi(struct hyp *hyp, struct aplic *aplic, int cpu_id, in aplic_handle_idc_claimi() argument
189 mtx_lock_spin(&aplic->mtx); in aplic_handle_idc_claimi()
190 for (i = 0; i < aplic->nirqs; i++) { in aplic_handle_idc_claimi()
191 irq = &aplic->irqs[i]; in aplic_handle_idc_claimi()
201 mtx_unlock_spin(&aplic->mtx); in aplic_handle_idc_claimi()
210 aplic_handle_idc(struct hyp *hyp, struct aplic *aplic, int cpu, int reg, in aplic_handle_idc() argument
223 error = aplic_handle_idc_claimi(hyp, aplic, cpu, write, val); in aplic_handle_idc()
233 aplic_mmio_access(struct hyp *hyp, struct aplic *aplic, uint64_t reg, in aplic_mmio_access() argument
242 (reg <= APLIC_SOURCECFG(aplic->nirqs))) { in aplic_mmio_access()
244 error = aplic_handle_sourcecfg(aplic, i, write, val); in aplic_mmio_access()
248 if ((reg >= APLIC_TARGET(1)) && (reg <= APLIC_TARGET(aplic->nirqs))) { in aplic_mmio_access()
250 error = aplic_handle_target(aplic, i, write, val); in aplic_mmio_access()
257 error = aplic_handle_idc(hyp, aplic, cpu, r, write, val); in aplic_mmio_access()
263 aplic->domaincfg = *val & DOMAINCFG_IE; in aplic_mmio_access()
267 error = aplic_set_enabled(aplic, write, val, true); in aplic_mmio_access()
270 error = aplic_set_enabled(aplic, write, val, false); in aplic_mmio_access()
287 struct aplic *aplic; in mem_read() local
294 aplic = hyp->aplic; in mem_read()
298 if (fault_ipa < aplic->mem_start || fault_ipa + size > aplic->mem_end) in mem_read()
301 reg = fault_ipa - aplic->mem_start; in mem_read()
303 error = aplic_mmio_access(hyp, aplic, reg, false, &val); in mem_read()
316 struct aplic *aplic; in mem_write() local
323 aplic = hyp->aplic; in mem_write()
328 if (fault_ipa < aplic->mem_start || fault_ipa + size > aplic->mem_end) in mem_write()
331 reg = fault_ipa - aplic->mem_start; in mem_write()
335 error = aplic_mmio_access(hyp, aplic, reg, true, &val); in mem_write()
343 struct aplic *aplic; in aplic_vminit() local
345 hyp->aplic = malloc(sizeof(*hyp->aplic), M_APLIC, in aplic_vminit()
347 aplic = hyp->aplic; in aplic_vminit()
349 mtx_init(&aplic->mtx, "APLIC lock", NULL, MTX_SPIN); in aplic_vminit()
355 struct aplic *aplic; in aplic_vmcleanup() local
357 aplic = hyp->aplic; in aplic_vmcleanup()
359 mtx_destroy(&aplic->mtx); in aplic_vmcleanup()
361 free(hyp->aplic, M_APLIC); in aplic_vmcleanup()
367 struct aplic *aplic; in aplic_attach_to_vm() local
377 aplic = hyp->aplic; in aplic_attach_to_vm()
378 aplic->nirqs = APLIC_NIRQS; in aplic_attach_to_vm()
379 aplic->mem_start = descr->mem_start; in aplic_attach_to_vm()
380 aplic->mem_end = descr->mem_start + descr->mem_size; in aplic_attach_to_vm()
381 aplic->irqs = malloc(sizeof(struct aplic_irq) * aplic->nirqs, M_APLIC, in aplic_attach_to_vm()
392 struct aplic *aplic; in aplic_detach_from_vm() local
394 aplic = hyp->aplic; in aplic_detach_from_vm()
400 free(aplic->irqs, M_APLIC); in aplic_detach_from_vm()
408 struct aplic *aplic; in aplic_check_pending() local
413 aplic = hyp->aplic; in aplic_check_pending()
415 mtx_lock_spin(&aplic->mtx); in aplic_check_pending()
416 if ((aplic->domaincfg & DOMAINCFG_IE) == 0) { in aplic_check_pending()
417 mtx_unlock_spin(&aplic->mtx); in aplic_check_pending()
421 for (i = 0; i < aplic->nirqs; i++) { in aplic_check_pending()
422 irq = &aplic->irqs[i]; in aplic_check_pending()
427 mtx_unlock_spin(&aplic->mtx); in aplic_check_pending()
432 mtx_unlock_spin(&aplic->mtx); in aplic_check_pending()
441 struct aplic *aplic; in aplic_inject_irq() local
445 aplic = hyp->aplic; in aplic_inject_irq()
449 mtx_lock_spin(&aplic->mtx); in aplic_inject_irq()
450 if ((aplic->domaincfg & DOMAINCFG_IE) == 0) { in aplic_inject_irq()
451 mtx_unlock_spin(&aplic->mtx); in aplic_inject_irq()
455 irq = &aplic->irqs[irqid]; in aplic_inject_irq()
457 mtx_unlock_spin(&aplic->mtx); in aplic_inject_irq()
479 mtx_unlock_spin(&aplic->mtx); in aplic_inject_irq()