VirtualBox

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

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

Converted system BIOS to Watcom C.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use