VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/Instructions/env-common.mac@ 46875

最後變更 在這個檔案從46875是 46875,由 vboxsync 提交於 12 年 前

yeah, finally getting somewhere...

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.1 KB
 
1; $Id: env-common.mac 46875 2013-06-29 02:15:38Z vboxsync $
2;; @file
3; Instruction Test Environment - Common Bits.
4;
5
6;
7; Copyright (C) 2006-2013 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.alldomusa.eu.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17
18%ifndef ___env_common_mac
19%define ___env_common_mac
20
21
22;*******************************************************************************
23;* Defined Constants And Macros *
24;*******************************************************************************
25%ifdef RT_ARCH_AMD64
26 %define MY_PUSH_FLAGS pushfq
27 %define MY_POP_FLAGS popfq
28 %define MY_PUSH_FLAGS_SIZE 8
29
30 %macro MY_PUSH_ALL 0
31 push rbp
32 mov rbp, rsp
33 push rax
34 push rbx
35 push rcx
36 push rdx
37 push rsi
38 push rdi
39 push r8
40 push r9
41 push r10
42 push r11
43 push r12
44 push r13
45 push r14
46 push r15
47 pushfq
48 %endm
49 %macro MY_POP_ALL 0
50 popfq
51 pop r15
52 pop r14
53 pop r13
54 pop r12
55 pop r11
56 pop r10
57 pop r9
58 pop r8
59 pop rdi
60 pop rsi
61 pop rdx
62 pop rcx
63 pop rbx
64 pop rax
65 pop rbp
66 %endm
67
68%else
69 %define MY_PUSH_FLAGS pushfd
70 %define MY_POP_FLAGS popfd
71 %define MY_PUSH_FLAGS_SIZE 4
72
73 %macro MY_PUSH_ALL 0
74 push eBP
75 mov xBP, xSP
76 push eax
77 push ebx
78 push ecx
79 push edx
80 push esi
81 push edi
82 pushfd
83 %endm
84 %macro MY_POP_ALL 0
85 popfd
86 pop edi
87 pop esi
88 pop edx
89 pop ecx
90 pop ebx
91 pop eax
92 pop ebp
93 %endm
94%endif
95
96
97
98;*******************************************************************************
99;* Internal Functions *
100;*******************************************************************************
101
102VBINSTST_BEGINCODE
103
104;;
105; Report bad register value.
106;
107; Primary purpose is save all registers and convert from our stack-based to
108; the correct calling convention for the environment.
109;
110; @param uExpected
111; @param uActual
112; @param uRegisterNo
113;
114VBINSTST_BEGINPROC Common_BadValue
115 MY_PUSH_ALL
116 mov xAX, xSP ; 16-byte align the stack and reserve space for arguments and stuff.
117 sub xSP, 40h
118 and xSP, ~15
119 mov [xSP + 38h], xAX
120
121%ifdef ASM_CALL64_GCC
122 mov r8d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
123 mov rcx, [rbp + 10h] ; expected
124 mov rdx, [rbp + 18h] ; actual
125 mov rsi, [rbp + 20h] ; reg#
126 lea rdi, [.szFmt wrt rip]
127 VBINSTST_CALL_FN_FAILURE_4
128
129%elifdef ASM_CALL64_MSC
130 mov r10d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
131 mov [rsp + 20h], r10
132 mov r9, [rbp + 10h] ; expected
133 mov r8, [rbp + 18h] ; actual
134 mov rdx, [rbp + 20h] ; reg#
135 lea rcx, [.szFmt wrt rip]
136 VBINSTST_CALL_FN_FAILURE_4
137
138%else
139 mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator)]
140 mov sCX, [xBP + 4 + xCB] ; expected
141 mov sAX, [xBP + 4 + xCB + 4] ; actual
142 mov sDX, [xBP + 4 + xCB + 8] ; reg#
143 mov [xSP + xCB + 3*sCB], sBX
144 mov [xSP + xCB + 2*sCB], sCX
145 mov [xSP + xCB + 1*sCB], sAX
146 mov [xSP + xCB], sDX
147 mov [xSP], RTCCPTR_PRE .szFmt
148 VBINSTST_CALL_FN_FAILURE_4
149%endif
150
151 mov xSP, [xSP + 38h]
152 MY_POP_ALL
153 ret
154%if ARCH_BITS == 64
155.szFmt: db 'Bad register %#llx value %#018llx, expected %#018llx (line %llu)', 0
156%else
157.szFmt: db 'Bad register %lx value %#010lx, expected %#010lx (line %lu)', 0
158%endif
159VBINSTST_ENDPROC Common_BadValue
160
161
162
163;
164; Global data variables used by Common_SetupMemReadUxx.
165; For address calculation reasons, these must be qword aligned.
166;
167BEGINDATA
168 dd 09d8af498h, 09ab3e5f8h
169VBINSTST_GLOBALNAME_EX g_u64Data, data hidden
170 dq 0
171 dd 07d7af797h, 096b36562h
172VBINSTST_GLOBALNAME_EX g_u32Data, data hidden
173 dd 0
174 dd 012305987h
175VBINSTST_GLOBALNAME_EX g_u16Data, data hidden
176 dw 0
177 dw 05865h
178 dw 03863h
179 dw 02679h
180VBINSTST_GLOBALNAME_EX g_u8Data, data hidden
181 db 0
182 db 90h
183 dw 0865ah
184 dd 058daffe2h
185
186BEGINCODE
187
188;;
189; Sets up g_u8Data.
190; @param uValue
191VBINSTST_BEGINPROC Common_SetupMemReadU8
192 push sAX
193 mov ax, [xSP + sCB + xCB]
194 mov [VBINSTST_NAME(g_u8Data) xWrtRIP], ax
195 pop sAX
196 ret sCB
197VBINSTST_ENDPROC Common_SetupMemReadU8
198
199;;
200; Sets up g_u16Data.
201; @param uValue
202VBINSTST_BEGINPROC Common_SetupMemReadU16
203 push sAX
204 mov ax, [xSP + sCB + xCB]
205 mov [VBINSTST_NAME(g_u16Data) xWrtRIP], ax
206 pop sAX
207 ret sCB
208VBINSTST_ENDPROC Common_SetupMemReadU16
209
210;;
211; Sets up g_u32Data.
212; @param uValue
213VBINSTST_BEGINPROC Common_SetupMemReadU32
214 push sAX
215 mov eax, [xSP + sCB + xCB]
216 mov [VBINSTST_NAME(g_u32Data) xWrtRIP], eax
217 pop sAX
218 ret sCB
219VBINSTST_ENDPROC Common_SetupMemReadU32
220
221;;
222; Sets up g_u64Data.
223; @param uValue
224VBINSTST_BEGINPROC Common_SetupMemReadU64
225 push sAX
226%ifdef RT_ARCH_AMD64
227 mov rax, [xSP + sCB + xCB]
228 mov [VBINSTST_NAME(g_u64Data) xWrtRIP], rax
229%else
230 mov eax, [xSP + sCB + xCB]
231 mov [VBINSTST_NAME(g_u64Data) xWrtRIP], eax
232 mov eax, [xSP + sCB + xCB + 4]
233 mov [VBINSTST_NAME(g_u64Data) + 4 xWrtRIP], eax
234%endif
235 pop sAX
236 ret sCB
237VBINSTST_ENDPROC Common_SetupMemReadU64
238
239
240%endif
241
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette