VirtualBox

Changeset 11209 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Aug 7, 2008 3:57:29 PM (16 years ago)
Author:
vboxsync
Message:

DevRTC: dropped the vl_vbox.h dependency.

File:
1 edited

Legend:

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

    r9212 r11209  
    5353#include <iprt/asm.h>
    5454#include <iprt/assert.h>
    55 
    56 #include "vl_vbox.h"
     55#include <iprt/string.h>
    5756
    5857struct RTCState;
     
    6463#define RTC_CRC_LOW     0x2f
    6564
    66 #ifndef VBOX_DEVICE_STRUCT_TESTCASE
     65
    6766/*******************************************************************************
    6867*   Internal Functions                                                         *
    6968*******************************************************************************/
     69#ifndef VBOX_DEVICE_STRUCT_TESTCASE
    7070__BEGIN_DECLS
    7171PDMBOTHCBDECL(int) rtcIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
     
    7777#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
    7878
     79
     80/*******************************************************************************
     81*   Defined Constants And Macros                                               *
     82*******************************************************************************/
    7983/*#define DEBUG_CMOS*/
    8084
     
    104108#define REG_B_UIE 0x10
    105109
     110
     111/*******************************************************************************
     112*   Structures and Typedefs                                                    *
     113*******************************************************************************/
    106114/** @todo Replace struct my_tm with RTTIME. */
    107115struct my_tm
     
    471479}
    472480
    473 static void rtc_save(QEMUFile *f, void *opaque)
    474 {
    475     RTCState *s = (RTCState*)opaque;
    476 
    477     qemu_put_buffer(f, s->cmos_data, 128);
    478     qemu_put_8s(f, &s->cmos_index);
    479 
    480     qemu_put_be32s(f, &s->current_tm.tm_sec);
    481     qemu_put_be32s(f, &s->current_tm.tm_min);
    482     qemu_put_be32s(f, &s->current_tm.tm_hour);
    483     qemu_put_be32s(f, &s->current_tm.tm_wday);
    484     qemu_put_be32s(f, &s->current_tm.tm_mday);
    485     qemu_put_be32s(f, &s->current_tm.tm_mon);
    486     qemu_put_be32s(f, &s->current_tm.tm_year);
    487 
    488     qemu_put_timer(f, s->CTXSUFF(pPeriodicTimer));
    489     qemu_put_be64s(f, &s->next_periodic_time);
    490 
    491     qemu_put_be64s(f, &s->next_second_time);
    492     qemu_put_timer(f, s->CTXSUFF(pSecondTimer));
    493     qemu_put_timer(f, s->CTXSUFF(pSecondTimer2));
    494 
    495 }
    496 
    497 static int rtc_load(QEMUFile *f, void *opaque, int version_id)
    498 {
    499     RTCState *s = (RTCState*)opaque;
    500 
    501     if (version_id != 1)
    502         return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    503 
    504     qemu_get_buffer(f, s->cmos_data, 128);
    505     qemu_get_8s(f, &s->cmos_index);
    506 
    507     qemu_get_be32s(f, (uint32_t *)&s->current_tm.tm_sec);
    508     qemu_get_be32s(f, (uint32_t *)&s->current_tm.tm_min);
    509     qemu_get_be32s(f, (uint32_t *)&s->current_tm.tm_hour);
    510     qemu_get_be32s(f, (uint32_t *)&s->current_tm.tm_wday);
    511     qemu_get_be32s(f, (uint32_t *)&s->current_tm.tm_mday);
    512     qemu_get_be32s(f, (uint32_t *)&s->current_tm.tm_mon);
    513     qemu_get_be32s(f, (uint32_t *)&s->current_tm.tm_year);
    514 
    515     qemu_get_timer(f, s->CTXSUFF(pPeriodicTimer));
    516 
    517     qemu_get_be64s(f, (uint64_t *)&s->next_periodic_time);
    518 
    519     qemu_get_be64s(f, (uint64_t *)&s->next_second_time);
    520     qemu_get_timer(f, s->CTXSUFF(pSecondTimer));
    521     qemu_get_timer(f, s->CTXSUFF(pSecondTimer2));
    522 
    523     int period_code = s->cmos_data[RTC_REG_A] & 0x0f;
    524     if (    period_code != 0
    525         &&  (s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
    526         if (period_code <= 2)
    527             period_code += 7;
    528         int period = 1 << (period_code - 1);
    529         LogRel(("RTC: period=%#x (%d) %u Hz (restore)\n", period, period, _32K / period));
    530         s->CurPeriod = period;
    531     } else {
    532         LogRel(("RTC: stopped the periodic timer (restore)\n"));
    533         s->CurPeriod = 0;
    534     }
    535     s->cRelLogEntries = 0;
    536     return 0;
    537 }
    538481#endif /* IN_RING3 */
    539482
     
    629572static DECLCALLBACK(int) rtcSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
    630573{
    631     RTCState *pData = PDMINS2DATA(pDevIns, RTCState *);
    632     rtc_save(pSSMHandle, pData);
     574    RTCState *pThis = PDMINS2DATA(pDevIns, RTCState *);
     575
     576    SSMR3PutMem(pSSMHandle, pThis->cmos_data, 128);
     577    SSMR3PutU8(pSSMHandle, pThis->cmos_index);
     578
     579    SSMR3PutS32(pSSMHandle, pThis->current_tm.tm_sec);
     580    SSMR3PutS32(pSSMHandle, pThis->current_tm.tm_min);
     581    SSMR3PutS32(pSSMHandle, pThis->current_tm.tm_hour);
     582    SSMR3PutS32(pSSMHandle, pThis->current_tm.tm_wday);
     583    SSMR3PutS32(pSSMHandle, pThis->current_tm.tm_mday);
     584    SSMR3PutS32(pSSMHandle, pThis->current_tm.tm_mon);
     585    SSMR3PutS32(pSSMHandle, pThis->current_tm.tm_year);
     586
     587    TMR3TimerSave(pThis->CTXSUFF(pPeriodicTimer), pSSMHandle);
     588
     589    SSMR3PutS64(pSSMHandle, pThis->next_periodic_time);
     590
     591    SSMR3PutS64(pSSMHandle, pThis->next_second_time);
     592    TMR3TimerSave(pThis->CTXSUFF(pSecondTimer), pSSMHandle);
     593    TMR3TimerSave(pThis->CTXSUFF(pSecondTimer2), pSSMHandle);
     594
    633595    return VINF_SUCCESS;
    634596}
     
    645607static DECLCALLBACK(int) rtcLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t u32Version)
    646608{
    647     RTCState *pData = PDMINS2DATA(pDevIns, RTCState *);
    648     return rtc_load(pSSMHandle, pData, u32Version);
     609    RTCState *pThis = PDMINS2DATA(pDevIns, RTCState *);
     610
     611    if (u32Version != 1)
     612        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
     613
     614    SSMR3GetMem(pSSMHandle, pThis->cmos_data, 128);
     615    SSMR3GetU8(pSSMHandle, &pThis->cmos_index);
     616
     617    SSMR3GetS32(pSSMHandle, &pThis->current_tm.tm_sec);
     618    SSMR3GetS32(pSSMHandle, &pThis->current_tm.tm_min);
     619    SSMR3GetS32(pSSMHandle, &pThis->current_tm.tm_hour);
     620    SSMR3GetS32(pSSMHandle, &pThis->current_tm.tm_wday);
     621    SSMR3GetS32(pSSMHandle, &pThis->current_tm.tm_mday);
     622    SSMR3GetS32(pSSMHandle, &pThis->current_tm.tm_mon);
     623    SSMR3GetS32(pSSMHandle, &pThis->current_tm.tm_year);
     624
     625    TMR3TimerLoad(pThis->CTXSUFF(pPeriodicTimer), pSSMHandle);
     626
     627    SSMR3GetS64(pSSMHandle, &pThis->next_periodic_time);
     628
     629    SSMR3GetS64(pSSMHandle, &pThis->next_second_time);
     630    TMR3TimerLoad(pThis->CTXSUFF(pSecondTimer), pSSMHandle);
     631    TMR3TimerLoad(pThis->CTXSUFF(pSecondTimer2), pSSMHandle);
     632
     633    int period_code = pThis->cmos_data[RTC_REG_A] & 0x0f;
     634    if (    period_code != 0
     635        &&  (pThis->cmos_data[RTC_REG_B] & REG_B_PIE)) {
     636        if (period_code <= 2)
     637            period_code += 7;
     638        int period = 1 << (period_code - 1);
     639        LogRel(("RTC: period=%#x (%d) %u Hz (restore)\n", period, period, _32K / period));
     640        pThis->CurPeriod = period;
     641    } else {
     642        LogRel(("RTC: stopped the periodic timer (restore)\n"));
     643        pThis->CurPeriod = 0;
     644    }
     645    pThis->cRelLogEntries = 0;
     646    return VINF_SUCCESS;
    649647}
    650648
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