VirtualBox

Changeset 47036 in vbox for trunk


Ignore:
Timestamp:
Jul 8, 2013 12:26:47 PM (12 years ago)
Author:
vboxsync
Message:

BIOS,DevFdc,DrvBlock: The floppy controller should query the block/host driver for the drive type, or it'll all go real bad if the guest code trusts CMOS/BIOS drive info. Changed the block driver to automatically upgrade the drive type (for fdc and bios/cmos setup only) if the image is larger than the configured drive capacity. Introduced two fake drive types with max capacities, 15.6 MB and 63.5 MB, the first is the max that INT13 can officially access, the second is reinterpreting CL as holding an 8-bit wide sector number and no cylinder bits (which actually seems to be how real bioses work with floppies).

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmifs.h

    r46933 r47036  
    894894    /** 2.88MB 3 1/2" floppy drive. */
    895895    PDMBLOCKTYPE_FLOPPY_2_88,
     896    /** Fake drive that can take up to 15.6 MB images.
     897     * C=255, H=2, S=63.  */
     898    PDMBLOCKTYPE_FLOPPY_FAKE_15_6,
     899    /** Fake drive that can take up to 63.5 MB images.
     900     * C=255, H=2, S=255.  */
     901    PDMBLOCKTYPE_FLOPPY_FAKE_63_5,
    896902    /** CDROM drive. */
    897903    PDMBLOCKTYPE_CDROM,
     
    902908} PDMBLOCKTYPE;
    903909
     910/** Check if the given block type is a floppy. */
     911#define PDMBLOCKTYPE_IS_FLOPPY(a_enmType) ( (a_enmType) >= PDMBLOCKTYPE_FLOPPY_360 && (a_enmType) <= PDMBLOCKTYPE_FLOPPY_2_88 )
    904912
    905913/**
  • trunk/src/VBox/Devices/PC/BIOS/floppy.c

    r46947 r47036  
    392392        retval = 1;
    393393    }
     394    else if ( drive_type == 14 || drive_type == 15 ) {
     395        // 15.6 MB 3.5" (fake) || 63.5 MB 3.5" (fake) - report same as 2.88 MB.
     396        config_data = 0xCC; // 1100 1100
     397        media_state = 0xD7; // 1101 0111
     398        retval = 1;
     399    }
    394400    else {
    395401        // not recognized
     
    10261032        SET_AL(0);
    10271033        SET_DL(num_floppies);
     1034        SET_DH(1);      // max head #
    10281035       
    10291036        switch (drive_type) {
     
    10351042        case 1: // 360KB, 5.25"
    10361043            CX = 0x2709;    // 40 tracks, 9 sectors
    1037             SET_DH(1);      // max head #
    10381044            break;
    10391045       
    10401046        case 2: // 1.2MB, 5.25"
    10411047            CX = 0x4f0f;    // 80 tracks, 15 sectors
    1042             SET_DH(1);      // max head #
    10431048            break;
    10441049       
    10451050        case 3: // 720KB, 3.5"
    10461051            CX = 0x4f09;    // 80 tracks, 9 sectors
    1047             SET_DH(1);      // max head #
    10481052            break;
    10491053       
    10501054        case 4: // 1.44MB, 3.5"
    10511055            CX = 0x4f12;    // 80 tracks, 18 sectors
    1052             SET_DH(1);      // max head #
    10531056            break;
    10541057       
    10551058        case 5: // 2.88MB, 3.5"
    10561059            CX = 0x4f24;    // 80 tracks, 36 sectors
    1057             SET_DH(1);      // max head #
    10581060            break;
    10591061       
     
    10701072        case 8: // 320k, 5.25"
    10711073            CX = 0x2708;    // 40 tracks, 8 sectors
    1072             SET_DH(1);      // max head #
    1073             break;
    1074        
     1074            break;
     1075       
     1076        case 14: // 15.6 MB 3.5" (fake)
     1077            CX = 0xfe3f;    // 255 tracks, 63 sectors
     1078            break;
     1079
     1080        case 15: // 63.5 MB 3.5" (fake)
     1081            CX = 0xfeff;    // 255 tracks, 255 sectors - This works because the cylinder
     1082            break;          // and sectors limits/encoding aren't checked by the BIOS
     1083                            // due to copy protection schemes and such stuff.
     1084
    10751085        default: // ?
    10761086            BX_PANIC("%s: bad floppy type\n", __func__);
  • trunk/src/VBox/Devices/PC/DevPcBios.cpp

    r46356 r47036  
    502502    PUVM            pUVM = PDMDevHlpGetUVM(pDevIns); AssertRelease(pUVM);
    503503    PPDMIBLOCKBIOS  apHDs[4] = {0};
    504     PPDMIBLOCKBIOS  apFDs[2] = {0};
    505504    LogFlow(("pcbiosInitComplete:\n"));
    506505
     
    587586     * Floppy drive type.
    588587     */
    589     for (i = 0; i < RT_ELEMENTS(apFDs); i++)
     588    uint32_t cFDs = 0;
     589    u32 = 0;
     590    for (i = 0; i < 2; i++)
    590591    {
    591592        PPDMIBASE pBase;
    592593        int rc = PDMR3QueryLun(pUVM, pThis->pszFDDevice, 0, i, &pBase);
    593594        if (RT_SUCCESS(rc))
    594             apFDs[i] = PDMIBASE_QUERY_INTERFACE(pBase, PDMIBLOCKBIOS);
    595     }
    596     u32 = 0;
    597     if (apFDs[0])
    598         switch (apFDs[0]->pfnGetType(apFDs[0]))
    599         {
    600             case PDMBLOCKTYPE_FLOPPY_360:   u32 |= 1 << 4; break;
    601             case PDMBLOCKTYPE_FLOPPY_1_20:  u32 |= 2 << 4; break;
    602             case PDMBLOCKTYPE_FLOPPY_720:   u32 |= 3 << 4; break;
    603             case PDMBLOCKTYPE_FLOPPY_1_44:  u32 |= 4 << 4; break;
    604             case PDMBLOCKTYPE_FLOPPY_2_88:  u32 |= 5 << 4; break;
    605             default:                        AssertFailed(); break;
    606         }
    607     if (apFDs[1])
    608         switch (apFDs[1]->pfnGetType(apFDs[1]))
    609         {
    610             case PDMBLOCKTYPE_FLOPPY_360:   u32 |= 1; break;
    611             case PDMBLOCKTYPE_FLOPPY_1_20:  u32 |= 2; break;
    612             case PDMBLOCKTYPE_FLOPPY_720:   u32 |= 3; break;
    613             case PDMBLOCKTYPE_FLOPPY_1_44:  u32 |= 4; break;
    614             case PDMBLOCKTYPE_FLOPPY_2_88:  u32 |= 5; break;
    615             default:                        AssertFailed(); break;
    616         }
     595        {
     596            PPDMIBLOCKBIOS pFD = PDMIBASE_QUERY_INTERFACE(pBase, PDMIBLOCKBIOS);
     597            if (pFD)
     598            {
     599                cFDs++;
     600                unsigned cShift = i == 0 ? 4 : 0;
     601                switch (pFD->pfnGetType(pFD))
     602                {
     603                    case PDMBLOCKTYPE_FLOPPY_360:       u32 |= 1  << cShift; break;
     604                    case PDMBLOCKTYPE_FLOPPY_1_20:      u32 |= 2  << cShift; break;
     605                    case PDMBLOCKTYPE_FLOPPY_720:       u32 |= 3  << cShift; break;
     606                    case PDMBLOCKTYPE_FLOPPY_1_44:      u32 |= 4  << cShift; break;
     607                    case PDMBLOCKTYPE_FLOPPY_2_88:      u32 |= 5  << cShift; break;
     608                    case PDMBLOCKTYPE_FLOPPY_FAKE_15_6: u32 |= 14 << cShift; break;
     609                    case PDMBLOCKTYPE_FLOPPY_FAKE_63_5: u32 |= 15 << cShift; break;
     610                    default:                        AssertFailed(); break;
     611                }
     612            }
     613        }
     614    }
    617615    pcbiosCmosWrite(pDevIns, 0x10, u32);                                        /* 10h - Floppy Drive Type */
    618616
     
    620618     * Equipment byte.
    621619     */
    622     u32 = !!apFDs[0] + !!apFDs[1];
    623     switch (u32)
    624     {
    625         case 1: u32 = 0x01; break;      /* floppy installed, 2 drives. */
    626         default:u32 = 0;    break;      /* floppy not installed. */
    627     }
     620    if (cFDs > 0)
     621        u32 = 0x01;                        /* floppy installed, 2 drives. */
     622    else
     623        u32 = 0x00;                        /* floppy not installed. */
    628624    u32 |= RT_BIT(1);                      /* math coprocessor installed  */
    629625    u32 |= RT_BIT(2);                      /* keyboard enabled (or mouse?) */
  • trunk/src/VBox/Devices/Storage/DevFdc.cpp

    r46339 r47036  
    122122    FDRIVE_DRV_120  = 0x02,   /* 1.2  MB 5"25 drive     */
    123123    FDRIVE_DRV_NONE = 0x03    /* No drive connected     */
     124#ifdef VBOX
     125    , FDRIVE_DRV_FAKE_15_6 = 0x0e /* Fake 15.6 MB drive. */
     126    , FDRIVE_DRV_FAKE_63_5 = 0x0f /* Fake 63.5 MB drive. */
     127#endif
    124128} fdrive_type_t;
    125129
     
    184188#define NUM_SIDES(drv)      (drv->flags & FDISK_DBL_SIDES ? 2 : 1)
    185189
    186 static void fd_init(fdrive_t *drv)
     190static void fd_init(fdrive_t *drv, bool fInit)
    187191{
    188192    /* Drive */
     193#ifndef VBOX
    189194    drv->drive = FDRIVE_DRV_NONE;
     195#else  /* VBOX */
     196    if (fInit) {
     197        /* Fixate the drive type at init time if possible. */
     198        if (drv->pDrvBlock) {
     199            PDMBLOCKTYPE enmType = drv->pDrvBlock->pfnGetType(drv->pDrvBlock);
     200            switch (enmType) {
     201                case PDMBLOCKTYPE_FLOPPY_360:
     202                case PDMBLOCKTYPE_FLOPPY_1_20:
     203                    drv->drive = FDRIVE_DRV_120;
     204                    break;
     205                case PDMBLOCKTYPE_FLOPPY_720:
     206                case PDMBLOCKTYPE_FLOPPY_1_44:
     207                    drv->drive = FDRIVE_DRV_144;
     208                    break;
     209                default:
     210                    AssertFailed();
     211                case PDMBLOCKTYPE_FLOPPY_2_88:
     212                    drv->drive = FDRIVE_DRV_288;
     213                    break;
     214                case PDMBLOCKTYPE_FLOPPY_FAKE_15_6:
     215                    drv->drive = FDRIVE_DRV_FAKE_15_6;
     216                    break;
     217                case PDMBLOCKTYPE_FLOPPY_FAKE_63_5:
     218                    drv->drive = FDRIVE_DRV_FAKE_63_5;
     219                    break;
     220            }
     221        } else {
     222            drv->drive = FDRIVE_DRV_NONE;
     223        }
     224    } /* else: The BIOS (and others) get the drive type via the CMOS, so
     225               don't change it after the VM has been constructed. */
     226#endif /* VBOX */
    190227    drv->perpendicular = 0;
    191228    /* Disk */
     
    267304    fdrive_type_t drive;
    268305    fdisk_type_t  disk;
    269     uint8_t last_sect;
    270     uint8_t max_track;
    271     uint8_t max_head;
     306    uint8_t last_sect;      /**< Number of sectors. */
     307    uint8_t max_track;      /**< Number of tracks. */
     308    uint8_t max_head;       /**< Max head number. */
    272309    fdrive_rate_t rate;
    273310    const char *str;
     
    317354    /* 360 kB must match 5"1/4 better than 3"1/2... */
    318355    { FDRIVE_DRV_144, FDRIVE_DISK_720,  9, 80, 0, FDRIVE_RATE_250K,  "360 kB 3\"1/2", },
     356#ifdef VBOX /* For larger than real life floppy images (see DrvBlock.cpp). */
     357    /* 15.6 MB fake floppy disk (just need something big). */
     358    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_USER,  63, 255, 1, FDRIVE_RATE_1M,   "15.6 MB 3\"1/2", },
     359    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_288,   36,  80, 1, FDRIVE_RATE_1M,   "2.88 MB 3\"1/2", },
     360    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_288,   39,  80, 1, FDRIVE_RATE_1M,   "3.12 MB 3\"1/2", },
     361    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_288,   40,  80, 1, FDRIVE_RATE_1M,    "3.2 MB 3\"1/2", },
     362    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_288,   44,  80, 1, FDRIVE_RATE_1M,   "3.52 MB 3\"1/2", },
     363    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_288,   48,  80, 1, FDRIVE_RATE_1M,   "3.84 MB 3\"1/2", },
     364    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   18,  80, 1, FDRIVE_RATE_500K, "1.44 MB 3\"1/2", },
     365    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   20,  80, 1, FDRIVE_RATE_500K,  "1.6 MB 3\"1/2", },
     366    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   21,  80, 1, FDRIVE_RATE_500K, "1.68 MB 3\"1/2", },
     367    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   21,  82, 1, FDRIVE_RATE_500K, "1.72 MB 3\"1/2", },
     368    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   21,  83, 1, FDRIVE_RATE_500K, "1.74 MB 3\"1/2", },
     369    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   22,  80, 1, FDRIVE_RATE_500K, "1.76 MB 3\"1/2", },
     370    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   23,  80, 1, FDRIVE_RATE_500K, "1.84 MB 3\"1/2", },
     371    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_144,   24,  80, 1, FDRIVE_RATE_500K, "1.92 MB 3\"1/2", },
     372    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_720,    9,  80, 1, FDRIVE_RATE_250K,  "720 kB 3\"1/2", },
     373    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_720,   10,  80, 1, FDRIVE_RATE_250K,  "800 kB 3\"1/2", },
     374    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_720,   10,  82, 1, FDRIVE_RATE_250K,  "820 kB 3\"1/2", },
     375    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_720,   10,  83, 1, FDRIVE_RATE_250K,  "830 kB 3\"1/2", },
     376    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_720,   13,  80, 1, FDRIVE_RATE_250K, "1.04 MB 3\"1/2", },
     377    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_720,   14,  80, 1, FDRIVE_RATE_250K, "1.12 MB 3\"1/2", },
     378    { FDRIVE_DRV_FAKE_15_6, FDRIVE_DISK_720,    9,  80, 0, FDRIVE_RATE_250K,  "360 kB 3\"1/2", },
     379    /* 63.5 MB fake floppy disk (just need something big). */
     380    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_USER, 255, 255, 1, FDRIVE_RATE_1M,   "63.5 MB 3\"1/2", },
     381    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_USER,  63, 255, 1, FDRIVE_RATE_1M,   "15.6 MB 3\"1/2", },
     382    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_288,   36,  80, 1, FDRIVE_RATE_1M,   "2.88 MB 3\"1/2", },
     383    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_288,   39,  80, 1, FDRIVE_RATE_1M,   "3.12 MB 3\"1/2", },
     384    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_288,   40,  80, 1, FDRIVE_RATE_1M,    "3.2 MB 3\"1/2", },
     385    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_288,   44,  80, 1, FDRIVE_RATE_1M,   "3.52 MB 3\"1/2", },
     386    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_288,   48,  80, 1, FDRIVE_RATE_1M,   "3.84 MB 3\"1/2", },
     387    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   18,  80, 1, FDRIVE_RATE_500K, "1.44 MB 3\"1/2", },
     388    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   20,  80, 1, FDRIVE_RATE_500K,  "1.6 MB 3\"1/2", },
     389    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   21,  80, 1, FDRIVE_RATE_500K, "1.68 MB 3\"1/2", },
     390    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   21,  82, 1, FDRIVE_RATE_500K, "1.72 MB 3\"1/2", },
     391    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   21,  83, 1, FDRIVE_RATE_500K, "1.74 MB 3\"1/2", },
     392    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   22,  80, 1, FDRIVE_RATE_500K, "1.76 MB 3\"1/2", },
     393    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   23,  80, 1, FDRIVE_RATE_500K, "1.84 MB 3\"1/2", },
     394    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_144,   24,  80, 1, FDRIVE_RATE_500K, "1.92 MB 3\"1/2", },
     395    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_720,    9,  80, 1, FDRIVE_RATE_250K,  "720 kB 3\"1/2", },
     396    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_720,   10,  80, 1, FDRIVE_RATE_250K,  "800 kB 3\"1/2", },
     397    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_720,   10,  82, 1, FDRIVE_RATE_250K,  "820 kB 3\"1/2", },
     398    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_720,   10,  83, 1, FDRIVE_RATE_250K,  "830 kB 3\"1/2", },
     399    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_720,   13,  80, 1, FDRIVE_RATE_250K, "1.04 MB 3\"1/2", },
     400    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_720,   14,  80, 1, FDRIVE_RATE_250K, "1.12 MB 3\"1/2", },
     401    { FDRIVE_DRV_FAKE_63_5, FDRIVE_DISK_720,    9,  80, 0, FDRIVE_RATE_250K,  "360 kB 3\"1/2", },
     402#endif
    319403    /* end */
    320404    { FDRIVE_DRV_NONE, FDRIVE_DISK_NONE, (uint8_t)-1, (uint8_t)-1, 0, (fdrive_rate_t)0, NULL, },
     
    335419        bdrv_get_geometry_hint(drv->bs, &nb_heads, &max_track, &last_sect);
    336420#else /* VBOX */
    337     if (drv->pDrvBlock
     421    if (   drv->pDrvBlock
    338422        && drv->pDrvMount
    339423        && drv->pDrvMount->pfnIsMounted (drv->pDrvMount)) {
     
    740824{
    741825    if (!(fdctrl->sra & FD_SRA_INTPEND)) {
     826        FLOPPY_DPRINTF("Raising interrupt...\n");
    742827#ifdef VBOX
    743828        PDMDevHlpISASetIrq (fdctrl->pDevIns, fdctrl->irq_lvl, 1);
     
    23632448 * @param   drv         The drive in question.
    23642449 * @param   pDevIns     The driver instance.
     2450 * @param   fInit       Set if we're at init time and can change the drive type.
    23652451 */
    2366 static int fdConfig (fdrive_t *drv, PPDMDEVINS pDevIns)
     2452static int fdConfig(fdrive_t *drv, PPDMDEVINS pDevIns, bool fInit)
    23672453{
    23682454    static const char * const s_apszDesc[] = {"Floppy Drive A:", "Floppy Drive B"};
     
    23882474                drv->pDrvMount = PDMIBASE_QUERY_INTERFACE(drv->pDrvBase, PDMIMOUNT);
    23892475                if (drv->pDrvMount) {
    2390                     fd_init(drv);
     2476                    fd_init(drv, fInit);
    23912477                } else {
    23922478                    AssertMsgFailed (("Configuration error: LUN#%d without mountable interface!\n", drv->iLUN));
     
    24672553    AssertRelease (!drv->pDrvMount);
    24682554
    2469     rc = fdConfig (drv, pDevIns);
     2555    rc = fdConfig (drv, pDevIns, false /*fInit*/);
    24702556    AssertMsg (rc != VERR_PDM_NO_ATTACHED_DRIVER,
    24712557               ("Configuration error: failed to configure drive %d, rc=%Rrc\n", rc));
     
    26702756    {
    26712757        fdrive_t *pDrv = &pThis->drives[i];
    2672         rc = fdConfig(pDrv, pDevIns);
     2758        rc = fdConfig(pDrv, pDevIns, true /*fInit*/);
    26732759        if (   RT_FAILURE(rc)
    26742760            && rc != VERR_PDM_NO_ATTACHED_DRIVER)
  • trunk/src/VBox/Devices/Storage/DrvBlock.cpp

    r44528 r47036  
    775775}
    776776
     777
    777778/**
    778779 * Reset notification.
     
    787788    pThis->fLocked = false;
    788789}
     790
     791
     792/**
     793 * Translates a PDMBLOCKTYPE value into a string.
     794 *
     795 * @returns Read only string.
     796 * @param   enmType             The type value.
     797 */
     798static const char *drvblockGetTypeName(PDMBLOCKTYPE enmType)
     799{
     800    switch (enmType)
     801    {
     802        case PDMBLOCKTYPE_ERROR:                return "ERROR";
     803        case PDMBLOCKTYPE_FLOPPY_360:           return "FLOPPY_360";
     804        case PDMBLOCKTYPE_FLOPPY_720:           return "FLOPPY_720";
     805        case PDMBLOCKTYPE_FLOPPY_1_20:          return "FLOPPY_1_20";
     806        case PDMBLOCKTYPE_FLOPPY_1_44:          return "FLOPPY_1_44";
     807        case PDMBLOCKTYPE_FLOPPY_2_88:          return "FLOPPY_2_88";
     808        case PDMBLOCKTYPE_FLOPPY_FAKE_15_6:     return "FLOPPY_FAKE_15_6";
     809        case PDMBLOCKTYPE_FLOPPY_FAKE_63_5:     return "FLOPPY_FAKE_63_5";
     810        case PDMBLOCKTYPE_CDROM:                return "CDROM";
     811        case PDMBLOCKTYPE_DVD:                  return "DVD";
     812        case PDMBLOCKTYPE_HARD_DISK:            return "HARD_DISK";
     813        default:                                return "Unknown";
     814
     815    }
     816}
     817
    789818
    790819/**
     
    890919    else if (!strcmp(psz, "Floppy 360"))
    891920        pThis->enmType = PDMBLOCKTYPE_FLOPPY_360;
     921    else if (!strcmp(psz, "Floppy 15.6"))
     922        pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_15_6;
     923    else if (!strcmp(psz, "Floppy 63.5"))
     924        pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_63_5;
    892925    else
    893926    {
     
    10081041        if (pThis->enmType == PDMBLOCKTYPE_HARD_DISK)
    10091042            pThis->pDrvMedia->pfnGetUuid(pThis->pDrvMedia, &pThis->Uuid);
     1043    }
     1044
     1045    /*
     1046     * Automatically upgrade the floppy drive if the specified one is too
     1047     * small to represent the whole boot time image. (We cannot do this later
     1048     * since the BIOS (and others) gets the info via CMOS.)
     1049     *
     1050     * This trick should make 2.88 images as well as the fake 15.6 and 63.5 MB
     1051     * images despite the hardcoded default 1.44 drive.
     1052     */
     1053    if (   PDMBLOCKTYPE_IS_FLOPPY(pThis->enmType)
     1054        && pThis->pDrvMedia)
     1055    {
     1056        uint64_t     const cbFloppyImg = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia);
     1057        PDMBLOCKTYPE const enmCfgType  = pThis->enmType;
     1058        switch (enmCfgType)
     1059        {
     1060            default:
     1061                AssertFailed();
     1062            case PDMBLOCKTYPE_FLOPPY_360:
     1063                if (cbFloppyImg > 40 * 2 * 9 * 512)
     1064                    pThis->enmType = PDMBLOCKTYPE_FLOPPY_360;
     1065                /* fall thru */
     1066            case PDMBLOCKTYPE_FLOPPY_720:
     1067                if (cbFloppyImg > 80 * 2 * 14 * 512)
     1068                    pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_20;
     1069                /* fall thru */
     1070            case PDMBLOCKTYPE_FLOPPY_1_20:
     1071                if (cbFloppyImg > 80 * 2 * 20 * 512)
     1072                    pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_44;
     1073                /* fall thru */
     1074            case PDMBLOCKTYPE_FLOPPY_1_44:
     1075                if (cbFloppyImg > 80 * 2 * 24 * 512)
     1076                    pThis->enmType = PDMBLOCKTYPE_FLOPPY_2_88;
     1077                /* fall thru */
     1078            case PDMBLOCKTYPE_FLOPPY_2_88:
     1079                if (cbFloppyImg > 80 * 2 * 48 * 512)
     1080                    pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_15_6;
     1081                /* fall thru */
     1082            case PDMBLOCKTYPE_FLOPPY_FAKE_15_6:
     1083                if (cbFloppyImg > 255 * 2 * 63 * 512)
     1084                    pThis->enmType = PDMBLOCKTYPE_FLOPPY_FAKE_63_5;
     1085            case PDMBLOCKTYPE_FLOPPY_FAKE_63_5:
     1086                if (cbFloppyImg > 255 * 2 * 255 * 512)
     1087                    LogRel(("Warning: Floppy image is larger that 63.5 MB! (%llu bytes)\n", cbFloppyImg));
     1088                break;
     1089        }
     1090        if (pThis->enmType != enmCfgType)
     1091            LogRel(("Automatically upgraded floppy drive from %s to %s to better support the %u byte image\n",
     1092                    drvblockGetTypeName(enmCfgType), drvblockGetTypeName(pThis->enmType), cbFloppyImg));
    10101093    }
    10111094
  • trunk/src/VBox/Devices/Storage/DrvHostBase.cpp

    r46625 r47036  
    20802080        case PDMBLOCKTYPE_FLOPPY_1_44:
    20812081        case PDMBLOCKTYPE_FLOPPY_2_88:
     2082        case PDMBLOCKTYPE_FLOPPY_FAKE_15_6:
     2083        case PDMBLOCKTYPE_FLOPPY_FAKE_63_5:
    20822084            if (uDriveType != DRIVE_REMOVABLE)
    20832085            {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette