diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
|---|---|---|
| committer | <> | 2014-05-08 15:03:54 +0000 |
| commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
| tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Devices/Storage/DrvBlock.cpp | |
| parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
| download | VirtualBox-master.tar.gz | |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Devices/Storage/DrvBlock.cpp')
| -rw-r--r-- | src/VBox/Devices/Storage/DrvBlock.cpp | 103 |
1 files changed, 102 insertions, 1 deletions
diff --git a/src/VBox/Devices/Storage/DrvBlock.cpp b/src/VBox/Devices/Storage/DrvBlock.cpp index 8353d805..30dfb9ee 100644 --- a/src/VBox/Devices/Storage/DrvBlock.cpp +++ b/src/VBox/Devices/Storage/DrvBlock.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -264,6 +264,23 @@ static DECLCALLBACK(uint64_t) drvblockGetSize(PPDMIBLOCK pInterface) } +/** @copydoc PDMIBLOCK::pfnGetSize */ +static DECLCALLBACK(uint32_t) drvblockGetSectorSize(PPDMIBLOCK pInterface) +{ + PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); + + /* + * Check the state. + */ + if (!pThis->pDrvMedia) + return 0; + + uint32_t cb = pThis->pDrvMedia->pfnGetSectorSize(pThis->pDrvMedia); + LogFlowFunc(("returns %u\n", cb)); + return cb; +} + + /** @copydoc PDMIBLOCK::pfnGetType */ static DECLCALLBACK(PDMBLOCKTYPE) drvblockGetType(PPDMIBLOCK pInterface) { @@ -774,6 +791,7 @@ static DECLCALLBACK(void) drvblockDetach(PPDMDRVINS pDrvIns, uint32_t fFlags) NOREF(fFlags); } + /** * Reset notification. * @@ -787,6 +805,34 @@ static DECLCALLBACK(void) drvblockReset(PPDMDRVINS pDrvIns) pThis->fLocked = false; } + +/** + * Translates a PDMBLOCKTYPE value into a string. + * + * @returns Read only string. + * @param enmType The type value. + */ +static const char *drvblockGetTypeName(PDMBLOCKTYPE enmType) +{ + switch (enmType) + { + case PDMBLOCKTYPE_ERROR: return "ERROR"; + case PDMBLOCKTYPE_FLOPPY_360: return "FLOPPY_360"; + case PDMBLOCKTYPE_FLOPPY_720: return "FLOPPY_720"; + case PDMBLOCKTYPE_FLOPPY_1_20: return "FLOPPY_1_20"; + case PDMBLOCKTYPE_FLOPPY_1_44: return "FLOPPY_1_44"; + case PDMBLOCKTYPE_FLOPPY_2_88: return "FLOPPY_2_88"; + case PDMBLOCKTYPE_FLOPPY_FAKE_15_6: return "FLOPPY_FAKE_15_6"; + case PDMBLOCKTYPE_FLOPPY_FAKE_63_5: return "FLOPPY_FAKE_63_5"; + case PDMBLOCKTYPE_CDROM: return "CDROM"; + case PDMBLOCKTYPE_DVD: return "DVD"; + case PDMBLOCKTYPE_HARD_DISK: return "HARD_DISK"; + default: return "Unknown"; + + } +} + + /** * Construct a block driver instance. * @@ -823,6 +869,7 @@ static DECLCALLBACK(int) drvblockConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, u pThis->IBlock.pfnMerge = drvblockMerge; pThis->IBlock.pfnIsReadOnly = drvblockIsReadOnly; pThis->IBlock.pfnGetSize = drvblockGetSize; + pThis->IBlock.pfnGetSectorSize = drvblockGetSectorSize; pThis->IBlock.pfnGetType = drvblockGetType; pThis->IBlock.pfnGetUuid = drvblockGetUuid; @@ -889,6 +936,10 @@ static DECLCALLBACK(int) drvblockConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, u pThis->enmType = PDMBLOCKTYPE_FLOPPY_720; else if (!strcmp(psz, "Floppy 360")) pThis->enmType = PDMBLOCKTYPE_FLOPPY_360; + else if (!strcmp(psz, "Floppy 15.6")) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_15_6; + else if (!strcmp(psz, "Floppy 63.5")) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_63_5; else { PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS, @@ -1009,6 +1060,56 @@ static DECLCALLBACK(int) drvblockConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, u pThis->pDrvMedia->pfnGetUuid(pThis->pDrvMedia, &pThis->Uuid); } + /* + * Automatically upgrade the floppy drive if the specified one is too + * small to represent the whole boot time image. (We cannot do this later + * since the BIOS (and others) gets the info via CMOS.) + * + * This trick should make 2.88 images as well as the fake 15.6 and 63.5 MB + * images despite the hardcoded default 1.44 drive. + */ + if ( PDMBLOCKTYPE_IS_FLOPPY(pThis->enmType) + && pThis->pDrvMedia) + { + uint64_t const cbFloppyImg = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia); + PDMBLOCKTYPE const enmCfgType = pThis->enmType; + switch (enmCfgType) + { + default: + AssertFailed(); + case PDMBLOCKTYPE_FLOPPY_360: + if (cbFloppyImg > 40 * 2 * 9 * 512) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_360; + /* fall thru */ + case PDMBLOCKTYPE_FLOPPY_720: + if (cbFloppyImg > 80 * 2 * 14 * 512) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_20; + /* fall thru */ + case PDMBLOCKTYPE_FLOPPY_1_20: + if (cbFloppyImg > 80 * 2 * 20 * 512) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_44; + /* fall thru */ + case PDMBLOCKTYPE_FLOPPY_1_44: + if (cbFloppyImg > 80 * 2 * 24 * 512) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_2_88; + /* fall thru */ + case PDMBLOCKTYPE_FLOPPY_2_88: + if (cbFloppyImg > 80 * 2 * 48 * 512) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_15_6; + /* fall thru */ + case PDMBLOCKTYPE_FLOPPY_FAKE_15_6: + if (cbFloppyImg > 255 * 2 * 63 * 512) + pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_63_5; + case PDMBLOCKTYPE_FLOPPY_FAKE_63_5: + if (cbFloppyImg > 255 * 2 * 255 * 512) + LogRel(("Warning: Floppy image is larger that 63.5 MB! (%llu bytes)\n", cbFloppyImg)); + break; + } + if (pThis->enmType != enmCfgType) + LogRel(("Automatically upgraded floppy drive from %s to %s to better support the %u byte image\n", + drvblockGetTypeName(enmCfgType), drvblockGetTypeName(pThis->enmType), cbFloppyImg)); + } + return VINF_SUCCESS; } |
