1 /* $NetBSD: i82093reg.h,v 1.5 2008/07/03 14:02:25 drochner 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 movb $1,%bl ; \ 18 76: \ 19 xchgb %bl,PIC_LOCK(%rdi) ; \ 20 testb %bl,%bl ; \ 21 jz 78f ; \ 22 77: \ 23 pause ; \ 24 nop ; \ 25 nop ; \ 26 cmpb $0,PIC_LOCK(%rdi) ; \ 27 jne 77b ; \ 28 jmp 76b ; \ 29 78: 30 31 #define ioapic_asm_unlock(num) \ 32 movb $0,PIC_LOCK(%rdi) 33 34 #else 35 36 #define ioapic_asm_lock(num) 37 #define ioapic_asm_unlock(num) 38 39 #endif /* MULTIPROCESSOR */ 40 41 42 #define ioapic_mask(num) \ 43 movq IS_PIC(%r14),%rdi ;\ 44 ioapic_asm_lock(num) ;\ 45 movl IS_PIN(%r14),%esi ;\ 46 leaq 0x10(%rsi,%rsi,1),%rsi ;\ 47 movq PIC_IOAPIC(%rdi),%rdi ;\ 48 movq IOAPIC_SC_REG(%rdi),%r15 ;\ 49 movl %esi, (%r15) ;\ 50 movq IOAPIC_SC_DATA(%rdi),%r15 ;\ 51 movl (%r15),%esi ;\ 52 orl $IOAPIC_REDLO_MASK,%esi ;\ 53 movl %esi,(%r15) ;\ 54 movq IS_PIC(%r14),%rdi ;\ 55 ioapic_asm_unlock(num) 56 57 #define ioapic_unmask(num) \ 58 cmpq $IREENT_MAGIC,(TF_ERR+8)(%rsp) ;\ 59 jne 79f ;\ 60 movq IS_PIC(%r14),%rdi ;\ 61 ioapic_asm_lock(num) ;\ 62 movl IS_PIN(%r14),%esi ;\ 63 leaq 0x10(%rsi,%rsi,1),%rsi ;\ 64 movq PIC_IOAPIC(%rdi),%rdi ;\ 65 movq IOAPIC_SC_REG(%rdi),%r15 ;\ 66 movq IOAPIC_SC_DATA(%rdi),%r13 ;\ 67 movl %esi, (%r15) ;\ 68 movl (%r13),%r12d ;\ 69 andl $~IOAPIC_REDLO_MASK,%r12d ;\ 70 movl %esi,(%r15) ;\ 71 movl %r12d,(%r13) ;\ 72 movq IS_PIC(%r14),%rdi ;\ 73 ioapic_asm_unlock(num) ;\ 74 79: 75 76 #endif 77