VirtualBox

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

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

BIOS-new: Enable interrupts when polling for keyboard input.

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