VirtualBox

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

Last change on this file since 91942 was 84752, checked in by vboxsync, 4 years ago

BIOS: On boot failure, call into INT 18h and report that to the host through the shutdown interface (see bugref:6549).

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