VirtualBox

儲存庫 vbox 的更動 34900


忽略:
時間撮記:
2010-12-9 下午03:24:38 (14 年 以前)
作者:
vboxsync
訊息:

Moved rounding fix so that the PIT IRQ stat still works.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/PC/DevPit-i8254.cpp

    r34896 r34900  
    356356    uint32_t period2;
    357357
    358     /* Add one to current_time; if we don't, integer truncation will cause
    359      * the algorithm to think that at the end of each period, it's still
    360      * within the first one instead of at the beginning of the next one.
    361      */
    362     d = ASMMultU64ByU32DivByU32(current_time + 1 - s->count_load_time, PIT_FREQ, TMTimerGetFreq(pTimer));
     358    d = ASMMultU64ByU32DivByU32(current_time - s->count_load_time, PIT_FREQ, TMTimerGetFreq(pTimer));
    363359    switch(s->mode) {
    364360    default:
     
    371367        break;
    372368    /*
    373      * Mode 2: The period is count + 1 PIT ticks.
     369     * Mode 2: The period is 'count' PIT ticks.
    374370     * When the counter reaches 1 we set the output low (for channel 0 that
    375371     * means lowering IRQ0). On the next tick, where we should be decrementing
     
    377373     * means raising IRQ0 again and triggering timer interrupt).
    378374     *
    379      * In VBox we simplify the tick cycle between 1 and 0 and immediately trigger
    380      * the interrupt. We also don't set it until we reach 0, which is a tick late
    381      *  - will try to fix that later some day.
     375     * In VirtualBox we compress the pulse and flip-flop the IRQ line at the
     376     * end of the period, which signals an interrupt at the exact same time.
    382377     */
    383378    case 2:
     
    385380#ifndef VBOX /* see above */
    386381        if ((d - base) == 0 && d != 0)
    387             next_time = base + s->count;
     382            next_time = base + s->count - 1;
    388383        else
    389384#endif
    390             next_time = base + s->count + 1;
     385            next_time = base + s->count;
    391386        break;
    392387    case 3:
     
    413408    next_time = s->count_load_time + ASMMultU64ByU32DivByU32(next_time, TMTimerGetFreq(pTimer), PIT_FREQ);
    414409    /* fix potential rounding problems */
    415     /* XXX: better solution: use a clock at PIT_FREQ Hz */
    416410    if (next_time <= current_time)
    417         next_time = current_time + 1;
    418     return next_time;
     411        next_time = current_time;
     412    /* Add one to next_time; if we don't, integer truncation will cause
     413     * the algorithm to think that at the end of each period, it's still
     414     * within the first one instead of at the beginning of the next one.
     415     */
     416    return next_time + 1;
    419417}
    420418
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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