- Timestamp:
- Oct 22, 2009 11:22:09 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r23933 r23968 4025 4025 */ 4026 4026 pHlp->pfnPrintf(pHlp, 4027 "pcnet #%d: port=%RTiop mmio=%RX32 mac-cfg=% .*Rhxs%s\n",4027 "pcnet #%d: port=%RTiop mmio=%RX32 mac-cfg=%RTmac %s\n", 4028 4028 pDevIns->iInstance, 4029 pThis->IOPortBase, pThis->MMIOBase, sizeof(pThis->MacConfigured),&pThis->MacConfigured,4029 pThis->IOPortBase, pThis->MMIOBase, &pThis->MacConfigured, 4030 4030 pThis->fAm79C973 ? "Am79C973" : "Am79C970A", pThis->fGCEnabled ? " GC" : "", pThis->fR0Enabled ? " R0" : ""); 4031 4031 … … 4252 4252 4253 4253 /** 4254 * Serializes the receive thread, it may be working inside the critsect. 4254 * Saves the configuration. 4255 * 4256 * @param pThis The PCNet instance data. 4257 * @param pSSM The saved state handle. 4258 */ 4259 static void pcnetSaveConfig(PCNetState *pThis, PSSMHANDLE pSSM) 4260 { 4261 SSMR3PutMem(pSSM, &pThis->MacConfigured, sizeof(pThis->MacConfigured)); 4262 SSMR3PutBool(pSSM, pThis->fAm79C973); /* >= If version 0.8 */ 4263 SSMR3PutU32(pSSM, pThis->u32LinkSpeed); 4264 } 4265 4266 4267 /** 4268 * Live Save, pass 0. 4255 4269 * 4256 4270 * @returns VBox status code. 4257 4271 * @param pDevIns The device instance. 4258 * @param pSSMHandle The handle to save the state to. 4259 */ 4260 static DECLCALLBACK(int) pcnetSavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle) 4272 * @param pSSM The saved state handle. 4273 * @param uPass The pass number. 4274 */ 4275 static DECLCALLBACK(int) pcnetLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 4276 { 4277 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 4278 pcnetSaveConfig(pThis, pSSM); 4279 return VINF_SUCCESS; 4280 } 4281 4282 4283 /** 4284 * Serializes the receive thread, it may be working inside the critsect. 4285 * 4286 * @returns VBox status code. 4287 * @param pDevIns The device instance. 4288 * @param pSSM The saved state handle. 4289 */ 4290 static DECLCALLBACK(int) pcnetSavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4261 4291 { 4262 4292 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); … … 4275 4305 * @returns VBox status code. 4276 4306 * @param pDevIns The device instance. 4277 * @param pSSM Handle The handle to save the state to.4278 */ 4279 static DECLCALLBACK(int) pcnetSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM Handle)4307 * @param pSSM The saved state handle. 4308 */ 4309 static DECLCALLBACK(int) pcnetSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4280 4310 { 4281 4311 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 4312 4313 SSMR3PutBool(pSSM, pThis->fLinkUp); 4314 SSMR3PutU32(pSSM, pThis->u32RAP); 4315 SSMR3PutS32(pSSM, pThis->iISR); 4316 SSMR3PutU32(pSSM, pThis->u32Lnkst); 4317 SSMR3PutBool(pSSM, pThis->fPrivIfEnabled); /* >= If version 0.9 */ 4318 SSMR3PutBool(pSSM, pThis->fSignalRxMiss); /* >= If version 0.10 */ 4319 SSMR3PutGCPhys32(pSSM, pThis->GCRDRA); 4320 SSMR3PutGCPhys32(pSSM, pThis->GCTDRA); 4321 SSMR3PutMem(pSSM, pThis->aPROM, sizeof(pThis->aPROM)); 4322 SSMR3PutMem(pSSM, pThis->aCSR, sizeof(pThis->aCSR)); 4323 SSMR3PutMem(pSSM, pThis->aBCR, sizeof(pThis->aBCR)); 4324 SSMR3PutMem(pSSM, pThis->aMII, sizeof(pThis->aMII)); 4325 SSMR3PutU16(pSSM, pThis->u16CSR0LastSeenByGuest); 4326 SSMR3PutU64(pSSM, pThis->u64LastPoll); 4327 pcnetSaveConfig(pThis, pSSM); 4328 4282 4329 int rc = VINF_SUCCESS; 4283 4284 SSMR3PutBool(pSSMHandle, pThis->fLinkUp); 4285 SSMR3PutU32(pSSMHandle, pThis->u32RAP); 4286 SSMR3PutS32(pSSMHandle, pThis->iISR); 4287 SSMR3PutU32(pSSMHandle, pThis->u32Lnkst); 4288 SSMR3PutBool(pSSMHandle, pThis->fPrivIfEnabled); /* >= If version 0.9 */ 4289 SSMR3PutBool(pSSMHandle, pThis->fSignalRxMiss); /* >= If version 0.10 */ 4290 SSMR3PutGCPhys32(pSSMHandle, pThis->GCRDRA); 4291 SSMR3PutGCPhys32(pSSMHandle, pThis->GCTDRA); 4292 SSMR3PutMem(pSSMHandle, pThis->aPROM, sizeof(pThis->aPROM)); 4293 SSMR3PutMem(pSSMHandle, pThis->aCSR, sizeof(pThis->aCSR)); 4294 SSMR3PutMem(pSSMHandle, pThis->aBCR, sizeof(pThis->aBCR)); 4295 SSMR3PutMem(pSSMHandle, pThis->aMII, sizeof(pThis->aMII)); 4296 SSMR3PutU16(pSSMHandle, pThis->u16CSR0LastSeenByGuest); 4297 SSMR3PutU64(pSSMHandle, pThis->u64LastPoll); 4298 SSMR3PutMem(pSSMHandle, &pThis->MacConfigured, sizeof(pThis->MacConfigured)); 4299 SSMR3PutBool(pSSMHandle, pThis->fAm79C973); /* >= If version 0.8 */ 4300 SSMR3PutU32(pSSMHandle, pThis->u32LinkSpeed); 4301 #ifdef PCNET_NO_POLLING 4302 return VINF_SUCCESS; 4303 #else 4304 rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerPoll), pSSMHandle); 4330 #ifndef PCNET_NO_POLLING 4331 rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerPoll), pSSM); 4305 4332 if (RT_FAILURE(rc)) 4306 4333 return rc; 4307 4334 #endif 4308 4335 if (pThis->fAm79C973) 4309 rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerSoftInt), pSSM Handle);4336 rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerSoftInt), pSSM); 4310 4337 return rc; 4311 4338 } … … 4317 4344 * @returns VBox status code. 4318 4345 * @param pDevIns The device instance. 4319 * @param pSSM Handle The handle to save the state to.4320 */ 4321 static DECLCALLBACK(int) pcnetLoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM Handle)4346 * @param pSSM The saved state handle. 4347 */ 4348 static DECLCALLBACK(int) pcnetLoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4322 4349 { 4323 4350 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); … … 4336 4363 * @returns VBox status code. 4337 4364 * @param pDevIns The device instance. 4338 * @param pSSM HandleThe handle to the saved state.4365 * @param pSSM The handle to the saved state. 4339 4366 * @param uVersion The data unit version number. 4340 4367 * @param uPass The data pass. 4341 4368 */ 4342 static DECLCALLBACK(int) pcnetLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM Handle, uint32_t uVersion, uint32_t uPass)4369 static DECLCALLBACK(int) pcnetLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 4343 4370 { 4344 4371 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 4345 RTMAC Mac; 4372 4346 4373 if ( SSM_VERSION_MAJOR_CHANGED(uVersion, PCNET_SAVEDSTATE_VERSION) 4347 4374 || SSM_VERSION_MINOR(uVersion) < 7) 4348 4375 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 4349 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 4350 4351 /* restore data */ 4352 SSMR3GetBool(pSSMHandle, &pThis->fLinkUp); 4353 SSMR3GetU32(pSSMHandle, &pThis->u32RAP); 4354 SSMR3GetS32(pSSMHandle, &pThis->iISR); 4355 SSMR3GetU32(pSSMHandle, &pThis->u32Lnkst); 4356 if ( SSM_VERSION_MAJOR(uVersion) > 0 4357 || SSM_VERSION_MINOR(uVersion) >= 9) 4358 { 4359 SSMR3GetBool(pSSMHandle, &pThis->fPrivIfEnabled); 4360 if (pThis->fPrivIfEnabled) 4361 LogRel(("PCNet#%d: Enabling private interface\n", PCNET_INST_NR)); 4362 } 4363 if ( SSM_VERSION_MAJOR(uVersion) > 0 4364 || SSM_VERSION_MINOR(uVersion) >= 10) 4365 { 4366 SSMR3GetBool(pSSMHandle, &pThis->fSignalRxMiss); 4367 } 4368 SSMR3GetGCPhys32(pSSMHandle, &pThis->GCRDRA); 4369 SSMR3GetGCPhys32(pSSMHandle, &pThis->GCTDRA); 4370 SSMR3GetMem(pSSMHandle, &pThis->aPROM, sizeof(pThis->aPROM)); 4371 SSMR3GetMem(pSSMHandle, &pThis->aCSR, sizeof(pThis->aCSR)); 4372 SSMR3GetMem(pSSMHandle, &pThis->aBCR, sizeof(pThis->aBCR)); 4373 SSMR3GetMem(pSSMHandle, &pThis->aMII, sizeof(pThis->aMII)); 4374 SSMR3GetU16(pSSMHandle, &pThis->u16CSR0LastSeenByGuest); 4375 SSMR3GetU64(pSSMHandle, &pThis->u64LastPoll); 4376 SSMR3GetMem(pSSMHandle, &Mac, sizeof(Mac)); 4377 Assert( !memcmp(&Mac, &pThis->MacConfigured, sizeof(Mac)) 4378 || SSMR3HandleGetAfter(pSSMHandle) == SSMAFTER_DEBUG_IT); 4379 SSMR3GetBool(pSSMHandle, &pThis->fAm79C973); 4380 SSMR3GetU32(pSSMHandle, &pThis->u32LinkSpeed); 4376 4377 if (uPass == SSM_PASS_FINAL) 4378 { 4379 /* restore data */ 4380 SSMR3GetBool(pSSM, &pThis->fLinkUp); 4381 SSMR3GetU32(pSSM, &pThis->u32RAP); 4382 SSMR3GetS32(pSSM, &pThis->iISR); 4383 SSMR3GetU32(pSSM, &pThis->u32Lnkst); 4384 if ( SSM_VERSION_MAJOR(uVersion) > 0 4385 || SSM_VERSION_MINOR(uVersion) >= 9) 4386 { 4387 SSMR3GetBool(pSSM, &pThis->fPrivIfEnabled); 4388 if (pThis->fPrivIfEnabled) 4389 LogRel(("PCNet#%d: Enabling private interface\n", PCNET_INST_NR)); 4390 } 4391 if ( SSM_VERSION_MAJOR(uVersion) > 0 4392 || SSM_VERSION_MINOR(uVersion) >= 10) 4393 { 4394 SSMR3GetBool(pSSM, &pThis->fSignalRxMiss); 4395 } 4396 SSMR3GetGCPhys32(pSSM, &pThis->GCRDRA); 4397 SSMR3GetGCPhys32(pSSM, &pThis->GCTDRA); 4398 SSMR3GetMem(pSSM, &pThis->aPROM, sizeof(pThis->aPROM)); 4399 SSMR3GetMem(pSSM, &pThis->aCSR, sizeof(pThis->aCSR)); 4400 SSMR3GetMem(pSSM, &pThis->aBCR, sizeof(pThis->aBCR)); 4401 SSMR3GetMem(pSSM, &pThis->aMII, sizeof(pThis->aMII)); 4402 SSMR3GetU16(pSSM, &pThis->u16CSR0LastSeenByGuest); 4403 SSMR3GetU64(pSSM, &pThis->u64LastPoll); 4404 } 4405 4406 /* check config */ 4407 RTMAC Mac; 4408 int rc = SSMR3GetMem(pSSM, &Mac, sizeof(Mac)); 4409 AssertRCReturn(rc, rc); 4410 if ( memcmp(&Mac, &pThis->MacConfigured, sizeof(Mac)) 4411 && (uPass == 0 || !PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns)) ) 4412 LogRel(("PCNet#%u: The mac address differs: config=%RTmac saved=%RTmac\n", PCNET_INST_NR, &pThis->MacConfigured, &Mac)); 4413 4414 bool fAm79C973; 4415 rc = SSMR3GetBool(pSSM, &fAm79C973); 4416 AssertRCReturn(rc, rc); 4417 if (pThis->fAm79C973 != fAm79C973) 4418 { 4419 LogRel(("PCNet#%u: The fAm79C973 flag differs: config=%RTbool saved=%RTbool\n", PCNET_INST_NR, pThis->fAm79C973, fAm79C973)); 4420 return VERR_SSM_LOAD_CONFIG_MISMATCH; 4421 } 4422 4423 uint32_t u32LinkSpeed; 4424 rc = SSMR3GetU32(pSSM, &u32LinkSpeed); 4425 AssertRCReturn(rc, rc); 4426 if ( pThis->u32LinkSpeed != u32LinkSpeed 4427 && (uPass == 0 || !PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns)) ) 4428 LogRel(("PCNet#%u: The mac link speed differs: config=%u saved=%u\n", PCNET_INST_NR, pThis->u32LinkSpeed, u32LinkSpeed)); 4429 4430 if (uPass == SSM_PASS_FINAL) 4431 { 4432 /* restore timers and stuff */ 4381 4433 #ifndef PCNET_NO_POLLING 4382 TMR3TimerLoad(pThis->CTX_SUFF(pTimerPoll), pSSMHandle);4383 #endif 4384 if (pThis->fAm79C973)4385 {4386 if ( SSM_VERSION_MAJOR(uVersion) > 04387 || SSM_VERSION_MINOR(uVersion) >= 8)4388 TMR3TimerLoad(pThis->CTX_SUFF(pTimerSoftInt), pSSMHandle);4389 }4390 4391 pThis->iLog2DescSize = BCR_SWSTYLE(pThis)4392 ? 44393 : 3;4394 pThis->GCUpperPhys = BCR_SSIZE32(pThis)4395 ? 04396 : (0xff00 & (uint32_t)pThis->aCSR[2]) << 16;4397 4398 /* update promiscuous mode. */4399 if (pThis->pDrv)4400 pThis->pDrv->pfnSetPromiscuousMode(pThis->pDrv, CSR_PROM(pThis));4434 TMR3TimerLoad(pThis->CTX_SUFF(pTimerPoll), pSSM); 4435 #endif 4436 if (pThis->fAm79C973) 4437 { 4438 if ( SSM_VERSION_MAJOR(uVersion) > 0 4439 || SSM_VERSION_MINOR(uVersion) >= 8) 4440 TMR3TimerLoad(pThis->CTX_SUFF(pTimerSoftInt), pSSM); 4441 } 4442 4443 pThis->iLog2DescSize = BCR_SWSTYLE(pThis) 4444 ? 4 4445 : 3; 4446 pThis->GCUpperPhys = BCR_SSIZE32(pThis) 4447 ? 0 4448 : (0xff00 & (uint32_t)pThis->aCSR[2]) << 16; 4449 4450 /* update promiscuous mode. */ 4451 if (pThis->pDrv) 4452 pThis->pDrv->pfnSetPromiscuousMode(pThis->pDrv, CSR_PROM(pThis)); 4401 4453 4402 4454 #ifdef PCNET_NO_POLLING 4403 /* Enable physical monitoring again (!) */ 4404 pcnetUpdateRingHandlers(pThis); 4405 #endif 4406 /* Indicate link down to the guest OS that all network connections have 4407 been lost, unless we've been teleported here. */ 4408 if (!PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns)) 4409 pcnetTempLinkDown(pThis); 4455 /* Enable physical monitoring again (!) */ 4456 pcnetUpdateRingHandlers(pThis); 4457 #endif 4458 /* Indicate link down to the guest OS that all network connections have 4459 been lost, unless we've been teleported here. */ 4460 if (!PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns)) 4461 pcnetTempLinkDown(pThis); 4462 } 4410 4463 4411 4464 return VINF_SUCCESS; … … 4915 4968 if (!CFGMR3AreValuesValid(pCfgHandle, "MAC\0" "CableConnected\0" "Am79C973\0" "LineSpeed\0" "GCEnabled\0" "R0Enabled\0" "PrivIfEnabled\0")) 4916 4969 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 4917 N_("Invalid configurat on for pcnet device"));4970 N_("Invalid configuration for pcnet device")); 4918 4971 4919 4972 /* … … 5099 5152 5100 5153 rc = PDMDevHlpSSMRegisterEx(pDevIns, PCNET_SAVEDSTATE_VERSION, sizeof(*pThis), NULL, 5101 NULL, NULL, NULL,5154 NULL, pcnetLiveExec, NULL, 5102 5155 pcnetSavePrep, pcnetSaveExec, NULL, 5103 5156 pcnetLoadPrep, pcnetLoadExec, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.