Changeset 27460 in vbox for trunk/src/VBox
- Timestamp:
- Mar 17, 2010 5:21:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevRTC.cpp
r27126 r27460 1 1 /* $Id$ */ 2 2 /** @file 3 * Motorola MC146818 RTC/CMOS Device .3 * Motorola MC146818 RTC/CMOS Device with PIIX4 extensions. 4 4 */ 5 5 … … 117 117 118 118 /** The saved state version. */ 119 #define RTC_SAVED_STATE_VERSION 3 119 #define RTC_SAVED_STATE_VERSION 4 120 /** The saved state version used by VirtualBox pre-3.2. 121 * This does not include the second 128-byte bank. */ 122 #define RTC_SAVED_STATE_VERSION_VBOX_32PRE 3 120 123 /** The saved state version used by VirtualBox 3.1 and earlier. 121 * This does not include disabled by HPET state. 124 * This does not include disabled by HPET state. */ 122 125 #define RTC_SAVED_STATE_VERSION_VBOX_31 2 123 126 /** The saved state version used by VirtualBox 3.0 and earlier. … … 144 147 145 148 struct RTCState { 146 uint8_t cmos_data[ 128];147 uint8_t cmos_index ;148 uint8_t Alignment0[ 7];149 uint8_t cmos_data[256]; 150 uint8_t cmos_index[2]; 151 uint8_t Alignment0[6]; 149 152 struct my_tm current_tm; 150 153 /** The configured IRQ. */ … … 258 261 { 259 262 RTCState *s = (RTCState*)opaque; 260 263 uint32_t bank; 264 265 bank = (addr >> 1) & 1; 261 266 if ((addr & 1) == 0) { 262 s->cmos_index = data & 0x7f;267 s->cmos_index[bank] = (data & 0x7f) + (bank * 128); 263 268 } else { 264 Log(("CMOS: Write idx %#04x: %#04x (old %#04x)\n", s->cmos_index, data, s->cmos_data[s->cmos_index])); 265 switch(s->cmos_index) { 269 Log(("CMOS: Write bank %d idx %#04x: %#04x (old %#04x)\n", bank, 270 s->cmos_index[bank], data, s->cmos_data[s->cmos_index[bank]])); 271 switch(s->cmos_index[bank]) { 266 272 case RTC_SECONDS_ALARM: 267 273 case RTC_MINUTES_ALARM: 268 274 case RTC_HOURS_ALARM: 269 s->cmos_data[s->cmos_index ] = data;275 s->cmos_data[s->cmos_index[0]] = data; 270 276 break; 271 277 case RTC_SECONDS: … … 276 282 case RTC_MONTH: 277 283 case RTC_YEAR: 278 s->cmos_data[s->cmos_index ] = data;284 s->cmos_data[s->cmos_index[0]] = data; 279 285 /* if in set mode, do not update the time */ 280 286 if (!(s->cmos_data[RTC_REG_B] & REG_B_SET)) { … … 309 315 break; 310 316 default: 311 s->cmos_data[s->cmos_index ] = data;317 s->cmos_data[s->cmos_index[bank]] = data; 312 318 break; 313 319 } … … 488 494 RTCState *s = (RTCState*)opaque; 489 495 int ret; 496 unsigned bank; 497 498 bank = (addr >> 1) & 1; 490 499 if ((addr & 1) == 0) { 491 500 return 0xff; 492 501 } else { 493 switch(s->cmos_index ) {502 switch(s->cmos_index[bank]) { 494 503 case RTC_SECONDS: 495 504 case RTC_MINUTES: … … 499 508 case RTC_MONTH: 500 509 case RTC_YEAR: 501 ret = s->cmos_data[s->cmos_index ];510 ret = s->cmos_data[s->cmos_index[0]]; 502 511 break; 503 512 case RTC_REG_A: 504 ret = s->cmos_data[s->cmos_index ];513 ret = s->cmos_data[s->cmos_index[0]]; 505 514 break; 506 515 case RTC_REG_C: 507 ret = s->cmos_data[s->cmos_index ];516 ret = s->cmos_data[s->cmos_index[0]]; 508 517 rtc_raise_irq(s, 0); 509 518 s->cmos_data[RTC_REG_C] = 0x00; 510 519 break; 511 520 default: 512 ret = s->cmos_data[s->cmos_index ];521 ret = s->cmos_data[s->cmos_index[bank]]; 513 522 break; 514 523 } 515 Log(("CMOS: Read idx %#04x: %#04x\n", s->cmos_index, ret));524 Log(("CMOS: Read bank %d idx %#04x: %#04x\n", bank, s->cmos_index[bank], ret)); 516 525 return ret; 517 526 } … … 645 654 /* The state. */ 646 655 SSMR3PutMem(pSSM, pThis->cmos_data, 128); 647 SSMR3PutU8(pSSM, pThis->cmos_index );656 SSMR3PutU8(pSSM, pThis->cmos_index[0]); 648 657 649 658 SSMR3PutS32(pSSM, pThis->current_tm.tm_sec); … … 663 672 TMR3TimerSave(pThis->CTX_SUFF(pSecondTimer2), pSSM); 664 673 665 return SSMR3PutBool(pSSM, pThis->fDisabledByHpet); 674 SSMR3PutBool(pSSM, pThis->fDisabledByHpet); 675 676 SSMR3PutMem(pSSM, &pThis->cmos_data[128], 128); 677 return SSMR3PutU8(pSSM, pThis->cmos_index[1]); 666 678 } 667 679 … … 676 688 677 689 if ( uVersion != RTC_SAVED_STATE_VERSION 690 && uVersion != RTC_SAVED_STATE_VERSION_VBOX_32PRE 678 691 && uVersion != RTC_SAVED_STATE_VERSION_VBOX_31 679 692 && uVersion != RTC_SAVED_STATE_VERSION_VBOX_30) … … 704 717 /* The state. */ 705 718 SSMR3GetMem(pSSM, pThis->cmos_data, 128); 706 SSMR3GetU8(pSSM, &pThis->cmos_index );719 SSMR3GetU8(pSSM, &pThis->cmos_index[0]); 707 720 708 721 SSMR3GetS32(pSSM, &pThis->current_tm.tm_sec); … … 724 737 if (uVersion > RTC_SAVED_STATE_VERSION_VBOX_31) 725 738 SSMR3GetBool(pSSM, &pThis->fDisabledByHpet); 739 740 if (uVersion > RTC_SAVED_STATE_VERSION_VBOX_32PRE) 741 { 742 /* Second CMOS bank. */ 743 SSMR3GetMem(pSSM, &pThis->cmos_data[128], 128); 744 SSMR3GetU8(pSSM, &pThis->cmos_index[1]); 745 } 726 746 727 747 int period_code = pThis->cmos_data[RTC_REG_A] & 0x0f; … … 767 787 * @returns VBox status code. 768 788 * @param pDevIns Device instance of the RTC. 769 * @param iReg The CMOS register index .789 * @param iReg The CMOS register index; bit 8 determines bank. 770 790 * @param u8Value The CMOS register value. 771 791 */ … … 794 814 * @returns VBox status code. 795 815 * @param pDevIns Device instance of the RTC. 796 * @param iReg The CMOS register index .816 * @param iReg The CMOS register index; bit 8 determines bank. 797 817 * @param pu8Value Where to store the CMOS register value. 798 818 */ … … 851 871 rtcCalcCRC(pThis); 852 872 853 Log(("CMOS: \n%16.128Rhxd\n", pThis->cmos_data)); 873 Log(("CMOS bank 0: \n%16.128Rhxd\n", &pThis->cmos_data[0])); 874 Log(("CMOS bank 1: \n%16.128Rhxd\n", &pThis->cmos_data[128])); 854 875 return VINF_SUCCESS; 855 876 } … … 1000 1021 return rc; 1001 1022 1002 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->IOPortBase, 2, NULL,1023 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->IOPortBase, 4, NULL, 1003 1024 rtcIOPortWrite, rtcIOPortRead, NULL, NULL, "MC146818 RTC/CMOS"); 1004 1025 if (RT_FAILURE(rc)) … … 1006 1027 if (fGCEnabled) 1007 1028 { 1008 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->IOPortBase, 2, 0,1029 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->IOPortBase, 4, 0, 1009 1030 "rtcIOPortWrite", "rtcIOPortRead", NULL, NULL, "MC146818 RTC/CMOS"); 1010 1031 if (RT_FAILURE(rc)) … … 1013 1034 if (fR0Enabled) 1014 1035 { 1015 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->IOPortBase, 2, 0,1036 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->IOPortBase, 4, 0, 1016 1037 "rtcIOPortWrite", "rtcIOPortRead", NULL, NULL, "MC146818 RTC/CMOS"); 1017 1038 if (RT_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.