VirtualBox

source: vbox/trunk/include/iprt/asm-amd64-x86-watcom-32.h@ 58802

Last change on this file since 58802 was 58749, checked in by vboxsync, 9 years ago

iprt/asm*.h: Watcom & RT_MANGLER, include #pragma aux before function prototypes so we can #undef the mangled symbol.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.5 KB
Line 
1/** @file
2 * IPRT - AMD64 and x86 Specific Assembly Functions, 32-bit Watcom C pragma aux.
3 */
4
5/*
6 * Copyright (C) 2006-2015 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_asm_amd64_x86_h
27# error "Don't include this header directly."
28#endif
29#ifndef ___iprt_asm_amd64_x86_watcom_32_h
30#define ___iprt_asm_amd64_x86_watcom_32_h
31
32#ifndef __FLAT__
33# error "Only works with flat pointers! (-mf)"
34#endif
35
36/*
37 * Note! The #undef that preceds the #pragma aux statements is for undoing
38 * the mangling, because the symbol in #pragma aux [symbol] statements
39 * doesn't get subjected to preprocessing. This is also why we include
40 * the watcom header at the top rather than at the bottom of the
41 * asm-amd64-x86.h file.
42 */
43
44#undef ASMGetIDTR
45#pragma aux ASMGetIDTR = \
46 "sidt fword ptr [ecx]" \
47 parm [ecx] \
48 modify exact [];
49
50#undef ASMGetIdtrLimit
51#pragma aux ASMGetIdtrLimit = \
52 "sub esp, 8" \
53 "sidt fword ptr [esp]" \
54 "mov cx, [esp]" \
55 "add esp, 8" \
56 parm [] \
57 value [cx] \
58 modify exact [ecx];
59
60#undef ASMSetIDTR
61#pragma aux ASMSetIDTR = \
62 "lidt fword ptr [ecx]" \
63 parm [ecx] nomemory \
64 modify nomemory;
65
66#undef ASMGetGDTR
67#pragma aux ASMGetGDTR = \
68 "sgdt fword ptr [ecx]" \
69 parm [ecx] \
70 modify exact [];
71
72#undef ASMSetGDTR
73#pragma aux ASMSetGDTR = \
74 "lgdt fword ptr [ecx]" \
75 parm [ecx] nomemory \
76 modify exact [] nomemory;
77
78#undef ASMGetCS
79#pragma aux ASMGetCS = \
80 "mov ax, cs" \
81 parm [] nomemory \
82 value [ax] \
83 modify exact [eax] nomemory;
84
85#undef ASMGetDS
86#pragma aux ASMGetDS = \
87 "mov ax, ds" \
88 parm [] nomemory \
89 value [ax] \
90 modify exact [eax] nomemory;
91
92#undef ASMGetES
93#pragma aux ASMGetES = \
94 "mov ax, es" \
95 parm [] nomemory \
96 value [ax] \
97 modify exact [eax] nomemory;
98
99#undef ASMGetFS
100#pragma aux ASMGetFS = \
101 "mov ax, fs" \
102 parm [] nomemory \
103 value [ax] \
104 modify exact [eax] nomemory;
105
106#undef ASMGetGS
107#pragma aux ASMGetGS = \
108 "mov ax, gs" \
109 parm [] nomemory \
110 value [ax] \
111 modify exact [eax] nomemory;
112
113#undef ASMGetSS
114#pragma aux ASMGetSS = \
115 "mov ax, ss" \
116 parm [] nomemory \
117 value [ax] \
118 modify exact [eax] nomemory;
119
120#undef ASMGetTR
121#pragma aux ASMGetTR = \
122 "str ax" \
123 parm [] nomemory \
124 value [ax] \
125 modify exact [eax] nomemory;
126
127#undef ASMGetLDTR
128#pragma aux ASMGetLDTR = \
129 "sldt ax" \
130 parm [] nomemory \
131 value [ax] \
132 modify exact [eax] nomemory;
133
134/** @todo ASMGetSegAttr */
135
136#undef ASMGetFlags
137#pragma aux ASMGetFlags = \
138 "pushfd" \
139 "pop eax" \
140 parm [] nomemory \
141 value [eax] \
142 modify exact [eax] nomemory;
143
144#undef ASMSetFlags
145#pragma aux ASMSetFlags = \
146 "push eax" \
147 "popfd" \
148 parm [eax] nomemory \
149 modify exact [] nomemory;
150
151#undef ASMChangeFlags
152#pragma aux ASMChangeFlags = \
153 "pushfd" \
154 "pop eax" \
155 "and edx, eax" \
156 "or edx, ecx" \
157 "push edx" \
158 "popfd" \
159 parm [edx] [ecx] nomemory \
160 value [eax] \
161 modify exact [edx] nomemory;
162
163#undef ASMAddFlags
164#pragma aux ASMAddFlags = \
165 "pushfd" \
166 "pop eax" \
167 "or edx, eax" \
168 "push edx" \
169 "popfd" \
170 parm [edx] nomemory \
171 value [eax] \
172 modify exact [edx] nomemory;
173
174#undef ASMClearFlags
175#pragma aux ASMClearFlags = \
176 "pushfd" \
177 "pop eax" \
178 "and edx, eax" \
179 "push edx" \
180 "popfd" \
181 parm [edx] nomemory \
182 value [eax] \
183 modify exact [edx] nomemory;
184
185/* Note! Must use the 64-bit integer return value convension.
186 The order of registers in the value [set] does not seem to mean anything. */
187#undef ASMReadTSC
188#pragma aux ASMReadTSC = \
189 ".586" \
190 "rdtsc" \
191 parm [] nomemory \
192 value [eax edx] \
193 modify exact [edx eax] nomemory;
194
195#undef ASMReadTscWithAux
196#pragma aux ASMReadTscWithAux = \
197 0x0f 0x01 0xf9 \
198 parm [ecx] \
199 value [eax edx] \
200 modify exact [eax edx];
201
202/* ASMCpuId: Implemented externally, too many parameters. */
203/* ASMCpuId_Idx_ECX: Implemented externally, too many parameters. */
204/* ASMCpuIdExSlow: Always implemented externally. */
205
206#undef ASMCpuId_ECX_EDX
207#pragma aux ASMCpuId_ECX_EDX = \
208 "cpuid" \
209 "mov [edi], ecx" \
210 "mov [esi], edx" \
211 parm [ecx] [edi] [esi] \
212 modify exact [eax ebx ecx edx];
213
214#undef ASMCpuId_EAX
215#pragma aux ASMCpuId_EAX = \
216 "cpuid" \
217 parm [ecx] \
218 value [eax] \
219 modify exact [eax ebx ecx edx];
220
221#undef ASMCpuId_EBX
222#pragma aux ASMCpuId_EBX = \
223 "cpuid" \
224 parm [ecx] \
225 value [ebx] \
226 modify exact [eax ebx ecx edx];
227
228#undef ASMCpuId_ECX
229#pragma aux ASMCpuId_ECX = \
230 "cpuid" \
231 parm [ecx] \
232 value [ecx] \
233 modify exact [eax ebx ecx edx];
234
235#undef ASMCpuId_EDX
236#pragma aux ASMCpuId_EDX = \
237 "cpuid" \
238 parm [ecx] \
239 value [edx] \
240 modify exact [eax ebx ecx edx];
241
242/* ASMHasCpuId: MSC inline in main source file. */
243/* ASMGetApicId: Implemented externally, lazy bird. */
244
245#undef ASMGetCR0
246#pragma aux ASMGetCR0 = \
247 "mov eax, cr0" \
248 parm [] nomemory \
249 value [eax] \
250 modify exact [eax] nomemory;
251
252#undef ASMSetCR0
253#pragma aux ASMSetCR0 = \
254 "mov cr0, eax" \
255 parm [eax] nomemory \
256 modify exact [] nomemory;
257
258#undef ASMGetCR2
259#pragma aux ASMGetCR2 = \
260 "mov eax, cr2" \
261 parm [] nomemory \
262 value [eax] \
263 modify exact [eax] nomemory;
264
265#undef ASMSetCR2
266#pragma aux ASMSetCR2 = \
267 "mov cr2, eax" \
268 parm [eax] nomemory \
269 modify exact [] nomemory;
270
271#undef ASMGetCR3
272#pragma aux ASMGetCR3 = \
273 "mov eax, cr3" \
274 parm [] nomemory \
275 value [eax] \
276 modify exact [eax] nomemory;
277
278#undef ASMSetCR3
279#pragma aux ASMSetCR3 = \
280 "mov cr3, eax" \
281 parm [eax] nomemory \
282 modify exact [] nomemory;
283
284#undef ASMReloadCR3
285#pragma aux ASMReloadCR3 = \
286 "mov eax, cr3" \
287 "mov cr3, eax" \
288 parm [] nomemory \
289 modify exact [eax] nomemory;
290
291#undef ASMGetCR4
292#pragma aux ASMGetCR4 = \
293 "mov eax, cr4" \
294 parm [] nomemory \
295 value [eax] \
296 modify exact [eax] nomemory;
297
298#undef ASMSetCR4
299#pragma aux ASMSetCR4 = \
300 "mov cr4, eax" \
301 parm [eax] nomemory \
302 modify exact [] nomemory;
303
304/* ASMGetCR8: Don't bother for 32-bit. */
305/* ASMSetCR8: Don't bother for 32-bit. */
306
307#undef ASMIntEnable
308#pragma aux ASMIntEnable = \
309 "sti" \
310 parm [] nomemory \
311 modify exact [] nomemory;
312
313#undef ASMIntDisable
314#pragma aux ASMIntDisable = \
315 "cli" \
316 parm [] nomemory \
317 modify exact [] nomemory;
318
319#undef ASMIntDisableFlags
320#pragma aux ASMIntDisableFlags = \
321 "pushfd" \
322 "cli" \
323 "pop eax" \
324 parm [] nomemory \
325 value [eax] \
326 modify exact [] nomemory;
327
328#undef ASMHalt
329#pragma aux ASMHalt = \
330 "hlt" \
331 parm [] nomemory \
332 modify exact [] nomemory;
333
334#undef ASMRdMsr
335#pragma aux ASMRdMsr = \
336 ".586" \
337 "rdmsr" \
338 parm [ecx] nomemory \
339 value [eax edx] \
340 modify exact [eax edx] nomemory;
341
342#undef ASMWrMsr
343#pragma aux ASMWrMsr = \
344 ".586" \
345 "wrmsr" \
346 parm [ecx] [eax edx] nomemory \
347 modify exact [] nomemory;
348
349#undef ASMRdMsrEx
350#pragma aux ASMRdMsrEx = \
351 ".586" \
352 "rdmsr" \
353 parm [ecx] [edi] nomemory \
354 value [eax edx] \
355 modify exact [eax edx] nomemory;
356
357#undef ASMWrMsrEx
358#pragma aux ASMWrMsrEx = \
359 ".586" \
360 "wrmsr" \
361 parm [ecx] [edi] [eax edx] nomemory \
362 modify exact [] nomemory;
363
364#undef ASMRdMsr_Low
365#pragma aux ASMRdMsr_Low = \
366 ".586" \
367 "rdmsr" \
368 parm [ecx] nomemory \
369 value [eax] \
370 modify exact [eax edx] nomemory;
371
372#undef ASMRdMsr_High
373#pragma aux ASMRdMsr_High = \
374 ".586" \
375 "rdmsr" \
376 parm [ecx] nomemory \
377 value [edx] \
378 modify exact [eax edx] nomemory;
379
380
381#undef ASMGetDR0
382#pragma aux ASMGetDR0 = \
383 "mov eax, dr0" \
384 parm [] nomemory \
385 value [eax] \
386 modify exact [eax] nomemory;
387
388#undef ASMGetDR1
389#pragma aux ASMGetDR1 = \
390 "mov eax, dr1" \
391 parm [] nomemory \
392 value [eax] \
393 modify exact [eax] nomemory;
394
395#undef ASMGetDR2
396#pragma aux ASMGetDR2 = \
397 "mov eax, dr2" \
398 parm [] nomemory \
399 value [eax] \
400 modify exact [eax] nomemory;
401
402#undef ASMGetDR3
403#pragma aux ASMGetDR3 = \
404 "mov eax, dr3" \
405 parm [] nomemory \
406 value [eax] \
407 modify exact [eax] nomemory;
408
409#undef ASMGetDR6
410#pragma aux ASMGetDR6 = \
411 "mov eax, dr6" \
412 parm [] nomemory \
413 value [eax] \
414 modify exact [eax] nomemory;
415
416#undef ASMGetAndClearDR6
417#pragma aux ASMGetAndClearDR6 = \
418 "mov edx, 0ffff0ff0h" \
419 "mov eax, dr6" \
420 "mov dr6, edx" \
421 parm [] nomemory \
422 value [eax] \
423 modify exact [eax edx] nomemory;
424
425#undef ASMGetDR7
426#pragma aux ASMGetDR7 = \
427 "mov eax, dr7" \
428 parm [] nomemory \
429 value [eax] \
430 modify exact [eax] nomemory;
431
432#undef ASMSetDR0
433#pragma aux ASMSetDR0 = \
434 "mov dr0, eax" \
435 parm [eax] nomemory \
436 modify exact [] nomemory;
437
438#undef ASMSetDR1
439#pragma aux ASMSetDR1 = \
440 "mov dr1, eax" \
441 parm [eax] nomemory \
442 modify exact [] nomemory;
443
444#undef ASMSetDR2
445#pragma aux ASMSetDR2 = \
446 "mov dr2, eax" \
447 parm [eax] nomemory \
448 modify exact [] nomemory;
449
450#undef ASMSetDR3
451#pragma aux ASMSetDR3 = \
452 "mov dr3, eax" \
453 parm [eax] nomemory \
454 modify exact [] nomemory;
455
456#undef ASMSetDR6
457#pragma aux ASMSetDR6 = \
458 "mov dr6, eax" \
459 parm [eax] nomemory \
460 modify exact [] nomemory;
461
462#undef ASMSetDR7
463#pragma aux ASMSetDR7 = \
464 "mov dr7, eax" \
465 parm [eax] nomemory \
466 modify exact [] nomemory;
467
468/* Yeah, could've used outp here, but this keeps the main file simpler. */
469#undef ASMOutU8
470#pragma aux ASMOutU8 = \
471 "out dx, al" \
472 parm [dx] [al] nomemory \
473 modify exact [] nomemory;
474
475#undef ASMInU8
476#pragma aux ASMInU8 = \
477 "in al, dx" \
478 parm [dx] nomemory \
479 value [al] \
480 modify exact [] nomemory;
481
482#undef ASMOutU16
483#pragma aux ASMOutU16 = \
484 "out dx, ax" \
485 parm [dx] [ax] nomemory \
486 modify exact [] nomemory;
487
488#undef ASMInU16
489#pragma aux ASMInU16 = \
490 "in ax, dx" \
491 parm [dx] nomemory \
492 value [ax] \
493 modify exact [] nomemory;
494
495#undef ASMOutU32
496#pragma aux ASMOutU32 = \
497 "out dx, eax" \
498 parm [dx] [eax] nomemory \
499 modify exact [] nomemory;
500
501#undef ASMInU32
502#pragma aux ASMInU32 = \
503 "in eax, dx" \
504 parm [dx] nomemory \
505 value [eax] \
506 modify exact [] nomemory;
507
508#undef ASMOutStrU8
509#pragma aux ASMOutStrU8 = \
510 "rep outsb" \
511 parm [dx] [esi] [ecx] nomemory \
512 modify exact [esi ecx] nomemory;
513
514#undef ASMInStrU8
515#pragma aux ASMInStrU8 = \
516 "rep insb" \
517 parm [dx] [edi] [ecx] \
518 modify exact [edi ecx];
519
520#undef ASMOutStrU16
521#pragma aux ASMOutStrU16 = \
522 "rep outsw" \
523 parm [dx] [esi] [ecx] nomemory \
524 modify exact [esi ecx] nomemory;
525
526#undef ASMInStrU16
527#pragma aux ASMInStrU16 = \
528 "rep insw" \
529 parm [dx] [edi] [ecx] \
530 modify exact [edi ecx];
531
532#undef ASMOutStrU32
533#pragma aux ASMOutStrU32 = \
534 "rep outsd" \
535 parm [dx] [esi] [ecx] nomemory \
536 modify exact [esi ecx] nomemory;
537
538#undef ASMInStrU32
539#pragma aux ASMInStrU32 = \
540 "rep insd" \
541 parm [dx] [edi] [ecx] \
542 modify exact [edi ecx];
543
544#undef ASMInvalidatePage
545#pragma aux ASMInvalidatePage = \
546 "invlpg [eax]" \
547 parm [eax] \
548 modify exact [];
549
550#undef ASMWriteBackAndInvalidateCaches
551#pragma aux ASMWriteBackAndInvalidateCaches = \
552 ".486" \
553 "wbinvd" \
554 parm [] nomemory \
555 modify exact [] nomemory;
556
557#undef ASMInvalidateInternalCaches
558#pragma aux ASMInvalidateInternalCaches = \
559 ".486" \
560 "invd" \
561 parm [] \
562 modify exact [];
563
564#endif
565
Note: See TracBrowser for help on using the repository browser.

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