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