VirtualBox

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


Ignore:
Timestamp:
Jun 6, 2012 1:45:19 PM (13 years ago)
Author:
vboxsync
Message:

CMOS Debuging: As suggested by Michal, moved the debug information functions from DevPcBios.cpp to DevRTC.cpp.
(Debug Functions: info cmos (CMOSBankInfo), info cmos2(CMOSBank2Info), info rtc (CMOSRTCInfo)

Location:
trunk/src/VBox/Devices/PC
Files:
2 edited

Legend:

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

    r41593 r41599  
    4242#define NET_BOOT_DEVS   4
    4343
    44 #define CMOS_BANK_LOWER_LIMIT 0x0E
    45 #define CMOS_BANK_UPPER_LIMIT 0x7F
    46 #define CMOS_BANK2_LOWER_LIMIT 0x80
    47 #define CMOS_BANK2_UPPER_LIMIT 0xFF
    48 
    49 #define CMOS_RTC_OFFSET_SEC          0x0
    50 #define CMOS_RTC_OFFSET_MIN          0x02
    51 #define CMOS_RTC_OFFSET_HR           0x04
    52 #define CMOS_RTC_OFFSET_DAY          0x07
    53 #define CMOS_RTC_OFFSET_MONTH        0x08
    54 #define CMOS_RTC_OFFSET_YEAR         0x09
    5544
    5645/** @page pg_devbios_cmos_assign    CMOS Assignments (BIOS)
     
    239228
    240229
    241 static uint8_t bcd2bin(uint8_t val)
    242 {
    243     return (val & 0x0f) + (val >>4) *10;
    244 }
    245 
    246230/**
    247231 * Write to CMOS memory.
     
    271255
    272256    return u8val;
    273 }
    274 
    275 /**
    276  * @callback_method_impl{FNDBGFHANDLERDEV,
    277  *      Dumps the cmos Bank Info.}
    278  */
    279 static DECLCALLBACK(void) CMOSBankInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    280 {
    281     const char *PChCMOSBank = "CMOS Bank Info 0x0E - 0x7F";
    282     uint16_t u16ByteCount = 0;
    283     uint8_t   u8CMOSByte;
    284     pHlp->pfnPrintf(pHlp, "%s\n" ,PChCMOSBank);
    285     for (u16ByteCount = CMOS_BANK_LOWER_LIMIT; u16ByteCount < CMOS_BANK_UPPER_LIMIT; u16ByteCount++)
    286     {
    287         u8CMOSByte  = pcbiosCmosRead(pDevIns, u16ByteCount);
    288         pHlp->pfnPrintf(pHlp, "Off: 0x%02x Val: 0x%02x\n",u16ByteCount, u8CMOSByte);
    289     }
    290 }
    291 
    292 /**
    293  * @callback_method_impl{FNDBGFHANDLERDEV,
    294  *      Dumps the cmos Bank2 Info.}
    295  */
    296 static DECLCALLBACK(void) CMOSBank2Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    297 {
    298     const char *PChCMOSBank = "CMOS Bank2 Info 0x80 - 0xFF";
    299     uint16_t u16ByteCount = 0;
    300     uint8_t   u8CMOSByte;
    301     pHlp->pfnPrintf(pHlp, "%s\n" ,PChCMOSBank);
    302     for (u16ByteCount = CMOS_BANK2_LOWER_LIMIT; u16ByteCount < CMOS_BANK2_UPPER_LIMIT; u16ByteCount++)
    303     {
    304         u8CMOSByte  = pcbiosCmosRead(pDevIns, u16ByteCount);
    305         pHlp->pfnPrintf(pHlp, "Off: 0x%02x Val: 0x%02x\n",u16ByteCount, u8CMOSByte);
    306     }
    307 }
    308 
    309 /**
    310  * @callback_method_impl{FNDBGFHANDLERDEV,
    311  *      Dumps the cmos RTC Info.}
    312  */
    313 static DECLCALLBACK(void) CMOSRTCInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    314 {
    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;
    322     uint8_t u8RegB = 0;
    323    
    324     /*Don't move further if update is in progress*/
    325     if((pcbiosCmosRead(pDevIns, 0x0A) & 0x80 ))
    326     {
    327         pHlp->pfnPrintf(pHlp, " %s\n", PCFailNotice);
    328     }
    329     else
    330     {
    331         u8Sec = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_SEC);
    332         u8Min = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_MIN);
    333         u8Hr  = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_HR);
    334         u8Day   = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_DAY);
    335         u8Month = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_MONTH);
    336         u8Year  = pcbiosCmosRead(pDevIns, CMOS_RTC_OFFSET_YEAR);
    337 
    338         u8RegB = pcbiosCmosRead(pDevIns, 0x0B);
    339         if (!(u8RegB & 0x04))
    340         {
    341             u8Sec = (u8Sec & 0x0F) + ((u8Sec / 16) * 10);
    342             u8Min = (u8Min & 0x0F) + ((u8Min / 16) * 10);
    343             u8Hr = (u8Hr & 0x0F) + (( (u8Hr & 0x70) / 16) * 10) | (u8Hr & 0x80);
    344             u8Day = (u8Day & 0x0F) + ((u8Day / 16) * 10);
    345             u8Month = (u8Month & 0x0F) + ((u8Month / 16) * 10);
    346             u8Year = (u8Year & 0x0F) + ((u8Year / 16) * 10);
    347         }
    348         pHlp->pfnPrintf(pHlp, " Time: Hr:%u Min:%u Sec:%u, Day:%u Month:%u Year:%u\n", u8Hr, u8Min, u8Sec, u8Day, u8Month, u8Year);
    349     }
    350257}
    351258
     
    1024931    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    1025932
    1026     /*
    1027      * Register debugger info callback.
    1028      */
    1029     PDMDevHlpDBGFInfoRegister(pDevIns, "cmos", "Display CMOS Bank 1 Info.. "
    1030                               "'cmos'. No argument.", CMOSBankInfo);
    1031     PDMDevHlpDBGFInfoRegister(pDevIns, "cmos2", "Display CMOS Bank 2 Info.. "
    1032                               "'cmos2'. No argument", CMOSBank2Info);
    1033     PDMDevHlpDBGFInfoRegister(pDevIns, "rtc", "Display CMOS RTC info "
    1034                               "'rtc'. No argument", CMOSRTCInfo);
    1035933    /*
    1036934     * Validate configuration.
     
    15321430    if (pThis->uBootDelay > 15)
    15331431        pThis->uBootDelay = 15;
    1534      
    15351432
    15361433    /*
  • trunk/src/VBox/Devices/PC/DevRTC.cpp

    r41566 r41599  
    4444*   Header Files                                                               *
    4545*******************************************************************************/
    46 #define LOG_GROUP LOG_GROUP_DEV_RTC
     46#define LOG_GROUP LOG_GROUP_DEV_RTC 
    4747#include <VBox/vmm/pdmdev.h>
    4848#include <VBox/log.h>
     
    5757
    5858#include "VBoxDD.h"
    59 
    6059struct RTCState;
    6160typedef struct RTCState RTCState;
     
    111110#define REG_B_UIE 0x10
    112111
     112#define CMOS_BANK_LOWER_LIMIT 0x0E
     113#define CMOS_BANK_UPPER_LIMIT 0x7F
     114#define CMOS_BANK2_LOWER_LIMIT 0x80
     115#define CMOS_BANK2_UPPER_LIMIT 0xFF
    113116
    114117/** The saved state version. */
     
    275278    return ((a >> 4) * 10) + (a & 0x0f);
    276279}
     280
     281#ifdef IN_RING3
     282
     283/**
     284 * @callback_method_impl{FNDBGFHANDLERDEV,
     285 *      Dumps the cmos Bank Info.}
     286 */
     287static DECLCALLBACK(void) CMOSBankInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     288{
     289    RTCState *pThis = PDMINS_2_DATA(pDevIns, RTCState *);
     290    const char *PChCMOSBank = "CMOS Bank Info 0x0E - 0x7F";
     291    uint16_t u16ByteCount = 0;
     292    uint8_t   u8CMOSByte;
     293    pHlp->pfnPrintf(pHlp, "%s\n" ,PChCMOSBank);
     294    for (u16ByteCount = CMOS_BANK_LOWER_LIMIT; u16ByteCount < CMOS_BANK_UPPER_LIMIT; u16ByteCount++)
     295    {
     296        u8CMOSByte  =  pThis->cmos_data[u16ByteCount];
     297        pHlp->pfnPrintf(pHlp, "Off: 0x%02x Val: 0x%02x\n",u16ByteCount, u8CMOSByte);
     298    }
     299}
     300
     301/**
     302 * @callback_method_impl{FNDBGFHANDLERDEV,
     303 *      Dumps the cmos Bank2 Info.}
     304 */
     305static DECLCALLBACK(void) CMOSBank2Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     306{
     307    RTCState *pThis = PDMINS_2_DATA(pDevIns, RTCState *);
     308    const char *PChCMOSBank = "CMOS Bank2 Info 0x80 - 0xFF";
     309    uint16_t u16ByteCount = 0;
     310    uint8_t   u8CMOSByte;
     311    pHlp->pfnPrintf(pHlp, "%s\n" ,PChCMOSBank);
     312    for (u16ByteCount = CMOS_BANK2_LOWER_LIMIT; u16ByteCount < CMOS_BANK2_UPPER_LIMIT; u16ByteCount++)
     313    {
     314        u8CMOSByte  =  pThis->cmos_data[u16ByteCount];
     315        pHlp->pfnPrintf(pHlp, "Off: 0x%02x Val: 0x%02x\n",u16ByteCount, u8CMOSByte);
     316    }
     317}
     318
     319/**
     320 * @callback_method_impl{FNDBGFHANDLERDEV,
     321 *      Dumps the cmos RTC Info.}
     322 */
     323static DECLCALLBACK(void) CMOSRTCInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     324{
     325    RTCState *pThis = PDMINS_2_DATA(pDevIns, RTCState *);
     326    uint8_t u8Sec = 0;
     327    uint8_t u8Min = 0;
     328    uint8_t u8Hr = 0;
     329    uint8_t u8Day = 0;
     330    uint8_t u8Month = 0;
     331    uint8_t u8Year = 0;
     332   
     333    u8Sec = from_bcd(pThis, pThis->cmos_data[RTC_SECONDS]);
     334    u8Min = from_bcd(pThis, pThis->cmos_data[RTC_MINUTES]);
     335    u8Hr = from_bcd(pThis, pThis->cmos_data[RTC_HOURS] & 0x7f);
     336    if (   !(pThis->cmos_data[RTC_REG_B] & 0x02)
     337        && (pThis->cmos_data[RTC_HOURS] & 0x80))
     338        u8Hr += 12;
     339    u8Day = from_bcd(pThis, pThis->cmos_data[RTC_DAY_OF_MONTH]);
     340    u8Month = from_bcd(pThis, pThis->cmos_data[RTC_MONTH]) ;
     341    u8Year = from_bcd(pThis, pThis->cmos_data[RTC_YEAR]);
     342    pHlp->pfnPrintf(pHlp, "Time: Hr:%u Min:%u Sec:%u, Day:%u Month:%u Year:%u\n", u8Hr, u8Min, u8Sec, u8Day, u8Month, u8Year);
     343}
     344
     345#endif
    277346
    278347
     
    11641233        return rc;
    11651234
     1235    /*
     1236     * Register debugger info callback.
     1237    */
     1238    PDMDevHlpDBGFInfoRegister(pDevIns, "cmos", "Display CMOS Bank 1 Info.. "
     1239                              "'cmos'. No argument.", CMOSBankInfo);
     1240    PDMDevHlpDBGFInfoRegister(pDevIns, "cmos2", "Display CMOS Bank 2 Info.. "
     1241                              "'cmos2'. No argument", CMOSBank2Info);
     1242    PDMDevHlpDBGFInfoRegister(pDevIns, "rtc", "Display CMOS RTC info "
     1243                              "'rtc'. No argument", CMOSRTCInfo);
    11661244    return VINF_SUCCESS;
    11671245}
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