VirtualBox

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

Last change on this file since 71963 was 69501, checked in by vboxsync, 7 years ago

PC/BIOS: Added LGPL disclaimer text where appropriate.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
1/* $Id: bios.c 69501 2017-10-28 16:12:47Z vboxsync $ */
2/** @file
3 * PC BIOS - ???
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 * --------------------------------------------------------------------
17 *
18 * This code is based on:
19 *
20 * ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
21 *
22 * Copyright (C) 2002 MandrakeSoft S.A.
23 *
24 * MandrakeSoft S.A.
25 * 43, rue d'Aboukir
26 * 75002 Paris - France
27 * http://www.linux-mandrake.com/
28 * http://www.mandrakesoft.com/
29 *
30 * This library is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU Lesser General Public
32 * License as published by the Free Software Foundation; either
33 * version 2 of the License, or (at your option) any later version.
34 *
35 * This library is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38 * Lesser General Public License for more details.
39 *
40 * You should have received a copy of the GNU Lesser General Public
41 * License along with this library; if not, write to the Free Software
42 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
43 *
44 */
45
46/*
47 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
48 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
49 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
50 * a choice of LGPL license versions is made available with the language indicating
51 * that LGPLv2 or any later version may be used, or where a choice of which version
52 * of the LGPL is applied is otherwise unspecified.
53 */
54
55
56#include <stdint.h>
57#include "inlines.h"
58#include "biosint.h"
59#ifndef VBOX_VERSION_STRING
60#include <VBox/version.h>
61#endif
62
63static const char bios_cvs_version_string[] = "VirtualBox " VBOX_VERSION_STRING;
64
65uint8_t read_byte(uint16_t seg, uint16_t offset)
66{
67 return( *(seg:>(uint8_t *)offset) );
68}
69
70void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
71{
72 *(seg:>(uint8_t *)offset) = data;
73}
74
75uint16_t read_word(uint16_t seg, uint16_t offset)
76{
77 return( *(seg:>(uint16_t *)offset) );
78}
79
80void write_word(uint16_t seg, uint16_t offset, uint16_t data)
81{
82 *(seg:>(uint16_t *)offset) = data;
83}
84
85uint32_t read_dword(uint16_t seg, uint16_t offset)
86{
87 return( *(seg:>(uint32_t *)offset) );
88}
89
90void write_dword(uint16_t seg, uint16_t offset, uint32_t data)
91{
92 *(seg:>(uint32_t *)offset) = data;
93}
94
95uint8_t inb_cmos(uint8_t cmos_reg)
96{
97 uint8_t cmos_port = 0x70;
98
99 if (cmos_reg >= 0x80)
100 cmos_port += 2;
101 outb(cmos_port, cmos_reg);
102 return inb(cmos_port + 1);
103}
104
105void outb_cmos(uint8_t cmos_reg, uint8_t val)
106{
107 uint8_t cmos_port = 0x70;
108
109 if (cmos_reg >= 0x80)
110 cmos_port += 2;
111 outb(cmos_port, cmos_reg);
112 outb(cmos_port + 1, val);
113}
114
115void BIOSCALL dummy_isr_function(pusha_regs_t regs, uint16_t es,
116 uint16_t ds, iret_addr_t iret_addr)
117{
118 // Interrupt handler for unexpected hardware interrupts. We have to clear
119 // the PIC because if we don't, the next EOI will clear the wrong interrupt
120 // and all hell will break loose! This routine also masks the unexpected
121 // interrupt so it will generally be called only once for each unexpected
122 // interrupt level.
123 uint8_t isrA, isrB, imr, last_int = 0xFF;
124
125 outb(PIC_MASTER, PIC_CMD_RD_ISR); // Read master ISR
126 isrA = inb(PIC_MASTER);
127 if (isrA) {
128 outb(PIC_SLAVE, PIC_CMD_RD_ISR); // Read slave ISR
129 isrB = inb(PIC_SLAVE);
130 if (isrB) {
131 imr = inb(PIC_SLAVE_MASK);
132 outb(PIC_SLAVE_MASK, imr | isrB ); // Mask this interrupt
133 outb(PIC_SLAVE, PIC_CMD_EOI); // Send EOI on slave PIC
134 } else {
135 imr = inb(PIC_MASTER_MASK);
136 isrA &= 0xFB; // Never mask the cascade interrupt
137 outb(PIC_MASTER_MASK, imr | isrA); // Mask this interrupt
138 }
139 outb(PIC_MASTER, PIC_CMD_EOI); // Send EOI on master PIC
140 last_int = isrA;
141 }
142 write_byte(0x40, 0x6B, last_int); // Write INTR_FLAG
143}
144
145
146void BIOSCALL nmi_handler_msg(void)
147{
148 BX_PANIC("NMI Handler called\n");
149}
150
151void BIOSCALL int18_panic_msg(void)
152{
153 BX_PANIC("INT18: BOOT FAILURE\n");
154}
155
156void BIOSCALL log_bios_start(void)
157{
158#if BX_DEBUG_SERIAL
159 outb(BX_DEBUG_PORT+UART_LCR, 0x03); /* setup for serial logging: 8N1 */
160#endif
161 BX_INFO("%s\n", bios_cvs_version_string);
162}
163
164/* Set video mode. */
165void set_mode(uint8_t mode);
166#pragma aux set_mode = \
167 "mov ah, 0" \
168 "int 10h" \
169 parm [al] modify [ax];
170
171/// @todo restore
172//#undef VBOX
173
174#define BX_PCIBIOS 1
175#define BX_APPNAME "VirtualBox"
176#define BIOS_BUILD_DATE __DATE__
177//--------------------------------------------------------------------------
178// print_bios_banner
179// displays a the bios version
180//--------------------------------------------------------------------------
181void BIOSCALL print_bios_banner(void)
182{
183#ifdef VBOX
184 // Skip the logo if a warm boot is requested.
185 uint16_t warm_boot = read_word(0x0040,0x0072);
186 write_word(0x0040,0x0072, 0);
187 if (warm_boot == 0x1234)
188 {
189 /* Only set text mode. */
190 set_mode(3);
191 return;
192 }
193 /* show graphical logo */
194 show_logo();
195#else /* !VBOX */
196 char *bios_conf;
197
198 /* Avoid using preprocessing directives within macro arguments. */
199 bios_conf =
200#ifdef __WATCOMC__
201 "watcom "
202#endif
203#if BX_APM
204 "apmbios "
205#endif
206#if BX_PCIBIOS
207 "pcibios "
208#endif
209#if BX_ELTORITO_BOOT
210 "eltorito "
211#endif
212#if BX_ROMBIOS32
213 "rombios32 "
214#endif
215 "\n\n";
216
217 printf(BX_APPNAME" BIOS - build: %s\n%s\nOptions: ",
218 BIOS_BUILD_DATE, bios_cvs_version_string);
219 printf(bios_conf, 0);
220#endif /* VBOX */
221}
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