VirtualBox

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

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

*: scm --update-copyright-year

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