Changeset 82177 in vbox
- Timestamp:
- Nov 25, 2019 1:54:41 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevFdc.cpp
r82152 r82177 56 56 #include "VBoxDD.h" 57 57 58 #define FDC_SAVESTATE_CURRENT 2 /* The new and improved saved state. */ 59 #define FDC_SAVESTATE_OLD 1 /* The original saved state. */ 58 59 /********************************************************************************************************************************* 60 * Defined Constants And Macros * 61 *********************************************************************************************************************************/ 62 /** @name FDC saved state versions 63 * @{ */ 64 #define FDC_SAVESTATE_CURRENT 2 /**< Current version. */ 65 #define FDC_SAVESTATE_PRE_DELAY 2 /**< Pre IRQDelay. */ 66 #define FDC_SAVESTATE_OLD 1 /**< The original saved state. */ 67 /** @}*/ 60 68 61 69 #define MAX_FD 2 … … 2278 2286 static DECLCALLBACK(void) fdcTransferDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2279 2287 { 2280 RT_NOREF(pDevIns, pTimer);2281 fdctrl_t *fdctrl = (fdctrl_t *)pvUser;2288 fdctrl_t *fdctrl = PDMDEVINS_2_DATA(pDevIns, fdctrl_t *); 2289 RT_NOREF(pvUser, pTimer); 2282 2290 fdctrl_stop_transfer_now(fdctrl, fdctrl->st0, fdctrl->st1, fdctrl->st2); 2283 2291 } 2292 2284 2293 2285 2294 /** … … 2288 2297 static DECLCALLBACK(void) fdcIrqDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2289 2298 { 2290 RT_NOREF(pDevIns, pTimer);2291 fdctrl_t *fdctrl = (fdctrl_t *)pvUser;2299 fdctrl_t *fdctrl = PDMDEVINS_2_DATA(pDevIns, fdctrl_t *); 2300 RT_NOREF(pvUser, pTimer); 2292 2301 fdctrl_raise_irq_now(fdctrl, fdctrl->st0); 2293 2302 } … … 2404 2413 } 2405 2414 rc = pHlp->pfnTimerSave(pDevIns, pThis->hXferDelayTimer, pSSM); 2406 if (RT_FAILURE(rc)) 2407 return rc; 2408 2415 AssertRCReturn(rc, rc); 2409 2416 rc = pHlp->pfnTimerSave(pDevIns, pThis->hIrqDelayTimer, pSSM); 2410 if (RT_FAILURE(rc)) 2411 return rc; 2412 2417 AssertRCReturn(rc, rc); 2413 2418 return pHlp->pfnTimerSave(pDevIns, pThis->hResultTimer, pSSM); 2414 2419 } … … 2431 2436 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 2432 2437 2433 /* The old saved state was significantly different. However, we can get 2434 * back most of the controller state and fix the rest by pretending the 2435 * disk in the drive (if any) has been replaced. At any rate there should 2436 * be no difficulty unless the state was saved during a floppy operation. 2437 */ 2438 if (uVersion == FDC_SAVESTATE_OLD) 2438 if (uVersion > FDC_SAVESTATE_OLD) 2439 2439 { 2440 /* Load the FDC I/O registers... */ 2441 pHlp->pfnSSMGetU8(pSSM, &pThis->sra); 2442 pHlp->pfnSSMGetU8(pSSM, &pThis->srb); 2443 pHlp->pfnSSMGetU8(pSSM, &pThis->dor); 2444 pHlp->pfnSSMGetU8(pSSM, &pThis->tdr); 2445 pHlp->pfnSSMGetU8(pSSM, &pThis->dsr); 2446 pHlp->pfnSSMGetU8(pSSM, &pThis->msr); 2447 /* ...the status registers... */ 2448 pHlp->pfnSSMGetU8(pSSM, &pThis->status0); 2449 pHlp->pfnSSMGetU8(pSSM, &pThis->status1); 2450 pHlp->pfnSSMGetU8(pSSM, &pThis->status2); 2451 /* ...the command FIFO, if the size matches... */ 2452 rc = pHlp->pfnSSMGetU32(pSSM, &val32); 2453 AssertRCReturn(rc, rc); 2454 AssertMsgReturn(sizeof(pThis->fifo) == val32, 2455 ("The size of FIFO in saved state doesn't match!\n"), 2456 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 2457 pHlp->pfnSSMGetMem(pSSM, &pThis->fifo, sizeof(pThis->fifo)); 2458 pHlp->pfnSSMGetU32(pSSM, &pThis->data_pos); 2459 pHlp->pfnSSMGetU32(pSSM, &pThis->data_len); 2460 pHlp->pfnSSMGetU8(pSSM, &pThis->data_state); 2461 pHlp->pfnSSMGetU8(pSSM, &pThis->data_dir); 2462 /* ...and miscellaneous internal FDC state. */ 2463 pHlp->pfnSSMGetU8(pSSM, &pThis->reset_sensei); 2464 pHlp->pfnSSMGetU8(pSSM, &pThis->eot); 2465 pHlp->pfnSSMGetU8(pSSM, &pThis->timer0); 2466 pHlp->pfnSSMGetU8(pSSM, &pThis->timer1); 2467 pHlp->pfnSSMGetU8(pSSM, &pThis->precomp_trk); 2468 pHlp->pfnSSMGetU8(pSSM, &pThis->config); 2469 pHlp->pfnSSMGetU8(pSSM, &pThis->lock); 2470 pHlp->pfnSSMGetU8(pSSM, &pThis->pwrd); 2471 pHlp->pfnSSMGetU8(pSSM, &pThis->version); 2472 2473 /* Validate the number of drives. */ 2474 rc = pHlp->pfnSSMGetU8(pSSM, &pThis->num_floppies); 2475 AssertRCReturn(rc, rc); 2476 AssertMsgReturn(RT_ELEMENTS(pThis->drives) == pThis->num_floppies, 2477 ("The number of drives in saved state doesn't match!\n"), 2478 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 2479 2480 /* Load the per-drive state. */ 2481 for (i = 0; i < pThis->num_floppies; ++i) 2482 { 2483 fdrive_t *d = &pThis->drives[i]; 2484 2485 pHlp->pfnSSMGetMem(pSSM, &d->Led, sizeof(d->Led)); 2486 rc = pHlp->pfnSSMGetU32(pSSM, &val32); 2487 AssertRCReturn(rc, rc); 2488 d->drive = (fdrive_type_t)val32; 2489 pHlp->pfnSSMGetU8(pSSM, &d->dsk_chg); 2490 pHlp->pfnSSMGetU8(pSSM, &d->perpendicular); 2491 pHlp->pfnSSMGetU8(pSSM, &d->head); 2492 pHlp->pfnSSMGetU8(pSSM, &d->track); 2493 pHlp->pfnSSMGetU8(pSSM, &d->sect); 2494 } 2495 2496 if (uVersion > FDC_SAVESTATE_PRE_DELAY) 2497 { 2498 pHlp->pfnTimerLoad(pDevIns, pThis->hXferDelayTimer, pSSM); 2499 pHlp->pfnTimerLoad(pDevIns, pThis->hIrqDelayTimer, pSSM); 2500 } 2501 } 2502 else if (uVersion == FDC_SAVESTATE_OLD) 2503 { 2504 /* The old saved state was significantly different. However, we can get 2505 * back most of the controller state and fix the rest by pretending the 2506 * disk in the drive (if any) has been replaced. At any rate there should 2507 * be no difficulty unless the state was saved during a floppy operation. 2508 */ 2509 2440 2510 /* First verify a few assumptions. */ 2441 2511 AssertMsgReturn(sizeof(pThis->fifo) == FD_SECTOR_LEN, … … 2500 2570 } 2501 2571 } 2502 else /* New state - straightforward. */ 2503 { 2504 Assert(uVersion == FDC_SAVESTATE_CURRENT); 2505 /* Load the FDC I/O registers... */ 2506 pHlp->pfnSSMGetU8(pSSM, &pThis->sra); 2507 pHlp->pfnSSMGetU8(pSSM, &pThis->srb); 2508 pHlp->pfnSSMGetU8(pSSM, &pThis->dor); 2509 pHlp->pfnSSMGetU8(pSSM, &pThis->tdr); 2510 pHlp->pfnSSMGetU8(pSSM, &pThis->dsr); 2511 pHlp->pfnSSMGetU8(pSSM, &pThis->msr); 2512 /* ...the status registers... */ 2513 pHlp->pfnSSMGetU8(pSSM, &pThis->status0); 2514 pHlp->pfnSSMGetU8(pSSM, &pThis->status1); 2515 pHlp->pfnSSMGetU8(pSSM, &pThis->status2); 2516 /* ...the command FIFO, if the size matches... */ 2517 rc = pHlp->pfnSSMGetU32(pSSM, &val32); 2518 AssertRCReturn(rc, rc); 2519 AssertMsgReturn(sizeof(pThis->fifo) == val32, 2520 ("The size of FIFO in saved state doesn't match!\n"), 2521 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 2522 pHlp->pfnSSMGetMem(pSSM, &pThis->fifo, sizeof(pThis->fifo)); 2523 pHlp->pfnSSMGetU32(pSSM, &pThis->data_pos); 2524 pHlp->pfnSSMGetU32(pSSM, &pThis->data_len); 2525 pHlp->pfnSSMGetU8(pSSM, &pThis->data_state); 2526 pHlp->pfnSSMGetU8(pSSM, &pThis->data_dir); 2527 /* ...and miscellaneous internal FDC state. */ 2528 pHlp->pfnSSMGetU8(pSSM, &pThis->reset_sensei); 2529 pHlp->pfnSSMGetU8(pSSM, &pThis->eot); 2530 pHlp->pfnSSMGetU8(pSSM, &pThis->timer0); 2531 pHlp->pfnSSMGetU8(pSSM, &pThis->timer1); 2532 pHlp->pfnSSMGetU8(pSSM, &pThis->precomp_trk); 2533 pHlp->pfnSSMGetU8(pSSM, &pThis->config); 2534 pHlp->pfnSSMGetU8(pSSM, &pThis->lock); 2535 pHlp->pfnSSMGetU8(pSSM, &pThis->pwrd); 2536 pHlp->pfnSSMGetU8(pSSM, &pThis->version); 2537 2538 /* Validate the number of drives. */ 2539 rc = pHlp->pfnSSMGetU8(pSSM, &pThis->num_floppies); 2540 AssertRCReturn(rc, rc); 2541 AssertMsgReturn(RT_ELEMENTS(pThis->drives) == pThis->num_floppies, 2542 ("The number of drives in saved state doesn't match!\n"), 2543 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 2544 2545 /* Load the per-drive state. */ 2546 for (i = 0; i < pThis->num_floppies; ++i) 2547 { 2548 fdrive_t *d = &pThis->drives[i]; 2549 2550 pHlp->pfnSSMGetMem(pSSM, &d->Led, sizeof(d->Led)); 2551 rc = pHlp->pfnSSMGetU32(pSSM, &val32); 2552 AssertRCReturn(rc, rc); 2553 d->drive = (fdrive_type_t)val32; 2554 pHlp->pfnSSMGetU8(pSSM, &d->dsk_chg); 2555 pHlp->pfnSSMGetU8(pSSM, &d->perpendicular); 2556 pHlp->pfnSSMGetU8(pSSM, &d->head); 2557 pHlp->pfnSSMGetU8(pSSM, &d->track); 2558 pHlp->pfnSSMGetU8(pSSM, &d->sect); 2559 } 2560 } 2572 else 2573 AssertFailedReturn(VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 2561 2574 return pHlp->pfnTimerLoad(pDevIns, pThis->hResultTimer, pSSM); 2562 2575 } … … 2850 2863 2851 2864 uint16_t uIrqDelay; 2852 rc = CFGMR3QueryU16Def(pCfg, "IRQDelay", &uIrqDelay, 0);2865 rc = pHlp->pfnCFGMQueryU16Def(pCfg, "IRQDelay", &uIrqDelay, 0); 2853 2866 AssertMsgRCReturn(rc, ("Configuration error: Failed to read U16 IRQDelay, rc=%Rrc\n", rc), rc); 2854 2867 … … 2897 2910 */ 2898 2911 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, fdcTimerCallback, pThis, 2899 2912 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "FDC Timer", &pThis->hResultTimer); 2900 2913 AssertRCReturn(rc, rc); 2901 2914 … … 2905 2918 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, fdcTransferDelayTimer, pThis, 2906 2919 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "FDC Transfer Delay Timer", &pThis->hXferDelayTimer); 2907 if (RT_FAILURE(rc)) 2908 return rc; 2920 AssertRCReturn(rc, rc); 2909 2921 2910 2922 /* … … 2913 2925 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, fdcIrqDelayTimer, pThis, 2914 2926 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "FDC IRQ Delay Timer", &pThis->hIrqDelayTimer); 2915 if (RT_FAILURE(rc)) 2916 return rc; 2927 AssertRCReturn(rc, rc); 2917 2928 2918 2929 pThis->uIrqDelayMsec = uIrqDelay;
Note:
See TracChangeset
for help on using the changeset viewer.