Changeset 22034 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Aug 6, 2009 12:38:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/SSM-new.cpp
r22029 r22034 4616 4616 VMMR3DECL(int) SSMR3PutBool(PSSMHANDLE pSSM, bool fBool) 4617 4617 { 4618 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4619 { 4620 uint8_t u8 = fBool; /* enforce 1 byte size */ 4621 return ssmR3DataWrite(pSSM, &u8, sizeof(u8)); 4622 } 4623 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4624 return VERR_SSM_INVALID_STATE; 4618 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4619 uint8_t u8 = fBool; /* enforce 1 byte size */ 4620 return ssmR3DataWrite(pSSM, &u8, sizeof(u8)); 4625 4621 } 4626 4622 … … 4635 4631 VMMR3DECL(int) SSMR3PutU8(PSSMHANDLE pSSM, uint8_t u8) 4636 4632 { 4637 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4638 return ssmR3DataWrite(pSSM, &u8, sizeof(u8)); 4639 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4640 return VERR_SSM_INVALID_STATE; 4633 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4634 return ssmR3DataWrite(pSSM, &u8, sizeof(u8)); 4641 4635 } 4642 4636 … … 4651 4645 VMMR3DECL(int) SSMR3PutS8(PSSMHANDLE pSSM, int8_t i8) 4652 4646 { 4653 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4654 return ssmR3DataWrite(pSSM, &i8, sizeof(i8)); 4655 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4656 return VERR_SSM_INVALID_STATE; 4647 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4648 return ssmR3DataWrite(pSSM, &i8, sizeof(i8)); 4657 4649 } 4658 4650 … … 4667 4659 VMMR3DECL(int) SSMR3PutU16(PSSMHANDLE pSSM, uint16_t u16) 4668 4660 { 4669 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4670 return ssmR3DataWrite(pSSM, &u16, sizeof(u16)); 4671 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4672 return VERR_SSM_INVALID_STATE; 4661 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4662 return ssmR3DataWrite(pSSM, &u16, sizeof(u16)); 4673 4663 } 4674 4664 … … 4683 4673 VMMR3DECL(int) SSMR3PutS16(PSSMHANDLE pSSM, int16_t i16) 4684 4674 { 4685 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4686 return ssmR3DataWrite(pSSM, &i16, sizeof(i16)); 4687 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4688 return VERR_SSM_INVALID_STATE; 4675 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4676 return ssmR3DataWrite(pSSM, &i16, sizeof(i16)); 4689 4677 } 4690 4678 … … 4699 4687 VMMR3DECL(int) SSMR3PutU32(PSSMHANDLE pSSM, uint32_t u32) 4700 4688 { 4701 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4702 return ssmR3DataWrite(pSSM, &u32, sizeof(u32)); 4703 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4704 return VERR_SSM_INVALID_STATE; 4689 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4690 return ssmR3DataWrite(pSSM, &u32, sizeof(u32)); 4705 4691 } 4706 4692 … … 4715 4701 VMMR3DECL(int) SSMR3PutS32(PSSMHANDLE pSSM, int32_t i32) 4716 4702 { 4717 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4718 return ssmR3DataWrite(pSSM, &i32, sizeof(i32)); 4719 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4720 return VERR_SSM_INVALID_STATE; 4703 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4704 return ssmR3DataWrite(pSSM, &i32, sizeof(i32)); 4721 4705 } 4722 4706 … … 4731 4715 VMMR3DECL(int) SSMR3PutU64(PSSMHANDLE pSSM, uint64_t u64) 4732 4716 { 4733 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4734 return ssmR3DataWrite(pSSM, &u64, sizeof(u64)); 4735 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4736 return VERR_SSM_INVALID_STATE; 4717 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4718 return ssmR3DataWrite(pSSM, &u64, sizeof(u64)); 4737 4719 } 4738 4720 … … 4747 4729 VMMR3DECL(int) SSMR3PutS64(PSSMHANDLE pSSM, int64_t i64) 4748 4730 { 4749 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4750 return ssmR3DataWrite(pSSM, &i64, sizeof(i64)); 4751 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4752 return VERR_SSM_INVALID_STATE; 4731 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4732 return ssmR3DataWrite(pSSM, &i64, sizeof(i64)); 4753 4733 } 4754 4734 … … 4763 4743 VMMR3DECL(int) SSMR3PutU128(PSSMHANDLE pSSM, uint128_t u128) 4764 4744 { 4765 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4766 return ssmR3DataWrite(pSSM, &u128, sizeof(u128)); 4767 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4768 return VERR_SSM_INVALID_STATE; 4745 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4746 return ssmR3DataWrite(pSSM, &u128, sizeof(u128)); 4769 4747 } 4770 4748 … … 4779 4757 VMMR3DECL(int) SSMR3PutS128(PSSMHANDLE pSSM, int128_t i128) 4780 4758 { 4781 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4782 return ssmR3DataWrite(pSSM, &i128, sizeof(i128)); 4783 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4784 return VERR_SSM_INVALID_STATE; 4759 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4760 return ssmR3DataWrite(pSSM, &i128, sizeof(i128)); 4785 4761 } 4786 4762 … … 4795 4771 VMMR3DECL(int) SSMR3PutUInt(PSSMHANDLE pSSM, RTUINT u) 4796 4772 { 4797 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4798 return ssmR3DataWrite(pSSM, &u, sizeof(u)); 4799 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4800 return VERR_SSM_INVALID_STATE; 4773 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4774 return ssmR3DataWrite(pSSM, &u, sizeof(u)); 4801 4775 } 4802 4776 … … 4811 4785 VMMR3DECL(int) SSMR3PutSInt(PSSMHANDLE pSSM, RTINT i) 4812 4786 { 4813 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4814 return ssmR3DataWrite(pSSM, &i, sizeof(i)); 4815 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4816 return VERR_SSM_INVALID_STATE; 4787 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4788 return ssmR3DataWrite(pSSM, &i, sizeof(i)); 4817 4789 } 4818 4790 … … 4829 4801 VMMR3DECL(int) SSMR3PutGCUInt(PSSMHANDLE pSSM, RTGCUINT u) 4830 4802 { 4831 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4832 return ssmR3DataWrite(pSSM, &u, sizeof(u)); 4833 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4834 return VERR_SSM_INVALID_STATE; 4803 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4804 return ssmR3DataWrite(pSSM, &u, sizeof(u)); 4835 4805 } 4836 4806 … … 4845 4815 VMMR3DECL(int) SSMR3PutGCUIntReg(PSSMHANDLE pSSM, RTGCUINTREG u) 4846 4816 { 4847 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4848 return ssmR3DataWrite(pSSM, &u, sizeof(u)); 4849 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4850 return VERR_SSM_INVALID_STATE; 4817 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4818 return ssmR3DataWrite(pSSM, &u, sizeof(u)); 4851 4819 } 4852 4820 … … 4861 4829 VMMR3DECL(int) SSMR3PutGCPhys32(PSSMHANDLE pSSM, RTGCPHYS32 GCPhys) 4862 4830 { 4863 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4864 return ssmR3DataWrite(pSSM, &GCPhys, sizeof(GCPhys)); 4865 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4866 return VERR_SSM_INVALID_STATE; 4831 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4832 return ssmR3DataWrite(pSSM, &GCPhys, sizeof(GCPhys)); 4867 4833 } 4868 4834 … … 4877 4843 VMMR3DECL(int) SSMR3PutGCPhys64(PSSMHANDLE pSSM, RTGCPHYS64 GCPhys) 4878 4844 { 4879 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4880 return ssmR3DataWrite(pSSM, &GCPhys, sizeof(GCPhys)); 4881 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4882 return VERR_SSM_INVALID_STATE; 4845 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4846 return ssmR3DataWrite(pSSM, &GCPhys, sizeof(GCPhys)); 4883 4847 } 4884 4848 … … 4893 4857 VMMR3DECL(int) SSMR3PutGCPhys(PSSMHANDLE pSSM, RTGCPHYS GCPhys) 4894 4858 { 4895 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4896 return ssmR3DataWrite(pSSM, &GCPhys, sizeof(GCPhys)); 4897 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4898 return VERR_SSM_INVALID_STATE; 4859 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4860 return ssmR3DataWrite(pSSM, &GCPhys, sizeof(GCPhys)); 4899 4861 } 4900 4862 … … 4909 4871 VMMR3DECL(int) SSMR3PutGCPtr(PSSMHANDLE pSSM, RTGCPTR GCPtr) 4910 4872 { 4911 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4912 return ssmR3DataWrite(pSSM, &GCPtr, sizeof(GCPtr)); 4913 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4914 return VERR_SSM_INVALID_STATE; 4873 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4874 return ssmR3DataWrite(pSSM, &GCPtr, sizeof(GCPtr)); 4915 4875 } 4916 4876 … … 4925 4885 VMMR3DECL(int) SSMR3PutRCPtr(PSSMHANDLE pSSM, RTRCPTR RCPtr) 4926 4886 { 4927 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4928 return ssmR3DataWrite(pSSM, &RCPtr, sizeof(RCPtr)); 4929 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4930 return VERR_SSM_INVALID_STATE; 4887 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4888 return ssmR3DataWrite(pSSM, &RCPtr, sizeof(RCPtr)); 4931 4889 } 4932 4890 … … 4941 4899 VMMR3DECL(int) SSMR3PutGCUIntPtr(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr) 4942 4900 { 4943 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4944 return ssmR3DataWrite(pSSM, &GCPtr, sizeof(GCPtr)); 4945 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4946 return VERR_SSM_INVALID_STATE; 4901 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4902 return ssmR3DataWrite(pSSM, &GCPtr, sizeof(GCPtr)); 4947 4903 } 4948 4904 … … 4957 4913 VMMR3DECL(int) SSMR3PutIOPort(PSSMHANDLE pSSM, RTIOPORT IOPort) 4958 4914 { 4959 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4960 return ssmR3DataWrite(pSSM, &IOPort, sizeof(IOPort)); 4961 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4962 return VERR_SSM_INVALID_STATE; 4915 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4916 return ssmR3DataWrite(pSSM, &IOPort, sizeof(IOPort)); 4963 4917 } 4964 4918 … … 4973 4927 VMMR3DECL(int) SSMR3PutSel(PSSMHANDLE pSSM, RTSEL Sel) 4974 4928 { 4975 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4976 return ssmR3DataWrite(pSSM, &Sel, sizeof(Sel)); 4977 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4978 return VERR_SSM_INVALID_STATE; 4929 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4930 return ssmR3DataWrite(pSSM, &Sel, sizeof(Sel)); 4979 4931 } 4980 4932 … … 4990 4942 VMMR3DECL(int) SSMR3PutMem(PSSMHANDLE pSSM, const void *pv, size_t cb) 4991 4943 { 4992 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 4993 return ssmR3DataWrite(pSSM, pv, cb); 4994 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 4995 return VERR_SSM_INVALID_STATE; 4944 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4945 return ssmR3DataWrite(pSSM, pv, cb); 4996 4946 } 4997 4947 … … 5006 4956 VMMR3DECL(int) SSMR3PutStrZ(PSSMHANDLE pSSM, const char *psz) 5007 4957 { 5008 if (pSSM->enmOp == SSMSTATE_SAVE_EXEC) 5009 { 5010 size_t cch = strlen(psz); 5011 if (cch > _1M) 5012 { 5013 AssertMsgFailed(("a %d byte long string, what's this!?!\n")); 5014 return VERR_TOO_MUCH_DATA; 5015 } 5016 uint32_t u32 = (uint32_t)cch; 5017 int rc = ssmR3DataWrite(pSSM, &u32, sizeof(u32)); 5018 if (rc) 5019 return rc; 5020 return ssmR3DataWrite(pSSM, psz, cch); 5021 } 5022 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5023 return VERR_SSM_INVALID_STATE; 4958 AssertMsgReturn(pSSM->enmOp == SSMSTATE_SAVE_EXEC, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 4959 4960 size_t cch = strlen(psz); 4961 if (cch > _1M) 4962 { 4963 AssertMsgFailed(("a %d byte long string, what's this!?!\n")); 4964 return VERR_TOO_MUCH_DATA; 4965 } 4966 uint32_t u32 = (uint32_t)cch; 4967 int rc = ssmR3DataWrite(pSSM, &u32, sizeof(u32)); 4968 if (rc) 4969 return rc; 4970 return ssmR3DataWrite(pSSM, psz, cch); 5024 4971 } 5025 4972 … … 5781 5728 VMMR3DECL(int) SSMR3GetBool(PSSMHANDLE pSSM, bool *pfBool) 5782 5729 { 5783 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5784 { 5785 uint8_t u8; /* see SSMR3PutBool */ 5786 int rc = ssmR3DataRead(pSSM, &u8, sizeof(u8)); 5787 if (RT_SUCCESS(rc)) 5788 { 5789 Assert(u8 <= 1); 5790 *pfBool = !!u8; 5791 } 5792 return rc; 5793 } 5794 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5795 return VERR_SSM_INVALID_STATE; 5730 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5731 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5732 uint8_t u8; /* see SSMR3PutBool */ 5733 int rc = ssmR3DataRead(pSSM, &u8, sizeof(u8)); 5734 if (RT_SUCCESS(rc)) 5735 { 5736 Assert(u8 <= 1); 5737 *pfBool = !!u8; 5738 } 5739 return rc; 5796 5740 } 5797 5741 … … 5806 5750 VMMR3DECL(int) SSMR3GetU8(PSSMHANDLE pSSM, uint8_t *pu8) 5807 5751 { 5808 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5809 return ssmR3DataRead(pSSM, pu8, sizeof(*pu8)); 5810 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5811 return VERR_SSM_INVALID_STATE; 5752 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5753 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5754 return ssmR3DataRead(pSSM, pu8, sizeof(*pu8)); 5812 5755 } 5813 5756 … … 5822 5765 VMMR3DECL(int) SSMR3GetS8(PSSMHANDLE pSSM, int8_t *pi8) 5823 5766 { 5824 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5825 return ssmR3DataRead(pSSM, pi8, sizeof(*pi8)); 5826 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5827 return VERR_SSM_INVALID_STATE; 5767 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5768 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5769 return ssmR3DataRead(pSSM, pi8, sizeof(*pi8)); 5828 5770 } 5829 5771 … … 5838 5780 VMMR3DECL(int) SSMR3GetU16(PSSMHANDLE pSSM, uint16_t *pu16) 5839 5781 { 5840 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5841 return ssmR3DataRead(pSSM, pu16, sizeof(*pu16)); 5842 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5843 return VERR_SSM_INVALID_STATE; 5782 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5783 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5784 return ssmR3DataRead(pSSM, pu16, sizeof(*pu16)); 5844 5785 } 5845 5786 … … 5854 5795 VMMR3DECL(int) SSMR3GetS16(PSSMHANDLE pSSM, int16_t *pi16) 5855 5796 { 5856 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5857 return ssmR3DataRead(pSSM, pi16, sizeof(*pi16)); 5858 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5859 return VERR_SSM_INVALID_STATE; 5797 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5798 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5799 return ssmR3DataRead(pSSM, pi16, sizeof(*pi16)); 5860 5800 } 5861 5801 … … 5870 5810 VMMR3DECL(int) SSMR3GetU32(PSSMHANDLE pSSM, uint32_t *pu32) 5871 5811 { 5872 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5873 return ssmR3DataRead(pSSM, pu32, sizeof(*pu32)); 5874 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5875 return VERR_SSM_INVALID_STATE; 5812 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5813 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5814 return ssmR3DataRead(pSSM, pu32, sizeof(*pu32)); 5876 5815 } 5877 5816 … … 5886 5825 VMMR3DECL(int) SSMR3GetS32(PSSMHANDLE pSSM, int32_t *pi32) 5887 5826 { 5888 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5889 return ssmR3DataRead(pSSM, pi32, sizeof(*pi32)); 5890 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5891 return VERR_SSM_INVALID_STATE; 5827 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5828 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5829 return ssmR3DataRead(pSSM, pi32, sizeof(*pi32)); 5892 5830 } 5893 5831 … … 5902 5840 VMMR3DECL(int) SSMR3GetU64(PSSMHANDLE pSSM, uint64_t *pu64) 5903 5841 { 5904 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5905 return ssmR3DataRead(pSSM, pu64, sizeof(*pu64)); 5906 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5907 return VERR_SSM_INVALID_STATE; 5842 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5843 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5844 return ssmR3DataRead(pSSM, pu64, sizeof(*pu64)); 5908 5845 } 5909 5846 … … 5918 5855 VMMR3DECL(int) SSMR3GetS64(PSSMHANDLE pSSM, int64_t *pi64) 5919 5856 { 5920 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5921 return ssmR3DataRead(pSSM, pi64, sizeof(*pi64)); 5922 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5923 return VERR_SSM_INVALID_STATE; 5857 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5858 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5859 return ssmR3DataRead(pSSM, pi64, sizeof(*pi64)); 5924 5860 } 5925 5861 … … 5934 5870 VMMR3DECL(int) SSMR3GetU128(PSSMHANDLE pSSM, uint128_t *pu128) 5935 5871 { 5936 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5937 return ssmR3DataRead(pSSM, pu128, sizeof(*pu128)); 5938 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5939 return VERR_SSM_INVALID_STATE; 5872 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5873 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5874 return ssmR3DataRead(pSSM, pu128, sizeof(*pu128)); 5940 5875 } 5941 5876 … … 5950 5885 VMMR3DECL(int) SSMR3GetS128(PSSMHANDLE pSSM, int128_t *pi128) 5951 5886 { 5952 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5953 return ssmR3DataRead(pSSM, pi128, sizeof(*pi128)); 5954 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5955 return VERR_SSM_INVALID_STATE; 5887 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5888 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5889 return ssmR3DataRead(pSSM, pi128, sizeof(*pi128)); 5956 5890 } 5957 5891 … … 5966 5900 VMMR3DECL(int) SSMR3GetUInt(PSSMHANDLE pSSM, PRTUINT pu) 5967 5901 { 5968 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5969 return ssmR3DataRead(pSSM, pu, sizeof(*pu)); 5970 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5971 return VERR_SSM_INVALID_STATE; 5902 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5903 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5904 return ssmR3DataRead(pSSM, pu, sizeof(*pu)); 5972 5905 } 5973 5906 … … 5982 5915 VMMR3DECL(int) SSMR3GetSInt(PSSMHANDLE pSSM, PRTINT pi) 5983 5916 { 5984 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 5985 return ssmR3DataRead(pSSM, pi, sizeof(*pi)); 5986 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 5987 return VERR_SSM_INVALID_STATE; 5917 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5918 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5919 return ssmR3DataRead(pSSM, pi, sizeof(*pi)); 5988 5920 } 5989 5921 … … 6028 5960 VMMR3DECL(int) SSMR3GetGCPhys32(PSSMHANDLE pSSM, PRTGCPHYS32 pGCPhys) 6029 5961 { 6030 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 6031 return ssmR3DataRead(pSSM, pGCPhys, sizeof(*pGCPhys)); 6032 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6033 return VERR_SSM_INVALID_STATE; 5962 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5963 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5964 return ssmR3DataRead(pSSM, pGCPhys, sizeof(*pGCPhys)); 6034 5965 } 6035 5966 … … 6044 5975 VMMR3DECL(int) SSMR3GetGCPhys64(PSSMHANDLE pSSM, PRTGCPHYS64 pGCPhys) 6045 5976 { 6046 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 6047 return ssmR3DataRead(pSSM, pGCPhys, sizeof(*pGCPhys)); 6048 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6049 return VERR_SSM_INVALID_STATE; 5977 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5978 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5979 return ssmR3DataRead(pSSM, pGCPhys, sizeof(*pGCPhys)); 6050 5980 } 6051 5981 … … 6060 5990 VMMR3DECL(int) SSMR3GetGCPhys(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys) 6061 5991 { 6062 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ)6063 {6064 if (RT_LIKELY(sizeof(*pGCPhys) == pSSM->u.Read.cbGCPhys)) 6065 return ssmR3DataRead(pSSM, pGCPhys, sizeof(*pGCPhys));6066 6067 /*6068 * Fiddly.6069 */6070 Assert(sizeof(*pGCPhys) == sizeof(uint64_t) || sizeof(*pGCPhys) == sizeof(uint32_t)); 6071 Assert(pSSM->u.Read.cbGCPhys == sizeof(uint64_t) || pSSM->u.Read.cbGCPhys == sizeof(uint32_t));6072 if (pSSM->u.Read.cbGCPhys == sizeof(uint64_t))6073 {6074 /* 64-bit saved, 32-bit load: try truncate it. */6075 uint64_t u64;6076 int rc = ssmR3DataRead(pSSM, &u64, sizeof(uint64_t));6077 if (RT_FAILURE(rc))6078 return rc;6079 if (u64 >= _4G)6080 return VERR_SSM_GCPHYS_OVERFLOW;6081 *pGCPhys = (RTGCPHYS)u64;5992 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 5993 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 5994 5995 /* 5996 * Default size? 5997 */ 5998 if (RT_LIKELY(sizeof(*pGCPhys) == pSSM->u.Read.cbGCPhys)) 5999 return ssmR3DataRead(pSSM, pGCPhys, sizeof(*pGCPhys)); 6000 6001 /* 6002 * Fiddly. 6003 */ 6004 Assert(sizeof(*pGCPhys) == sizeof(uint64_t) || sizeof(*pGCPhys) == sizeof(uint32_t)); 6005 Assert(pSSM->u.Read.cbGCPhys == sizeof(uint64_t) || pSSM->u.Read.cbGCPhys == sizeof(uint32_t)); 6006 if (pSSM->u.Read.cbGCPhys == sizeof(uint64_t)) 6007 { 6008 /* 64-bit saved, 32-bit load: try truncate it. */ 6009 uint64_t u64; 6010 int rc = ssmR3DataRead(pSSM, &u64, sizeof(uint64_t)); 6011 if (RT_FAILURE(rc)) 6082 6012 return rc; 6083 } 6084 6085 /* 32-bit saved, 64-bit load: clear the high part. */ 6086 *pGCPhys = 0; 6087 return ssmR3DataRead(pSSM, pGCPhys, sizeof(uint32_t)); 6088 } 6089 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6090 return VERR_SSM_INVALID_STATE; 6013 if (u64 >= _4G) 6014 return VERR_SSM_GCPHYS_OVERFLOW; 6015 *pGCPhys = (RTGCPHYS)u64; 6016 return rc; 6017 } 6018 6019 /* 32-bit saved, 64-bit load: clear the high part. */ 6020 *pGCPhys = 0; 6021 return ssmR3DataRead(pSSM, pGCPhys, sizeof(uint32_t)); 6091 6022 } 6092 6023 … … 6136 6067 VMMR3DECL(int) SSMR3GetGCPtr(PSSMHANDLE pSSM, PRTGCPTR pGCPtr) 6137 6068 { 6138 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ)6139 {6140 if (RT_LIKELY(sizeof(*pGCPtr) == pSSM->u.Read.cbGCPtr)) 6141 return ssmR3DataRead(pSSM, pGCPtr, sizeof(*pGCPtr));6142 6143 /*6144 * Fiddly.6145 */6146 Assert(sizeof(*pGCPtr) == sizeof(uint64_t) || sizeof(*pGCPtr) == sizeof(uint32_t)); 6147 Assert(pSSM->u.Read.cbGCPtr == sizeof(uint64_t) || pSSM->u.Read.cbGCPtr == sizeof(uint32_t));6148 if (pSSM->u.Read.cbGCPtr == sizeof(uint64_t))6149 {6150 /* 64-bit saved, 32-bit load: try truncate it. */6151 uint64_t u64;6152 int rc = ssmR3DataRead(pSSM, &u64, sizeof(uint64_t));6153 if (RT_FAILURE(rc))6154 return rc;6155 if (u64 >= _4G)6156 return VERR_SSM_GCPTR_OVERFLOW;6157 *pGCPtr = (RTGCPTR)u64;6069 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6070 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6071 6072 /* 6073 * Default size? 6074 */ 6075 if (RT_LIKELY(sizeof(*pGCPtr) == pSSM->u.Read.cbGCPtr)) 6076 return ssmR3DataRead(pSSM, pGCPtr, sizeof(*pGCPtr)); 6077 6078 /* 6079 * Fiddly. 6080 */ 6081 Assert(sizeof(*pGCPtr) == sizeof(uint64_t) || sizeof(*pGCPtr) == sizeof(uint32_t)); 6082 Assert(pSSM->u.Read.cbGCPtr == sizeof(uint64_t) || pSSM->u.Read.cbGCPtr == sizeof(uint32_t)); 6083 if (pSSM->u.Read.cbGCPtr == sizeof(uint64_t)) 6084 { 6085 /* 64-bit saved, 32-bit load: try truncate it. */ 6086 uint64_t u64; 6087 int rc = ssmR3DataRead(pSSM, &u64, sizeof(uint64_t)); 6088 if (RT_FAILURE(rc)) 6158 6089 return rc; 6159 } 6160 6161 /* 32-bit saved, 64-bit load: clear the high part. */ 6162 *pGCPtr = 0; 6163 return ssmR3DataRead(pSSM, pGCPtr, sizeof(uint32_t)); 6164 } 6165 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6166 return VERR_SSM_INVALID_STATE; 6090 if (u64 >= _4G) 6091 return VERR_SSM_GCPTR_OVERFLOW; 6092 *pGCPtr = (RTGCPTR)u64; 6093 return rc; 6094 } 6095 6096 /* 32-bit saved, 64-bit load: clear the high part. */ 6097 *pGCPtr = 0; 6098 return ssmR3DataRead(pSSM, pGCPtr, sizeof(uint32_t)); 6167 6099 } 6168 6100 … … 6191 6123 VMMR3DECL(int) SSMR3GetRCPtr(PSSMHANDLE pSSM, PRTRCPTR pRCPtr) 6192 6124 { 6193 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 6194 return ssmR3DataRead(pSSM, pRCPtr, sizeof(*pRCPtr)); 6195 6196 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6197 return VERR_SSM_INVALID_STATE; 6125 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6126 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6127 return ssmR3DataRead(pSSM, pRCPtr, sizeof(*pRCPtr)); 6198 6128 } 6199 6129 … … 6208 6138 VMMR3DECL(int) SSMR3GetIOPort(PSSMHANDLE pSSM, PRTIOPORT pIOPort) 6209 6139 { 6210 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 6211 return ssmR3DataRead(pSSM, pIOPort, sizeof(*pIOPort)); 6212 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6213 return VERR_SSM_INVALID_STATE; 6140 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6141 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6142 return ssmR3DataRead(pSSM, pIOPort, sizeof(*pIOPort)); 6214 6143 } 6215 6144 … … 6224 6153 VMMR3DECL(int) SSMR3GetSel(PSSMHANDLE pSSM, PRTSEL pSel) 6225 6154 { 6226 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 6227 return ssmR3DataRead(pSSM, pSel, sizeof(*pSel)); 6228 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6229 return VERR_SSM_INVALID_STATE; 6155 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6156 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6157 return ssmR3DataRead(pSSM, pSel, sizeof(*pSel)); 6230 6158 } 6231 6159 … … 6241 6169 VMMR3DECL(int) SSMR3GetMem(PSSMHANDLE pSSM, void *pv, size_t cb) 6242 6170 { 6243 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 6244 return ssmR3DataRead(pSSM, pv, cb); 6245 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6246 return VERR_SSM_INVALID_STATE; 6171 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6172 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6173 return ssmR3DataRead(pSSM, pv, cb); 6247 6174 } 6248 6175 … … 6273 6200 VMMR3DECL(int) SSMR3GetStrZEx(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr) 6274 6201 { 6275 if (pSSM->enmOp == SSMSTATE_LOAD_EXEC || pSSM->enmOp == SSMSTATE_OPEN_READ) 6276 { 6277 /* read size prefix. */ 6278 uint32_t u32; 6279 int rc = SSMR3GetU32(pSSM, &u32); 6280 if (RT_SUCCESS(rc)) 6281 { 6282 if (pcbStr) 6283 *pcbStr = u32; 6284 if (u32 < cbMax) 6285 { 6286 /* terminate and read string content. */ 6287 psz[u32] = '\0'; 6288 return ssmR3DataRead(pSSM, psz, u32); 6289 } 6290 return VERR_TOO_MUCH_DATA; 6291 } 6292 return rc; 6293 } 6294 AssertMsgFailed(("Invalid state %d\n", pSSM->enmOp)); 6295 return VERR_SSM_INVALID_STATE; 6202 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6203 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6204 6205 /* read size prefix. */ 6206 uint32_t u32; 6207 int rc = SSMR3GetU32(pSSM, &u32); 6208 if (RT_SUCCESS(rc)) 6209 { 6210 if (pcbStr) 6211 *pcbStr = u32; 6212 if (u32 < cbMax) 6213 { 6214 /* terminate and read string content. */ 6215 psz[u32] = '\0'; 6216 return ssmR3DataRead(pSSM, psz, u32); 6217 } 6218 return VERR_TOO_MUCH_DATA; 6219 } 6220 return rc; 6296 6221 } 6297 6222 … … 6307 6232 { 6308 6233 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6309 || pSSM->enmOp == SSMSTATE_OPEN_READ, 6310 ("Invalid state %d\n", pSSM->enmOp), 6311 VERR_SSM_INVALID_STATE); 6234 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6312 6235 while (cb > 0) 6313 6236 { … … 6337 6260 { 6338 6261 AssertMsgReturn( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6339 || pSSM->enmOp == SSMSTATE_OPEN_READ, 6340 ("Invalid state %d\n", pSSM->enmOp), 6341 VERR_SSM_INVALID_STATE); 6262 || pSSM->enmOp == SSMSTATE_OPEN_READ, ("Invalid state %d\n", pSSM->enmOp), VERR_SSM_INVALID_STATE); 6342 6263 if (pSSM->u.Read.uFmtVerMajor >= 2) 6343 6264 {
Note:
See TracChangeset
for help on using the changeset viewer.