VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use