- Timestamp:
- Mar 5, 2010 6:13:57 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmifs.h
r26935 r27121 1937 1937 #define PDMIVMMDEVPORT_IID "d7e52035-3b6c-422e-9215-2a75646a945d" 1938 1938 1939 /** Pointer to a PIT port interface. */ 1940 typedef struct PDMIPITPORT *PPDMIPITPORT; 1941 /** 1942 * PIT port interface. 1943 */ 1944 typedef struct PDMIPITPORT 1945 { 1946 /** 1947 * Notify PIT about change of HPET legacy mode. 1948 * 1949 * @returns VBox status code 1950 * @param pInterface Pointer to the interface structure containing the called function pointer. 1951 * @param fActivate If HPET legacy mode activated or deactivated. 1952 */ 1953 DECLR3CALLBACKMEMBER(int, pfnNotifyHpetLegacy,(PPDMIPITPORT pInterface, bool fActivate)); 1954 } PDMIPITPORT; 1955 /** PDMIPITPORT interface ID. */ 1956 #define PDMIPITPORT_IID "06127207-3182-4394-b16e-0ecfeb5cbb27" 1957 1958 /** Pointer to a RTC port interface. */ 1959 typedef struct PDMIRTCPORT *PPDMIRTCPORT; 1960 /** 1961 * RTC port interface. 1962 */ 1963 typedef struct PDMIRTCPORT 1964 { 1965 /** 1966 * Notify RTC about change of HPET legacy mode. 1967 * 1968 * @returns VBox status code 1969 * @param pInterface Pointer to the interface structure containing the called function pointer. 1970 * @param fActivate If HPET legacy mode activated or deactivated. 1971 */ 1972 DECLR3CALLBACKMEMBER(int, pfnNotifyHpetLegacy,(PPDMIRTCPORT pInterface, bool fActivate)); 1973 } PDMIRTCPORT; 1974 /** PDMIRTCPORT interface ID. */ 1975 #define PDMIRTCPORT_IID "b6af0d7c-56c7-4064-85aa-ba78b43a26e7" 1976 1977 1939 1978 /** @name Flags for PDMIVMMDEVPORT::pfnSetCredentials. 1940 1979 * @{ */ -
trunk/src/VBox/Devices/PC/DevHPET.cpp
r26939 r27121 36 36 * - not entirely correct time of interrupt, i.e. never 37 37 * schedule interrupt earlier than in 1ms 38 * - interaction with RTC and PIT in legacy mode not yet fully implemented39 * (HPET part OK, PDM and PIT/RTC to be done)40 38 * - statistics not implemented 41 39 */ … … 590 588 rc = VINF_IOM_HC_MMIO_WRITE; 591 589 #else /* IN_RING3 */ 592 LogRel(("HPET: cannot update PIT/RTC in legacy mode yet"));593 590 if (pThis->pHpetHlpR3) 594 591 rc = pThis->pHpetHlpR3->pfnSetLegacyMode(pThis->pDevInsR3, fActivate); … … 618 615 619 616 iOldValue = (uint32_t)(pThis->u64Config); 617 618 /** 619 * This check must be here, before actual update, as hpetLegacyMode 620 * may request retry in R3 - so we must keep state intact. 621 */ 622 if (isBitJustSet(iOldValue, iNewValue, HPET_CFG_LEGACY)) 623 { 624 rc = hpetLegacyMode(pThis, true); 625 } 626 else if (isBitJustCleared(iOldValue, iNewValue, HPET_CFG_LEGACY)) 627 { 628 rc = hpetLegacyMode(pThis, false); 629 } 630 if (rc != VINF_SUCCESS) 631 return rc; 632 620 633 pThis->u64Config = updateMasked(iNewValue, iOldValue, HPET_CFG_WRITE_MASK); 621 634 if (isBitJustSet(iOldValue, iNewValue, HPET_CFG_ENABLE)) … … 635 648 TMTimerStop(pThis->aTimers[i].CTX_SUFF(pTimer)); 636 649 } 637 /** @todo: implement i8254 and RTC interaction */638 if (isBitJustSet(iNewValue, iOldValue, HPET_CFG_LEGACY))639 {640 rc = hpetLegacyMode(pThis, true);641 }642 else if (isBitJustCleared(iOldValue, iNewValue, HPET_CFG_LEGACY))643 {644 rc = hpetLegacyMode(pThis, false);645 }646 650 break; 647 651 } … … 1077 1081 1078 1082 LogFlow(("hpetReset:\n")); 1083 1084 pThis->u64Config = 0; 1079 1085 for (i = 0; i < HPET_NUM_TIMERS; i++) 1080 1086 { -
trunk/src/VBox/Devices/PC/DevPit-i8254.cpp
r26173 r27121 55 55 #include <iprt/asm.h> 56 56 57 #ifdef IN_RING3 58 # include <iprt/alloc.h> 59 # include <iprt/string.h> 60 # include <iprt/uuid.h> 61 #endif /* IN_RING3 */ 62 57 63 #include "../Builtins.h" 58 64 … … 70 76 71 77 /** The current saved state version. */ 72 #define PIT_SAVED_STATE_VERSION 3 78 #define PIT_SAVED_STATE_VERSION 4 79 /** The saved state version used by VirtualBox 3.1 and earlier. 80 * This did not include disable by HPET flag. */ 81 #define PIT_SAVED_STATE_VERSION_VBOX_31 3 73 82 /** The saved state version used by VirtualBox 3.0 and earlier. 74 83 * This did not include the config part. */ … … 147 156 /** Config: Speaker enabled. */ 148 157 bool fSpeakerCfg; 149 bool afAlignment0[HC_ARCH_BITS == 32 ? 1 : 5]; 158 uint8_t fDisabledByHpet; 159 #if HC_ARCH_BITS == 64 160 bool afAlignment0[4]; 161 #endif 162 /** PIT port interface. */ 163 PDMIPITPORT IPITPort; 150 164 /** Pointer to the device instance. */ 151 165 PPDMDEVINSR3 pDevIns; … … 414 428 /* We just flip-flop the irq level to save that extra timer call, which isn't generally required (we haven't served it for months). */ 415 429 pDevIns = s->CTX_SUFF(pPit)->pDevIns; 416 PDMDevHlpISASetIrq(pDevIns, s->irq, irq_level); 417 if (irq_level) 418 PDMDevHlpISASetIrq(pDevIns, s->irq, 0); 430 431 /* If PIT disabled by HPET - just disconnect ticks from interrupt controllers, and not modify 432 * other moments of device functioning. 433 * @todo: is it correct? 434 */ 435 if (!s->pPitR3->fDisabledByHpet) 436 { 437 PDMDevHlpISASetIrq(pDevIns, s->irq, irq_level); 438 if (irq_level) 439 PDMDevHlpISASetIrq(pDevIns, s->irq, 0); 440 } 441 419 442 if (irq_level) 420 443 { … … 763 786 764 787 SSMR3PutS32(pSSM, pThis->speaker_data_on); 788 789 765 790 #ifdef FAKE_REFRESH_CLOCK 766 returnSSMR3PutS32(pSSM, pThis->dummy_refresh_clock);791 SSMR3PutS32(pSSM, pThis->dummy_refresh_clock); 767 792 #else 768 returnSSMR3PutS32(pSSM, 0);793 SSMR3PutS32(pSSM, 0); 769 794 #endif 795 796 SSMR3PutU8(pSSM, pThis->fDisabledByHpet); 797 798 return 0; 770 799 } 771 800 … … 780 809 781 810 if ( uVersion != PIT_SAVED_STATE_VERSION 782 && uVersion != PIT_SAVED_STATE_VERSION_VBOX_30) 811 && uVersion != PIT_SAVED_STATE_VERSION_VBOX_30 812 && uVersion != PIT_SAVED_STATE_VERSION_VBOX_31) 783 813 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 784 814 … … 839 869 SSMR3GetS32(pSSM, &pThis->speaker_data_on); 840 870 #ifdef FAKE_REFRESH_CLOCK 841 returnSSMR3GetS32(pSSM, &pThis->dummy_refresh_clock);871 SSMR3GetS32(pSSM, &pThis->dummy_refresh_clock); 842 872 #else 843 873 int32_t u32Dummy; 844 returnSSMR3GetS32(pSSM, &u32Dummy);874 SSMR3GetS32(pSSM, &u32Dummy); 845 875 #endif 876 877 if (uVersion > PIT_SAVED_STATE_VERSION_VBOX_31) 878 SSMR3GetU8(pSSM, &pThis->fDisabledByHpet); 879 880 return 0; 846 881 } 847 882 … … 900 935 unsigned i; 901 936 LogFlow(("pitReset: \n")); 937 938 pThis->fDisabledByHpet = false; 902 939 903 940 for (i = 0; i < RT_ELEMENTS(pThis->channels); i++) … … 963 1000 pHlp->pfnPrintf(pHlp, "speaker_data_on=%#x\n", pThis->speaker_data_on); 964 1001 #endif 965 } 966 1002 if (pThis->fDisabledByHpet) 1003 pHlp->pfnPrintf(pHlp, "Disabled by HPET\n"); 1004 } 1005 1006 /** 1007 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 1008 */ 1009 static DECLCALLBACK(void *) pitQueryInterface(PPDMIBASE pInterface, const char *pszIID) 1010 { 1011 PPDMDEVINS pDevIns = RT_FROM_MEMBER(pInterface, PDMDEVINS, IBase); 1012 PITState *pThis = PDMINS_2_DATA(pDevIns, PITState *); 1013 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDevIns->IBase); 1014 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIPITPORT, &pThis->IPITPort); 1015 return NULL; 1016 } 1017 1018 /** 1019 * @interface_method_impl{PDMIPITPORT,pfnNotifyHpetLegacy} 1020 * 1021 * @returns VBox status code 1022 * @param pInterface Pointer to the interface structure containing the called function pointer. 1023 */ 1024 static DECLCALLBACK(int) pitNotifyHpetLegacy(PPDMIPITPORT pInterface, bool fActivate) 1025 { 1026 PITState *pThis = RT_FROM_MEMBER(pInterface, PITState, IPITPort); 1027 pThis->fDisabledByHpet = fActivate; 1028 return VINF_SUCCESS; 1029 } 967 1030 968 1031 /** … … 1069 1132 if (RT_FAILURE(rc)) 1070 1133 return rc; 1134 1135 /* 1136 * Interfaces 1137 */ 1138 /* IBase */ 1139 pDevIns->IBase.pfnQueryInterface = pitQueryInterface; 1140 /* IPITPort */ 1141 pThis->IPITPort.pfnNotifyHpetLegacy = pitNotifyHpetLegacy; 1071 1142 1072 1143 /* … … 1130 1201 /* pfnDetach */ 1131 1202 NULL, 1132 /* pfnQueryInterface .*/1203 /* pfnQueryInterface */ 1133 1204 NULL, 1134 1205 /* pfnInitComplete */ -
trunk/src/VBox/Devices/PC/DevRTC.cpp
r26173 r27121 54 54 #include <iprt/assert.h> 55 55 #include <iprt/string.h> 56 57 #ifdef IN_RING3 58 # include <iprt/alloc.h> 59 # include <iprt/uuid.h> 60 #endif /* IN_RING3 */ 56 61 57 62 #include "../Builtins.h" … … 112 117 113 118 /** The saved state version. */ 114 #define RTC_SAVED_STATE_VERSION 2 119 #define RTC_SAVED_STATE_VERSION 3 120 /** The saved state version used by VirtualBox 3.1 and earlier. 121 * This does not include disabled by HPET state. */ 122 #define RTC_SAVED_STATE_VERSION_VBOX_31 2 115 123 /** The saved state version used by VirtualBox 3.0 and earlier. 116 124 * This does not include the configuration. */ … … 138 146 uint8_t cmos_data[128]; 139 147 uint8_t cmos_index; 140 uint8_t Alignment0[7]; 148 uint8_t fDisabledByHpet; 149 uint8_t Alignment0[6]; 141 150 struct my_tm current_tm; 142 151 /** The configured IRQ. */ … … 151 160 int64_t next_second_time; 152 161 162 /** RTC port interface. */ 163 PDMIRTCPORT IRTCPort; 164 153 165 /** Pointer to the device instance - R3 Ptr. */ 154 166 PPDMDEVINSR3 pDevInsR3; … … 226 238 } 227 239 240 241 static void rtc_raise_irq(RTCState* pThis, uint32_t iLevel) 242 { 243 if (!pThis->fDisabledByHpet) 244 PDMDevHlpISASetIrq(pThis->CTX_SUFF(pDevIns), pThis->irq, iLevel); 245 } 246 228 247 static void rtc_periodic_timer(void *opaque) 229 248 { … … 232 251 rtc_timer_update(s, s->next_periodic_time); 233 252 s->cmos_data[RTC_REG_C] |= 0xc0; 234 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), s->irq, 1); 253 254 rtc_raise_irq(s, 1); 235 255 } 236 256 … … 446 466 447 467 s->cmos_data[RTC_REG_C] |= 0xa0; 448 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), s->irq, 1);468 rtc_raise_irq(s, 1); 449 469 } 450 470 } … … 453 473 if (s->cmos_data[RTC_REG_B] & REG_B_UIE) { 454 474 s->cmos_data[RTC_REG_C] |= 0x90; 455 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), s->irq, 1);475 rtc_raise_irq(s, 1); 456 476 } 457 477 … … 486 506 case RTC_REG_C: 487 507 ret = s->cmos_data[s->cmos_index]; 488 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), s->irq, 0);508 rtc_raise_irq(s, 0); 489 509 s->cmos_data[RTC_REG_C] = 0x00; 490 510 break; … … 643 663 TMR3TimerSave(pThis->CTX_SUFF(pSecondTimer2), pSSM); 644 664 665 SSMR3PutU8(pSSM, pThis->fDisabledByHpet); 666 645 667 return VINF_SUCCESS; 646 668 } … … 656 678 657 679 if ( uVersion != RTC_SAVED_STATE_VERSION 680 && uVersion != RTC_SAVED_STATE_VERSION_VBOX_31 658 681 && uVersion != RTC_SAVED_STATE_VERSION_VBOX_30) 659 682 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; … … 714 737 } 715 738 pThis->cRelLogEntries = 0; 739 740 741 if (uVersion > RTC_SAVED_STATE_VERSION_VBOX_31) 742 SSMR3GetU8(pSSM, &pThis->fDisabledByHpet); 743 716 744 return VINF_SUCCESS; 717 745 } … … 846 874 } 847 875 876 /** 877 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 878 */ 879 static DECLCALLBACK(void *) rtcQueryInterface(PPDMIBASE pInterface, const char *pszIID) 880 { 881 PPDMDEVINS pDevIns = RT_FROM_MEMBER(pInterface, PDMDEVINS, IBase); 882 RTCState *pThis = PDMINS_2_DATA(pDevIns, RTCState *); 883 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDevIns->IBase); 884 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIRTCPORT, &pThis->IRTCPort); 885 return NULL; 886 } 887 888 /** 889 * @interface_method_impl{PDMIRTCPORT,pfnNotifyHpetLegacy} 890 */ 891 static DECLCALLBACK(int) rtcNotifyHpetLegacy(PPDMIRTCPORT pInterface, bool fActivate) 892 { 893 RTCState *pThis = RT_FROM_MEMBER(pInterface, RTCState, IRTCPort); 894 pThis->fDisabledByHpet = fActivate; 895 return VINF_SUCCESS; 896 } 848 897 849 898 /** … … 913 962 pThis->RtcReg.pfnRead = rtcCMOSRead; 914 963 pThis->RtcReg.pfnWrite = rtcCMOSWrite; 964 pThis->fDisabledByHpet = false; 915 965 916 966 /* … … 970 1020 971 1021 /* 1022 * Interfaces 1023 */ 1024 /* IBase */ 1025 pDevIns->IBase.pfnQueryInterface = rtcQueryInterface; 1026 /* IRTCPort */ 1027 pThis->IRTCPort.pfnNotifyHpetLegacy = rtcNotifyHpetLegacy; 1028 1029 /* 972 1030 * Register ourselves as the RTC/CMOS with PDM. 1031 * @todo: maybe use generic iface above? 973 1032 */ 974 1033 rc = PDMDevHlpRTCRegister(pDevIns, &pThis->RtcReg, &pThis->pRtcHlpR3); … … 1037 1096 #endif /* IN_RING3 */ 1038 1097 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ 1039 -
trunk/src/VBox/VMM/PDMDevMiscHlp.cpp
r26939 r27121 561 561 PDMDEV_ASSERT_DEVINS(pDevIns); 562 562 LogFlow(("pdmR3HpetHlp_SetLegacyMode: caller='%s'/%d: fActivate=%d\n", pDevIns->pReg->szName, pDevIns->iInstance, fActivate)); 563 return 0; 563 564 PPDMIBASE pBase; 565 int rc; 566 567 rc = PDMR3QueryDevice(pDevIns->Internal.s.pVMR3, "i8254", 0, &pBase); 568 /* No PIT - no problems too */ 569 if (RT_SUCCESS(rc)) 570 { 571 Assert(pBase); 572 PPDMIPITPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIPITPORT); 573 574 rc = pPort ? pPort->pfnNotifyHpetLegacy(pPort, fActivate) : VINF_SUCCESS; 575 } 576 else 577 rc = VINF_SUCCESS; 578 579 if (RT_FAILURE(rc)) 580 return rc; 581 582 rc = PDMR3QueryDevice(pDevIns->Internal.s.pVMR3, "mc146818", 0, &pBase); 583 /* No RTC - no problems too */ 584 if (RT_SUCCESS(rc)) 585 { 586 Assert(pBase); 587 PPDMIRTCPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIRTCPORT); 588 rc = pPort ? pPort->pfnNotifyHpetLegacy(pPort, fActivate) : VINF_SUCCESS; 589 } 590 else 591 rc = VINF_SUCCESS; 592 593 return rc; 564 594 } 565 595
Note:
See TracChangeset
for help on using the changeset viewer.