VirtualBox

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

Last change on this file since 56292 was 56292, checked in by vboxsync, 10 years ago

Devices: Updated (C) year.

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