VirtualBox

Changeset 4429 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Aug 30, 2007 3:41:19 AM (17 years ago)
Author:
vboxsync
Message:

proper implementation of the ram refresh bit in 61h (bit 4).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevPit-i8254.cpp

    r4071 r4429  
    6868#define PIT_SAVED_STATE_VERSION 2
    6969
     70/** @def FAKE_REFRESH_CLOCK
     71 * Define this to flip the 15usec refresh bit on every read.
     72 * If not defined, it will be flipped correctly. */
     73//#define FAKE_REFRESH_CLOCK
    7074
    7175/*******************************************************************************
     
    118122    /** Speaker data. */
    119123    int32_t                 speaker_data_on;
     124#ifdef FAKE_REFRESH_CLOCK
    120125    /** Speaker dummy. */
    121126    int32_t                 dummy_refresh_clock;
     127#endif
    122128    /** Pointer to the device instance. */
    123129    HCPTRTYPE(PPDMDEVINS)   pDevIns;
     
    298304    if (    s->pTimerHC /* ch 0 */
    299305        &&  s->cRelLogEntries++ < 32)
    300         LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=0)\n", 
     306        LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=0)\n",
    301307                s->mode, s->count, s->count, PIT_FREQ / s->count, (PIT_FREQ * 100 / s->count) % 100));
    302308}
     
    627633    {
    628634        PITState *pData = PDMINS2DATA(pDevIns, PITState *);
    629         int out = pit_get_out(pData, 2, TMTimerGet(pData->channels[0].CTXSUFF(pTimer)));
     635        const uint64_t u64Now = TMTimerGet(pData->channels[0].CTXSUFF(pTimer));
     636        Assert(TMTimerGetFreq(pData->channels[0].CTXSUFF(pTimer)) == 1000000000); /* lazy bird. */
     637
     638        /* bit 6,7 Parity error stuff. */
     639        /* bit 5 - mirrors timer 2 output condition. */
     640        const int fOut = pit_get_out(pData, 2, u64Now);
     641        /* bit 4 - toggled every with each (DRAM?) refresh request, every 15.085 µs. */
     642#ifdef FAKE_REFRESH_CLOCK
    630643        pData->dummy_refresh_clock ^= 1;
    631         *pu32 = (pData->speaker_data_on << 1) | pit_get_gate(pData, 2) | (out << 5) | (pData->dummy_refresh_clock << 4);
     644        const int fRefresh = pData->dummy_refresh_clock;
     645#else
     646        const int fRefresh = (u64Now / 15085) & 1;
     647#endif
     648        /* bit 2,3 NMI / parity status stuff. */
     649        /* bit 1 - speaker data status */
     650        const int fSpeakerStatus = pData->speaker_data_on;
     651        /* bit 0 - timer 2 clock gate to speaker status. */
     652        const int fTimer2GateStatus = pit_get_gate(pData, 2);
     653
     654        *pu32 = fTimer2GateStatus
     655              | (fSpeakerStatus << 1)
     656              | (fRefresh << 4)
     657              | (fOut << 5);
    632658        Log(("pitIOPortSpeakerRead: Port=%#x cb=%x *pu32=%#x\n", Port, cb, *pu32));
    633659        return VINF_SUCCESS;
     
    700726
    701727    SSMR3PutS32(pSSMHandle, pData->speaker_data_on);
     728#ifdef FAKE_REFRESH_CLOCK
    702729    return SSMR3PutS32(pSSMHandle, pData->dummy_refresh_clock);
     730#else
     731    return SSMR3PutS32(pSSMHandle, 0);
     732#endif
    703733}
    704734
     
    742772        {
    743773            TMR3TimerLoad(s->CTXSUFF(pTimer), pSSMHandle);
    744             LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=%d) (restore)\n", 
     774            LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=%d) (restore)\n",
    745775                    s->mode, s->count, s->count, PIT_FREQ / s->count, (PIT_FREQ * 100 / s->count) % 100, i));
    746776        }
     
    749779
    750780    SSMR3GetS32(pSSMHandle, &pData->speaker_data_on);
     781#ifdef FAKE_REFRESH_CLOCK
    751782    return SSMR3GetS32(pSSMHandle, &pData->dummy_refresh_clock);
     783#else
     784    int32_t u32Dummy;
     785    return SSMR3GetS32(pSSMHandle, &u32Dummy);
     786#endif
    752787}
    753788
     
    861896                        pCh->u64ReloadTS,       pCh->u64NextTS);
    862897    }
     898#ifdef FAKE_REFRESH_CLOCK
    863899    pHlp->pfnPrintf(pHlp, "speaker_data_on=%#x dummy_refresh_clock=%#x\n",
    864900                    pData->speaker_data_on, pData->dummy_refresh_clock);
     901#else
     902    pHlp->pfnPrintf(pHlp, "speaker_data_on=%#x\n", pData->speaker_data_on);
     903#endif
    865904}
    866905
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