Changeset 11209 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Aug 7, 2008 3:57:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevRTC.cpp
r9212 r11209 53 53 #include <iprt/asm.h> 54 54 #include <iprt/assert.h> 55 56 #include "vl_vbox.h" 55 #include <iprt/string.h> 57 56 58 57 struct RTCState; … … 64 63 #define RTC_CRC_LOW 0x2f 65 64 66 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 65 67 66 /******************************************************************************* 68 67 * Internal Functions * 69 68 *******************************************************************************/ 69 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 70 70 __BEGIN_DECLS 71 71 PDMBOTHCBDECL(int) rtcIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb); … … 77 77 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ 78 78 79 80 /******************************************************************************* 81 * Defined Constants And Macros * 82 *******************************************************************************/ 79 83 /*#define DEBUG_CMOS*/ 80 84 … … 104 108 #define REG_B_UIE 0x10 105 109 110 111 /******************************************************************************* 112 * Structures and Typedefs * 113 *******************************************************************************/ 106 114 /** @todo Replace struct my_tm with RTTIME. */ 107 115 struct my_tm … … 471 479 } 472 480 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 != 0525 && (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 }538 481 #endif /* IN_RING3 */ 539 482 … … 629 572 static DECLCALLBACK(int) rtcSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle) 630 573 { 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 633 595 return VINF_SUCCESS; 634 596 } … … 645 607 static DECLCALLBACK(int) rtcLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t u32Version) 646 608 { 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; 649 647 } 650 648
Note:
See TracChangeset
for help on using the changeset viewer.