VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS-new/bios.c@ 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: 5.3 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#include <stdint.h>
43#include "inlines.h"
44#include "biosint.h"
45#include "ebda.h"
46
47static const char bios_cvs_version_string[] = "VirtualBox " VBOX_VERSION_STRING;
48
49uint8_t read_byte(uint16_t seg, uint16_t offset)
50{
51 return( *(seg:>(uint8_t *)offset) );
52}
53
54void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
55{
56 *(seg:>(uint8_t *)offset) = data;
57}
58
59uint16_t read_word(uint16_t seg, uint16_t offset)
60{
61 return( *(seg:>(uint16_t *)offset) );
62}
63
64void write_word(uint16_t seg, uint16_t offset, uint16_t data)
65{
66 *(seg:>(uint16_t *)offset) = data;
67}
68
69uint32_t read_dword(uint16_t seg, uint16_t offset)
70{
71 return( *(seg:>(uint32_t *)offset) );
72}
73
74void write_dword(uint16_t seg, uint16_t offset, uint32_t data)
75{
76 *(seg:>(uint32_t *)offset) = data;
77}
78
79uint8_t inb_cmos(uint8_t cmos_reg)
80{
81 outb(0x70, cmos_reg);
82 return inb(0x71);
83}
84
85void outb_cmos(uint8_t cmos_reg, uint8_t val)
86{
87 outb(0x70, cmos_reg);
88 outb(0x71, val);
89}
90
91void BIOSCALL dummy_isr_function(pusha_regs_t regs, uint16_t es,
92 uint16_t ds, iret_addr_t iret_addr)
93{
94 // Interrupt handler for unexpected hardware interrupts. We have to clear
95 // the PIC because if we don't, the next EOI will clear the wrong interrupt
96 // and all hell will break loose! This routine also masks the unexpected
97 // interrupt so it will generally be called only once for each unexpected
98 // interrupt level.
99 uint8_t isrA, isrB, imr, last_int = 0xFF;
100
101 outb(PIC_MASTER, PIC_CMD_RD_ISR); // Read master ISR
102 isrA = inb(PIC_MASTER);
103 if (isrA) {
104 outb(PIC_SLAVE, PIC_CMD_RD_ISR); // Read slave ISR
105 isrB = inb(PIC_SLAVE);
106 if (isrB) {
107 imr = inb(PIC_SLAVE_MASK);
108 outb(PIC_SLAVE_MASK, imr | isrB ); // Mask this interrupt
109 outb(PIC_SLAVE, PIC_CMD_EOI); // Send EOI on slave PIC
110 } else {
111 imr = inb(PIC_MASTER_MASK);
112 isrA &= 0xFB; // Never mask the cascade interrupt
113 outb(PIC_MASTER_MASK, imr | isrA); // Mask this interrupt
114 }
115 outb(PIC_MASTER, PIC_CMD_EOI); // Send EOI on master PIC
116 last_int = isrA;
117 }
118 write_byte(0x40, 0x6B, last_int); // Write INTR_FLAG
119}
120
121
122void BIOSCALL nmi_handler_msg(void)
123{
124 BX_PANIC("NMI Handler called\n");
125}
126
127void BIOSCALL int18_panic_msg(void)
128{
129 BX_PANIC("INT18: BOOT FAILURE\n");
130}
131
132void BIOSCALL log_bios_start(void)
133{
134#if BX_DEBUG_SERIAL
135 outb(BX_DEBUG_PORT+UART_LCR, 0x03); /* setup for serial logging: 8N1 */
136#endif
137 BX_INFO("%s\n", bios_cvs_version_string);
138}
139
140//@todo: restore
141//#undef VBOX
142
143#define BX_PCIBIOS 1
144#define BX_APPNAME "VirtualBox"
145#define BIOS_BUILD_DATE __DATE__
146//--------------------------------------------------------------------------
147// print_bios_banner
148// displays a the bios version
149//--------------------------------------------------------------------------
150void BIOSCALL print_bios_banner(void)
151{
152#ifdef VBOX
153 // Skip the logo if a warm boot is requested.
154 uint16_t warm_boot = read_word(0x0040,0x0072);
155 write_word(0x0040,0x0072, 0);
156 if (warm_boot == 0x1234)
157 return;
158 /* show graphical logo */
159 show_logo();
160#else /* !VBOX */
161 char *bios_conf;
162
163 /* Avoid using preprocessing directives within macro arguments. */
164 bios_conf =
165#ifdef __WATCOMC__
166 "watcom "
167#endif
168#if BX_APM
169 "apmbios "
170#endif
171#if BX_PCIBIOS
172 "pcibios "
173#endif
174#if BX_ELTORITO_BOOT
175 "eltorito "
176#endif
177#if BX_ROMBIOS32
178 "rombios32 "
179#endif
180 "\n\n";
181
182 printf(BX_APPNAME" BIOS - build: %s\n%s\nOptions: ",
183 BIOS_BUILD_DATE, bios_cvs_version_string);
184 printf(bios_conf, 0);
185#endif /* VBOX */
186}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use