i82093reg.h revision 1.2 1 /* $NetBSD: i82093reg.h,v 1.2 2003/05/04 23:46:41 fvdl Exp $ */
2
3 #include <x86/i82093reg.h>
4
5 #ifdef _KERNEL
6
7 #if defined(_KERNEL_OPT)
8 #include "opt_multiprocessor.h"
9 #endif
10
11 #define ioapic_asm_ack(num) \
12 movl $0,(_C_LABEL(local_apic)+LAPIC_EOI)(%rip)
13
14 #ifdef MULTIPROCESSOR
15
16 #define ioapic_asm_lock(num) \
17 movl $1,%esi ;\
18 77: \
19 xchgl %esi,PIC_LOCK(%rdi) ;\
20 testl %esi,%esi ;\
21 jne 77b
22
23 #define ioapic_asm_unlock(num) \
24 movl $0,PIC_LOCK(%rdi)
25
26 #else
27
28 #define ioapic_asm_lock(num)
29 #define ioapic_asm_unlock(num)
30
31 #endif /* MULTIPROCESSOR */
32
33
34 #define ioapic_mask(num) \
35 movq IS_PIC(%r14),%rdi ;\
36 ioapic_asm_lock(num) ;\
37 movl IS_PIN(%r14),%esi ;\
38 leaq 0x10(%rsi,%rsi,1),%rsi ;\
39 movq IOAPIC_SC_REG(%rdi),%r15 ;\
40 movl %esi, (%r15) ;\
41 movq IOAPIC_SC_DATA(%rdi),%r15 ;\
42 movl (%r15),%esi ;\
43 orl $IOAPIC_REDLO_MASK,%esi ;\
44 movl %esi,(%r15) ;\
45 ioapic_asm_unlock(num)
46
47 #define ioapic_unmask(num) \
48 cmpq $IREENT_MAGIC,(TF_ERR+8)(%rsp) ;\
49 jne 79f ;\
50 movq IS_PIC(%r14),%rdi ;\
51 ioapic_asm_lock(num) ;\
52 movl IS_PIN(%r14),%esi ;\
53 leaq 0x10(%rsi,%rsi,1),%rsi ;\
54 movq IOAPIC_SC_REG(%rdi),%r15 ;\
55 movl %esi, (%r15) ;\
56 movq IOAPIC_SC_DATA(%rdi),%r15 ;\
57 movl (%r15),%esi ;\
58 andl $~IOAPIC_REDLO_MASK,%esi ;\
59 movl %esi,(%r15) ;\
60 ioapic_asm_unlock(num) ;\
61 79:
62
63 #endif
64