VirtualBox

Changeset 22034 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Aug 6, 2009 12:38:19 PM (15 years ago)
Author:
vboxsync
Message:

SSM: We've got AssertMsgReturn now, use it for assertion the SSMSTATE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/SSM-new.cpp

    r22029 r22034  
    46164616VMMR3DECL(int) SSMR3PutBool(PSSMHANDLE pSSM, bool fBool)
    46174617{
    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));
    46254621}
    46264622
     
    46354631VMMR3DECL(int) SSMR3PutU8(PSSMHANDLE pSSM, uint8_t u8)
    46364632{
    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));
    46414635}
    46424636
     
    46514645VMMR3DECL(int) SSMR3PutS8(PSSMHANDLE pSSM, int8_t i8)
    46524646{
    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));
    46574649}
    46584650
     
    46674659VMMR3DECL(int) SSMR3PutU16(PSSMHANDLE pSSM, uint16_t u16)
    46684660{
    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));
    46734663}
    46744664
     
    46834673VMMR3DECL(int) SSMR3PutS16(PSSMHANDLE pSSM, int16_t i16)
    46844674{
    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));
    46894677}
    46904678
     
    46994687VMMR3DECL(int) SSMR3PutU32(PSSMHANDLE pSSM, uint32_t u32)
    47004688{
    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));
    47054691}
    47064692
     
    47154701VMMR3DECL(int) SSMR3PutS32(PSSMHANDLE pSSM, int32_t i32)
    47164702{
    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));
    47214705}
    47224706
     
    47314715VMMR3DECL(int) SSMR3PutU64(PSSMHANDLE pSSM, uint64_t u64)
    47324716{
    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));
    47374719}
    47384720
     
    47474729VMMR3DECL(int) SSMR3PutS64(PSSMHANDLE pSSM, int64_t i64)
    47484730{
    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));
    47534733}
    47544734
     
    47634743VMMR3DECL(int) SSMR3PutU128(PSSMHANDLE pSSM, uint128_t u128)
    47644744{
    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));
    47694747}
    47704748
     
    47794757VMMR3DECL(int) SSMR3PutS128(PSSMHANDLE pSSM, int128_t i128)
    47804758{
    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));
    47854761}
    47864762
     
    47954771VMMR3DECL(int) SSMR3PutUInt(PSSMHANDLE pSSM, RTUINT u)
    47964772{
    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));
    48014775}
    48024776
     
    48114785VMMR3DECL(int) SSMR3PutSInt(PSSMHANDLE pSSM, RTINT i)
    48124786{
    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));
    48174789}
    48184790
     
    48294801VMMR3DECL(int) SSMR3PutGCUInt(PSSMHANDLE pSSM, RTGCUINT u)
    48304802{
    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));
    48354805}
    48364806
     
    48454815VMMR3DECL(int) SSMR3PutGCUIntReg(PSSMHANDLE pSSM, RTGCUINTREG u)
    48464816{
    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));
    48514819}
    48524820
     
    48614829VMMR3DECL(int) SSMR3PutGCPhys32(PSSMHANDLE pSSM, RTGCPHYS32 GCPhys)
    48624830{
    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));
    48674833}
    48684834
     
    48774843VMMR3DECL(int) SSMR3PutGCPhys64(PSSMHANDLE pSSM, RTGCPHYS64 GCPhys)
    48784844{
    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));
    48834847}
    48844848
     
    48934857VMMR3DECL(int) SSMR3PutGCPhys(PSSMHANDLE pSSM, RTGCPHYS GCPhys)
    48944858{
    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));
    48994861}
    49004862
     
    49094871VMMR3DECL(int) SSMR3PutGCPtr(PSSMHANDLE pSSM, RTGCPTR GCPtr)
    49104872{
    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));
    49154875}
    49164876
     
    49254885VMMR3DECL(int) SSMR3PutRCPtr(PSSMHANDLE pSSM, RTRCPTR RCPtr)
    49264886{
    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));
    49314889}
    49324890
     
    49414899VMMR3DECL(int) SSMR3PutGCUIntPtr(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr)
    49424900{
    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));
    49474903}
    49484904
     
    49574913VMMR3DECL(int) SSMR3PutIOPort(PSSMHANDLE pSSM, RTIOPORT IOPort)
    49584914{
    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));
    49634917}
    49644918
     
    49734927VMMR3DECL(int) SSMR3PutSel(PSSMHANDLE pSSM, RTSEL Sel)
    49744928{
    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));
    49794931}
    49804932
     
    49904942VMMR3DECL(int) SSMR3PutMem(PSSMHANDLE pSSM, const void *pv, size_t cb)
    49914943{
    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);
    49964946}
    49974947
     
    50064956VMMR3DECL(int) SSMR3PutStrZ(PSSMHANDLE pSSM, const char *psz)
    50074957{
    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);
    50244971}
    50254972
     
    57815728VMMR3DECL(int) SSMR3GetBool(PSSMHANDLE pSSM, bool *pfBool)
    57825729{
    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;
    57965740}
    57975741
     
    58065750VMMR3DECL(int) SSMR3GetU8(PSSMHANDLE pSSM, uint8_t *pu8)
    58075751{
    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));
    58125755}
    58135756
     
    58225765VMMR3DECL(int) SSMR3GetS8(PSSMHANDLE pSSM, int8_t *pi8)
    58235766{
    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));
    58285770}
    58295771
     
    58385780VMMR3DECL(int) SSMR3GetU16(PSSMHANDLE pSSM, uint16_t *pu16)
    58395781{
    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));
    58445785}
    58455786
     
    58545795VMMR3DECL(int) SSMR3GetS16(PSSMHANDLE pSSM, int16_t *pi16)
    58555796{
    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));
    58605800}
    58615801
     
    58705810VMMR3DECL(int) SSMR3GetU32(PSSMHANDLE pSSM, uint32_t *pu32)
    58715811{
    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));
    58765815}
    58775816
     
    58865825VMMR3DECL(int) SSMR3GetS32(PSSMHANDLE pSSM, int32_t *pi32)
    58875826{
    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));
    58925830}
    58935831
     
    59025840VMMR3DECL(int) SSMR3GetU64(PSSMHANDLE pSSM, uint64_t *pu64)
    59035841{
    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));
    59085845}
    59095846
     
    59185855VMMR3DECL(int) SSMR3GetS64(PSSMHANDLE pSSM, int64_t *pi64)
    59195856{
    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));
    59245860}
    59255861
     
    59345870VMMR3DECL(int) SSMR3GetU128(PSSMHANDLE pSSM, uint128_t *pu128)
    59355871{
    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));
    59405875}
    59415876
     
    59505885VMMR3DECL(int) SSMR3GetS128(PSSMHANDLE pSSM, int128_t *pi128)
    59515886{
    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));
    59565890}
    59575891
     
    59665900VMMR3DECL(int) SSMR3GetUInt(PSSMHANDLE pSSM, PRTUINT pu)
    59675901{
    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));
    59725905}
    59735906
     
    59825915VMMR3DECL(int) SSMR3GetSInt(PSSMHANDLE pSSM, PRTINT pi)
    59835916{
    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));
    59885920}
    59895921
     
    60285960VMMR3DECL(int) SSMR3GetGCPhys32(PSSMHANDLE pSSM, PRTGCPHYS32 pGCPhys)
    60295961{
    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));
    60345965}
    60355966
     
    60445975VMMR3DECL(int) SSMR3GetGCPhys64(PSSMHANDLE pSSM, PRTGCPHYS64 pGCPhys)
    60455976{
    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));
    60505980}
    60515981
     
    60605990VMMR3DECL(int) SSMR3GetGCPhys(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys)
    60615991{
    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))
    60826012            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));
    60916022}
    60926023
     
    61366067VMMR3DECL(int) SSMR3GetGCPtr(PSSMHANDLE pSSM, PRTGCPTR pGCPtr)
    61376068{
    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))
    61586089            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));
    61676099}
    61686100
     
    61916123VMMR3DECL(int) SSMR3GetRCPtr(PSSMHANDLE pSSM, PRTRCPTR pRCPtr)
    61926124{
    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));
    61986128}
    61996129
     
    62086138VMMR3DECL(int) SSMR3GetIOPort(PSSMHANDLE pSSM, PRTIOPORT pIOPort)
    62096139{
    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));
    62146143}
    62156144
     
    62246153VMMR3DECL(int) SSMR3GetSel(PSSMHANDLE pSSM, PRTSEL pSel)
    62256154{
    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));
    62306158}
    62316159
     
    62416169VMMR3DECL(int) SSMR3GetMem(PSSMHANDLE pSSM, void *pv, size_t cb)
    62426170{
    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);
    62476174}
    62486175
     
    62736200VMMR3DECL(int) SSMR3GetStrZEx(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr)
    62746201{
    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;
    62966221}
    62976222
     
    63076232{
    63086233    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);
    63126235    while (cb > 0)
    63136236    {
     
    63376260{
    63386261    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);
    63426263    if (pSSM->u.Read.uFmtVerMajor >= 2)
    63436264    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette