VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/inlines.h@ 71963

Last change on this file since 71963 was 69501, checked in by vboxsync, 7 years ago

PC/BIOS: Added LGPL disclaimer text where appropriate.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
1/* $Id: inlines.h 69501 2017-10-28 16:12:47Z vboxsync $ */
2/** @file
3 * Inline routines for Watcom C.
4 */
5
6/*
7 * Copyright (C) 2010-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.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
19extern unsigned inp(unsigned port);
20extern unsigned outp(unsigned port, unsigned value);
21extern unsigned inpw(unsigned port);
22extern unsigned outpw(unsigned port, unsigned value);
23#pragma intrinsic(inp,outp,inpw,outpw)
24#define inb(p) inp(p)
25#define outb(p, v) outp(p, v)
26#define inw(p) inpw(p)
27#define outw(p, v) outpw(p, v)
28
29extern uint8_t read_byte(uint16_t seg, uint16_t offset);
30extern uint16_t read_word(uint16_t seg, uint16_t offset);
31extern uint32_t read_dword(uint16_t seg, uint16_t offset);
32extern void write_byte(uint16_t seg, uint16_t offset, uint8_t data);
33extern void write_word(uint16_t seg, uint16_t offset, uint16_t data);
34extern void write_dword(uint16_t seg, uint16_t offset, uint32_t data);
35
36void int_enable(void);
37#pragma aux int_enable = "sti" modify exact [] nomemory;
38
39void int_disable(void);
40#pragma aux int_disable = "cli" modify exact [] nomemory;
41
42void int_enable_hlt_disable(void);
43#pragma aux int_enable_hlt_disable = \
44 "sti" \
45 "hlt" \
46 "cli" \
47 modify exact [] nomemory;
48
49uint16_t int_query(void);
50#pragma aux int_query = \
51 "pushf" \
52 "pop ax" \
53 value [ax] modify exact [ax] nomemory;
54
55void int_restore(uint16_t old_flags);
56#pragma aux int_restore = \
57 "push ax" \
58 "popf" \
59 parm [ax] modify exact [] nomemory;
60
61void halt(void);
62#pragma aux halt = "hlt" modify exact [] nomemory;
63
64void halt_forever(void);
65#pragma aux halt_forever = \
66 "forever:" \
67 "hlt" \
68 "jmp forever" \
69 modify exact [] nomemory aborts;
70
71#ifdef __386__
72
73void rep_movsb(void __far *d, void __far *s, int nbytes);
74#pragma aux rep_movsb = \
75 "push ds" \
76 "mov ds, dx" \
77 "rep movsb" \
78 "pop ds" \
79 parm [es edi] [dx esi] [ecx];
80
81#else
82
83void rep_movsb(void __far *d, void __far *s, int nbytes);
84#pragma aux rep_movsb = \
85 "push ds" \
86 "mov ds, dx" \
87 "rep movsb" \
88 "pop ds" \
89 parm [es di] [dx si] [cx];
90
91#endif
92
93void rep_movsw(void __far *d, void __far *s, int nwords);
94#pragma aux rep_movsw = \
95 "push ds" \
96 "mov ds, dx" \
97 "rep movsw" \
98 "pop ds" \
99 parm [es di] [dx si] [cx];
100
101#ifndef __386__
102
103char __far *rep_insb(char __far *buffer, unsigned nbytes, unsigned port);
104#pragma aux rep_insb = ".286" "rep insb" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
105
106char __far *rep_insw(char __far *buffer, unsigned nwords, unsigned port);
107#pragma aux rep_insw = ".286" "rep insw" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
108
109# if VBOX_BIOS_CPU >= 80386
110char __far *rep_insd(char __far *buffer, unsigned ndwords, unsigned port);
111# pragma aux rep_insd = ".386" "rep insd" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
112# endif
113
114char __far *rep_outsb(char __far *buffer, unsigned nbytes, unsigned port);
115#pragma aux rep_outsb = ".286" "rep outs dx,byte ptr es:[si]" parm [es si] [cx] [dx] value [es si] modify exact [cx si];
116
117char __far *rep_outsw(char __far *buffer, unsigned nwords, unsigned port);
118#pragma aux rep_outsw = ".286" "rep outs dx,word ptr es:[si]" parm [es si] [cx] [dx] value [es si] modify exact [cx si];
119
120# if VBOX_BIOS_CPU >= 80386
121char __far *rep_outsd(char __far *buffer, unsigned ndwords, unsigned port);
122# pragma aux rep_outsd = ".386" "rep outs dx,dword ptr es:[si]" parm [es si] [cx] [dx] value [es si] modify exact [cx si];
123# endif
124
125uint16_t swap_16(uint16_t val);
126#pragma aux swap_16 = "xchg ah,al" parm [ax] value [ax] modify exact [ax] nomemory;
127
128uint32_t swap_32(uint32_t val);
129#pragma aux swap_32 = \
130 "xchg ah, al" \
131 "xchg dh, dl" \
132 "xchg ax, dx" \
133 parm [dx ax] value [dx ax] modify exact [dx ax] nomemory;
134
135uint64_t swap_64(uint64_t val);
136#pragma aux swap_64 = \
137 "xchg ah, al" \
138 "xchg bh, bl" \
139 "xchg ch, cl" \
140 "xchg dh, dl" \
141 "xchg ax, dx" \
142 "xchg bx, cx" \
143 parm [ax bx cx dx] value [ax bx cx dx] modify exact [ax bx cx dx] nomemory;
144
145#endif
146
147#if VBOX_BIOS_CPU >= 80386
148
149/* Warning: msr_read/msr_write destroy high bits of 32-bit registers (EAX, ECX, EDX). */
150
151uint64_t msr_read(uint32_t msr);
152#pragma aux msr_read = \
153 ".586" \
154 "shl ecx, 16" \
155 "mov cx, ax" \
156 "rdmsr" \
157 "xchg eax, edx" \
158 "mov bx, ax" \
159 "shr eax, 16" \
160 "mov cx, dx" \
161 "shr edx, 16" \
162 "xchg dx, cx" \
163 parm [cx ax] value [ax bx cx dx] modify [] nomemory;
164
165void msr_write(uint64_t val, uint32_t msr);
166#pragma aux msr_write = \
167 ".586" \
168 "shl eax, 16" \
169 "mov ax, bx" \
170 "xchg dx, cx" \
171 "shl edx, 16" \
172 "mov dx, cx" \
173 "xchg eax, edx" \
174 "mov cx, di" \
175 "shl ecx, 16" \
176 "mov cx, si" \
177 "wrmsr" \
178 parm [ax bx cx dx] [di si] modify [] nomemory;
179
180/* Warning: eflags_read/eflags_write destroy high bits of 32-bit registers (EDX). */
181uint32_t eflags_read( void );
182#pragma aux eflags_read = \
183 ".386" \
184 "pushfd" \
185 "pop edx" \
186 "mov ax, dx" \
187 "shr edx, 16" \
188 value [dx ax] modify [dx ax];
189
190uint32_t eflags_write( uint32_t e_flags );
191#pragma aux eflags_write = \
192 ".386" \
193 "shl edx, 16" \
194 "mov dx, ax" \
195 "push edx" \
196 "popfd" \
197 parm [dx ax] modify [dx ax];
198
199/* Warning cpuid destroys high bits of 32-bit registers (EAX, EBX, ECX, EDX). */
200void cpuid( uint32_t __far cpu_id[4], uint32_t leaf );
201#pragma aux cpuid = \
202 ".586" \
203 "shl edx, 16" \
204 "mov dx, ax" \
205 "mov eax, edx" \
206 "cpuid" \
207 "mov es:[di+0], eax" \
208 "mov es:[di+4], ebx" \
209 "mov es:[di+8], ecx" \
210 "mov es:[di+12], edx" \
211 parm [es di] [dx ax] modify [bx cx dx]
212
213#endif
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