Home | History | Annotate | Line # | Download | only in include
frameasm.h revision 1.1
      1 /*	$NetBSD: frameasm.h,v 1.1 2002/11/22 15:07:10 fvdl Exp $	*/
      2 
      3 #ifndef _I386_FRAMEASM_H_
      4 #define _I386_FRAMEASM_H_
      5 
      6 #ifdef _KERNEL_OPT
      7 #include "opt_multiprocessor.h"
      8 #endif
      9 
     10 #ifndef TRAPLOG
     11 #define TLOG		/**/
     12 #else
     13 /*
     14  * Fill in trap record
     15  */
     16 #define TLOG						\
     17 9:							\
     18 	movl	%fs:CPU_TLOG_OFFSET, %eax;		\
     19 	movl	%fs:CPU_TLOG_BASE, %ebx;		\
     20 	addl	$SIZEOF_TREC,%eax;			\
     21 	andl	$SIZEOF_TLOG-1,%eax;			\
     22 	addl	%eax,%ebx;				\
     23 	movl	%eax,%fs:CPU_TLOG_OFFSET;		\
     24 	movl	%esp,TREC_SP(%ebx);			\
     25 	movl	$9b,TREC_HPC(%ebx);			\
     26 	movl	TF_EIP(%esp),%eax;			\
     27 	movl	%eax,TREC_IPC(%ebx);			\
     28 	rdtsc			;			\
     29 	movl	%eax,TREC_TSC(%ebx);			\
     30 	movl	$MSR_LASTBRANCHFROMIP,%ecx;		\
     31 	rdmsr			;			\
     32 	movl	%eax,TREC_LBF(%ebx);			\
     33 	incl	%ecx		;			\
     34 	rdmsr			;			\
     35 	movl	%eax,TREC_LBT(%ebx);			\
     36 	incl	%ecx		;			\
     37 	rdmsr			;			\
     38 	movl	%eax,TREC_IBF(%ebx);			\
     39 	incl	%ecx		;			\
     40 	rdmsr			;			\
     41 	movl	%eax,TREC_IBT(%ebx)
     42 #endif
     43 
     44 /*
     45  * These are used on interrupt or trap entry or exit.
     46  */
     47 #define	INTRENTRY \
     48 	subl	$TF_PUSHSIZE,%esp	; \
     49 	movl	%gs,TF_GS(%esp)	; \
     50 	movl	%fs,TF_FS(%esp) ; \
     51 	movl	%es,TF_ES(%esp) ; \
     52 	movl	%ds,TF_DS(%esp) ; \
     53 	movl	%edi,TF_EDI(%esp)	; \
     54 	movl	%esi,TF_ESI(%esp)	; \
     55 	movl	%eax,TF_EAX(%esp)	; \
     56 	movl	$GSEL(GDATA_SEL, SEL_KPL),%eax	; \
     57 	movl	%eax,%ds	; \
     58 	movl	%ebp,TF_EBP(%esp)	; \
     59 	movl	%eax,%es	; \
     60 	movl	%ebx,TF_EBX(%esp)	; \
     61 	movl	%eax,%gs	; \
     62 	movl	$GSEL(GCPU_SEL, SEL_KPL),%eax	; \
     63 	movl	%edx,TF_EDX(%esp)	; \
     64 	movl	%eax,%fs	; \
     65 	movl	%ecx,TF_ECX(%esp)	; \
     66 	TLOG
     67 
     68 #define	INTRFASTEXIT \
     69 	movl	TF_GS(%esp),%gs	; \
     70 	movl	TF_FS(%esp),%fs	; \
     71 	movl	TF_ES(%esp),%es	; \
     72 	movl	TF_DS(%esp),%ds	; \
     73 	movl	TF_EDI(%esp),%edi	; \
     74 	movl	TF_ESI(%esp),%esi	; \
     75 	movl	TF_EBP(%esp),%ebp	; \
     76 	movl	TF_EBX(%esp),%ebx	; \
     77 	movl	TF_EDX(%esp),%edx	; \
     78 	movl	TF_ECX(%esp),%ecx	; \
     79 	movl	TF_EAX(%esp),%eax	; \
     80 	addl	$(TF_PUSHSIZE+8),%esp	; \
     81 	iret
     82 
     83 #define CHECK_ASTPENDING()              cmpl $0,CPUVAR(ASTPENDING)
     84 #define CLEAR_ASTPENDING()              movl $0,CPUVAR(ASTPENDING)
     85 
     86 #endif /* _I386_FRAMEASM_H_ */
     87