VirtualBox

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

Last change on this file since 42975 was 42935, checked in by vboxsync, 12 years ago

Forgotten logging.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 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#define DEBUG_APM 0
67
68#define FP_OFF(p) ((unsigned)(p))
69#define FP_SEG(p) ((unsigned)((unsigned long)(void __far*)(p) >> 16))
70#define MK_FP(s,o) (((unsigned short)(s)):>((void __near *)(o)))
71
72typedef struct {
73 union {
74 struct {
75 uint16_t di, si, bp, sp;
76 uint16_t bx, dx, cx, ax;
77 } r16;
78 struct {
79 uint16_t filler[4];
80 uint8_t bl, bh, dl, dh, cl, ch, al, ah;
81 } r8;
82 } u;
83} pusha_regs_t;
84
85typedef struct {
86 union {
87 struct {
88 uint32_t edi, esi, ebp, esp;
89 uint32_t ebx, edx, ecx, eax;
90 } r32;
91 struct {
92 uint16_t di, filler1, si, filler2, bp, filler3, sp, filler4;
93 uint16_t bx, filler5, dx, filler6, cx, filler7, ax, filler8;
94 } r16;
95 struct {
96 uint32_t filler[4];
97 uint8_t bl, bh;
98 uint16_t filler1;
99 uint8_t dl, dh;
100 uint16_t filler2;
101 uint8_t cl, ch;
102 uint16_t filler3;
103 uint8_t al, ah;
104 uint16_t filler4;
105 } r8;
106 } u;
107} pushad_regs_t;
108
109typedef struct {
110 union {
111 struct {
112 uint16_t flags;
113 } r16;
114 struct {
115 uint8_t flagsl;
116 uint8_t flagsh;
117 } r8;
118 } u;
119} flags_t;
120
121typedef struct {
122 uint16_t ip;
123 uint16_t cs;
124 flags_t flags;
125} iret_addr_t;
126
127typedef struct {
128 uint16_t ds;
129 uint16_t es;
130 pusha_regs_t gr;
131 iret_addr_t ra;
132} disk_regs_t;
133
134typedef struct {
135 pusha_regs_t gr;
136 uint16_t es;
137 uint16_t ds;
138 iret_addr_t ra;
139} kbd_regs_t;
140
141typedef struct {
142 pusha_regs_t gr;
143 uint16_t es;
144 uint16_t ds;
145 flags_t fl;
146} sys_regs_t;
147
148typedef struct {
149 pushad_regs_t gr;
150 uint16_t es;
151 uint16_t ds;
152 flags_t fl;
153} sys32_regs_t;
154
155typedef struct {
156 pusha_regs_t gr;
157 iret_addr_t ra;
158} i1apci_regs_t;
159
160
161#define SetCF(x) x.u.r8.flagsl |= 0x01
162#define SetZF(x) x.u.r8.flagsl |= 0x40
163#define ClearCF(x) x.u.r8.flagsl &= 0xfe
164#define ClearZF(x) x.u.r8.flagsl &= 0xbf
165#define GetCF(x) (x.u.r8.flagsl & 0x01)
166
167#define SET_AL(val8) AX = ((AX & 0xff00) | (val8))
168#define SET_BL(val8) BX = ((BX & 0xff00) | (val8))
169#define SET_CL(val8) CX = ((CX & 0xff00) | (val8))
170#define SET_DL(val8) DX = ((DX & 0xff00) | (val8))
171#define SET_AH(val8) AX = ((AX & 0x00ff) | ((val8) << 8))
172#define SET_BH(val8) BX = ((BX & 0x00ff) | ((val8) << 8))
173#define SET_CH(val8) CX = ((CX & 0x00ff) | ((val8) << 8))
174#define SET_DH(val8) DX = ((DX & 0x00ff) | ((val8) << 8))
175
176#define GET_AL() ( AX & 0x00ff )
177#define GET_BL() ( BX & 0x00ff )
178#define GET_CL() ( CX & 0x00ff )
179#define GET_DL() ( DX & 0x00ff )
180#define GET_AH() ( AX >> 8 )
181#define GET_BH() ( BX >> 8 )
182#define GET_CH() ( CX >> 8 )
183#define GET_DH() ( DX >> 8 )
184
185#define GET_ELDL() ( ELDX & 0x00ff )
186#define GET_ELDH() ( ELDX >> 8 )
187
188#define SET_CF() FLAGS |= 0x0001
189#define CLEAR_CF() FLAGS &= 0xfffe
190#define GET_CF() (FLAGS & 0x0001)
191
192#define SET_ZF() FLAGS |= 0x0040
193#define CLEAR_ZF() FLAGS &= 0xffbf
194#define GET_ZF() (FLAGS & 0x0040)
195
196#define SET_IF() FLAGS |= 0x0200
197
198typedef unsigned short bx_bool;
199
200#define BX_VIRTUAL_PORTS 1 /* normal output to Bochs ports */
201#define BX_DEBUG_SERIAL 0 /* output to COM1 */
202
203#define BIOS_PRINTF_HALT 1
204#define BIOS_PRINTF_SCREEN 2
205#define BIOS_PRINTF_INFO 4
206#define BIOS_PRINTF_DEBUG 8
207#define BIOS_PRINTF_ALL (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO)
208#define BIOS_PRINTF_DEBHALT (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO | BIOS_PRINTF_HALT)
209
210extern const char bios_prefix_string[];
211extern void bios_printf(uint16_t action, const char *s, ...);
212extern void put_str(uint16_t action, const char __far *s);
213extern void put_str_near(uint16_t action, const char __near *s);
214extern uint8_t inb_cmos(uint8_t cmos_reg);
215extern void outb_cmos(uint8_t cmos_reg, uint8_t val);
216extern uint16_t cdrom_boot(void);
217extern void show_logo(void);
218extern void delay_boot(uint16_t secs);
219extern bx_bool set_enable_a20(bx_bool val);
220
221#define printf(...) bios_printf(BIOS_PRINTF_SCREEN, __VA_ARGS__)
222
223// Defines the output macros.
224// BX_DEBUG goes to INFO port until we can easily choose debug info on a
225// per-device basis. Debug info are sent only in debug mode
226#define DEBUG_ROMBIOS 1
227#if DEBUG_ROMBIOS
228# define BX_DEBUG(...) bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__)
229#else
230# define BX_DEBUG(...)
231#endif
232#ifdef VBOX
233#define BX_INFO(...) do { put_str(BIOS_PRINTF_INFO, bios_prefix_string); bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__); } while (0)
234#else /* !VBOX */
235#define BX_INFO(...) bios_printf(BIOS_PRINTF_INFO, __VA_ARGS__)
236#endif /* !VBOX */
237#define BX_PANIC(...) bios_printf(BIOS_PRINTF_DEBHALT, __VA_ARGS__)
238
239/* Because we don't tell the recompiler when guest physical memory
240 * is written, it can incorrectly cache guest code overwritten by
241 * DMA (bus master or not). We just re-write the memory block to flush
242 * any of its caches. This is not exactly efficient, but works!
243 */
244#define DMA_WORKAROUND 1
245
246/* Random hardware-related definitions. */
247
248#define PIC_MASTER 0x20
249#define PIC_MASTER_MASK 0x21
250#define PIC_SLAVE 0xA0
251#define PIC_SLAVE_MASK 0xA1
252#define PIC_CMD_EOI 0x20
253#define PIC_CMD_RD_ISR 0x0B
254#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