VirtualBox

Changeset 41592 in vbox


Ignore:
Timestamp:
Jun 6, 2012 8:35:54 AM (13 years ago)
Author:
vboxsync
Message:

PC/DevPcBios: Addition of checks for bcd/hex output and code improvement.

File:
1 edited

Legend:

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

    r41582 r41592  
    307307}
    308308
    309 
    310309/**
    311310 * @callback_method_impl{FNDBGFHANDLERDEV,
     
    314313static DECLCALLBACK(void) CMOSRTCInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    315314{
    316     uint8_t u8Sec;
    317     uint8_t u8Min;
    318     uint8_t u8Hr;
    319     uint8_t u8Day;
    320     uint8_t u8Month;
    321     uint8_t u8Year;
    322 
    323     u8Sec = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_SEC);
    324     u8Min = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_MIN);
    325     u8Min = bcd2bin(u8Min);
    326     u8Hr  = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_HR);
     315    const char * PCFailNotice = "Failed To Read Values. Time Update in Progress";
     316    uint8_t u8Sec = 0;
     317    uint8_t u8Min = 0;
     318    uint8_t u8Hr = 0;
     319    uint8_t u8Day = 0;
     320    uint8_t u8Month = 0;
     321    uint8_t u8Year = 0;
    327322   
    328     u8Day   = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_DAY);
    329     u8Month = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_MONTH);
    330    
    331     u8Year  = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_YEAR);
    332     u8Year = bcd2bin(u8Year);
    333     pHlp->pfnPrintf(pHlp, "Day:%u Month:%u Year:%u, Time: Hr:%u Min:%u Sec%u\n",u8Day, u8Month, u8Year, u8Hr, u8Min, u8Sec);
    334 
    335          
     323    /*Don't move further if update is in progress*/
     324    if((pcbiosCmosRead(pDevIns, 0x0A) & 0x80 ))
     325    {
     326        pHlp->pfnPrintf(pHlp, " %s\n", PCFailNotice);
     327    }
     328    else
     329    {
     330        u8Sec = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_SEC);
     331        u8Min = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_MIN);
     332        u8Hr  = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_HR);
     333        u8Day   = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_DAY);
     334        u8Month = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_MONTH);
     335        u8Year  = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_YEAR);
     336
     337        u8RegB = pcbiosCmosRead(pDevIns, 0x0B);
     338        if (!(u8RegB & 0x04))
     339        {
     340            u8Sec = (u8Sec & 0x0F) + ((u8Sec / 16) * 10);
     341            u8Min = (u8Min & 0x0F) + ((u8Min / 16) * 10);
     342            u8Hr = (u8Hr & 0x0F) + (( (u8Hr & 0x70) / 16) * 10) | (u8Hr & 0x80);
     343            u8Day = (u8Day & 0x0F) + ((u8Day / 16) * 10);
     344            u8Month = (u8Month & 0x0F) + ((u8Month / 16) * 10);
     345            u8Year = (u8Year & 0x0F) + ((u8Year / 16) * 10);
     346        }
     347        pHlp->pfnPrintf(pHlp, " Time: Hr:%u Min:%u Sec:%u, Day:%u Month:%u Year:%u\n", u8Hr, u8Min, u8Sec, u8Day, u8Month, u8Year);
     348    }
    336349}
    337350
     
    10101023    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    10111024
     1025    /*
     1026     * Register debugger info callback.
     1027     */
     1028    PDMDevHlpDBGFInfoRegister(pDevIns, "cmos", "Display CMOS Bank 1 Info.. "
     1029                              "'cmos'. No argument.", CMOSBankInfo);
     1030    PDMDevHlpDBGFInfoRegister(pDevIns, "cmos2", "Display CMOS Bank 2 Info.. "
     1031                              "'cmos2'. No argument", CMOSBank2Info);
     1032    PDMDevHlpDBGFInfoRegister(pDevIns, "rtc", "Display CMOS RTC info "
     1033                              "'rtc'. No argument", CMOSRTCInfo);
    10121034    /*
    10131035     * Validate configuration.
     
    15101532        pThis->uBootDelay = 15;
    15111533     
    1512     /*
    1513      * Register debugger info callback.
    1514      */
    1515     PDMDevHlpDBGFInfoRegister(pDevIns, "cmos", "Display CMOS Bank 1 Info.. "
    1516                               "'cmos'. No argument.", CMOSBankInfo);
    1517     PDMDevHlpDBGFInfoRegister(pDevIns, "cmos2", "Display CMOS Bank 2 Info.. "
    1518                               "'cmos2'. No argument", CMOSBank2Info);
    1519     PDMDevHlpDBGFInfoRegister(pDevIns, "rtc", "Display CMOS RTC info "
    1520                               "'rtc'. No argument", CMOSRTCInfo);
    15211534
    15221535    /*
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