1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/** @file
* Inline routines for Watcom C.
*/
/*
* Copyright (C) 2010-2023 Oracle and/or its affiliates.
*
* This file is part of VirtualBox base platform packages, as
* available from https://www.virtualbox.org.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, in version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses>.
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#ifndef VBOX_INCLUDED_SRC_Graphics_BIOS_inlines_h
#define VBOX_INCLUDED_SRC_Graphics_BIOS_inlines_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif
extern unsigned inp(unsigned port);
extern unsigned outp(unsigned port, unsigned value);
extern unsigned inpw(unsigned port);
extern unsigned outpw(unsigned port, unsigned value);
#pragma intrinsic(inp,outp,inpw,outpw)
#define inb(p) inp(p)
#define outb(p, v) outp(p, v)
#define inw(p) inpw(p)
#define outw(p, v) outpw(p, v)
/* Far byte/word/dword access routines. */
inline uint8_t read_byte(uint16_t seg, uint16_t offset)
{
return( *(seg:>(uint8_t *)offset) );
}
inline void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
{
*(seg:>(uint8_t *)offset) = data;
}
inline uint16_t read_word(uint16_t seg, uint16_t offset)
{
return( *(seg:>(uint16_t *)offset) );
}
inline void write_word(uint16_t seg, uint16_t offset, uint16_t data)
{
*(seg:>(uint16_t *)offset) = data;
}
inline uint32_t read_dword(uint16_t seg, uint16_t offset)
{
return( *(seg:>(uint32_t *)offset) );
}
inline void write_dword(uint16_t seg, uint16_t offset, uint32_t data)
{
*(seg:>(uint32_t *)offset) = data;
}
void int_enable(void);
#pragma aux int_enable = "sti" modify exact [] nomemory;
void int_disable(void);
#pragma aux int_disable = "cli" modify exact [] nomemory;
uint16_t int_query(void);
#pragma aux int_query = \
"pushf" \
"pop ax" \
value [ax] modify exact [ax] nomemory;
void int_restore(uint16_t old_flags);
#pragma aux int_restore = \
"push ax" \
"popf" \
parm [ax] modify exact [] nomemory;
void halt(void);
#pragma aux halt = "hlt" modify exact [] nomemory;
void halt_forever(void);
#pragma aux halt_forever = \
"forever:" \
"hlt" \
"jmp forever" \
modify exact [] nomemory aborts;
void rep_movsw(void __far *d, void __far *s, int nwords);
#pragma aux rep_movsw = \
"push ds" \
"mov ds, dx" \
"rep movsw" \
"pop ds" \
parm [es di] [dx si] [cx];
int repe_cmpsb(void __far *d, void __far *s, int nbytes);
#pragma aux repe_cmpsb = \
"push ds" \
"mov ds, dx" \
"repe cmpsb" \
"pop ds" \
"mov ax, 0" \
"jz match" \
"inc al" \
"match:" \
parm [es di] [dx si] [cx] value [ax] modify nomemory;
char __far *rep_insb(char __far *buffer, unsigned nbytes, unsigned port);
#pragma aux rep_insb = ".286" "rep insb" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
char __far *rep_insw(char __far *buffer, unsigned nwords, unsigned port);
#pragma aux rep_insw = ".286" "rep insw" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
char __far *rep_outsb(char __far *buffer, unsigned nbytes, unsigned port);
#pragma aux rep_outsb = ".286" "rep outs dx,byte ptr es:[si]" parm [es si] [cx] [dx] value [es si] modify exact [cx si];
char __far *rep_outsw(char __far *buffer, unsigned nwords, unsigned port);
#pragma aux rep_outsw = ".286" "rep outs dx,word ptr es:[si]" parm [es si] [cx] [dx] value [es si] modify exact [cx si];
uint16_t __far swap_16(uint16_t val);
#pragma aux swap_16 = "xchg ah,al" parm [ax] value [ax] modify exact [ax] nomemory;
uint32_t __far swap_32(uint32_t val);
#pragma aux swap_32 = \
"xchg ah, al" \
"xchg dh, dl" \
"xchg ax, dx" \
parm [dx ax] value [dx ax] modify exact [dx ax] nomemory;
extern void memsetb(uint16_t seg, uint16_t offset, uint16_t value, uint16_t count);
#pragma aux memsetb = \
"jcxz no_copy" \
"rep stosb" \
"no_copy:" \
parm [es] [di] [ax] [cx];
extern void memsetw(uint16_t seg, uint16_t offset, uint16_t value, uint16_t count);
#pragma aux memsetw = \
"jcxz no_copy" \
"rep stosw" \
"no_copy:" \
parm [es] [di] [ax] [cx];
extern void memcpyb(uint16_t dseg, uint16_t doffset, uint16_t sseg, uint16_t soffset, uint16_t count);
#pragma aux memcpyb = \
"jcxz no_copy" \
"push ds" \
"mov ds, dx" \
"rep movsb" \
"pop ds" \
"no_copy:" \
parm [es] [di] [dx] [si] [cx];
extern void memcpyw(uint16_t dseg, uint16_t doffset, uint16_t sseg, uint16_t soffset, uint16_t count);
#pragma aux memcpyw = \
"jcxz no_copy" \
"push ds" \
"mov ds, dx" \
"rep movsw" \
"pop ds" \
"no_copy:" \
parm [es] [di] [dx] [si] [cx];
#endif /* !VBOX_INCLUDED_SRC_Graphics_BIOS_inlines_h */
|