1 | /** @file
|
---|
2 | * Inline routines for Watcom C.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2010-2022 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 |
|
---|
17 | #ifndef VBOX_INCLUDED_SRC_Graphics_BIOS_inlines_h
|
---|
18 | #define VBOX_INCLUDED_SRC_Graphics_BIOS_inlines_h
|
---|
19 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
20 | # pragma once
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | extern unsigned inp(unsigned port);
|
---|
24 | extern unsigned outp(unsigned port, unsigned value);
|
---|
25 | extern unsigned inpw(unsigned port);
|
---|
26 | extern unsigned outpw(unsigned port, unsigned value);
|
---|
27 | #pragma intrinsic(inp,outp,inpw,outpw)
|
---|
28 | #define inb(p) inp(p)
|
---|
29 | #define outb(p, v) outp(p, v)
|
---|
30 | #define inw(p) inpw(p)
|
---|
31 | #define outw(p, v) outpw(p, v)
|
---|
32 |
|
---|
33 | /* Far byte/word/dword access routines. */
|
---|
34 |
|
---|
35 | inline uint8_t read_byte(uint16_t seg, uint16_t offset)
|
---|
36 | {
|
---|
37 | return( *(seg:>(uint8_t *)offset) );
|
---|
38 | }
|
---|
39 |
|
---|
40 | inline void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
|
---|
41 | {
|
---|
42 | *(seg:>(uint8_t *)offset) = data;
|
---|
43 | }
|
---|
44 |
|
---|
45 | inline uint16_t read_word(uint16_t seg, uint16_t offset)
|
---|
46 | {
|
---|
47 | return( *(seg:>(uint16_t *)offset) );
|
---|
48 | }
|
---|
49 |
|
---|
50 | inline void write_word(uint16_t seg, uint16_t offset, uint16_t data)
|
---|
51 | {
|
---|
52 | *(seg:>(uint16_t *)offset) = data;
|
---|
53 | }
|
---|
54 |
|
---|
55 | inline uint32_t read_dword(uint16_t seg, uint16_t offset)
|
---|
56 | {
|
---|
57 | return( *(seg:>(uint32_t *)offset) );
|
---|
58 | }
|
---|
59 |
|
---|
60 | inline void write_dword(uint16_t seg, uint16_t offset, uint32_t data)
|
---|
61 | {
|
---|
62 | *(seg:>(uint32_t *)offset) = data;
|
---|
63 | }
|
---|
64 |
|
---|
65 | void int_enable(void);
|
---|
66 | #pragma aux int_enable = "sti" modify exact [] nomemory;
|
---|
67 |
|
---|
68 | void int_disable(void);
|
---|
69 | #pragma aux int_disable = "cli" modify exact [] nomemory;
|
---|
70 |
|
---|
71 | uint16_t int_query(void);
|
---|
72 | #pragma aux int_query = \
|
---|
73 | "pushf" \
|
---|
74 | "pop ax" \
|
---|
75 | value [ax] modify exact [ax] nomemory;
|
---|
76 |
|
---|
77 | void int_restore(uint16_t old_flags);
|
---|
78 | #pragma aux int_restore = \
|
---|
79 | "push ax" \
|
---|
80 | "popf" \
|
---|
81 | parm [ax] modify exact [] nomemory;
|
---|
82 |
|
---|
83 | void halt(void);
|
---|
84 | #pragma aux halt = "hlt" modify exact [] nomemory;
|
---|
85 |
|
---|
86 | void halt_forever(void);
|
---|
87 | #pragma aux halt_forever = \
|
---|
88 | "forever:" \
|
---|
89 | "hlt" \
|
---|
90 | "jmp forever" \
|
---|
91 | modify exact [] nomemory aborts;
|
---|
92 |
|
---|
93 | void 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 | int repe_cmpsb(void __far *d, void __far *s, int nbytes);
|
---|
102 | #pragma aux repe_cmpsb = \
|
---|
103 | "push ds" \
|
---|
104 | "mov ds, dx" \
|
---|
105 | "repe cmpsb" \
|
---|
106 | "pop ds" \
|
---|
107 | "mov ax, 0" \
|
---|
108 | "jz match" \
|
---|
109 | "inc al" \
|
---|
110 | "match:" \
|
---|
111 | parm [es di] [dx si] [cx] value [ax] modify nomemory;
|
---|
112 |
|
---|
113 | char __far *rep_insb(char __far *buffer, unsigned nbytes, unsigned port);
|
---|
114 | #pragma aux rep_insb = ".286" "rep insb" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
|
---|
115 |
|
---|
116 | char __far *rep_insw(char __far *buffer, unsigned nwords, unsigned port);
|
---|
117 | #pragma aux rep_insw = ".286" "rep insw" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
|
---|
118 |
|
---|
119 | char __far *rep_outsb(char __far *buffer, unsigned nbytes, unsigned port);
|
---|
120 | #pragma aux rep_outsb = ".286" "rep outs dx,byte ptr es:[si]" parm [es si] [cx] [dx] value [es si] modify exact [cx si];
|
---|
121 |
|
---|
122 | char __far *rep_outsw(char __far *buffer, unsigned nwords, unsigned port);
|
---|
123 | #pragma aux rep_outsw = ".286" "rep outs dx,word ptr es:[si]" parm [es si] [cx] [dx] value [es si] modify exact [cx si];
|
---|
124 |
|
---|
125 | uint16_t __far swap_16(uint16_t val);
|
---|
126 | #pragma aux swap_16 = "xchg ah,al" parm [ax] value [ax] modify exact [ax] nomemory;
|
---|
127 |
|
---|
128 | uint32_t __far 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 |
|
---|
135 | extern void memsetb(uint16_t seg, uint16_t offset, uint16_t value, uint16_t count);
|
---|
136 | #pragma aux memsetb = \
|
---|
137 | "jcxz no_copy" \
|
---|
138 | "rep stosb" \
|
---|
139 | "no_copy:" \
|
---|
140 | parm [es] [di] [ax] [cx];
|
---|
141 |
|
---|
142 | extern void memsetw(uint16_t seg, uint16_t offset, uint16_t value, uint16_t count);
|
---|
143 | #pragma aux memsetw = \
|
---|
144 | "jcxz no_copy" \
|
---|
145 | "rep stosw" \
|
---|
146 | "no_copy:" \
|
---|
147 | parm [es] [di] [ax] [cx];
|
---|
148 |
|
---|
149 | extern void memcpyb(uint16_t dseg, uint16_t doffset, uint16_t sseg, uint16_t soffset, uint16_t count);
|
---|
150 | #pragma aux memcpyb = \
|
---|
151 | "jcxz no_copy" \
|
---|
152 | "push ds" \
|
---|
153 | "mov ds, dx" \
|
---|
154 | "rep movsb" \
|
---|
155 | "pop ds" \
|
---|
156 | "no_copy:" \
|
---|
157 | parm [es] [di] [dx] [si] [cx];
|
---|
158 |
|
---|
159 | extern void memcpyw(uint16_t dseg, uint16_t doffset, uint16_t sseg, uint16_t soffset, uint16_t count);
|
---|
160 | #pragma aux memcpyw = \
|
---|
161 | "jcxz no_copy" \
|
---|
162 | "push ds" \
|
---|
163 | "mov ds, dx" \
|
---|
164 | "rep movsw" \
|
---|
165 | "pop ds" \
|
---|
166 | "no_copy:" \
|
---|
167 | parm [es] [di] [dx] [si] [cx];
|
---|
168 |
|
---|
169 | #endif /* !VBOX_INCLUDED_SRC_Graphics_BIOS_inlines_h */
|
---|
170 |
|
---|