VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS-new/biosint.h@ 39346

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

Started refactoring disk support.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette