儲存庫 vbox 的更動 49754
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r49414 r49754 55 55 #include <VBox/vmm/pdmnetifs.h> 56 56 #include <VBox/vmm/pgm.h> 57 #include <VBox/DevPCNet.h>58 57 #include <iprt/asm.h> 59 58 #include <iprt/assert.h> … … 273 272 /** LUN\#0: The network config port interface. */ 274 273 PDMINETWORKCONFIG INetworkConfig; 275 /** The shared memory used for the private interface - R3. */276 R3PTRTYPE(PPCNETGUESTSHAREDMEMORY) pSharedMMIOR3;277 274 /** Software Interrupt timer - R3. */ 278 275 PTMTIMERR3 pTimerSoftIntR3; … … 293 290 /** Pointer to the connector of the attached network driver - R0. */ 294 291 PPDMINETWORKUPR0 pDrvR0; 295 /** The shared memory used for the private interface - R0. */296 R0PTRTYPE(PPCNETGUESTSHAREDMEMORY) pSharedMMIOR0;297 292 /** Software Interrupt timer - R0. */ 298 293 PTMTIMERR0 pTimerSoftIntR0; … … 310 305 /** Pointer to the connector of the attached network driver - RC. */ 311 306 PPDMINETWORKUPRC pDrvRC; 312 /** The shared memory used for the private interface - RC. */313 RCPTRTYPE(PPCNETGUESTSHAREDMEMORY) pSharedMMIORC;314 307 /** Software Interrupt timer - RC. */ 315 308 PTMTIMERRC pTimerSoftIntRC; … … 319 312 #endif 320 313 321 //#if HC_ARCH_BITS == 64 314 /** Alignment padding. */ 322 315 uint32_t Alignment1; 323 //#endif324 325 316 /** Register Address Pointer */ 326 317 uint32_t u32RAP; … … 342 333 * seen by the guest. */ 343 334 uint16_t u16CSR0LastSeenByGuest; 344 uint16_t Alignment2[HC_ARCH_BITS == 32 ? 2 : 2];345 335 /** Last time we polled the queues */ 346 336 uint64_t u64LastPoll; … … 351 341 uint8_t abRecvBuf[4096]; 352 342 353 /** Unused /padding. */354 uint32_t u32Unused;343 /** Alignment padding. */ 344 uint32_t Alignment2; 355 345 356 346 /** Size of a RX/TX descriptor (8 or 16 bytes according to SWSTYLE */ … … 373 363 RTMAC MacConfigured; 374 364 /** Alignment padding. */ 375 uint8_t Alignment 4[HC_ARCH_BITS == 64 ? 2 :2];365 uint8_t Alignment3[2]; 376 366 377 367 /** The LED. */ … … 390 380 /** True if we signal the guest that RX packets are missing. */ 391 381 bool fSignalRxMiss; 392 uint8_t Alignment5[HC_ARCH_BITS == 64 ? 2 : 6]; 382 /** Alignment padding. */ 383 uint8_t Alignment4[HC_ARCH_BITS == 64 ? 2 : 6]; 393 384 394 385 #ifdef PCNET_NO_POLLING … … 405 396 /** Error counter for bad receive descriptors. */ 406 397 uint32_t uCntBadRMD; 407 408 /** True if host and guest admitted to use the private interface. */ 409 bool fPrivIfEnabled; 398 /* True if raw context is enabled. */ 410 399 bool fGCEnabled; 400 /* True if R0 context is enabled. */ 411 401 bool fR0Enabled; 402 /* True: Emulate Am79C973. False: Emulate 79C970A. */ 412 403 bool fAm79C973; 404 /* Link speed to be reported through CSR68. */ 405 bool Alignment5; 406 /* Alignment padding. */ 413 407 uint32_t u32LinkSpeed; 408 /* MS to wait before we enable the link. */ 414 409 uint32_t cMsLinkUpDelay; 410 /* Alignment padding. */ 415 411 uint32_t Alignment6; 416 412 … … 663 659 uint8_t ownbyte; 664 660 665 if (pThis->fPrivIfEnabled) 666 { 667 /* RX/TX descriptors shared between host and guest => direct copy */ 668 uint8_t *pv = (uint8_t*)pThis->CTX_SUFF(pSharedMMIO) 669 + (addr - pThis->GCTDRA) 670 + pThis->CTX_SUFF(pSharedMMIO)->V.V1.offTxDescriptors; 671 if (!(pv[7] & 0x80) && fRetIfNotOwn) 672 return false; 673 memcpy(tmd, pv, 16); 674 return true; 675 } 676 else if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 661 if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 677 662 { 678 663 uint16_t xda[4]; … … 725 710 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatTmdStore), a); 726 711 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); 727 if (pThis->fPrivIfEnabled) 728 { 729 /* RX/TX descriptors shared between host and guest => direct copy */ 730 uint8_t *pv = (uint8_t*)pThis->CTX_SUFF(pSharedMMIO) 731 + (addr - pThis->GCTDRA) 732 + pThis->CTX_SUFF(pSharedMMIO)->V.V1.offTxDescriptors; 733 memcpy(pv, tmd, 16); 734 pv[7] &= ~0x80; 735 } 736 else if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 712 if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 737 713 { 738 714 uint16_t xda[4]; … … 782 758 uint8_t ownbyte; 783 759 784 if (pThis->fPrivIfEnabled) 785 { 786 /* RX/TX descriptors shared between host and guest => direct copy */ 787 uint8_t *pb = (uint8_t*)pThis->CTX_SUFF(pSharedMMIO) 788 + (addr - pThis->GCRDRA) 789 + pThis->CTX_SUFF(pSharedMMIO)->V.V1.offRxDescriptors; 790 if (!(pb[7] & 0x80) && fRetIfNotOwn) 791 return false; 792 memcpy(rmd, pb, 16); 793 return true; 794 } 795 else if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 760 if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 796 761 { 797 762 uint16_t rda[4]; … … 843 808 { 844 809 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); 845 if (pThis->fPrivIfEnabled) 846 { 847 /* RX/TX descriptors shared between host and guest => direct copy */ 848 uint8_t *pv = (uint8_t*)pThis->CTX_SUFF(pSharedMMIO) 849 + (addr - pThis->GCRDRA) 850 + pThis->CTX_SUFF(pSharedMMIO)->V.V1.offRxDescriptors; 851 memcpy(pv, rmd, 16); 852 pv[7] &= ~0x80; 853 } 854 else if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 810 if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 855 811 { 856 812 uint16_t rda[4]; … … 893 849 { 894 850 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); 895 896 if (!pThis->fPrivIfEnabled) 897 { 898 uint8_t aBuf[16]; 899 size_t cbDesc; 900 if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 901 cbDesc = 8; 902 else 903 cbDesc = 16; 904 PDMDevHlpPhysRead(pDevIns, addr, aBuf, cbDesc); 905 PDMDevHlpPCIPhysWrite(pDevIns, addr, aBuf, cbDesc); 906 } 851 uint8_t aBuf[16]; 852 size_t cbDesc; 853 if (RT_UNLIKELY(BCR_SWSTYLE(pThis) == 0)) 854 cbDesc = 8; 855 else 856 cbDesc = 16; 857 PDMDevHlpPhysRead(pDevIns, addr, aBuf, cbDesc); 858 PDMDevHlpPCIPhysWrite(pDevIns, addr, aBuf, cbDesc); 907 859 } 908 860 #endif /* IN_RING3 */ … … 945 897 } while (0) 946 898 947 948 #ifdef IN_RING3949 /**950 * Initialize the shared memory for the private guest interface.951 *952 * @note Changing this layout will break SSM for guests using the private guest interface!953 */954 static void pcnetInitSharedMemory(PPCNETSTATE pThis)955 {956 /* Clear the entire block for pcnetReset usage. */957 memset(pThis->pSharedMMIOR3, 0, PCNET_GUEST_SHARED_MEMORY_SIZE);958 959 pThis->pSharedMMIOR3->u32Version = PCNET_GUEST_INTERFACE_VERSION;960 uint32_t off = 2048; /* Leave some space for more fields within the header */961 962 /*963 * The Descriptor arrays.964 */965 pThis->pSharedMMIOR3->V.V1.offTxDescriptors = off;966 off = RT_ALIGN(off + PCNET_GUEST_TX_DESCRIPTOR_SIZE * PCNET_GUEST_MAX_TX_DESCRIPTORS, 32);967 968 pThis->pSharedMMIOR3->V.V1.offRxDescriptors = off;969 off = RT_ALIGN(off + PCNET_GUEST_RX_DESCRIPTOR_SIZE * PCNET_GUEST_MAX_RX_DESCRIPTORS, 32);970 971 /* Make sure all the descriptors are mapped into HMA space (and later ring-0). The 8192972 bytes limit is hardcoded in the PDMDevHlpMMHyperMapMMIO2 call down in pcnetConstruct. */973 AssertRelease(off <= 8192);974 975 /*976 * The buffer arrays.977 */978 #if 0979 /* Don't allocate TX buffers since Windows guests cannot use it */980 pThis->pSharedMMIOR3->V.V1.offTxBuffers = off;981 off = RT_ALIGN(off + PCNET_GUEST_NIC_BUFFER_SIZE * PCNET_GUEST_MAX_TX_DESCRIPTORS, 32);982 #endif983 984 pThis->pSharedMMIOR3->V.V1.offRxBuffers = off;985 pThis->pSharedMMIOR3->fFlags = PCNET_GUEST_FLAGS_ADMIT_HOST;986 off = RT_ALIGN(off + PCNET_GUEST_NIC_BUFFER_SIZE * PCNET_GUEST_MAX_RX_DESCRIPTORS, 32);987 AssertRelease(off <= PCNET_GUEST_SHARED_MEMORY_SIZE);988 989 /* Update the header with the final size. */990 pThis->pSharedMMIOR3->cbUsed = off;991 }992 #endif /* IN_RING3 */993 899 994 900 #define MULTICAST_FILTER_LEN 8 … … 1431 1337 } 1432 1338 1433 /**1434 * Enable/disable the private guest interface.1435 */1436 static void pcnetEnablePrivateIf(PPCNETSTATE pThis)1437 {1438 bool fPrivIfEnabled = pThis->pSharedMMIOR31439 && !!(pThis->CTX_SUFF(pSharedMMIO)->fFlags & PCNET_GUEST_FLAGS_ADMIT_GUEST);1440 if (fPrivIfEnabled != pThis->fPrivIfEnabled)1441 {1442 pThis->fPrivIfEnabled = fPrivIfEnabled;1443 LogRel(("PCNet#%d: %s private interface\n", PCNET_INST_NR, fPrivIfEnabled ? "Enabling" : "Disabling"));1444 }1445 }1446 1447 1339 #ifdef IN_RING3 1448 1340 #ifdef PCNET_NO_POLLING … … 1560 1452 } while (0) 1561 1453 1562 pcnetEnablePrivateIf(pThis);1563 1564 1454 if (BCR_SSIZE32(pThis)) 1565 1455 { … … 1647 1537 if (!CSR_DRX(pThis)) 1648 1538 pThis->aCSR[0] |= 0x0020; /* set RXON */ 1649 pcnetEnablePrivateIf(pThis);1650 1539 pThis->aCSR[0] &= ~0x0004; /* clear STOP bit */ 1651 1540 pThis->aCSR[0] |= 0x0002; /* STRT */ … … 1663 1552 pThis->aCSR[4] &= ~0x02c2; 1664 1553 pThis->aCSR[5] &= ~0x0011; 1665 pcnetEnablePrivateIf(pThis);1666 1554 pcnetPollTimer(pThis); 1667 1555 } … … 4346 4234 SSMR3PutS32(pSSM, pThis->iISR); 4347 4235 SSMR3PutU32(pSSM, pThis->u32Lnkst); 4348 SSMR3PutBool(pSSM, pThis->fPrivIfEnabled);/* >= If version 0.9 */4236 SSMR3PutBool(pSSM, false/* was ffPrivIfEnabled */); /* >= If version 0.9 */ 4349 4237 SSMR3PutBool(pSSM, pThis->fSignalRxMiss); /* >= If version 0.10 */ 4350 4238 SSMR3PutGCPhys32(pSSM, pThis->GCRDRA); … … 4407 4295 || SSM_VERSION_MINOR(uVersion) >= 9) 4408 4296 { 4409 SSMR3GetBool(pSSM, &pThis->fPrivIfEnabled); 4410 if (pThis->fPrivIfEnabled) 4411 LogRel(("PCNet#%d: Enabling private interface\n", PCNET_INST_NR)); 4297 bool fPrivIfEnabled = false; 4298 SSMR3GetBool(pSSM, &fPrivIfEnabled); 4299 if (fPrivIfEnabled) 4300 { 4301 /* no longer implemented */ 4302 LogRel(("PCNet#%d: Cannot enabling private interface!\n", PCNET_INST_NR)); 4303 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 4304 } 4412 4305 } 4413 4306 if ( SSM_VERSION_MAJOR(uVersion) > 0 … … 4865 4758 pcnetTimerRestore(pDevIns, pThis->pTimerRestore, pThis); 4866 4759 } 4867 if (pThis->pSharedMMIOR3)4868 pcnetInitSharedMemory(pThis);4869 4760 4870 4761 /** @todo How to flush the queues? */ … … 4882 4773 pThis->pXmitQueueRC = PDMQueueRCPtr(pThis->pXmitQueueR3); 4883 4774 pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3); 4884 if (pThis->pSharedMMIOR3)4885 pThis->pSharedMMIORC += offDelta;4886 4775 #ifdef PCNET_NO_POLLING 4887 4776 pThis->pfnEMInterpretInstructionRC += offDelta; … … 5066 4955 if (RT_FAILURE(rc)) 5067 4956 return rc; 5068 5069 bool fPrivIfEnabled;5070 rc = CFGMR3QueryBool(pCfg, "PrivIfEnabled", &fPrivIfEnabled);5071 if (rc == VERR_CFGM_VALUE_NOT_FOUND)5072 fPrivIfEnabled = true;5073 else if (RT_FAILURE(rc))5074 return PDMDEV_SET_ERROR(pDevIns, rc,5075 N_("Configuration error: Failed to get the \"PrivIfEnabled\" value"));5076 5077 if (fPrivIfEnabled)5078 {5079 /*5080 * Initialize shared memory between host and guest for descriptors and RX buffers. Most guests5081 * should not care if there is an additional PCI resource but just in case we made this configurable.5082 */5083 rc = PDMDevHlpMMIO2Register(pDevIns, 2, PCNET_GUEST_SHARED_MEMORY_SIZE, 0, (void **)&pThis->pSharedMMIOR3, "PCNetShMem");5084 if (RT_FAILURE(rc))5085 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,5086 N_("Failed to allocate %u bytes of memory for the PCNet device"), PCNET_GUEST_SHARED_MEMORY_SIZE);5087 rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, 2, 0, 8192, "PCNetShMem", &pThis->pSharedMMIORC);5088 if (RT_FAILURE(rc))5089 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,5090 N_("Failed to map 8192 bytes of memory for the PCNet device into the hyper memory"));5091 pThis->pSharedMMIOR0 = (uintptr_t)pThis->pSharedMMIOR3; /** @todo @bugref{1865}: Map MMIO2 into ring-0. */5092 5093 pcnetInitSharedMemory(pThis);5094 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, PCNET_GUEST_SHARED_MEMORY_SIZE,5095 PCI_ADDRESS_SPACE_MEM, pcnetMMIOSharedMap);5096 if (RT_FAILURE(rc))5097 return rc;5098 }5099 4957 5100 4958 #ifdef PCNET_NO_POLLING -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r49173 r49754 525 525 GEN_CHECK_OFF(PCNETSTATE, pfnEMInterpretInstructionR0 526 526 #endif 527 GEN_CHECK_OFF(PCNETSTATE, pSharedMMIOR3);528 GEN_CHECK_OFF(PCNETSTATE, pSharedMMIOR0);529 GEN_CHECK_OFF(PCNETSTATE, pSharedMMIORC);530 GEN_CHECK_OFF(PCNETSTATE, fPrivIfEnabled);531 527 GEN_CHECK_OFF(PCNETSTATE, fGCEnabled); 532 528 GEN_CHECK_OFF(PCNETSTATE, fR0Enabled);
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器