Annotation of src/sys/arch/i386/include/frameasm.h, Revision 1.11
1.10 yamt 1: /* $NetBSD$ */
1.1 fvdl 2:
3: #ifndef _I386_FRAMEASM_H_
4: #define _I386_FRAMEASM_H_
5:
6: #ifdef _KERNEL_OPT
7: #include "opt_multiprocessor.h"
1.11 ! bouyer 8: #include "opt_xen.h"
! 9: #endif
! 10:
! 11: #if !defined(XEN)
! 12: #define CLI(reg) cli
! 13: #define STI(reg) sti
! 14: #else
! 15: /* XXX assym.h */
! 16: #define TRAP_INSTR int $0x82
! 17: #define XEN_BLOCK_EVENTS(reg) movb $1,EVTCHN_UPCALL_MASK(reg)
! 18: #define XEN_UNBLOCK_EVENTS(reg) movb $0,EVTCHN_UPCALL_MASK(reg)
! 19: #define XEN_TEST_PENDING(reg) testb $0xFF,EVTCHN_UPCALL_PENDING(reg)
! 20:
! 21: #define CLI(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
! 22: XEN_BLOCK_EVENTS(reg)
! 23: #define STI(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
! 24: XEN_UNBLOCK_EVENTS(reg)
! 25: #define STIC(reg) movl _C_LABEL(HYPERVISOR_shared_info),reg ; \
! 26: XEN_UNBLOCK_EVENTS(reg) ; \
! 27: testb $0xff,EVTCHN_UPCALL_PENDING(reg)
1.1 fvdl 28: #endif
29:
30: #ifndef TRAPLOG
31: #define TLOG /**/
32: #else
33: /*
34: * Fill in trap record
35: */
36: #define TLOG \
37: 9: \
38: movl %fs:CPU_TLOG_OFFSET, %eax; \
39: movl %fs:CPU_TLOG_BASE, %ebx; \
40: addl $SIZEOF_TREC,%eax; \
41: andl $SIZEOF_TLOG-1,%eax; \
42: addl %eax,%ebx; \
43: movl %eax,%fs:CPU_TLOG_OFFSET; \
44: movl %esp,TREC_SP(%ebx); \
45: movl $9b,TREC_HPC(%ebx); \
46: movl TF_EIP(%esp),%eax; \
47: movl %eax,TREC_IPC(%ebx); \
48: rdtsc ; \
49: movl %eax,TREC_TSC(%ebx); \
50: movl $MSR_LASTBRANCHFROMIP,%ecx; \
51: rdmsr ; \
52: movl %eax,TREC_LBF(%ebx); \
53: incl %ecx ; \
54: rdmsr ; \
55: movl %eax,TREC_LBT(%ebx); \
56: incl %ecx ; \
57: rdmsr ; \
58: movl %eax,TREC_IBF(%ebx); \
59: incl %ecx ; \
60: rdmsr ; \
61: movl %eax,TREC_IBT(%ebx)
62: #endif
63:
64: /*
65: * These are used on interrupt or trap entry or exit.
66: */
67: #define INTRENTRY \
68: subl $TF_PUSHSIZE,%esp ; \
69: movl %gs,TF_GS(%esp) ; \
70: movl %fs,TF_FS(%esp) ; \
1.3 junyoung 71: movl %eax,TF_EAX(%esp) ; \
1.1 fvdl 72: movl %es,TF_ES(%esp) ; \
73: movl %ds,TF_DS(%esp) ; \
1.3 junyoung 74: movl $GSEL(GDATA_SEL, SEL_KPL),%eax ; \
1.1 fvdl 75: movl %edi,TF_EDI(%esp) ; \
76: movl %esi,TF_ESI(%esp) ; \
77: movl %eax,%ds ; \
78: movl %ebp,TF_EBP(%esp) ; \
79: movl %eax,%es ; \
80: movl %ebx,TF_EBX(%esp) ; \
81: movl %eax,%gs ; \
1.3 junyoung 82: movl %edx,TF_EDX(%esp) ; \
1.1 fvdl 83: movl $GSEL(GCPU_SEL, SEL_KPL),%eax ; \
1.3 junyoung 84: movl %ecx,TF_ECX(%esp) ; \
1.1 fvdl 85: movl %eax,%fs ; \
1.9 ad 86: cld ; \
1.1 fvdl 87: TLOG
88:
1.5 yamt 89: /*
90: * INTRFASTEXIT should be in sync with trap(), resume_iret and friends.
91: */
1.1 fvdl 92: #define INTRFASTEXIT \
93: movl TF_GS(%esp),%gs ; \
94: movl TF_FS(%esp),%fs ; \
95: movl TF_ES(%esp),%es ; \
96: movl TF_DS(%esp),%ds ; \
97: movl TF_EDI(%esp),%edi ; \
98: movl TF_ESI(%esp),%esi ; \
99: movl TF_EBP(%esp),%ebp ; \
100: movl TF_EBX(%esp),%ebx ; \
101: movl TF_EDX(%esp),%edx ; \
102: movl TF_ECX(%esp),%ecx ; \
103: movl TF_EAX(%esp),%eax ; \
104: addl $(TF_PUSHSIZE+8),%esp ; \
105: iret
106:
1.8 yamt 107: #define DO_DEFERRED_SWITCH \
1.4 yamt 108: cmpl $0, CPUVAR(WANT_PMAPLOAD) ; \
109: jz 1f ; \
110: call _C_LABEL(pmap_load) ; \
111: 1:
112:
1.10 yamt 113: #define DO_DEFERRED_SWITCH_RETRY \
114: 1: ; \
115: cmpl $0, CPUVAR(WANT_PMAPLOAD) ; \
116: jz 1f ; \
117: call _C_LABEL(pmap_load) ; \
118: jmp 1b ; \
119: 1:
120:
1.8 yamt 121: #define CHECK_DEFERRED_SWITCH \
1.4 yamt 122: cmpl $0, CPUVAR(WANT_PMAPLOAD)
123:
1.2 thorpej 124: #define CHECK_ASTPENDING(reg) movl CPUVAR(CURLWP),reg ; \
125: cmpl $0, reg ; \
126: je 1f ; \
1.7 ad 127: cmpl $0, L_MD_ASTPENDING(reg); \
1.2 thorpej 128: 1:
1.7 ad 129: #define CLEAR_ASTPENDING(reg) movl $0, L_MD_ASTPENDING(reg)
1.1 fvdl 130:
1.6 yamt 131: /*
132: * IDEPTH_INCR:
133: * increase ci_idepth and switch to the interrupt stack if necessary.
134: * note that the initial value of ci_idepth is -1.
135: *
136: * => should be called with interrupt disabled.
137: * => save the old value of %esp in %eax.
138: */
139:
140: #define IDEPTH_INCR \
141: incl CPUVAR(IDEPTH); \
142: movl %esp, %eax; \
143: jne 999f; \
144: movl CPUVAR(INTRSTACK), %esp; \
145: 999: pushl %eax; \
146:
147: /*
148: * IDEPTH_DECR:
149: * decrement ci_idepth and switch back to
150: * the original stack saved by IDEPTH_INCR.
151: *
152: * => should be called with interrupt disabled.
153: */
154:
155: #define IDEPTH_DECR \
156: popl %esp; \
157: decl CPUVAR(IDEPTH)
158:
1.1 fvdl 159: #endif /* _I386_FRAMEASM_H_ */
CVSweb <webmaster@jp.NetBSD.org>