VirtualBox

Changeset 20049 in vbox


Ignore:
Timestamp:
May 26, 2009 5:10:42 PM (16 years ago)
Author:
vboxsync
Message:

DevPit-i8254.cpp: Don't call TMVirtualGet multiple times when reprogramming the timer. Fixes the TM.cpp assertion.

File:
1 edited

Legend:

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

    r16158 r20049  
    162162#ifdef IN_RING3
    163163PDMBOTHCBDECL(int) pitIOPortSpeakerWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);
    164 static void pit_irq_timer_update(PITChannelState *s, uint64_t current_time);
     164static void pit_irq_timer_update(PITChannelState *s, uint64_t current_time, uint64_t now);
    165165#endif
    166166__END_DECLS
     
    287287        if (s->gate < val) {
    288288            /* restart counting on rising edge */
     289            Log(("pit_set_gate: restarting mode %d\n", s->mode));
    289290            s->count_load_time = TMTimerGet(pTimer);
    290             pit_irq_timer_update(s, s->count_load_time);
     291            pit_irq_timer_update(s, s->count_load_time, s->count_load_time);
    291292        }
    292293        break;
     
    295296        if (s->gate < val) {
    296297            /* restart counting on rising edge */
     298            Log(("pit_set_gate: restarting mode %d\n", s->mode));
    297299            s->count_load_time = s->u64ReloadTS = TMTimerGet(pTimer);
    298             pit_irq_timer_update(s, s->count_load_time);
     300            pit_irq_timer_update(s, s->count_load_time, s->count_load_time);
    299301        }
    300302        /* XXX: disable/enable counting */
     
    311313    s->count_load_time = s->u64ReloadTS = TMTimerGet(pTimer);
    312314    s->count = val;
    313     pit_irq_timer_update(s, s->count_load_time);
     315    pit_irq_timer_update(s, s->count_load_time, s->count_load_time);
    314316
    315317    /* log the new rate (ch 0 only). */
     
    318320        LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=0)\n",
    319321                s->mode, s->count, s->count, PIT_FREQ / s->count, (PIT_FREQ * 100 / s->count) % 100));
     322    else
     323        Log(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=0)\n",
     324             s->mode, s->count, s->count, PIT_FREQ / s->count, (PIT_FREQ * 100 / s->count) % 100));
    320325}
    321326
     
    377382    }
    378383    /* convert to timer units */
    379     LogFlow(("PIT: next_time=%14RI64 %20RI64 mode=%#x count=%#06x\n", next_time,
     384    LogFlow(("PIT: next_time=%'14RU64 %'20RU64 mode=%#x count=%#06x\n", next_time,
    380385             ASMMultU64ByU32DivByU32(next_time, TMTimerGetFreq(pTimer), PIT_FREQ), s->mode, s->count));
    381386    next_time = s->count_load_time + ASMMultU64ByU32DivByU32(next_time, TMTimerGetFreq(pTimer), PIT_FREQ);
     
    387392}
    388393
    389 static void pit_irq_timer_update(PITChannelState *s, uint64_t current_time)
    390 {
    391     uint64_t now;
     394static void pit_irq_timer_update(PITChannelState *s, uint64_t current_time, uint64_t now)
     395{
    392396    int64_t expire_time;
    393397    int irq_level;
     
    405409    if (irq_level)
    406410        PDMDevHlpISASetIrq(pDevIns, s->irq, 0);
    407     now = TMTimerGet(pTimer);
    408     Log3(("pit_irq_timer_update: %lldns late\n", now - s->u64NextTS));
    409411    if (irq_level)
    410412    {
     
    415417    if (expire_time != -1)
    416418    {
     419        Log3(("pit_irq_timer_update: next=%'RU64 now=%'RU64\n", expire_time, now));
    417420        s->u64NextTS = expire_time;
    418421        TMTimerSet(s->CTX_SUFF(pTimer), s->u64NextTS);
     
    812815    PITChannelState *s = &pThis->channels[0];
    813816    STAM_PROFILE_ADV_START(&s->CTX_SUFF(pPit)->StatPITHandler, a);
    814     pit_irq_timer_update(s, s->next_transition_time);
     817    Log(("pitTimer\n"));
     818    pit_irq_timer_update(s, s->next_transition_time, TMTimerGet(pTimer));
    815819    STAM_PROFILE_ADV_STOP(&s->CTX_SUFF(pPit)->StatPITHandler, a);
    816820}
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