diff -rNPc --exclude=CVS freebsd7_vanilla/src/sys/i386/i386/genassym.c freebsd7/src/sys/i386/i386/genassym.c *** freebsd7_vanilla/src/sys/i386/i386/genassym.c Thu Dec 29 14:23:48 2005 --- freebsd7/src/sys/i386/i386/genassym.c Wed Nov 22 15:13:07 2006 *************** *** 81,86 **** --- 81,87 ---- ASSYM(P_SFLAG, offsetof(struct proc, p_sflag)); ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); + ASSYM(TD_ID, offsetof(struct thread, td_id)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_MD, offsetof(struct thread, td_md)); diff -rNPc --exclude=CVS freebsd7_vanilla/src/sys/i386/i386/intr_machdep.c freebsd7/src/sys/i386/i386/intr_machdep.c *** freebsd7_vanilla/src/sys/i386/i386/intr_machdep.c Wed Jul 12 23:22:43 2006 --- freebsd7/src/sys/i386/i386/intr_machdep.c Wed Nov 22 15:13:07 2006 *************** *** 172,179 **** --- 172,181 ---- struct intr_event *ie; struct intr_handler *ih; int error, vector, thread; + u_int16_t id; td = curthread; + id = curthread->td_id; /* * We count software interrupts when we process them. The *************** *** 242,247 **** --- 244,251 ---- isrc->is_pic->pic_disable_source(isrc, PIC_EOI); else isrc->is_pic->pic_eoi_source(isrc); + if (curthread->td_id) + TSTMP(0,0,83,id); critical_exit(); /* Schedule the ithread if needed. */ diff -rNPc --exclude=CVS freebsd7_vanilla/src/sys/i386/i386/local_apic.c freebsd7/src/sys/i386/i386/local_apic.c *** freebsd7_vanilla/src/sys/i386/i386/local_apic.c Wed Jul 12 23:22:43 2006 --- freebsd7/src/sys/i386/i386/local_apic.c Wed Nov 22 15:13:07 2006 *************** *** 41,50 **** --- 41,52 ---- #include #include #include + #include #include #include #include #include + #include #include #include *************** *** 596,606 **** --- 598,625 ---- lapic->eoi = 0; } + struct intr_thread { + struct intr_event *it_event; + struct thread *it_thread; /* Kernel thread. */ + int it_flags; /* (j) IT_* flags. */ + int it_need; /* Needs service. */ + }; + + extern u_int16_t td_cnt; + extern int td_src; + void lapic_handle_intr(int vector, struct trapframe frame) { struct intsrc *isrc; + int vec = apic_idt_to_irq(vector); + isrc = intr_lookup_source(apic_idt_to_irq(vector)); + /* does it come from the source we want to track down? */ + // XXX - instead of doing it in the asm code, do it here for + // XXX - code simplicity + if (td_src != 0 && vec == td_src) + isrc->is_event->ie_thread->it_thread->td_id = td_cnt++; if (vector == -1) panic("Couldn't get vector from ISR!"); isrc = intr_lookup_source(apic_idt_to_irq(vector)); diff -rNPc --exclude=CVS freebsd7_vanilla/src/sys/i386/include/asmacros.h freebsd7/src/sys/i386/include/asmacros.h *** freebsd7_vanilla/src/sys/i386/include/asmacros.h Mon Dec 5 22:44:47 2005 --- freebsd7/src/sys/i386/include/asmacros.h Wed Nov 22 15:13:07 2006 *************** *** 174,177 **** --- 174,229 ---- #endif /* LOCORE */ + // par != eax + #define ASMTSTMP(class, unit, event, par) \ + .type _TSTMP,@function ; \ + xorl %eax,%eax ; \ + pushl %eax ; \ + movl par,%eax ; \ + andl $0xFFFF,%eax ; \ + movl $event,%ecx ; \ + andl $0xFF,%ecx ; \ + shrl $16,%ecx ; \ + orl %ecx,%eax ; \ + movl $unit,%ecx ; \ + andl $0xF,%ecx ; \ + shrl $24,%ecx ; \ + orl %ecx,%eax ; \ + movl $class,%ecx ; \ + andl $0xF,%ecx ; \ + shrl $28,%ecx ; \ + orl %ecx,%eax ; \ + pushl %eax ; \ + call _TSTMP ; \ + addl $8,%esp + + // vec != eax + #define INITTSTMP(val1, val2, val3, vec) \ + .type td_src,@object ; \ + .type td_cnt,@object ; \ + movl $td_src,%eax ; \ + movl (%eax),%eax ; \ + cmpl $0x00,%eax ; \ + je 1f ; \ + cmpl vec,%eax ; \ + jne 1f ; \ + movl PCPU(CURTHREAD),%ecx ; \ + movl $td_cnt,%eax ; \ + movl (%eax),%eax ; \ + movl %eax,TD_ID(%ecx) ; \ + movl %eax,%ecx ; \ + movl $td_cnt,%eax ; \ + movl %ecx,(%eax) ; \ + incl (%eax) ; \ + ASMTSTMP(val1, val2, val3, %ecx) ; \ + 1: + + #define GENTSTMP(val1, val2, val3) \ + movl PCPU(CURTHREAD),%ecx ; \ + movl TD_ID(%ecx),%ecx ; \ + cmpl $0x00,%ecx ; \ + je 1f ; \ + ASMTSTMP(val1, val2, val3, %ecx) ; \ + 1: + #endif /* !_MACHINE_ASMACROS_H_ */ diff -rNPc --exclude=CVS freebsd7_vanilla/src/sys/i386/isa/atpic.c freebsd7/src/sys/i386/isa/atpic.c *** freebsd7_vanilla/src/sys/i386/isa/atpic.c Tue Feb 28 23:24:55 2006 --- freebsd7/src/sys/i386/isa/atpic.c Wed Nov 22 15:13:26 2006 *************** *** 45,50 **** --- 45,51 ---- #include #include #include + #include #include #include *************** *** 552,557 **** --- 553,568 ---- } SYSINIT(atpic_init, SI_SUB_INTR, SI_ORDER_SECOND + 1, atpic_init, NULL) + struct intr_thread { + struct intr_event *it_event; + struct thread *it_thread; /* Kernel thread. */ + int it_flags; /* (j) IT_* flags. */ + int it_need; /* Needs service. */ + }; + + extern u_int16_t td_cnt; + extern int td_src; + void atpic_handle_intr(u_int vector, struct trapframe frame) { *************** *** 579,584 **** --- 590,600 ---- mtx_unlock_spin(&icu_lock); if ((isr & IRQ_MASK(7)) == 0) return; + } + if (td_src != 0 && vector == td_src) { + curthread->td_id = td_cnt++; + isrc->is_event->ie_thread->it_thread->td_id = td_cnt++; + TSTMP(0,0,7,curthread->td_id); } intr_execute_handlers(isrc, &frame); } diff -rNPc --exclude=CVS freebsd7_vanilla/src/sys/kern/kern_intr.c freebsd7/src/sys/kern/kern_intr.c *** freebsd7_vanilla/src/sys/kern/kern_intr.c Wed Jul 12 23:22:44 2006 --- freebsd7/src/sys/kern/kern_intr.c Wed Nov 22 15:13:07 2006 *************** *** 617,622 **** --- 617,623 ---- ithread_execute_handlers(struct proc *p, struct intr_event *ie) { struct intr_handler *ih, *ihn; + u_int16_t id = curthread->td_id; /* Interrupt handlers should not sleep. */ if (!(ie->ie_flags & IE_SOFT)) *************** *** 693,698 **** --- 694,701 ---- */ if (ie->ie_enable != NULL) ie->ie_enable(ie->ie_source); + if (curthread->td_id) + TSTMP(0,0,84,id); } /*