2 * from: vector.s, 386BSD 0.1 unknown origin
3 * $FreeBSD: src/sys/i386/isa/apic_vector.s,v 1.47.2.5 2001/09/01 22:33:38 tegge Exp $
6 #include <machine/asmacros.h>
7 #include <machine/lock.h>
8 #include <machine/psl.h>
9 #include <machine/trap.h>
13 /* convert an absolute IRQ# into bitmask */
14 #define IRQ_LBIT(irq_num) (1 << ((irq_num) & 0x1f))
16 /* convert an absolute IRQ# into ipending index */
17 #define IRQ_LIDX(irq_num) ((irq_num) >> 5)
20 * Push an interrupt frame in a format acceptable to doreti, reload
21 * the segment registers for the kernel.
23 #define MSI_PUSH_FRAME \
24 pushl $0 ; /* dummy error code */ \
25 pushl $0 ; /* dummy trap type */ \
26 pushl $0 ; /* dummy xflags type */ \
28 pushl %ds ; /* save data and extra segments ... */ \
41 * Interrupt call handlers run in the following sequence:
43 * - Push the trap frame required by doreti
44 * - Mask the interrupt and reenable its source
45 * - If we cannot take the interrupt set its ipending bit and
47 * - If we can take the interrupt clear its ipending bit,
48 * call the handler, then unmask and doreti.
50 * YYY can cache gd base opitner instead of using hidden %fs prefixes.
53 #define MSI_HANDLER(irq_num) \
56 IDTVEC(msi_intr##irq_num) ; \
58 FAKE_MCOUNT(15*4(%esp)) ; \
60 movl $0,LA_EOI(%eax) ; \
61 movl PCPU(curthread),%ebx ; \
62 movl $0,%eax ; /* CURRENT CPL IN FRAME (REMOVED) */ \
64 testl $-1,TD_NEST_COUNT(%ebx) ; \
66 testl $-1,TD_CRITCOUNT(%ebx) ; \
69 /* in critical section, make interrupt pending */ \
70 /* set the pending bit and return, leave interrupt masked */ \
71 movl $IRQ_LIDX(irq_num),%edx ; \
72 orl $IRQ_LBIT(irq_num),PCPU_E4(ipending,%edx) ; \
73 orl $RQF_INTPEND,PCPU(reqflags) ; \
76 /* clear pending bit, run handler */ \
77 movl $IRQ_LIDX(irq_num),%edx ; \
78 andl $~IRQ_LBIT(irq_num),PCPU_E4(ipending,%edx) ; \
80 pushl %esp ; /* pass frame by reference */ \
81 incl TD_CRITCOUNT(%ebx) ; \
83 call ithread_fast_handler ; /* returns 0 to unmask */ \
84 decl TD_CRITCOUNT(%ebx) ; \