Example #1
0
int acpiintrenable(Vctl *v)
{
    int vno;
    ilock(&vctllock);
    vno = bus_irq_setup(v);
    if(vno == -1) {
        iunlock(&vctllock);
        print("intrenable: couldn't enable irq %d, tbdf %#x for %s\n",
              v->Vkey.irq, v->Vkey.tbdf, v->name);
        free(v);
        return -1;
    }
    if(vctl[vno]) {
        if(vctl[v->vno]->isr != v->isr || vctl[v->vno]->eoi != v->eoi)
            panic("intrenable: handler: %s %s %#p %#p %#p %#p",
                  vctl[v->vno]->name, v->name,
                  vctl[v->vno]->isr, v->isr, vctl[v->vno]->eoi, v->eoi);
    }
    v->vno = vno;
    v->next = vctl[vno];
    vctl[vno] = v;
    iunlock(&vctllock);

    if(v->mask)
        v->mask(&v->Vkey, 0);

    return -1;
}
Example #2
0
void*
intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
{
	int vno;
	Vctl *v;

	if(f == nil){
		print("intrenable: nil handler for %d, tbdf %#x for %s\n",
			irq, tbdf, name);
		return nil;
	}

	v = malloc(sizeof(Vctl));
	v->isintr = 1;
	v->Vkey.irq = irq;
	v->Vkey.tbdf = tbdf;
	v->f = f;
	v->a = a;
	strncpy(v->name, name, KNAMELEN-1);
	v->name[KNAMELEN-1] = 0;

	ilock(&vctllock);
	vno = bus_irq_setup(v);
	if(vno == -1){
		iunlock(&vctllock);
		print("intrenable: couldn't enable irq %d, tbdf %#x for %s\n",
			irq, tbdf, v->name);
		free(v);
		return nil;
	}
	if(vctl[vno]){
		if(vctl[v->vno]->isr != v->isr || vctl[v->vno]->eoi != v->eoi)
			panic("intrenable: handler: %s %s %#p %#p %#p %#p",
				vctl[v->vno]->name, v->name,
				vctl[v->vno]->isr, v->isr, vctl[v->vno]->eoi, v->eoi);
	}
	v->vno = vno;
	v->next = vctl[vno];
	vctl[vno] = v;
	iunlock(&vctllock);

	if(v->mask)
		v->mask(&v->Vkey, 0);

	/*
	 * Return the assigned vector so intrdisable can find
	 * the handler; the IRQ is useless in the wonderful world
	 * of the IOAPIC.
	 */
	return v;
}