VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/bios.c@ 46757

Last change on this file since 46757 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

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