etc/protocols - sync with NetBSD-8
[minix.git] / sys / arch / i386 / include / i82093reg.h
blob0af7acb1abddd407115431417a829135d017cdcb
1 /* $NetBSD: i82093reg.h,v 1.8 2008/07/03 14:02:25 drochner Exp $ */
3 #include <x86/i82093reg.h>
5 #ifdef _KERNEL
7 #if defined(_KERNEL_OPT)
8 #include "opt_multiprocessor.h"
9 #endif
11 #define ioapic_asm_ack(num) \
12 movl $0,_C_LABEL(local_apic)+LAPIC_EOI
14 #ifdef MULTIPROCESSOR
16 #define ioapic_asm_lock(num) \
17 movl $1,%esi ;\
18 77: \
19 xchgl %esi,PIC_LOCK(%edi) ;\
20 testl %esi,%esi ;\
21 jne 77b
23 #define ioapic_asm_unlock(num) \
24 movl $0,PIC_LOCK(%edi)
26 #else
28 #define ioapic_asm_lock(num)
29 #define ioapic_asm_unlock(num)
31 #endif /* MULTIPROCESSOR */
33 #define ioapic_mask(num) \
34 movl IS_PIC(%ebp),%edi ;\
35 ioapic_asm_lock(num) ;\
36 movl IS_PIN(%ebp),%esi ;\
37 leal 0x10(%esi,%esi,1),%esi ;\
38 movl PIC_IOAPIC(%edi),%edi ;\
39 movl IOAPIC_SC_REG(%edi),%ebx ;\
40 movl %esi, (%ebx) ;\
41 movl IOAPIC_SC_DATA(%edi),%ebx ;\
42 movl (%ebx),%esi ;\
43 orl $IOAPIC_REDLO_MASK,%esi ;\
44 movl %esi,(%ebx) ;\
45 movl IS_PIC(%ebp),%edi ;\
46 ioapic_asm_unlock(num)
49 * Since this is called just before the interrupt stub exits, AND
50 * because the apic ACK doesn't use any registers, all registers
51 * can be used here.
52 * XXX this is not obvious
54 #define ioapic_unmask(num) \
55 movl (%esp),%eax ;\
56 cmpl $IREENT_MAGIC,(TF_ERR+4)(%eax) ;\
57 jne 79f ;\
58 movl IS_PIC(%ebp),%edi ;\
59 ioapic_asm_lock(num) ;\
60 movl IS_PIN(%ebp),%esi ;\
61 leal 0x10(%esi,%esi,1),%esi ;\
62 movl PIC_IOAPIC(%edi),%edi ;\
63 movl IOAPIC_SC_REG(%edi),%ebx ;\
64 movl IOAPIC_SC_DATA(%edi),%eax ;\
65 movl %esi, (%ebx) ;\
66 movl (%eax),%edx ;\
67 andl $~IOAPIC_REDLO_MASK,%edx ;\
68 movl %esi, (%ebx) ;\
69 movl %edx,(%eax) ;\
70 movl IS_PIC(%ebp),%edi ;\
71 ioapic_asm_unlock(num) ;\
72 79:
74 #endif