VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/BIOS/inlines.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use