VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/biosint.h@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 22 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: 9.5 KB
Line 
1/* $Id: biosint.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * PC BIOS - BIOS internal definitions.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 * --------------------------------------------------------------------
27 *
28 * This code is based on:
29 *
30 * ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
31 *
32 * Copyright (C) 2002 MandrakeSoft S.A.
33 *
34 * MandrakeSoft S.A.
35 * 43, rue d'Aboukir
36 * 75002 Paris - France
37 * http://www.linux-mandrake.com/
38 * http://www.mandrakesoft.com/
39 *
40 * This library is free software; you can redistribute it and/or
41 * modify it under the terms of the GNU Lesser General Public
42 * License as published by the Free Software Foundation; either
43 * version 2 of the License, or (at your option) any later version.
44 *
45 * This library is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
48 * Lesser General Public License for more details.
49 *
50 * You should have received a copy of the GNU Lesser General Public
51 * License along with this library; if not, write to the Free Software
52 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
53 *
54 */
55
56/*
57 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
58 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
59 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
60 * a choice of LGPL license versions is made available with the language indicating
61 * that LGPLv2 or any later version may be used, or where a choice of which version
62 * of the LGPL is applied is otherwise unspecified.
63 */
64
65#ifndef VBOX_INCLUDED_SRC_PC_BIOS_biosint_h
66#define VBOX_INCLUDED_SRC_PC_BIOS_biosint_h
67#ifndef RT_WITHOUT_PRAGMA_ONCE
68# pragma once
69#endif
70
71/* Compile-time assertion macro. */
72#define ct_assert(a) extern int ct_ass_arr[!!(a) == 1];
73
74/* For functions called from assembly code. */
75#define BIOSCALL __cdecl
76
77#define BX_ELTORITO_BOOT 1
78#define BX_PCIBIOS 1
79#define BX_USE_PS2_MOUSE 1
80#define BX_APM 1
81
82#ifndef DEBUG_ATA
83# define DEBUG_ATA 0
84#endif
85#ifdef DEBUG_AHCI
86# define DEBUG_AHCI 0
87#endif
88#ifndef DEBUG_SCSI
89# define DEBUG_SCSI 0
90#endif
91#ifndef DEBUG_CD_BOOT
92# define DEBUG_CD_BOOT 0
93#endif
94#ifndef DEBUG_ELTORITO
95# define DEBUG_ELTORITO 0
96#endif
97#ifndef DEBUG_INT13_HD
98# define DEBUG_INT13_HD 0
99#endif
100#ifndef DEBUG_INT13_FL
101# define DEBUG_INT13_FL 0
102#endif
103#ifndef DEBUG_INT13_CD
104# define DEBUG_INT13_CD 0
105#endif
106#ifndef DEBUG_INT15
107# define DEBUG_INT15 0
108#endif
109#ifndef DEBUG_INT15_MS
110# define DEBUG_INT15_MS 0
111#endif
112#ifndef DEBUG_INT16
113# define DEBUG_INT16 0
114#endif
115#ifndef DEBUG_INT1A
116# define DEBUG_INT1A 0
117#endif
118#ifndef DEBUG_INT74
119# define DEBUG_INT74 0
120#endif
121#ifndef DEBUG_PCI
122# define DEBUG_PCI 0
123#endif
124#ifndef DEBUG_APM
125# define DEBUG_APM 0
126#endif
127#ifndef DEBUG_POST
128# define DEBUG_POST 0
129#endif
130
131#define FP_OFF(p) ((unsigned)(p))
132#define FP_SEG(p) ((unsigned)((unsigned long)(void __far*)(p) >> 16))
133#define MK_FP(s,o) (((unsigned short)(s)):>((void __near *)(o)))
134
135typedef struct {
136 union {
137 struct {
138 uint16_t di, si, bp, sp;
139 uint16_t bx, dx, cx, ax;
140 } r16;
141 struct {
142 uint16_t filler[4];
143 uint8_t bl, bh, dl, dh, cl, ch, al, ah;
144 } r8;
145 } u;
146} pusha_regs_t;
147
148typedef struct {
149 union {
150 struct {
151 uint32_t edi, esi, ebp, esp;
152 uint32_t ebx, edx, ecx, eax;
153 } r32;
154 struct {
155 uint16_t di, filler1, si, filler2, bp, filler3, sp, filler4;
156 uint16_t bx, filler5, dx, filler6, cx, filler7, ax, filler8;
157 } r16;
158 struct {
159 uint32_t filler[4];
160 uint8_t bl, bh;
161 uint16_t filler1;
162 uint8_t dl, dh;
163 uint16_t filler2;
164 uint8_t cl, ch;
165 uint16_t filler3;
166 uint8_t al, ah;
167 uint16_t filler4;
168 } r8;
169 } u;
170} pushad_regs_t;
171
172typedef struct {
173 union {
174 struct {
175 uint16_t flags;
176 } r16;
177 struct {
178 uint8_t flagsl;
179 uint8_t flagsh;
180 } r8;
181 } u;
182} flags_t;
183
184typedef struct {
185 uint16_t ip;
186 uint16_t cs;
187 flags_t flags;
188} iret_addr_t;
189
190typedef struct {
191 uint16_t ds;
192 uint16_t es;
193 pusha_regs_t gr;
194 iret_addr_t ra;
195} disk_regs_t;
196
197typedef struct {
198 pusha_regs_t gr;
199 uint16_t es;
200 uint16_t ds;
201 uint16_t ifl;
202 iret_addr_t ra;
203} kbd_regs_t;
204
205typedef struct {
206 pusha_regs_t gr;
207 uint16_t es;
208 uint16_t ds;
209 flags_t fl;
210} sys_regs_t;
211
212typedef struct {
213 pushad_regs_t gr;
214 uint16_t es;
215 uint16_t ds;
216 flags_t fl;
217} sys32_regs_t;
218
219typedef struct {
220 pusha_regs_t gr;
221 iret_addr_t ra;
222} i1apci_regs_t;
223
224
225#define SetCF(x) x.u.r8.flagsl |= 0x01
226#define SetZF(x) x.u.r8.flagsl |= 0x40
227#define ClearCF(x) x.u.r8.flagsl &= 0xfe
228#define ClearZF(x) x.u.r8.flagsl &= 0xbf
229#define GetCF(x) (x.u.r8.flagsl & 0x01)
230
231#define SET_AL(val8) AX = ((AX & 0xff00) | (val8))
232#define SET_BL(val8) BX = ((BX & 0xff00) | (val8))
233#define SET_CL(val8) CX = ((CX & 0xff00) | (val8))
234#define SET_DL(val8) DX = ((DX & 0xff00) | (val8))
235#define SET_AH(val8) AX = ((AX & 0x00ff) | ((val8) << 8))
236#define SET_BH(val8) BX = ((BX & 0x00ff) | ((val8) << 8))
237#define SET_CH(val8) CX = ((CX & 0x00ff) | ((val8) << 8))
238#define SET_DH(val8) DX = ((DX & 0x00ff) | ((val8) << 8))
239
240#define GET_AL() ( AX & 0x00ff )
241#define GET_BL() ( BX & 0x00ff )
242#define GET_CL() ( CX & 0x00ff )
243#define GET_DL() ( DX & 0x00ff )
244#define GET_AH() ( AX >> 8 )
245#define GET_BH() ( BX >> 8 )
246#define GET_CH() ( CX >> 8 )
247#define GET_DH() ( DX >> 8 )
248
249#define GET_ELDL() ( ELDX & 0x00ff )
250#define GET_ELDH() ( ELDX >> 8 )
251
252#define SET_CF() FLAGS |= 0x0001
253#define CLEAR_CF() FLAGS &= 0xfffe
254#define GET_CF() (FLAGS & 0x0001)
255
256#define SET_ZF() FLAGS |= 0x0040
257#define CLEAR_ZF() FLAGS &= 0xffbf
258#define GET_ZF() (FLAGS & 0x0040)
259
260#define SET_IF() FLAGS |= 0x0200
261
262typedef unsigned short bx_bool;
263
264#define BX_VIRTUAL_PORTS 1 /* normal output to Bochs ports */
265#define BX_DEBUG_SERIAL 0 /* output to COM1 */
266
267#define BIOS_PRINTF_HALT 1
268#define BIOS_PRINTF_SCREEN 2
269#define BIOS_PRINTF_INFO 4
270#define BIOS_PRINTF_DEBUG 8
271#define BIOS_PRINTF_ALL (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO)
272#define BIOS_PRINTF_DEBHALT (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO | BIOS_PRINTF_HALT)
273
274extern const char bios_prefix_string[];
275extern void bios_printf(uint16_t action, const char *s, ...);
276extern void put_str(uint16_t action, const char __far *s);
277extern void put_str_near(uint16_t action, const char __near *s);
278extern uint8_t inb_cmos(uint8_t cmos_reg);
279extern void outb_cmos(uint8_t cmos_reg, uint8_t val);
280extern uint16_t get_cmos_word(uint8_t idxFirst);
281extern uint16_t cdrom_boot(void);
282extern void show_logo(void);
283extern void delay_boot(uint16_t secs);
284extern bx_bool set_enable_a20(bx_bool val);
285
286#define printf(...) bios_printf(BIOS_PRINTF_SCREEN, __VA_ARGS__)
287
288// Defines the output macros.
289// BX_DEBUG goes to INFO port until we can easily choose debug info on a
290// per-device basis. Debug info are sent only in debug mode
291#define DEBUG_ROMBIOS 1
292#if DEBUG_ROMBIOS
293# define BX_DEBUG(...) bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__)
294#else
295# define BX_DEBUG(...)
296#endif
297#ifdef VBOX
298#define BX_INFO(...) do { put_str(BIOS_PRINTF_INFO, bios_prefix_string); bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__); } while (0)
299#define BX_INFO_CON(...)do { put_str(BIOS_PRINTF_INFO, bios_prefix_string); bios_printf(BIOS_PRINTF_ALL, __VA_ARGS__); } while (0)
300#else /* !VBOX */
301#define BX_INFO(...) bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__)
302#endif /* !VBOX */
303#define BX_PANIC(...) bios_printf(BIOS_PRINTF_DEBHALT, __VA_ARGS__)
304
305uint16_t pci16_find_device(uint32_t search_item, uint16_t index, int search_class, int ignore_if);
306
307/* Because we don't tell the recompiler when guest physical memory
308 * is written, it can incorrectly cache guest code overwritten by
309 * DMA (bus master or not). We just re-write the memory block to flush
310 * any of its caches. This is not exactly efficient, but works!
311 */
312#define DMA_WORKAROUND 1
313
314/* Random hardware-related definitions. */
315
316#define PIC_MASTER 0x20
317#define PIC_MASTER_MASK 0x21
318#define PIC_SLAVE 0xA0
319#define PIC_SLAVE_MASK 0xA1
320#define PIC_CMD_EOI 0x20
321#define PIC_CMD_RD_ISR 0x0B
322#define PIC_CMD_INIT 0x11
323
324#endif /* !VBOX_INCLUDED_SRC_PC_BIOS_biosint_h */
325
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