1 /* $NetBSD: i82093reg.h,v 1.4 2008/04/27 17:47:11 skd 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 IOAPIC_SC_REG(%rdi),%r15 ;\ 48 movl %esi, (%r15) ;\ 49 movq IOAPIC_SC_DATA(%rdi),%r15 ;\ 50 movl (%r15),%esi ;\ 51 orl $IOAPIC_REDLO_MASK,%esi ;\ 52 movl %esi,(%r15) ;\ 53 ioapic_asm_unlock(num) 54 55 #define ioapic_unmask(num) \ 56 cmpq $IREENT_MAGIC,(TF_ERR+8)(%rsp) ;\ 57 jne 79f ;\ 58 movq IS_PIC(%r14),%rdi ;\ 59 ioapic_asm_lock(num) ;\ 60 movl IS_PIN(%r14),%esi ;\ 61 leaq 0x10(%rsi,%rsi,1),%rsi ;\ 62 movq IOAPIC_SC_REG(%rdi),%r15 ;\ 63 movq IOAPIC_SC_DATA(%rdi),%r13 ;\ 64 movl %esi, (%r15) ;\ 65 movl (%r13),%r12d ;\ 66 andl $~IOAPIC_REDLO_MASK,%r12d ;\ 67 movl %esi,(%r15) ;\ 68 movl %r12d,(%r13) ;\ 69 ioapic_asm_unlock(num) ;\ 70 79: 71 72 #endif 73