summaryrefslogtreecommitdiff
path: root/sys/src/9/xen/xensystem.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-11-29 17:43:22 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2020-11-29 17:43:22 +0100
commit1d93a5628adc0f08463fe4272dc88fb0f61e631d (patch)
treeb96cb74f50ab891af2fc72ebaf0d8ac6309ae385 /sys/src/9/xen/xensystem.c
parent32a5ff9658cfa2d0d15cecf3b2a27be6b0742227 (diff)
pc, pc64, xen: rewrite interrupt handling code
This implements proper intrdisable() support for all interrupt controllers. For enable, (*arch->intrassign)(Vctl*) fills in the Vctl.enable and Vctl.disable pointers with the appropriate routines and returns the assigned vector number. Once the Vctl struct has been linked to its vector chain, Vctl.enable(Vctl*, shared) gets called with a flag if the vector has been already enabled (shared). This order is important here as enabling the interrupt on the controller before we have linked the chain can cause spurious interrupts, expecially on mp system where the interrupt can target a different cpu than the caller of intrenable(). The intrdisable() case is the other way around. We first disable the interrupt on the controller and after that unlink the Vctl from the chain. On a multiprocessor, the xfree() of the Vctl struct is delayed to avoid freeing it while it is still in use by another cpu. The xen port now also uses pc/irq.c which has been made generic enougth to handle xen's irq scheme. Also, archgeneric is now a separate file to avoid pulling in dependencies from the 8259 interrupt controller code.
Diffstat (limited to 'sys/src/9/xen/xensystem.c')
-rw-r--r--sys/src/9/xen/xensystem.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/sys/src/9/xen/xensystem.c b/sys/src/9/xen/xensystem.c
index bff81afb3..82196d9ad 100644
--- a/sys/src/9/xen/xensystem.c
+++ b/sys/src/9/xen/xensystem.c
@@ -389,6 +389,26 @@ xenupcall(Ureg *ureg)
}
+static int
+xenirqenable(Vctl *v, int shared)
+{
+ if(!shared){
+ uint port = v->vno-100;
+ HYPERVISOR_shared_info->evtchn_mask[port/32] &= ~(1<<(port%32));
+ }
+ return 0;
+}
+
+static int
+xenirqdisable(Vctl *v, int shared)
+{
+ if(!shared){
+ uint port = v->vno-100;
+ HYPERVISOR_shared_info->evtchn_mask[port/32] |= (1<<(port%32));
+ }
+ return 0;
+}
+
/*
* tbdf field is abused to distinguish virqs from channels:
*
@@ -396,37 +416,30 @@ xenupcall(Ureg *ureg)
* tbdf=0 -> irq is a channel number
*/
int
-xenintrenable(Vctl *v)
+xenintrassign(Vctl *v)
{
evtchn_op_t op;
uint port;
- /* XXX locking? */
if (v->tbdf != BUSUNKNOWN) {
op.cmd = EVTCHNOP_bind_virq;
op.u.bind_virq.virq = v->irq;
op.u.bind_virq.vcpu = m->machno;
- if(HYPERVISOR_event_channel_op(&op) != 0)
- panic("xenintrenable: bind %d failed", v->irq);
+ if(HYPERVISOR_event_channel_op(&op) != 0){
+ print("xenintrenable: bind %d failed", v->irq);
+ return -1;
+ }
port = op.u.bind_virq.port;
} else
port = v->irq;
if (port > 155)
return -1;
- HYPERVISOR_shared_info->evtchn_mask[port/32] &= ~(1<<(port%32));
- if(0)print("xenintrenable %s: irq %d port %d mask[%d] = %#lux\n", v->name, v->irq, port, port/32, HYPERVISOR_shared_info->evtchn_mask[port/32]);
+ v->enable = xenirqenable;
+ v->disable = xenirqdisable;
return 100+port;
}
int
-xenintrdisable(int irq)
-{
- USED(irq);
- panic("xenintrdisable notyet\n");
- return 0;
-}
-
-int
xenintrvecno(int irq)
{
return irq;