VirtualBox

Changeset 89735 in vbox


Ignore:
Timestamp:
Jun 16, 2021 8:13:58 AM (3 years ago)
Author:
vboxsync
Message:

DevRTC: Added more statistics to the RTC device, tracking interrupt behavior. Also a few more symbolic constants instead of hardcoded numbers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevRTC.cpp

    r88836 r89735  
    9494#define REG_B_UIE 0x10
    9595
     96#define REG_C_IRQF  0x80
     97#define REG_C_PF    0x40
     98#define REG_C_AF    0x20
     99#define REG_C_UF    0x10
     100
    96101#define CMOS_BANK_LOWER_LIMIT   0x0E
    97102#define CMOS_BANK_UPPER_LIMIT   0x7F
     
    171176    /** Number of times the timer callback handler ran. */
    172177    STAMCOUNTER             StatRTCTimerCB;
     178    /** Number of times the PIE bit was changed. */
     179    STAMCOUNTER             StatRTCPieFlip;
     180    /** Number of times an interrupt was cleared. */
     181    STAMCOUNTER             StatRTCIrqClear;
     182    /** How long the periodic interrupt remains active. */
     183    STAMPROFILEADV          StatPIrqPending;
    173184} RTCSTATE;
    174185/** Pointer to the RTC device state. */
     
    381392            case RTC_REG_C:
    382393                *pu32 = pThis->cmos_data[pThis->cmos_index[0]];
     394                if (*pu32)  /* If any bits were set, reading will clear them. */
     395                {
     396                    STAM_REL_COUNTER_INC(&pThis->StatRTCIrqClear);
     397                    if (pThis->cmos_data[RTC_REG_C] & REG_C_PF)
     398                        STAM_REL_PROFILE_ADV_STOP(&pThis->StatPIrqPending, dummy);
     399                }
    383400                rtc_raise_irq(pDevIns, pThis, 0);
    384401                pThis->cmos_data[RTC_REG_C] = 0x00;
     
    481498                            rtc_set_time(pThis);
    482499                    }
     500
     501                    if (((uint8_t)u32 & REG_B_PIE) != (pThis->cmos_data[RTC_REG_B] & REG_B_PIE))
     502                        STAM_REL_COUNTER_INC(&pThis->StatRTCPieFlip);
     503
    483504                    pThis->cmos_data[RTC_REG_B] = u32;
    484505                }
     
    579600                    pThis->cmos_data[RTC_REG_A], pThis->cmos_data[RTC_REG_B],
    580601                    pThis->cmos_data[RTC_REG_C], pThis->cmos_data[RTC_REG_D]);
     602
     603    if (pThis->cmos_data[RTC_REG_B] & REG_B_PIE)
     604    {
     605        if (pThis->CurHintPeriod)
     606            pHlp->pfnPrintf(pHlp, "Periodic Interrupt Enabled: %d Hz\n", _32K / pThis->CurHintPeriod);
     607    }
    581608}
    582609
     
    599626    rtc_timer_update(pDevIns, pThis, pThis->next_periodic_time);
    600627    STAM_REL_COUNTER_INC(&pThis->StatRTCTimerCB);
    601     pThis->cmos_data[RTC_REG_C] |= 0xc0;
     628
     629    if (!(pThis->cmos_data[RTC_REG_C] & REG_C_PF))
     630        STAM_REL_PROFILE_ADV_START(&pThis->StatPIrqPending, dummy);
     631
     632    pThis->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_PF;
    602633
    603634    rtc_raise_irq(pDevIns, pThis, 1);
     
    756787            )
    757788        {
    758             pThis->cmos_data[RTC_REG_C] |= 0xa0;
     789            pThis->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_AF;
    759790            rtc_raise_irq(pDevIns, pThis, 1);
    760791        }
     
    764795    if (pThis->cmos_data[RTC_REG_B] & REG_B_UIE)
    765796    {
    766         pThis->cmos_data[RTC_REG_C] |= 0x90;
     797        pThis->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_UF;
    767798        rtc_raise_irq(pDevIns, pThis, 1);
    768799    }
     
    12221253     * Register statistics.
    12231254     */
    1224     PDMDevHlpSTAMRegister(pDevIns, &pThis->StatRTCIrq,      STAMTYPE_COUNTER, "Irq",      STAMUNIT_OCCURENCES,  "The number of times a RTC interrupt was triggered.");
    1225     PDMDevHlpSTAMRegister(pDevIns, &pThis->StatRTCTimerCB,  STAMTYPE_COUNTER, "TimerCB",  STAMUNIT_OCCURENCES,  "The number of times the RTC timer callback ran.");
     1255    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatRTCIrq,      STAMTYPE_COUNTER, "Irq",      STAMUNIT_OCCURENCES,      "The number of times a RTC interrupt was triggered.");
     1256    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatRTCTimerCB,  STAMTYPE_COUNTER, "TimerCB",  STAMUNIT_OCCURENCES,      "The number of times the RTC timer callback ran.");
     1257    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatRTCPieFlip,  STAMTYPE_COUNTER, "PieFlip",  STAMUNIT_OCCURENCES,      "The number of times Periodic Interrupt Enable changed.");
     1258    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatRTCIrqClear, STAMTYPE_COUNTER, "IrqClear", STAMUNIT_OCCURENCES,      "The number of times an active interrupt was cleared.");
     1259    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatPIrqPending, STAMTYPE_PROFILE, "PiActive", STAMUNIT_TICKS_PER_CALL,  "How long periodic interrupt stays active (pending).");
    12261260
    12271261    return VINF_SUCCESS;
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