DevPcBios.cpp revision e44c3c2cf8408163ddd061cfba5e515e853bd25c
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * DevPcBios - PC BIOS Device.
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * Copyright (C) 2006-2013 Oracle Corporation
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * This file is part of VirtualBox Open Source Edition (OSE), as
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * available from http://www.virtualbox.org. This file is free software;
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * you can redistribute it and/or modify it under the terms of the GNU
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * General Public License (GPL) as published by the Free Software
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * Foundation, in version 2 as it comes in the "COPYING" file of the
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington/*******************************************************************************
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington* Header Files *
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington*******************************************************************************/
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington/** @page pg_devbios_cmos_assign CMOS Assignments (BIOS)
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * The BIOS uses a CMOS to store configuration data.
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington * It is currently used as follows:
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington First CMOS bank (offsets 0x00 to 0x7f):
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington Floppy drive type:
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington Hard disk type (old):
d72b59ef0fcc0226a5a655ad967e4c24729afa3ePhill Cunnington Equipment byte:
typedef enum DEVPCBIOSBOOT
typedef struct DEVPCBIOS
char *pszFDDevice;
char *pszHDDevice;
char *pszSataDevice;
char *pszPcBiosFile;
char *pszLanBootFile;
} DEVPCBIOS;
static DECLCALLBACK(int) pcbiosIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
return VERR_IOM_IOPORT_UNUSED;
static DECLCALLBACK(int) pcbiosIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
return VERR_INTERNAL_ERROR;
switch (u32)
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
int rc;
if (!pBlock)
return VERR_INVALID_PARAMETER;
return rc;
return VERR_INVALID_PARAMETER;
return VINF_SUCCESS;
return VERR_INVALID_PARAMETER;
return u8val;
static void pcbiosCmosInitHardDisk(PPDMDEVINS pDevIns, int offType, int offInfo, PCPDMMEDIAGEOMETRY pLCHSGeometry)
Log2(("%s: offInfo=%#x: LCHS=%d/%d/%d\n", __FUNCTION__, offInfo, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
if (offType)
static int setLogicalDiskGeometry(PPDMIBASE pBase, PPDMIBLOCKBIOS pHardDisk, PPDMMEDIAGEOMETRY pLCHSGeometry)
return rc;
case DEVPCBIOSBOOT_NONE:
case DEVPCBIOSBOOT_FLOPPY:
case DEVPCBIOSBOOT_HD:
case DEVPCBIOSBOOT_DVD:
case DEVPCBIOSBOOT_LAN:
u32 = pThis->cbRam > 640 ? 640 : (uint32_t)pThis->cbRam / _1K; /* <-- this test is wrong, but it doesn't matter since we never assign less than 1MB */
u32 = (uint32_t)( (RT_MIN(RT_MIN(pThis->cbRam, offRamHole), UINT32_C(0xffe00000)) - 16U * _1M) / _64K );
u32 = 0;
c64KBAbove4GB = 0;
AssertLogRelMsgReturn((c64KBAbove4GB >> (3 * 8)) < 255, ("%#RX64\n", c64KBAbove4GB), VERR_OUT_OF_RANGE);
* See rombios.c line ~7215 (int19_function).
for (i = 0; i < NET_BOOT_DEVS; ++i)
u32 = 0;
if (apFDs[0])
default: AssertFailed(); break;
default: AssertFailed(); break;
switch (u32)
if ( apHDs[i]
if (apHDs[i])
&LCHSGeometry);
LogRel(("DevPcBios: ATA LUN#%d LCHS=%u/%u/%u\n", i, LCHSGeometry.cCylinders, LCHSGeometry.cHeads, LCHSGeometry.cSectors));
if ( apHDs[i]
if (apHDs[i])
int offInfo;
&LCHSGeometry);
LogRel(("DevPcBios: SATA LUN#%d LCHS=%u/%u/%u\n", i, LCHSGeometry.cCylinders, LCHSGeometry.cHeads, LCHSGeometry.cSectors));
return VINF_SUCCESS;
while (cPages > 0)
int rc;
cPages--;
return VINF_SUCCESS;
static int pcbiosBootFromCfg(PPDMDEVINS pDevIns, PCFGMNODE pCfg, const char *pszParam, DEVPCBIOSBOOT *penmBoot)
char *psz;
pszParam);
return rc;
int rc;
int cb;
static const char * const s_apszBootDevices[] = { "BootDevice0", "BootDevice1", "BootDevice2", "BootDevice3" };
return rc;
static const char * const s_apszSataDisks[] =
return rc;
return rc;
for (unsigned i = 0; i < NET_BOOT_DEVS; ++i)
return rc;
LogRel(("DevPcBios: Using BIOS ROM '%s' with a size of %#x bytes\n", pThis->pszPcBiosFile, pThis->cbPcBios));
/* Convert the UUID to network byte order. Not entirely straightforward as parts are MSB already... */
return rc;
/* If the DMI table is located at the expected place, patch the DMI table length and the checksum. */
return rc;
return rc;
rc = PDMDevHlpROMRegister(pDevIns, (uint32_t)-(int32_t)cbPcBiosBinary, cbPcBiosBinary, pu8PcBiosBinary, cbPcBiosBinary,
return rc;
LogRel(("DevPcBios: Failed to open LAN boot ROM file '%s', rc=%Rrc!\n", pThis->pszLanBootFile, rc));
LogRel(("DevPcBios: Using LAN ROM '%s' with a size of %#x bytes\n", pThis->pszLanBootFile, cbFileLanBoot));
#ifdef VBOX_WITH_PXE_ROM
if (pu8LanBootBinary)
return VINF_SUCCESS;
sizeof(DEVPCBIOS),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,