Home | History | Annotate | Line # | Download | only in include
i82093reg.h revision 1.8.64.1
      1 /*	 $NetBSD: i82093reg.h,v 1.8.64.1 2017/01/07 08:56:18 pgoyette 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	_C_LABEL(local_apic_va),%eax	; \
     13 	movl	$0,LAPIC_EOI(%eax)
     14 
     15 #ifdef MULTIPROCESSOR
     16 
     17 #define ioapic_asm_lock(num) \
     18 	movl	$1,%esi						;\
     19 77:								\
     20 	xchgl	%esi,PIC_LOCK(%edi)				;\
     21 	testl	%esi,%esi					;\
     22 	jne	77b
     23 
     24 #define ioapic_asm_unlock(num) \
     25 	movl	$0,PIC_LOCK(%edi)
     26 
     27 #else
     28 
     29 #define ioapic_asm_lock(num)
     30 #define ioapic_asm_unlock(num)
     31 
     32 #endif	/* MULTIPROCESSOR */
     33 
     34 #define ioapic_mask(num) \
     35 	movl	IS_PIC(%ebp),%edi				;\
     36 	ioapic_asm_lock(num)					;\
     37 	movl	IS_PIN(%ebp),%esi				;\
     38 	leal	0x10(%esi,%esi,1),%esi				;\
     39 	movl	PIC_IOAPIC(%edi),%edi				;\
     40 	movl	IOAPIC_SC_REG(%edi),%ebx			;\
     41 	movl	%esi, (%ebx)					;\
     42 	movl	IOAPIC_SC_DATA(%edi),%ebx			;\
     43 	movl	(%ebx),%esi					;\
     44 	orl	$IOAPIC_REDLO_MASK,%esi				;\
     45 	movl	%esi,(%ebx)					;\
     46 	movl	IS_PIC(%ebp),%edi				;\
     47 	ioapic_asm_unlock(num)
     48 
     49 /*
     50  * Since this is called just before the interrupt stub exits, AND
     51  * because the apic ACK doesn't use any registers, all registers
     52  * can be used here.
     53  * XXX this is not obvious
     54  */
     55 #define ioapic_unmask(num) \
     56 	movl    (%esp),%eax					;\
     57 	cmpl    $IREENT_MAGIC,(TF_ERR+4)(%eax)			;\
     58 	jne     79f						;\
     59 	movl	IS_PIC(%ebp),%edi				;\
     60 	ioapic_asm_lock(num)					;\
     61 	movl	IS_PIN(%ebp),%esi				;\
     62 	leal	0x10(%esi,%esi,1),%esi				;\
     63 	movl	PIC_IOAPIC(%edi),%edi				;\
     64 	movl	IOAPIC_SC_REG(%edi),%ebx			;\
     65 	movl	IOAPIC_SC_DATA(%edi),%eax			;\
     66 	movl	%esi, (%ebx)					;\
     67 	movl	(%eax),%edx					;\
     68 	andl	$~IOAPIC_REDLO_MASK,%edx			;\
     69 	movl	%esi, (%ebx)					;\
     70 	movl	%edx,(%eax)					;\
     71 	movl	IS_PIC(%ebp),%edi				;\
     72 	ioapic_asm_unlock(num)					;\
     73 79:
     74 
     75 #endif
     76