Changeset 24087 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- Oct 26, 2009 3:48:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevPit-i8254.cpp
r24085 r24087 69 69 #define RW_STATE_WORD1 4 70 70 71 /** The version of the saved state. */ 72 #define PIT_SAVED_STATE_VERSION 2 71 /** The current saved state version. */ 72 #define PIT_SAVED_STATE_VERSION 3 73 /** The saved state version used by VirtualBox 3.0 and earlier. 74 * This did not include the config part. */ 75 #define PIT_SAVED_STATE_VERSION_VBOX_30 2 73 76 74 77 /** @def FAKE_REFRESH_CLOCK … … 140 143 uint32_t Alignment1; 141 144 #endif 145 /** Config: I/O port base. */ 146 RTIOPORT IOPortBaseCfg; 147 /** Config: Speaker enabled. */ 148 bool fSpeakerCfg; 149 bool afAlignment0[HC_ARCH_BITS == 32 ? 1 : 5]; 142 150 /** Pointer to the device instance. */ 143 151 PPDMDEVINSR3 pDevIns; 144 #if HC_ARCH_BITS == 32145 uint32_t Alignment0;146 #endif147 152 /** Number of IRQs that's been raised. */ 148 153 STAMCOUNTER StatPITIrq; … … 710 715 711 716 /** 712 * Saves a state of the programmable interval timer device. 713 * 714 * @returns VBox status code. 715 * @param pDevIns The device instance. 716 * @param pSSMHandle The handle to save the state to. 717 */ 718 static DECLCALLBACK(int) pitSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle) 717 * @copydoc FNSSMDEVLIVEEXEC 718 */ 719 static DECLCALLBACK(int) pitLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 720 { 721 PITState *pThis = PDMINS_2_DATA(pDevIns, PITState *); 722 SSMR3PutIOPort(pSSM, pThis->IOPortBaseCfg); 723 SSMR3PutU8( pSSM, pThis->channels[0].irq); 724 SSMR3PutBool( pSSM, pThis->fSpeakerCfg); 725 return VINF_SSM_DONT_CALL_AGAIN; 726 } 727 728 729 /** 730 * @copydoc FNSSMDEVSAVEEXEC 731 */ 732 static DECLCALLBACK(int) pitSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 719 733 { 720 734 PITState *pThis = PDMINS_2_DATA(pDevIns, PITState *); 721 735 unsigned i; 722 736 737 /* The config. */ 738 pitLiveExec(pDevIns, pSSM, SSM_PASS_FINAL); 739 740 /* The state. */ 723 741 for (i = 0; i < RT_ELEMENTS(pThis->channels); i++) 724 742 { 725 743 PITChannelState *s = &pThis->channels[i]; 726 SSMR3PutU32(pSSM Handle, s->count);727 SSMR3PutU16(pSSM Handle, s->latched_count);728 SSMR3PutU8(pSSM Handle, s->count_latched);729 SSMR3PutU8(pSSM Handle, s->status_latched);730 SSMR3PutU8(pSSM Handle, s->status);731 SSMR3PutU8(pSSM Handle, s->read_state);732 SSMR3PutU8(pSSM Handle, s->write_state);733 SSMR3PutU8(pSSM Handle, s->write_latch);734 SSMR3PutU8(pSSM Handle, s->rw_mode);735 SSMR3PutU8(pSSM Handle, s->mode);736 SSMR3PutU8(pSSM Handle, s->bcd);737 SSMR3PutU8(pSSM Handle, s->gate);738 SSMR3PutU64(pSSM Handle, s->count_load_time);739 SSMR3PutU64(pSSM Handle, s->u64NextTS);740 SSMR3PutU64(pSSM Handle, s->u64ReloadTS);741 SSMR3PutS64(pSSM Handle, s->next_transition_time);744 SSMR3PutU32(pSSM, s->count); 745 SSMR3PutU16(pSSM, s->latched_count); 746 SSMR3PutU8(pSSM, s->count_latched); 747 SSMR3PutU8(pSSM, s->status_latched); 748 SSMR3PutU8(pSSM, s->status); 749 SSMR3PutU8(pSSM, s->read_state); 750 SSMR3PutU8(pSSM, s->write_state); 751 SSMR3PutU8(pSSM, s->write_latch); 752 SSMR3PutU8(pSSM, s->rw_mode); 753 SSMR3PutU8(pSSM, s->mode); 754 SSMR3PutU8(pSSM, s->bcd); 755 SSMR3PutU8(pSSM, s->gate); 756 SSMR3PutU64(pSSM, s->count_load_time); 757 SSMR3PutU64(pSSM, s->u64NextTS); 758 SSMR3PutU64(pSSM, s->u64ReloadTS); 759 SSMR3PutS64(pSSM, s->next_transition_time); 742 760 if (s->CTX_SUFF(pTimer)) 743 TMR3TimerSave(s->CTX_SUFF(pTimer), pSSM Handle);744 } 745 746 SSMR3PutS32(pSSM Handle, pThis->speaker_data_on);761 TMR3TimerSave(s->CTX_SUFF(pTimer), pSSM); 762 } 763 764 SSMR3PutS32(pSSM, pThis->speaker_data_on); 747 765 #ifdef FAKE_REFRESH_CLOCK 748 return SSMR3PutS32(pSSM Handle, pThis->dummy_refresh_clock);766 return SSMR3PutS32(pSSM, pThis->dummy_refresh_clock); 749 767 #else 750 return SSMR3PutS32(pSSM Handle, 0);768 return SSMR3PutS32(pSSM, 0); 751 769 #endif 752 770 } … … 754 772 755 773 /** 756 * Loads a saved programmable interval timer device state. 757 * 758 * @returns VBox status code. 759 * @param pDevIns The device instance. 760 * @param pSSMHandle The handle to the saved state. 761 * @param uVersion The data unit version number. 762 * @param uPass The data pass. 763 */ 764 static DECLCALLBACK(int) pitLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t uVersion, uint32_t uPass) 765 { 766 PITState *pThis = PDMINS_2_DATA(pDevIns, PITState *); 767 768 if (uVersion != PIT_SAVED_STATE_VERSION) 774 * @copydoc FNSSMDEVLOADEXEC 775 */ 776 static DECLCALLBACK(int) pitLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 777 { 778 PITState *pThis = PDMINS_2_DATA(pDevIns, PITState *); 779 int rc; 780 781 if ( uVersion != PIT_SAVED_STATE_VERSION 782 && uVersion != PIT_SAVED_STATE_VERSION_VBOX_30) 769 783 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 770 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 771 784 785 /* The config. */ 786 if (uVersion > PIT_SAVED_STATE_VERSION_VBOX_30) 787 { 788 RTIOPORT IOPortBaseCfg; 789 rc = SSMR3GetIOPort(pSSM, &IOPortBaseCfg); AssertRCReturn(rc, rc); 790 if (IOPortBaseCfg != pThis->IOPortBaseCfg) 791 { 792 LogRel(("PIT: Config mismatch - IOPortBaseCfg: saved=%RTiop config=%RTiop\n", IOPortBaseCfg, pThis->IOPortBaseCfg)); 793 return VERR_SSM_LOAD_CONFIG_MISMATCH; 794 } 795 796 uint8_t u8Irq; 797 rc = SSMR3GetU8(pSSM, &u8Irq); AssertRCReturn(rc, rc); 798 if (u8Irq != pThis->channels[0].irq) 799 { 800 LogRel(("PIT: Config mismatch - u8Irq: saved=%#x config=%#x\n", u8Irq, pThis->channels[0].irq)); 801 return VERR_SSM_LOAD_CONFIG_MISMATCH; 802 } 803 804 bool fSpeakerCfg; 805 rc = SSMR3GetBool(pSSM, &fSpeakerCfg); AssertRCReturn(rc, rc); 806 if (fSpeakerCfg != pThis->fSpeakerCfg) 807 { 808 LogRel(("PIT: Config mismatch - fSpeakerCfg: saved=%RTbool config=%RTbool\n", fSpeakerCfg, pThis->fSpeakerCfg)); 809 return VERR_SSM_LOAD_CONFIG_MISMATCH; 810 } 811 } 812 813 if (uPass != SSM_PASS_FINAL) 814 return VINF_SUCCESS; 815 816 /* The state. */ 772 817 for (unsigned i = 0; i < RT_ELEMENTS(pThis->channels); i++) 773 818 { 774 819 PITChannelState *s = &pThis->channels[i]; 775 SSMR3GetU32(pSSM Handle, &s->count);776 SSMR3GetU16(pSSM Handle, &s->latched_count);777 SSMR3GetU8(pSSM Handle, &s->count_latched);778 SSMR3GetU8(pSSM Handle, &s->status_latched);779 SSMR3GetU8(pSSM Handle, &s->status);780 SSMR3GetU8(pSSM Handle, &s->read_state);781 SSMR3GetU8(pSSM Handle, &s->write_state);782 SSMR3GetU8(pSSM Handle, &s->write_latch);783 SSMR3GetU8(pSSM Handle, &s->rw_mode);784 SSMR3GetU8(pSSM Handle, &s->mode);785 SSMR3GetU8(pSSM Handle, &s->bcd);786 SSMR3GetU8(pSSM Handle, &s->gate);787 SSMR3GetU64(pSSM Handle, &s->count_load_time);788 SSMR3GetU64(pSSM Handle, &s->u64NextTS);789 SSMR3GetU64(pSSM Handle, &s->u64ReloadTS);790 SSMR3GetS64(pSSM Handle, &s->next_transition_time);820 SSMR3GetU32(pSSM, &s->count); 821 SSMR3GetU16(pSSM, &s->latched_count); 822 SSMR3GetU8(pSSM, &s->count_latched); 823 SSMR3GetU8(pSSM, &s->status_latched); 824 SSMR3GetU8(pSSM, &s->status); 825 SSMR3GetU8(pSSM, &s->read_state); 826 SSMR3GetU8(pSSM, &s->write_state); 827 SSMR3GetU8(pSSM, &s->write_latch); 828 SSMR3GetU8(pSSM, &s->rw_mode); 829 SSMR3GetU8(pSSM, &s->mode); 830 SSMR3GetU8(pSSM, &s->bcd); 831 SSMR3GetU8(pSSM, &s->gate); 832 SSMR3GetU64(pSSM, &s->count_load_time); 833 SSMR3GetU64(pSSM, &s->u64NextTS); 834 SSMR3GetU64(pSSM, &s->u64ReloadTS); 835 SSMR3GetS64(pSSM, &s->next_transition_time); 791 836 if (s->CTX_SUFF(pTimer)) 792 837 { 793 TMR3TimerLoad(s->CTX_SUFF(pTimer), pSSM Handle);838 TMR3TimerLoad(s->CTX_SUFF(pTimer), pSSM); 794 839 LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=%d) (restore)\n", 795 840 s->mode, s->count, s->count, PIT_FREQ / s->count, (PIT_FREQ * 100 / s->count) % 100, i)); … … 798 843 } 799 844 800 SSMR3GetS32(pSSM Handle, &pThis->speaker_data_on);845 SSMR3GetS32(pSSM, &pThis->speaker_data_on); 801 846 #ifdef FAKE_REFRESH_CLOCK 802 return SSMR3GetS32(pSSM Handle, &pThis->dummy_refresh_clock);847 return SSMR3GetS32(pSSM, &pThis->dummy_refresh_clock); 803 848 #else 804 849 int32_t u32Dummy; 805 return SSMR3GetS32(pSSM Handle, &u32Dummy);850 return SSMR3GetS32(pSSM, &u32Dummy); 806 851 #endif 807 852 } … … 986 1031 N_("Configuration error: failed to read R0Enabled as boolean")); 987 1032 988 pThis->pDevIns = pDevIns; 1033 pThis->pDevIns = pDevIns; 1034 pThis->IOPortBaseCfg = u16Base; 1035 pThis->fSpeakerCfg = fSpeaker; 989 1036 pThis->channels[0].irq = u8Irq; 990 1037 for (i = 0; i < RT_ELEMENTS(pThis->channels); i++) … … 1035 1082 } 1036 1083 1037 rc = PDMDevHlpSSMRegister (pDevIns, PIT_SAVED_STATE_VERSION, sizeof(*pThis), pitSaveExec, pitLoadExec);1084 rc = PDMDevHlpSSMRegister3(pDevIns, PIT_SAVED_STATE_VERSION, sizeof(*pThis), pitLiveExec, pitSaveExec, pitLoadExec); 1038 1085 if (RT_FAILURE(rc)) 1039 1086 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.