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