Changeset 86485 in vbox
- Timestamp:
- Oct 8, 2020 6:56:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r85955 r86485 759 759 } 760 760 761 762 /** 763 * Memory read helper to handle PCI/ISA differences. 764 * 765 * @returns nothing. 766 * @param pDevIns The device instance. 767 * @param pThis Pointer to the PCNet device instance. 768 * @param GCPhys Guest physical memory address. 769 * @param pvBuf Host side buffer address. 770 * @param cbRead Number of bytes to read. 771 */ 772 static void pcnetPhysRead(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) 773 { 774 if (!PCNET_IS_ISA(pThis)) 775 PDMDevHlpPCIPhysRead(pDevIns, GCPhys, pvBuf, cbRead); 776 else 777 PDMDevHlpPhysRead(pDevIns, GCPhys, pvBuf, cbRead); 778 } 779 780 761 781 /** 762 782 * Load transmit message descriptor (TMD) if we own it. … … 779 799 780 800 /* For SWSTYLE=0, the OWN bit is in the second WORD we need and must be read before the first WORD. */ 781 PDMDevHlpPhysRead(pDevIns, addr + sizeof(uint16_t), (void*)&xda[1], 2 * sizeof(uint16_t));801 pcnetPhysRead(pDevIns, pThis, addr + sizeof(uint16_t), (void*)&xda[1], 2 * sizeof(uint16_t)); 782 802 if (!(xda[1] & RT_BIT(15))) 783 803 return false; 784 PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda[0], sizeof(uint16_t));804 pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda[0], sizeof(uint16_t)); 785 805 ((uint32_t *)tmd)[0] = (uint32_t)xda[0] | ((uint32_t)(xda[1] & 0x00ff) << 16); /* TMD0, buffer address. */ 786 806 ((uint32_t *)tmd)[1] = (uint32_t)xda[2] | ((uint32_t)(xda[1] & 0xff00) << 16); /* TMD1, buffer size and control bits. */ … … 792 812 /* For SWSTYLE=2, the OWN bit is in the second DWORD we need and must be read first. */ 793 813 uint32_t xda[2]; 794 PDMDevHlpPhysRead(pDevIns, addr + sizeof(uint32_t), (void*)&xda[1], sizeof(uint32_t));814 pcnetPhysRead(pDevIns, pThis, addr + sizeof(uint32_t), (void*)&xda[1], sizeof(uint32_t)); 795 815 if (!(xda[1] & RT_BIT(31))) 796 816 return false; 797 PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda[0], sizeof(uint32_t));817 pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda[0], sizeof(uint32_t)); 798 818 ((uint32_t *)tmd)[0] = xda[0]; /* TMD0, buffer address. */ 799 819 ((uint32_t *)tmd)[1] = xda[1]; /* TMD1, buffer size and control bits. */ … … 805 825 /* For SWSTYLE=3, the OWN bit is in the first DWORD we need, therefore a single read suffices. */ 806 826 uint32_t xda[2]; 807 PDMDevHlpPhysRead(pDevIns, addr + sizeof(uint32_t), (void*)&xda, sizeof(xda));827 pcnetPhysRead(pDevIns, pThis, addr + sizeof(uint32_t), (void*)&xda, sizeof(xda)); 808 828 if (!(xda[0] & RT_BIT(31))) 809 829 return false; … … 834 854 835 855 /* For SWSTYLE=0, we have to do a bit of work. */ 836 PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda, sizeof(xda));856 pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda, sizeof(xda)); 837 857 ((uint32_t *)tmd)[0] = (uint32_t)xda[0] | ((uint32_t)(xda[1] & 0x00ff) << 16); /* TMD0, buffer address. */ 838 858 ((uint32_t *)tmd)[1] = (uint32_t)xda[2] | ((uint32_t)(xda[1] & 0xff00) << 16); /* TMD1, buffer size and control bits. */ … … 843 863 { 844 864 /* For SWSTYLE=2, simply read the TMD as is. */ 845 PDMDevHlpPhysRead(pDevIns, addr, (void*)tmd, sizeof(*tmd));865 pcnetPhysRead(pDevIns, pThis, addr, (void*)tmd, sizeof(*tmd)); 846 866 } 847 867 else … … 849 869 /* For SWSTYLE=3, swap the first and third DWORD around. */ 850 870 uint32_t xda[4]; 851 PDMDevHlpPhysRead(pDevIns, addr, (void*)&xda, sizeof(xda));871 pcnetPhysRead(pDevIns, pThis, addr, (void*)&xda, sizeof(xda)); 852 872 ((uint32_t *)tmd)[0] = xda[2]; /* TMD0, buffer address. */ 853 873 ((uint32_t *)tmd)[1] = xda[1]; /* TMD1, buffer size and control bits. */ … … 918 938 { 919 939 uint16_t rda[4]; 920 PDMDevHlpPhysRead(pDevIns, addr+3, &ownbyte, 1);940 pcnetPhysRead(pDevIns, pThis, addr+3, &ownbyte, 1); 921 941 if (!(ownbyte & 0x80) && fRetIfNotOwn) 922 942 return false; 923 PDMDevHlpPhysRead(pDevIns, addr, (void*)&rda[0], sizeof(rda));943 pcnetPhysRead(pDevIns, pThis, addr, (void*)&rda[0], sizeof(rda)); 924 944 ((uint32_t *)rmd)[0] = (uint32_t)rda[0] | ((rda[1] & 0x00ff) << 16); 925 945 ((uint32_t *)rmd)[1] = (uint32_t)rda[2] | ((rda[1] & 0xff00) << 16); … … 929 949 else if (RT_LIKELY(BCR_SWSTYLE(pThis) != 3)) 930 950 { 931 PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);951 pcnetPhysRead(pDevIns, pThis, addr+7, &ownbyte, 1); 932 952 if (!(ownbyte & 0x80) && fRetIfNotOwn) 933 953 return false; 934 PDMDevHlpPhysRead(pDevIns, addr, (void*)rmd, 16);954 pcnetPhysRead(pDevIns, pThis, addr, (void*)rmd, 16); 935 955 } 936 956 else 937 957 { 938 958 uint32_t rda[4]; 939 PDMDevHlpPhysRead(pDevIns, addr+7, &ownbyte, 1);959 pcnetPhysRead(pDevIns, pThis, addr+7, &ownbyte, 1); 940 960 if (!(ownbyte & 0x80) && fRetIfNotOwn) 941 961 return false; 942 PDMDevHlpPhysRead(pDevIns, addr, (void*)&rda[0], sizeof(rda));962 pcnetPhysRead(pDevIns, pThis, addr, (void*)&rda[0], sizeof(rda)); 943 963 ((uint32_t *)rmd)[0] = rda[2]; 944 964 ((uint32_t *)rmd)[1] = rda[1]; … … 1009 1029 else 1010 1030 cbDesc = 16; 1011 PDMDevHlpPhysRead(pDevIns, addr, aBuf, cbDesc);1031 pcnetPhysRead(pDevIns, pThis, addr, aBuf, cbDesc); 1012 1032 pcnetPhysWrite(pDevIns, pThis, addr, aBuf, cbDesc); 1013 1033 } … … 1577 1597 * Software is allowed to write these registers directly. */ 1578 1598 # define PCNET_INIT() do { \ 1579 PDMDevHlpPhysRead(pDevIns, PHYSADDR(pThis, CSR_IADR(pThis)),\1580 (uint8_t *)&initblk, sizeof(initblk));\1599 pcnetPhysRead(pDevIns, pThis, PHYSADDR(pThis, CSR_IADR(pThis)), \ 1600 (uint8_t *)&initblk, sizeof(initblk)); \ 1581 1601 pThis->aCSR[15] = RT_LE2H_U16(initblk.mode); \ 1582 1602 CSR_RCVRL(pThis) = (initblk.rlen < 9) ? (1 << initblk.rlen) : 512; \ … … 2281 2301 static void pcnetXmitRead1stSlow(PPDMDEVINS pDevIns, RTGCPHYS32 GCPhysFrame, unsigned cbFrame, PPDMSCATTERGATHER pSgBuf) 2282 2302 { 2303 PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE); 2283 2304 pSgBuf->cbUsed = cbFrame; 2284 2305 for (uint32_t iSeg = 0; ; iSeg++) … … 2292 2313 2293 2314 uint32_t cbRead = (uint32_t)RT_MIN(cbFrame, pSgBuf->aSegs[iSeg].cbSeg); 2294 PDMDevHlpPhysRead(pDevIns, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead);2315 pcnetPhysRead(pDevIns, pThis, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead); 2295 2316 cbFrame -= cbRead; 2296 2317 if (!cbFrame) … … 2307 2328 static void pcnetXmitReadMoreSlow(PPDMDEVINS pDevIns, RTGCPHYS32 GCPhysFrame, unsigned cbFrame, PPDMSCATTERGATHER pSgBuf) 2308 2329 { 2330 PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE); 2331 2309 2332 /* Find the segment which we'll put the next byte into. */ 2310 2333 size_t off = pSgBuf->cbUsed; … … 2331 2354 size_t offIntoSeg = off - offSeg; 2332 2355 uint32_t cbRead = (uint32_t)RT_MIN(pSgBuf->aSegs[iSeg].cbSeg - offIntoSeg, cbFrame); 2333 PDMDevHlpPhysRead(pDevIns, GCPhysFrame,2334 2356 pcnetPhysRead(pDevIns, pThis, GCPhysFrame, 2357 (uint8_t *)pSgBuf->aSegs[iSeg].pvSeg + offIntoSeg, cbRead); 2335 2358 cbFrame -= cbRead; 2336 2359 if (!cbFrame) … … 2351 2374 2352 2375 uint32_t cbRead = (uint32_t)RT_MIN(pSgBuf->aSegs[iSeg].cbSeg, cbFrame); 2353 PDMDevHlpPhysRead(pDevIns, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead);2376 pcnetPhysRead(pDevIns, pThis, GCPhysFrame, pSgBuf->aSegs[iSeg].pvSeg, cbRead); 2354 2377 cbFrame -= cbRead; 2355 2378 if (!cbFrame) … … 2372 2395 { 2373 2396 pSgBuf->cbUsed = cbFrame; 2374 PDMDevHlpPhysRead(pDevIns, GCPhysFrame, pSgBuf->aSegs[0].pvSeg, cbFrame);2397 pcnetPhysRead(pDevIns, pThis, GCPhysFrame, pSgBuf->aSegs[0].pvSeg, cbFrame); 2375 2398 } 2376 2399 else … … 2389 2412 { 2390 2413 pSgBuf->cbUsed = cbFrame + off; 2391 PDMDevHlpPhysRead(pDevIns, GCPhysFrame, (uint8_t *)pSgBuf->aSegs[0].pvSeg + off, cbFrame); 2414 PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE); 2415 pcnetPhysRead(pDevIns, pThis, GCPhysFrame, (uint8_t *)pSgBuf->aSegs[0].pvSeg + off, cbFrame); 2392 2416 } 2393 2417 else
Note:
See TracChangeset
for help on using the changeset viewer.