| plan 9 kernel history: overview | file list | diff list |
1998/0910/pc/trap.c (diff list | history)
| 1998/0825/sys/src/9/pc/trap.c:12,47 – 1998/0910/sys/src/9/pc/trap.c:12,69 (short | long | prev | next) | ||
|
XXX big interrupt change
rsc Fri Mar 4 12:44:25 2005 | ||
| 1997/0327 | static void debugbpt(Ureg*, void*); static void fault386(Ureg*, void*); | |
| 1991/0731 | ||
| 1997/0327 |
| |
| 1998/0910 | static Lock vctllock; static Vctl *vctl[256]; | |
| 1991/0709 | ||
| 1991/0703 | void | |
| 1997/0327 |
| |
| 1998/0910 | intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf) | |
| 1991/0613 | { | |
| 1998/0806 |
| |
| 1997/0327 |
| |
| 1998/0910 | int vno; Vctl *v; | |
| 1991/0614 | ||
| 1997/0327 |
| |
| 1998/0806 |
| |
| 1998/0910 | v = xalloc(sizeof(Vctl)); v->isintr = 1; v->irq = irq; v->tbdf = tbdf; v->f = f; v->a = a; | |
| 1998/0806 |
| |
| 1997/0327 |
| |
| 1998/0806 |
| |
| 1998/0910 | ilock(&vctllock); vno = arch->intrenable(v); //print("irq%d, vno %d\n", irq, vno); if(vno == -1){ iunlock(&vctllock); print("intrenable: couldn't enable irq %d, tbdf 0x%uX\n", irq, tbdf); xfree(v); | |
| 1998/0806 | return; | |
| 1991/0709 | } | |
| 1998/0910 | if(vctl[vno]){ if(vctl[vno]->isr != v->isr || vctl[vno]->eoi != v->eoi) panic("intrenable: irq handler botch: %luX %luX %luX %luX\n", vctl[vno]->isr, v->isr, vctl[vno]->eoi, v->eoi); v->next = vctl[vno]->next; } vctl[vno] = v; iunlock(&vctllock); } | |
| 1998/0806 | ||
| 1997/0327 |
| |
| 1998/0910 | void trapenable(int vno, void (*f)(Ureg*, void*), void* a) { Vctl *v; if(vno < 0 || vno >= VectorPIC) panic("trapenable: vno %d\n", vno); v = xalloc(sizeof(Vctl)); v->tbdf = BUSUNKNOWN; v->f = f; v->a = a; lock(&vctllock); if(vctl[vno]) v->next = vctl[vno]->next; vctl[vno] = v; unlock(&vctllock); | |
| 1991/0703 | } | |
| 1997/0405 | static void | |
| 1998/0825/sys/src/9/pc/trap.c:94,125 – 1998/0910/sys/src/9/pc/trap.c:116,160 | ||
| 1997/1101 | * Special traps. * Syscall() is called directly without going through trap(). */ | |
| 1997/0327 |
| |
| 1998/0910 | trapenable(VectorBPT, debugbpt, 0); trapenable(VectorPF, fault386, 0); | |
| 1997/0405 | nmienable(); | |
| 1991/0703 | } | |
| 1998/0320 |
| |
| 1994/0722 |
| |
| 1997/0327 |
| |
| 1994/0722 |
| |
| 1997/0327 |
| |
| 1994/0722 |
| |
| 1994/1029 |
| |
| 1997/0327 |
| |
| 1998/0910 | static char* excname[32] = { "divide error", "debug exception", "nonmaskable interrupt", "breakpoint", "overflow", "bounds check", "invalid opcode", "coprocessor not available", "double fault", "coprocessor segment overrun", "invalid TSS", "segment not present", "stack exception", "general protection violation", "page fault", "15 (reserved)", "coprocessor error", "alignment check", "machine check", "19 (reserved)", "20 (reserved)", "21 (reserved)", "22 (reserved)", "23 (reserved)", "24 (reserved)", "25 (reserved)", "26 (reserved)", "27 (reserved)", "28 (reserved)", "29 (reserved)", "30 (reserved)", "31 (reserved)", | |
| 1991/1113 | }; | |
| 1991/0614 | /* | |
| 1998/0825/sys/src/9/pc/trap.c:131,140 – 1998/0910/sys/src/9/pc/trap.c:166,174 | ||
| 1991/0710 | void | |
| 1997/0327 | trap(Ureg* ureg) | |
| 1991/0614 | { | |
| 1998/0115 |
| |
| 1998/0910 | int i, vno, user; | |
| 1991/1113 | char buf[ERRLEN]; | |
| 1997/0327 |
| |
| 1998/0910 | Vctl *ctl, *v; | |
| 1998/0115 | Mach *mach; | |
| 1991/0703 | ||
| 1997/1101 | user = 0; | |
| 1998/0825/sys/src/9/pc/trap.c:143,163 – 1998/0910/sys/src/9/pc/trap.c:177,198 | ||
| 1997/0327 | up->dbgreg = ureg; | |
| 1997/1101 | } | |
| 1991/1112 | ||
| 1997/0327 |
| |
| 1998/0910 | vno = ureg->trap; if(ctl = vctl[vno]){ | |
| 1997/1101 | if(ctl->isintr){ | |
| 1997/0327 | m->intr++; | |
| 1997/1101 |
| |
| 1998/0115 |
| |
| 1998/0910 | if(vno >= VectorPIC && vno != VectorSYSCALL) m->lastintr = ctl->irq; | |
| 1997/1101 | } | |
| 1991/1113 | ||
| 1997/0327 |
| |
| 1993/0224 | ||
| 1998/0910 | if(ctl->isr) ctl->isr(vno); for(v = ctl; v != nil; v = v->next){ if(v->f) v->f(ureg, v->a); } | |
| 1997/0327 | if(ctl->eoi) | |
| 1998/0910 | ctl->eoi(vno); | |
| 1998/0401 | ||
| 1998/0516 | /* * preemptive scheduling. to limit stack depth, | |
| 1998/0825/sys/src/9/pc/trap.c:165,171 – 1998/0910/sys/src/9/pc/trap.c:200,206 | ||
| 1998/0516 | * the current interrupt before being preempted a * second time. */ | |
| 1998/0401 |
| |
| 1998/0910 | if(ctl->isintr && ctl->irq != IrqTIMER && ctl->irq != IrqCLOCK) | |
| 1998/0512 | if(up && up->state == Running) if(anyhigher()) | |
| 1998/0516 | if(up->preempted == 0) | |
| 1998/0825/sys/src/9/pc/trap.c:177,188 – 1998/0910/sys/src/9/pc/trap.c:212,223 | ||
| 1998/0605 | return; | |
| 1998/0516 | } | |
| 1991/0731 | } | |
| 1997/0327 |
| |
| 1998/0910 | else if(vno <= nelem(excname) && user){ | |
| 1997/0327 | spllo(); | |
| 1998/0910 | sprint(buf, "sys: trap: %s", excname[vno]); | |
| 1997/0327 | postnote(up, 1, buf, NDebug); } | |
| 1998/0910 | else if(vno >= VectorPIC && vno != VectorSYSCALL){ | |
| 1997/0327 | /* * An unknown interrupt. * Check for a default IRQ7. This can happen when | |
| 1998/0825/sys/src/9/pc/trap.c:192,198 – 1998/0910/sys/src/9/pc/trap.c:227,233 | ||
| 1997/0327 | * In fact, just ignore all such interrupts. */ | |
| 1998/0115 | print("cpu%d: spurious interrupt %d, last %d", | |
| 1998/0910 | m->machno, vno, m->lastintr); | |
| 1998/0115 | for(i = 0; i < 32; i++){ if(!(active.machs & (1<<i))) continue; | |
| 1998/0825/sys/src/9/pc/trap.c:206,212 – 1998/0910/sys/src/9/pc/trap.c:241,247 | ||
| 1997/0327 | return; } else{ | |
| 1998/0320 |
| |
| 1998/0910 | if(vno == VectorNMI){ | |
| 1998/0401 | nmienable(); if(m->machno != 0){ | |
| 1998/0825 | print("cpu%d: PC %8.8luX\n", m->machno, ureg->pc); | |
| 1998/0825/sys/src/9/pc/trap.c:214,222 – 1998/0910/sys/src/9/pc/trap.c:249,257 | ||
| 1998/0401 | } | |
| 1997/0405 | } | |
| 1997/0327 | dumpregs(ureg); | |
| 1998/0910 | if(vno < nelem(excname)) panic("%s", excname[vno]); panic("unknown trap/intr: %d\n", vno); | |
| 1997/0327 | } | |
| 1991/0801 | ||
| 1997/1101 | if(user && (up->procctl || up->nnote)){ | |
| 1998/0825/sys/src/9/pc/trap.c:335,348 – 1998/0910/sys/src/9/pc/trap.c:370,382 | ||
| 1997/0327 | spllo(); n = fault(addr, read); if(n < 0){ | |
| 1998/0910 | if(!user){ dumpregs(ureg); panic("fault: 0x%lux\n", addr); | |
| 1997/0327 | } | |
| 1998/0731 |
| |
| 1998/0910 | sprint(buf, "sys: trap: fault %s addr=0x%lux", read? "read" : "write", addr); postnote(up, 1, buf, NDebug); | |
| 1997/0327 | } up->insyscall = insyscall; } | |