VirtualBox

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

Last change on this file since 42532 was 42532, checked in by vboxsync, 13 years ago

BIOS: Tiny logging improvement.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/*
2 * Copyright (C) 2006-2011 Oracle Corporation
3 *
4 * This file is part of VirtualBox Open Source Edition (OSE), as
5 * available from http://www.virtualbox.org. This file is free software;
6 * you can redistribute it and/or modify it under the terms of the GNU
7 * General Public License (GPL) as published by the Free Software
8 * Foundation, in version 2 as it comes in the "COPYING" file of the
9 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11 * --------------------------------------------------------------------
12 *
13 * This code is based on:
14 *
15 * ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
16 *
17 * Copyright (C) 2002 MandrakeSoft S.A.
18 *
19 * MandrakeSoft S.A.
20 * 43, rue d'Aboukir
21 * 75002 Paris - France
22 * http://www.linux-mandrake.com/
23 * http://www.mandrakesoft.com/
24 *
25 * This library is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU Lesser General Public
27 * License as published by the Free Software Foundation; either
28 * version 2 of the License, or (at your option) any later version.
29 *
30 * This library is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 * Lesser General Public License for more details.
34 *
35 * You should have received a copy of the GNU Lesser General Public
36 * License along with this library; if not, write to the Free Software
37 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
38 *
39 */
40
41
42/* Compile-time assertion macro. */
43#define ct_assert(a) extern int ct_ass_arr[!!(a) == 1];
44
45/* For functions called from assembly code. */
46#define BIOSCALL __cdecl
47
48#define BX_ELTORITO_BOOT 1
49#define BX_PCIBIOS 1
50#define BX_USE_PS2_MOUSE 1
51#define BX_APM 1
52
53#define DEBUG_ATA 0
54#define DEBUG_AHCI 0
55#define DEBUG_CD_BOOT 0
56#define DEBUG_ELTORITO 0
57#define DEBUG_INT13_HD 0
58#define DEBUG_INT13_FL 0
59#define DEBUG_INT13_CD 0
60#define DEBUG_INT15 0
61#define DEBUG_INT15_MS 0
62#define DEBUG_INT16 0
63#define DEBUG_INT1A 0
64#define DEBUG_INT74 0
65#define DEBUG_PCI 0
66
67#define FP_OFF(p) ((unsigned)(p))
68#define FP_SEG(p) ((unsigned)((unsigned long)(void __far*)(p) >> 16))
69#define MK_FP(s,o) (((unsigned short)(s)):>((void __near *)(o)))
70
71typedef struct {
72 union {
73 struct {
74 uint16_t di, si, bp, sp;
75 uint16_t bx, dx, cx, ax;
76 } r16;
77 struct {
78 uint16_t filler[4];
79 uint8_t bl, bh, dl, dh, cl, ch, al, ah;
80 } r8;
81 } u;
82} pusha_regs_t;
83
84typedef struct {
85 union {
86 struct {
87 uint32_t edi, esi, ebp, esp;
88 uint32_t ebx, edx, ecx, eax;
89 } r32;
90 struct {
91 uint16_t di, filler1, si, filler2, bp, filler3, sp, filler4;
92 uint16_t bx, filler5, dx, filler6, cx, filler7, ax, filler8;
93 } r16;
94 struct {
95 uint32_t filler[4];
96 uint8_t bl, bh;
97 uint16_t filler1;
98 uint8_t dl, dh;
99 uint16_t filler2;
100 uint8_t cl, ch;
101 uint16_t filler3;
102 uint8_t al, ah;
103 uint16_t filler4;
104 } r8;
105 } u;
106} pushad_regs_t;
107
108typedef struct {
109 union {
110 struct {
111 uint16_t flags;
112 } r16;
113 struct {
114 uint8_t flagsl;
115 uint8_t flagsh;
116 } r8;
117 } u;
118} flags_t;
119
120typedef struct {
121 uint16_t ip;
122 uint16_t cs;
123 flags_t flags;
124} iret_addr_t;
125
126typedef struct {
127 uint16_t ds;
128 uint16_t es;
129 pusha_regs_t gr;
130 iret_addr_t ra;
131} disk_regs_t;
132
133typedef struct {
134 pusha_regs_t gr;
135 uint16_t es;
136 uint16_t ds;
137 iret_addr_t ra;
138} kbd_regs_t;
139
140typedef struct {
141 pusha_regs_t gr;
142 uint16_t es;
143 uint16_t ds;
144 flags_t fl;
145} sys_regs_t;
146
147typedef struct {
148 pushad_regs_t gr;
149 uint16_t es;
150 uint16_t ds;
151 flags_t fl;
152} sys32_regs_t;
153
154typedef struct {
155 pusha_regs_t gr;
156 iret_addr_t ra;
157} i1apci_regs_t;
158
159
160#define SetCF(x) x.u.r8.flagsl |= 0x01
161#define SetZF(x) x.u.r8.flagsl |= 0x40
162#define ClearCF(x) x.u.r8.flagsl &= 0xfe
163#define ClearZF(x) x.u.r8.flagsl &= 0xbf
164#define GetCF(x) (x.u.r8.flagsl & 0x01)
165
166#define SET_AL(val8) AX = ((AX & 0xff00) | (val8))
167#define SET_BL(val8) BX = ((BX & 0xff00) | (val8))
168#define SET_CL(val8) CX = ((CX & 0xff00) | (val8))
169#define SET_DL(val8) DX = ((DX & 0xff00) | (val8))
170#define SET_AH(val8) AX = ((AX & 0x00ff) | ((val8) << 8))
171#define SET_BH(val8) BX = ((BX & 0x00ff) | ((val8) << 8))
172#define SET_CH(val8) CX = ((CX & 0x00ff) | ((val8) << 8))
173#define SET_DH(val8) DX = ((DX & 0x00ff) | ((val8) << 8))
174
175#define GET_AL() ( AX & 0x00ff )
176#define GET_BL() ( BX & 0x00ff )
177#define GET_CL() ( CX & 0x00ff )
178#define GET_DL() ( DX & 0x00ff )
179#define GET_AH() ( AX >> 8 )
180#define GET_BH() ( BX >> 8 )
181#define GET_CH() ( CX >> 8 )
182#define GET_DH() ( DX >> 8 )
183
184#define GET_ELDL() ( ELDX & 0x00ff )
185#define GET_ELDH() ( ELDX >> 8 )
186
187#define SET_CF() FLAGS |= 0x0001
188#define CLEAR_CF() FLAGS &= 0xfffe
189#define GET_CF() (FLAGS & 0x0001)
190
191#define SET_ZF() FLAGS |= 0x0040
192#define CLEAR_ZF() FLAGS &= 0xffbf
193#define GET_ZF() (FLAGS & 0x0040)
194
195#define SET_IF() FLAGS |= 0x0200
196
197typedef unsigned short bx_bool;
198
199#define BX_VIRTUAL_PORTS 1 /* normal output to Bochs ports */
200#define BX_DEBUG_SERIAL 0 /* output to COM1 */
201
202#define BIOS_PRINTF_HALT 1
203#define BIOS_PRINTF_SCREEN 2
204#define BIOS_PRINTF_INFO 4
205#define BIOS_PRINTF_DEBUG 8
206#define BIOS_PRINTF_ALL (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO)
207#define BIOS_PRINTF_DEBHALT (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO | BIOS_PRINTF_HALT)
208
209extern const char bios_prefix_string[];
210extern void bios_printf(uint16_t action, const char *s, ...);
211extern void put_str(uint16_t action, const char __far *s);
212extern void put_str_near(uint16_t action, const char __near *s);
213extern uint8_t inb_cmos(uint8_t cmos_reg);
214extern void outb_cmos(uint8_t cmos_reg, uint8_t val);
215extern uint16_t cdrom_boot(void);
216extern void show_logo(void);
217extern void delay_boot(uint16_t secs);
218extern bx_bool set_enable_a20(bx_bool val);
219
220#define printf(...) bios_printf(BIOS_PRINTF_SCREEN, __VA_ARGS__)
221
222// Defines the output macros.
223// BX_DEBUG goes to INFO port until we can easily choose debug info on a
224// per-device basis. Debug info are sent only in debug mode
225#define DEBUG_ROMBIOS 1
226#if DEBUG_ROMBIOS
227# define BX_DEBUG(...) bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__)
228#else
229# define BX_DEBUG(...)
230#endif
231#ifdef VBOX
232#define BX_INFO(...) do { put_str(BIOS_PRINTF_INFO, bios_prefix_string); bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__); } while (0)
233#else /* !VBOX */
234#define BX_INFO(...) bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__)
235#endif /* !VBOX */
236#define BX_PANIC(...) bios_printf(BIOS_PRINTF_DEBHALT, __VA_ARGS__)
237
238/* Because we don't tell the recompiler when guest physical memory
239 * is written, it can incorrectly cache guest code overwritten by
240 * DMA (bus master or not). We just re-write the memory block to flush
241 * any of its caches. This is not exactly efficient, but works!
242 */
243#define DMA_WORKAROUND 1
244
245/* Random hardware-related definitions. */
246
247#define PIC_MASTER 0x20
248#define PIC_MASTER_MASK 0x21
249#define PIC_SLAVE 0xA0
250#define PIC_SLAVE_MASK 0xA1
251#define PIC_CMD_EOI 0x20
252#define PIC_CMD_RD_ISR 0x0B
253#define PIC_CMD_INIT 0x11
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