VirtualBox

source: vbox/trunk/include/iprt/asm-amd64-x86-watcom-16.h@ 58749

Last change on this file since 58749 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: 13.6 KB
Line 
1/** @file
2 * IPRT - AMD64 and x86 Specific Assembly Functions, 16-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_16_h
30#define ___iprt_asm_amd64_x86_watcom_16_h
31
32#if !RT_FAR_DATA
33# error "Only works with far data pointers!"
34#endif
35
36/*
37 * Turns out we cannot use 'ds' for segment stuff here because the compiler
38 * seems to insists on loading the DGROUP segment into 'ds' before calling
39 * stuff when using -ecc. Using 'es' instead as this seems to work fine.
40 *
41 * Note! The #undef that preceds the #pragma aux statements is for undoing
42 * the mangling, because the symbol in #pragma aux [symbol] statements
43 * doesn't get subjected to preprocessing. This is also why we include
44 * the watcom header at the top rather than at the bottom of the
45 * asm-amd64-x86.h file.
46 */
47
48#undef ASMGetIDTR
49#pragma aux ASMGetIDTR = \
50 "sidt fword ptr es:[bx]" \
51 parm [es bx] \
52 modify exact [];
53
54#undef ASMGetIdtrLimit
55#pragma aux ASMGetIdtrLimit = \
56 "sub sp, 8" \
57 "mov bx, sp" \
58 "sidt fword ptr ss:[bx]" \
59 "mov bx, ss:[bx]" \
60 "add sp, 8" \
61 parm [] \
62 value [bx] \
63 modify exact [bx];
64
65#undef ASMSetIDTR
66#pragma aux ASMSetIDTR = \
67 "lidt fword ptr es:[bx]" \
68 parm [es bx] nomemory \
69 modify nomemory;
70
71#undef ASMGetGDTR
72#pragma aux ASMGetGDTR = \
73 "sgdt fword ptr es:[bx]" \
74 parm [es bx] \
75 modify exact [];
76
77#undef ASMSetGDTR
78#pragma aux ASMSetGDTR = \
79 "lgdt fword ptr es:[bx]" \
80 parm [es bx] nomemory \
81 modify exact [] nomemory;
82
83#undef ASMGetCS
84#pragma aux ASMGetCS = \
85 "mov ax, cs" \
86 parm [] nomemory \
87 value [ax] \
88 modify exact [ax] nomemory;
89
90#undef ASMGetDS
91#pragma aux ASMGetDS = \
92 "mov ax, ds" \
93 parm [] nomemory \
94 value [ax] \
95 modify exact [ax] nomemory;
96
97#undef ASMGetES
98#pragma aux ASMGetES = \
99 "mov ax, es" \
100 parm [] nomemory \
101 value [ax] \
102 modify exact [ax] nomemory;
103
104#undef ASMGetFS
105#pragma aux ASMGetFS = \
106 "mov ax, fs" \
107 parm [] nomemory \
108 value [ax] \
109 modify exact [ax] nomemory;
110
111#undef ASMGetGS
112#pragma aux ASMGetGS = \
113 "mov ax, gs" \
114 parm [] nomemory \
115 value [ax] \
116 modify exact [ax] nomemory;
117
118#undef ASMGetSS
119#pragma aux ASMGetSS = \
120 "mov ax, ss" \
121 parm [] nomemory \
122 value [ax] \
123 modify exact [ax] nomemory;
124
125#undef ASMGetTR
126#pragma aux ASMGetTR = \
127 "str ax" \
128 parm [] nomemory \
129 value [ax] \
130 modify exact [ax] nomemory;
131
132#undef ASMGetLDTR
133#pragma aux ASMGetLDTR = \
134 "sldt ax" \
135 parm [] nomemory \
136 value [ax] \
137 modify exact [ax] nomemory;
138
139/** @todo ASMGetSegAttr */
140
141#undef ASMGetFlags
142#pragma aux ASMGetFlags = \
143 "pushf" \
144 "pop ax" \
145 parm [] nomemory \
146 value [ax] \
147 modify exact [ax] nomemory;
148
149#undef ASMSetFlags
150#pragma aux ASMSetFlags = \
151 "push ax" \
152 "popf" \
153 parm [ax] nomemory \
154 modify exact [] nomemory;
155
156#undef ASMChangeFlags
157#pragma aux ASMChangeFlags = \
158 "pushf" \
159 "pop ax" \
160 "and dx, ax" \
161 "or dx, cx" \
162 "push dx" \
163 "popf" \
164 parm [dx] [cx] nomemory \
165 value [ax] \
166 modify exact [dx] nomemory;
167
168#undef ASMAddFlags
169#pragma aux ASMAddFlags = \
170 "pushf" \
171 "pop ax" \
172 "or dx, ax" \
173 "push dx" \
174 "popf" \
175 parm [dx] nomemory \
176 value [ax] \
177 modify exact [dx] nomemory;
178
179#undef ASMClearFlags
180#pragma aux ASMClearFlags = \
181 "pushf" \
182 "pop ax" \
183 "and dx, ax" \
184 "push dx" \
185 "popf" \
186 parm [dx] nomemory \
187 value [ax] \
188 modify exact [dx] nomemory;
189
190/* Note! Must use the 64-bit integer return value convension.
191 The order of registers in the value [set] does not seem to mean anything. */
192#undef ASMReadTSC
193#pragma aux ASMReadTSC = \
194 ".586" \
195 "rdtsc" \
196 "mov ebx, edx" \
197 "mov ecx, eax" \
198 "shr ecx, 16" \
199 "xchg eax, edx" \
200 "shr eax, 16" \
201 parm [] nomemory \
202 value [dx cx bx ax] \
203 modify exact [ax bx cx dx] nomemory;
204
205/** @todo ASMReadTscWithAux if needed (rdtscp not recognized by compiler) */
206
207
208/* ASMCpuId: Implemented externally, too many parameters. */
209/* ASMCpuId_Idx_ECX: Implemented externally, too many parameters. */
210/* ASMCpuIdExSlow: Always implemented externally. */
211/* ASMCpuId_ECX_EDX: Implemented externally, too many parameters. */
212/* ASMCpuId_EAX: Implemented externally, lazy bird. */
213/* ASMCpuId_EBX: Implemented externally, lazy bird. */
214/* ASMCpuId_ECX: Implemented externally, lazy bird. */
215/* ASMCpuId_EDX: Implemented externally, lazy bird. */
216/* ASMHasCpuId: MSC inline in main source file. */
217/* ASMGetApicId: Implemented externally, lazy bird. */
218
219/* Note! Again, when returning two registers, watcom have certain fixed ordering rules (low:high):
220 ax:bx, ax:cx, ax:dx, ax:si, ax:di
221 bx:cx, bx:dx, bx:si, bx:di
222 dx:cx, si:cx, di:cx
223 si:dx, di:dx
224 si:di
225 This ordering seems to apply to parameter values too. */
226#undef ASMGetCR0
227#pragma aux ASMGetCR0 = \
228 "mov eax, cr0" \
229 "mov edx, eax" \
230 "shr edx, 16" \
231 parm [] nomemory \
232 value [ax dx] \
233 modify exact [ax dx] nomemory;
234
235#undef ASMSetCR0
236#pragma aux ASMSetCR0 = \
237 "shl edx, 16" \
238 "mov dx, ax" \
239 "mov cr0, edx" \
240 parm [ax dx] nomemory \
241 modify exact [dx] nomemory;
242
243#undef ASMGetCR2
244#pragma aux ASMGetCR2 = \
245 "mov eax, cr2" \
246 "mov edx, eax" \
247 "shr edx, 16" \
248 parm [] nomemory \
249 value [ax dx] \
250 modify exact [ax dx] nomemory;
251
252#undef ASMSetCR2
253#pragma aux ASMSetCR2 = \
254 "shl edx, 16" \
255 "mov dx, ax" \
256 "mov cr2, edx" \
257 parm [ax dx] nomemory \
258 modify exact [dx] nomemory;
259
260#undef ASMGetCR3
261#pragma aux ASMGetCR3 = \
262 "mov eax, cr3" \
263 "mov edx, eax" \
264 "shr edx, 16" \
265 parm [] nomemory \
266 value [ax dx] \
267 modify exact [ax dx] nomemory;
268
269#undef ASMSetCR3
270#pragma aux ASMSetCR3 = \
271 "shl edx, 16" \
272 "mov dx, ax" \
273 "mov cr3, edx" \
274 parm [ax dx] nomemory \
275 modify exact [dx] nomemory;
276
277#undef ASMReloadCR3
278#pragma aux ASMReloadCR3 = \
279 "mov eax, cr3" \
280 "mov cr3, eax" \
281 parm [] nomemory \
282 modify exact [ax] nomemory;
283
284#undef ASMGetCR4
285#pragma aux ASMGetCR4 = \
286 "mov eax, cr4" \
287 "mov edx, eax" \
288 "shr edx, 16" \
289 parm [] nomemory \
290 value [ax dx] \
291 modify exact [ax dx] nomemory;
292
293#undef ASMSetCR4
294#pragma aux ASMSetCR4 = \
295 "shl edx, 16" \
296 "mov dx, ax" \
297 "mov cr4, edx" \
298 parm [ax dx] nomemory \
299 modify exact [dx] nomemory;
300
301/* ASMGetCR8: Don't bother for 16-bit. */
302/* ASMSetCR8: Don't bother for 16-bit. */
303
304#undef ASMIntEnable
305#pragma aux ASMIntEnable = \
306 "sti" \
307 parm [] nomemory \
308 modify exact [] nomemory;
309
310#undef ASMIntDisable
311#pragma aux ASMIntDisable = \
312 "cli" \
313 parm [] nomemory \
314 modify exact [] nomemory;
315
316#undef ASMIntDisableFlags
317#pragma aux ASMIntDisableFlags = \
318 "pushf" \
319 "cli" \
320 "pop ax" \
321 parm [] nomemory \
322 value [ax] \
323 modify exact [] nomemory;
324
325#undef ASMHalt
326#pragma aux ASMHalt = \
327 "hlt" \
328 parm [] nomemory \
329 modify exact [] nomemory;
330
331#undef ASMRdMsr
332#pragma aux ASMRdMsr = \
333 ".586" \
334 "shl ecx, 16" \
335 "mov cx, ax" \
336 "rdmsr" \
337 "mov ebx, edx" \
338 "mov ecx, eax" \
339 "shr ecx, 16" \
340 "xchg eax, edx" \
341 "shr eax, 16" \
342 parm [ax cx] nomemory \
343 value [dx cx bx ax] \
344 modify exact [ax bx cx dx] nomemory;
345
346/* ASMWrMsr: Implemented externally, lazy bird. */
347/* ASMRdMsrEx: Implemented externally, lazy bird. */
348/* ASMWrMsrEx: Implemented externally, lazy bird. */
349
350#undef ASMRdMsr_Low
351#pragma aux ASMRdMsr_Low = \
352 ".586" \
353 "shl ecx, 16" \
354 "mov cx, ax" \
355 "rdmsr" \
356 "mov edx, eax" \
357 "shr edx, 16" \
358 parm [ax cx] nomemory \
359 value [ax dx] \
360 modify exact [ax bx cx dx] nomemory;
361
362#undef ASMRdMsr_High
363#pragma aux ASMRdMsr_High = \
364 ".586" \
365 "shl ecx, 16" \
366 "mov cx, ax" \
367 "rdmsr" \
368 "mov eax, edx" \
369 "shr edx, 16" \
370 parm [ax cx] nomemory \
371 value [ax dx] \
372 modify exact [ax bx cx dx] nomemory;
373
374
375#undef ASMGetDR0
376#pragma aux ASMGetDR0 = \
377 "mov eax, dr0" \
378 "mov edx, eax" \
379 "shr edx, 16" \
380 parm [] nomemory \
381 value [ax dx] \
382 modify exact [ax dx] nomemory;
383
384#undef ASMGetDR1
385#pragma aux ASMGetDR1 = \
386 "mov eax, dr1" \
387 "mov edx, eax" \
388 "shr edx, 16" \
389 parm [] nomemory \
390 value [ax dx] \
391 modify exact [ax dx] nomemory;
392
393#undef ASMGetDR2
394#pragma aux ASMGetDR2 = \
395 "mov eax, dr2" \
396 "mov edx, eax" \
397 "shr edx, 16" \
398 parm [] nomemory \
399 value [ax dx] \
400 modify exact [ax dx] nomemory;
401
402#undef ASMGetDR3
403#pragma aux ASMGetDR3 = \
404 "mov eax, dr3" \
405 "mov edx, eax" \
406 "shr edx, 16" \
407 parm [] nomemory \
408 value [ax dx] \
409 modify exact [ax dx] nomemory;
410
411#undef ASMGetDR6
412#pragma aux ASMGetDR6 = \
413 "mov eax, dr6" \
414 "mov edx, eax" \
415 "shr edx, 16" \
416 parm [] nomemory \
417 value [ax dx] \
418 modify exact [ax dx] nomemory;
419
420#undef ASMGetAndClearDR6
421#pragma aux ASMGetAndClearDR6 = \
422 "mov edx, 0ffff0ff0h" \
423 "mov eax, dr6" \
424 "mov dr6, edx" \
425 "mov edx, eax" \
426 "shr edx, 16" \
427 parm [] nomemory \
428 value [ax dx] \
429 modify exact [ax dx] nomemory;
430
431#undef ASMGetDR7
432#pragma aux ASMGetDR7 = \
433 "mov eax, dr7" \
434 "mov edx, eax" \
435 "shr edx, 16" \
436 parm [] nomemory \
437 value [ax dx] \
438 modify exact [ax dx] nomemory;
439
440#undef ASMSetDR0
441#pragma aux ASMSetDR0 = \
442 "shl edx, 16" \
443 "mov dx, ax" \
444 "mov dr0, edx" \
445 parm [ax dx] nomemory \
446 modify exact [dx] nomemory;
447
448#undef ASMSetDR1
449#pragma aux ASMSetDR1 = \
450 "shl edx, 16" \
451 "mov dx, ax" \
452 "mov dr1, edx" \
453 parm [ax dx] nomemory \
454 modify exact [dx] nomemory;
455
456#undef ASMSetDR2
457#pragma aux ASMSetDR2 = \
458 "shl edx, 16" \
459 "mov dx, ax" \
460 "mov dr2, edx" \
461 parm [ax dx] nomemory \
462 modify exact [dx] nomemory;
463
464#undef ASMSetDR3
465#pragma aux ASMSetDR3 = \
466 "shl edx, 16" \
467 "mov dx, ax" \
468 "mov dr3, edx" \
469 parm [ax dx] nomemory \
470 modify exact [dx] nomemory;
471
472#undef ASMSetDR6
473#pragma aux ASMSetDR6 = \
474 "shl edx, 16" \
475 "mov dx, ax" \
476 "mov dr6, edx" \
477 parm [ax dx] nomemory \
478 modify exact [dx] nomemory;
479
480#undef ASMSetDR7
481#pragma aux ASMSetDR7 = \
482 "shl edx, 16" \
483 "mov dx, ax" \
484 "mov dr7, edx" \
485 parm [ax dx] nomemory \
486 modify exact [dx] nomemory;
487
488/* Yeah, could've used outp here, but this keeps the main file simpler. */
489#undef ASMOutU8
490#pragma aux ASMOutU8 = \
491 "out dx, al" \
492 parm [dx] [al] nomemory \
493 modify exact [] nomemory;
494
495#undef ASMInU8
496#pragma aux ASMInU8 = \
497 "in al, dx" \
498 parm [dx] nomemory \
499 value [al] \
500 modify exact [] nomemory;
501
502#undef ASMOutU16
503#undef ASMOutU16
504#pragma aux ASMOutU16 = \
505 "out dx, ax" \
506 parm [dx] [ax] nomemory \
507 modify exact [] nomemory;
508
509#undef ASMInU16
510#pragma aux ASMInU16 = \
511 "in ax, dx" \
512 parm [dx] nomemory \
513 value [ax] \
514 modify exact [] nomemory;
515
516#undef ASMOutU32
517#pragma aux ASMOutU32 = \
518 "shl ecx, 16" \
519 "mov cx, ax" \
520 "mov eax, ecx" \
521 "out dx, eax" \
522 parm [dx] [ax cx] nomemory \
523 modify exact [] nomemory;
524
525#undef ASMInU32
526#pragma aux ASMInU32 = \
527 "in eax, dx" \
528 "mov ecx, eax" \
529 "shr ecx, 16" \
530 parm [dx] nomemory \
531 value [ax cx] \
532 modify exact [] nomemory;
533
534#undef ASMOutStrU8
535#pragma aux ASMOutStrU8 = \
536 "mov ds, bx" \
537 "rep outsb" \
538 parm [dx] [bx si] [cx] nomemory \
539 modify exact [si cx ds] nomemory;
540
541#undef ASMInStrU8
542#pragma aux ASMInStrU8 = \
543 "rep insb" \
544 parm [dx] [es di] [cx] \
545 modify exact [di cx];
546
547#undef ASMOutStrU16
548#pragma aux ASMOutStrU16 = \
549 "mov ds, bx" \
550 "rep outsw" \
551 parm [dx] [bx si] [cx] nomemory \
552 modify exact [si cx ds] nomemory;
553
554#undef ASMInStrU16
555#pragma aux ASMInStrU16 = \
556 "rep insw" \
557 parm [dx] [es di] [cx] \
558 modify exact [di cx];
559
560#undef ASMOutStrU32
561#pragma aux ASMOutStrU32 = \
562 "mov ds, bx" \
563 "rep outsd" \
564 parm [dx] [bx si] [cx] nomemory \
565 modify exact [si cx ds] nomemory;
566
567#undef ASMInStrU32
568#pragma aux ASMInStrU32 = \
569 "rep insd" \
570 parm [dx] [es di] [cx] \
571 modify exact [di cx];
572
573/* ASMInvalidatePage: When needed. */
574
575#undef ASMWriteBackAndInvalidateCaches
576#pragma aux ASMWriteBackAndInvalidateCaches = \
577 ".486" \
578 "wbinvd" \
579 parm [] nomemory \
580 modify exact [] nomemory;
581
582#undef ASMInvalidateInternalCaches
583#pragma aux ASMInvalidateInternalCaches = \
584 ".486" \
585 "invd" \
586 parm [] \
587 modify exact [];
588
589#endif
590
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