Changeset 44892 in vbox for trunk/src/VBox
- Timestamp:
- Mar 1, 2013 6:40:50 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84061
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r44890 r44892 11 11 12 12 /* 13 * Copyright (C) 2006-201 2Oracle Corporation13 * Copyright (C) 2006-2013 Oracle Corporation 14 14 * 15 15 * This file is part of VirtualBox Open Source Edition (OSE), as … … 253 253 * @implements PDMILEDPORTS 254 254 */ 255 typedef struct PCN etState_st255 typedef struct PCNETSTATE 256 256 { 257 257 PCIDEVICE PciDev; … … 468 468 # endif 469 469 #endif /* VBOX_WITH_STATISTICS */ 470 } PCN etState, PCNETSTATE;471 //AssertCompileMemberAlignment(PCN etState, StatReceiveBytes, 8);470 } PCNETSTATE; 471 //AssertCompileMemberAlignment(PCNETSTATE, StatReceiveBytes, 8); 472 472 /** Pointer to a PC-Net state structure. */ 473 473 typedef PCNETSTATE *PPCNETSTATE; … … 634 634 (R)->rmd2.zeros)) 635 635 636 static void pcnetPollTimerStart(P CNetState *pThis);637 static int pcnetXmitPending(P CNetState *pThis, bool fOnWorkerThread);636 static void pcnetPollTimerStart(PPCNETSTATE pThis); 637 static int pcnetXmitPending(PPCNETSTATE pThis, bool fOnWorkerThread); 638 638 639 639 … … 644 644 * @returns false if the link is down. 645 645 */ 646 DECLINLINE(bool) pcnetIsLinkUp(P CNetState *pThis)646 DECLINLINE(bool) pcnetIsLinkUp(PPCNETSTATE pThis) 647 647 { 648 648 return pThis->pDrvR3 && !pThis->fLinkTempDown && pThis->fLinkUp; … … 658 658 * @return true if we own the descriptor, false otherwise 659 659 */ 660 DECLINLINE(bool) pcnetTmdLoad(P CNetState *pThis, TMD *tmd, RTGCPHYS32 addr, bool fRetIfNotOwn)660 DECLINLINE(bool) pcnetTmdLoad(PPCNETSTATE pThis, TMD *tmd, RTGCPHYS32 addr, bool fRetIfNotOwn) 661 661 { 662 662 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); … … 721 721 * Make sure that all data are transmitted before we clear the own flag. 722 722 */ 723 DECLINLINE(void) pcnetTmdStorePassHost(P CNetState *pThis, TMD *tmd, RTGCPHYS32 addr)723 DECLINLINE(void) pcnetTmdStorePassHost(PPCNETSTATE pThis, TMD *tmd, RTGCPHYS32 addr) 724 724 { 725 725 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatTmdStore), a); … … 777 777 * @return true if we own the descriptor, false otherwise 778 778 */ 779 DECLINLINE(int) pcnetRmdLoad(P CNetState *pThis, RMD *rmd, RTGCPHYS32 addr, bool fRetIfNotOwn)779 DECLINLINE(int) pcnetRmdLoad(PPCNETSTATE pThis, RMD *rmd, RTGCPHYS32 addr, bool fRetIfNotOwn) 780 780 { 781 781 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); … … 840 840 * Make sure that all data are transmitted before we clear the own flag. 841 841 */ 842 DECLINLINE(void) pcnetRmdStorePassHost(P CNetState *pThis, RMD *rmd, RTGCPHYS32 addr)842 DECLINLINE(void) pcnetRmdStorePassHost(PPCNETSTATE pThis, RMD *rmd, RTGCPHYS32 addr) 843 843 { 844 844 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); … … 890 890 * pages later when we shouldn't schedule to EMT. Temporarily hack. 891 891 */ 892 static void pcnetDescTouch(P CNetState *pThis, RTGCPHYS32 addr)892 static void pcnetDescTouch(PPCNETSTATE pThis, RTGCPHYS32 addr) 893 893 { 894 894 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); … … 952 952 * @note Changing this layout will break SSM for guests using the private guest interface! 953 953 */ 954 static void pcnetInitSharedMemory(P CNetState *pThis)954 static void pcnetInitSharedMemory(PPCNETSTATE pThis) 955 955 { 956 956 /* Clear the entire block for pcnetReset usage. */ … … 1087 1087 }; 1088 1088 1089 DECLINLINE(int) padr_match(P CNetState *pThis, const uint8_t *buf, size_t size)1089 DECLINLINE(int) padr_match(PPCNETSTATE pThis, const uint8_t *buf, size_t size) 1090 1090 { 1091 1091 struct ether_header *hdr = (struct ether_header *)buf; … … 1114 1114 } 1115 1115 1116 DECLINLINE(int) padr_bcast(P CNetState *pThis, const uint8_t *buf, size_t size)1116 DECLINLINE(int) padr_bcast(PPCNETSTATE pThis, const uint8_t *buf, size_t size) 1117 1117 { 1118 1118 static uint8_t aBCAST[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; … … 1125 1125 } 1126 1126 1127 static int ladr_match(P CNetState *pThis, const uint8_t *buf, size_t size)1127 static int ladr_match(PPCNETSTATE pThis, const uint8_t *buf, size_t size) 1128 1128 { 1129 1129 struct ether_header *hdr = (struct ether_header *)buf; … … 1155 1155 * Get the receive descriptor ring address with a given index. 1156 1156 */ 1157 DECLINLINE(RTGCPHYS32) pcnetRdraAddr(P CNetState *pThis, int idx)1157 DECLINLINE(RTGCPHYS32) pcnetRdraAddr(PPCNETSTATE pThis, int idx) 1158 1158 { 1159 1159 return pThis->GCRDRA + ((CSR_RCVRL(pThis) - idx) << pThis->iLog2DescSize); … … 1163 1163 * Get the transmit descriptor ring address with a given index. 1164 1164 */ 1165 DECLINLINE(RTGCPHYS32) pcnetTdraAddr(P CNetState *pThis, int idx)1165 DECLINLINE(RTGCPHYS32) pcnetTdraAddr(PPCNETSTATE pThis, int idx) 1166 1166 { 1167 1167 return pThis->GCTDRA + ((CSR_XMTRL(pThis) - idx) << pThis->iLog2DescSize); … … 1180 1180 #define htons(x) ( (((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8) ) 1181 1181 1182 static void pcnetPollRxTx(P CNetState *pThis);1183 static void pcnetPollTimer(P CNetState *pThis);1184 static void pcnetUpdateIrq(P CNetState *pThis);1185 static uint32_t pcnetBCRReadU16(P CNetState *pThis, uint32_t u32RAP);1186 static int pcnetBCRWriteU16(P CNetState *pThis, uint32_t u32RAP, uint32_t val);1182 static void pcnetPollRxTx(PPCNETSTATE pThis); 1183 static void pcnetPollTimer(PPCNETSTATE pThis); 1184 static void pcnetUpdateIrq(PPCNETSTATE pThis); 1185 static uint32_t pcnetBCRReadU16(PPCNETSTATE pThis, uint32_t u32RAP); 1186 static int pcnetBCRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val); 1187 1187 1188 1188 … … 1204 1204 RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser) 1205 1205 { 1206 P CNetState *pThis = (PCNetState *)pvUser;1206 PPCNETSTATE pThis = (PPCNETSTATE)pvUser; 1207 1207 1208 1208 Log(("#%d pcnetHandleRingWriteGC: write to %#010x\n", PCNET_INST_NR, GCPhysFault)); … … 1265 1265 { 1266 1266 PPDMDEVINS pDevIns = (PPDMDEVINS)pvUser; 1267 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);1267 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 1268 1268 1269 1269 Log(("#%d pcnetHandleRingWrite: write to %#010x\n", PCNET_INST_NR, GCPhys)); … … 1300 1300 #endif /* PCNET_NO_POLLING */ 1301 1301 1302 static void pcnetSoftReset(P CNetState *pThis)1302 static void pcnetSoftReset(PPCNETSTATE pThis) 1303 1303 { 1304 1304 Log(("#%d pcnetSoftReset:\n", PCNET_INST_NR)); … … 1345 1345 * - csr5 (only written by pcnetSoftReset(), pcnetStop or by the driver guest) 1346 1346 */ 1347 static void pcnetUpdateIrq(P CNetState *pThis)1347 static void pcnetUpdateIrq(PPCNETSTATE pThis) 1348 1348 { 1349 1349 register int iISR = 0; … … 1434 1434 * Enable/disable the private guest interface. 1435 1435 */ 1436 static void pcnetEnablePrivateIf(P CNetState *pThis)1436 static void pcnetEnablePrivateIf(PPCNETSTATE pThis) 1437 1437 { 1438 1438 bool fPrivIfEnabled = pThis->pSharedMMIOR3 … … 1447 1447 #ifdef IN_RING3 1448 1448 #ifdef PCNET_NO_POLLING 1449 static void pcnetUpdateRingHandlers(P CNetState *pThis)1449 static void pcnetUpdateRingHandlers(PPCNETSTATE pThis) 1450 1450 { 1451 1451 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); … … 1535 1535 #endif /* PCNET_NO_POLLING */ 1536 1536 1537 static void pcnetInit(P CNetState *pThis)1537 static void pcnetInit(PPCNETSTATE pThis) 1538 1538 { 1539 1539 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); … … 1640 1640 * Start RX/TX operation. 1641 1641 */ 1642 static void pcnetStart(P CNetState *pThis)1642 static void pcnetStart(PPCNETSTATE pThis) 1643 1643 { 1644 1644 Log(("#%d pcnetStart:\n", PCNET_INST_NR)); … … 1656 1656 * Stop RX/TX operation. 1657 1657 */ 1658 static void pcnetStop(P CNetState *pThis)1658 static void pcnetStop(PPCNETSTATE pThis) 1659 1659 { 1660 1660 Log(("#%d pcnetStop:\n", PCNET_INST_NR)); … … 1670 1670 static DECLCALLBACK(void) pcnetWakeupReceive(PPDMDEVINS pDevIns) 1671 1671 { 1672 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);1672 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 1673 1673 STAM_COUNTER_INC(&pThis->StatRxOverflowWakeup); 1674 1674 if (pThis->hEventOutOfRxSpace != NIL_RTSEMEVENT) … … 1691 1691 * @param fSkipCurrent if true, don't scan the current RDTE. 1692 1692 */ 1693 static void pcnetRdtePoll(P CNetState *pThis, bool fSkipCurrent=false)1693 static void pcnetRdtePoll(PPCNETSTATE pThis, bool fSkipCurrent=false) 1694 1694 { 1695 1695 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatRdtePoll), a); … … 1799 1799 * @return true if transmit descriptors available 1800 1800 */ 1801 static int pcnetTdtePoll(P CNetState *pThis, TMD *tmd)1801 static int pcnetTdtePoll(PPCNETSTATE pThis, TMD *tmd) 1802 1802 { 1803 1803 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatTdtePoll), a); … … 1847 1847 * @return true if transmit descriptors available 1848 1848 */ 1849 static int pcnetCalcPacketLen(P CNetState *pThis, unsigned cb)1849 static int pcnetCalcPacketLen(PPCNETSTATE pThis, unsigned cb) 1850 1850 { 1851 1851 TMD tmd; … … 1895 1895 * Write data into guest receive buffers. 1896 1896 */ 1897 static void pcnetReceiveNoSync(P CNetState *pThis, const uint8_t *buf, size_t cbToRecv, bool fAddFCS)1897 static void pcnetReceiveNoSync(PPCNETSTATE pThis, const uint8_t *buf, size_t cbToRecv, bool fAddFCS) 1898 1898 { 1899 1899 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); … … 1935 1935 /* Not owned by controller. This should not be possible as 1936 1936 * we already called pcnetCanReceive(). */ 1937 LogRel(("PCNet#%d: no buffer: RCVRC=%d\n", 1938 PCNET_INST_NR, CSR_RCVRC(pThis))); 1937 LogRel(("PCNet#%d: no buffer: RCVRC=%d\n", PCNET_INST_NR, CSR_RCVRC(pThis))); 1939 1938 /* Dump the status of all RX descriptors */ 1940 1939 const unsigned cb = 1 << pThis->iLog2DescSize; … … 2124 2123 static DECLCALLBACK(bool) pcnetXmitQueueConsumer(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem) 2125 2124 { 2126 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);2125 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 2127 2126 NOREF(pItem); 2128 2127 … … 2147 2146 * Always set. 2148 2147 */ 2149 DECLINLINE(int) pcnetXmitAllocBuf(P CNetState *pThis, size_t cbMin, bool fLoopback,2148 DECLINLINE(int) pcnetXmitAllocBuf(PPCNETSTATE pThis, size_t cbMin, bool fLoopback, 2150 2149 PPDMSCATTERGATHER pSgLoop, PPPDMSCATTERGATHER ppSgBuf) 2151 2150 { … … 2192 2191 * @param pSgBuf The SG to free. Can be NULL. 2193 2192 */ 2194 DECLINLINE(void) pcnetXmitFreeBuf(P CNetState *pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf)2193 DECLINLINE(void) pcnetXmitFreeBuf(PPCNETSTATE pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf) 2195 2194 { 2196 2195 if (pSgBuf) … … 2220 2219 * if an EMT. 2221 2220 */ 2222 DECLINLINE(int) pcnetXmitSendBuf(P CNetState *pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf, bool fOnWorkerThread)2221 DECLINLINE(int) pcnetXmitSendBuf(PPCNETSTATE pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf, bool fOnWorkerThread) 2223 2222 { 2224 2223 int rc; … … 2265 2264 * path. 2266 2265 */ 2267 static void pcnetXmitRead1stSlow(P CNetState *pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame,2266 static void pcnetXmitRead1stSlow(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame, 2268 2267 PPDMSCATTERGATHER pSgBuf) 2269 2268 { … … 2288 2287 * path. 2289 2288 */ 2290 static void pcnetXmitReadMoreSlow(P CNetState *pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame,2289 static void pcnetXmitReadMoreSlow(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame, 2291 2290 PPDMSCATTERGATHER pSgBuf) 2292 2291 { … … 2339 2338 * Reads the first part of a frame into the scatter gather buffer. 2340 2339 */ 2341 DECLINLINE(void) pcnetXmitRead1st(P CNetState *pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,2340 DECLINLINE(void) pcnetXmitRead1st(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame, 2342 2341 PPDMSCATTERGATHER pSgBuf) 2343 2342 { … … 2357 2356 * Reads more into the current frame. 2358 2357 */ 2359 DECLINLINE(void) pcnetXmitReadMore(P CNetState *pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,2358 DECLINLINE(void) pcnetXmitReadMore(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame, 2360 2359 PPDMSCATTERGATHER pSgBuf) 2361 2360 { … … 2377 2376 * Fails a TMD with a link down error. 2378 2377 */ 2379 static void pcnetXmitFailTMDLinkDown(P CNetState *pThis, TMD *pTmd)2378 static void pcnetXmitFailTMDLinkDown(PPCNETSTATE pThis, TMD *pTmd) 2380 2379 { 2381 2380 /* make carrier error - hope this is correct. */ … … 2391 2390 * Fails a TMD with a generic error. 2392 2391 */ 2393 static void pcnetXmitFailTMDGeneric(P CNetState *pThis, TMD *pTmd)2392 static void pcnetXmitFailTMDGeneric(PPCNETSTATE pThis, TMD *pTmd) 2394 2393 { 2395 2394 /* make carrier error - hope this is correct. */ … … 2405 2404 * Try to transmit frames 2406 2405 */ 2407 static void pcnetTransmit(P CNetState *pThis)2406 static void pcnetTransmit(PPCNETSTATE pThis) 2408 2407 { 2409 2408 if (RT_UNLIKELY(!CSR_TXON(pThis))) … … 2452 2451 * @threads TX or EMT. 2453 2452 */ 2454 static int pcnetAsyncTransmit(P CNetState *pThis, bool fOnWorkerThread)2453 static int pcnetAsyncTransmit(PPCNETSTATE pThis, bool fOnWorkerThread) 2455 2454 { 2456 2455 Assert(PDMCritSectIsOwner(&pThis->CritSect)); … … 2722 2721 * @param fOnWorkerThread Whether we're on a worker thread or on an EMT. 2723 2722 */ 2724 static int pcnetXmitPending(P CNetState *pThis, bool fOnWorkerThread)2723 static int pcnetXmitPending(PPCNETSTATE pThis, bool fOnWorkerThread) 2725 2724 { 2726 2725 int rc = VINF_SUCCESS; … … 2763 2762 * Poll for changes in RX and TX descriptor rings. 2764 2763 */ 2765 static void pcnetPollRxTx(P CNetState *pThis)2764 static void pcnetPollRxTx(PPCNETSTATE pThis) 2766 2765 { 2767 2766 if (CSR_RXON(pThis)) … … 2787 2786 * @thread EMT, TAP. 2788 2787 */ 2789 static void pcnetPollTimerStart(P CNetState *pThis)2788 static void pcnetPollTimerStart(PPCNETSTATE pThis) 2790 2789 { 2791 2790 TMTimerSetMillies(pThis->CTX_SUFF(pTimerPoll), 2); … … 2797 2796 * @thread EMT. 2798 2797 */ 2799 static void pcnetPollTimer(P CNetState *pThis)2798 static void pcnetPollTimer(PPCNETSTATE pThis) 2800 2799 { 2801 2800 STAM_PROFILE_ADV_START(&pThis->StatPollTimer, a); … … 2858 2857 2859 2858 2860 static int pcnetCSRWriteU16(P CNetState *pThis, uint32_t u32RAP, uint32_t val)2859 static int pcnetCSRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val) 2861 2860 { 2862 2861 int rc = VINF_SUCCESS; … … 3070 3069 } 3071 3070 3072 static uint32_t pcnetCSRReadU16(P CNetState *pThis, uint32_t u32RAP)3071 static uint32_t pcnetCSRReadU16(PPCNETSTATE pThis, uint32_t u32RAP) 3073 3072 { 3074 3073 uint32_t val; … … 3103 3102 } 3104 3103 3105 static int pcnetBCRWriteU16(P CNetState *pThis, uint32_t u32RAP, uint32_t val)3104 static int pcnetBCRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val) 3106 3105 { 3107 3106 int rc = VINF_SUCCESS; … … 3175 3174 } 3176 3175 3177 static uint32_t pcnetMIIReadU16(P CNetState *pThis, uint32_t miiaddr)3176 static uint32_t pcnetMIIReadU16(PPCNETSTATE pThis, uint32_t miiaddr) 3178 3177 { 3179 3178 uint32_t val; … … 3289 3288 } 3290 3289 3291 static uint32_t pcnetBCRReadU16(P CNetState *pThis, uint32_t u32RAP)3290 static uint32_t pcnetBCRReadU16(PPCNETSTATE pThis, uint32_t u32RAP) 3292 3291 { 3293 3292 uint32_t val; … … 3331 3330 3332 3331 #ifdef IN_RING3 /* move down */ 3333 static void pcnet HardReset(PCNetState *pThis)3332 static void pcnetR3HardReset(PPCNETSTATE pThis) 3334 3333 { 3335 3334 int i; … … 3375 3374 #endif /* IN_RING3 */ 3376 3375 3377 static void pcnetAPROMWriteU8(PCNetState *pThis, uint32_t addr, uint32_t val) 3376 3377 /* -=-=-=-=-=- APROM I/O Port access -=-=-=-=-=- */ 3378 3379 static void pcnetAPROMWriteU8(PPCNETSTATE pThis, uint32_t addr, uint32_t val) 3378 3380 { 3379 3381 addr &= 0x0f; … … 3385 3387 } 3386 3388 3387 static uint32_t pcnetAPROMReadU8(P CNetState *pThis, uint32_t addr)3389 static uint32_t pcnetAPROMReadU8(PPCNETSTATE pThis, uint32_t addr) 3388 3390 { 3389 3391 uint32_t val = pThis->aPROM[addr &= 0x0f]; … … 3392 3394 } 3393 3395 3394 static int pcnetIoportWriteU8(PCNetState *pThis, uint32_t addr, uint32_t val) 3395 { 3396 int rc = VINF_SUCCESS; 3397 3398 #ifdef PCNET_DEBUG_IO 3399 Log2(("#%d pcnetIoportWriteU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, 3400 addr, val)); 3401 #endif 3402 if (RT_LIKELY(!BCR_DWIO(pThis))) 3403 { 3404 switch (addr & 0x0f) 3405 { 3406 case 0x04: /* RESET */ 3407 break; 3408 } 3409 } 3410 else 3411 Log(("#%d pcnetIoportWriteU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3412 3413 return rc; 3414 } 3415 3416 static uint32_t pcnetIoportReadU8(PCNetState *pThis, uint32_t addr, int *pRC) 3417 { 3418 uint32_t val = ~0U; 3419 3420 *pRC = VINF_SUCCESS; 3421 3422 if (RT_LIKELY(!BCR_DWIO(pThis))) 3423 { 3424 switch (addr & 0x0f) 3425 { 3426 case 0x04: /* RESET */ 3427 pcnetSoftReset(pThis); 3428 val = 0; 3429 break; 3430 } 3431 } 3432 else 3433 Log(("#%d pcnetIoportReadU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xff)); 3434 3435 pcnetUpdateIrq(pThis); 3436 3437 #ifdef PCNET_DEBUG_IO 3438 Log2(("#%d pcnetIoportReadU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xff)); 3439 #endif 3440 return val; 3441 } 3442 3443 static int pcnetIoportWriteU16(PCNetState *pThis, uint32_t addr, uint32_t val) 3444 { 3445 int rc = VINF_SUCCESS; 3446 3447 #ifdef PCNET_DEBUG_IO 3448 Log2(("#%d pcnetIoportWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, 3449 addr, val)); 3450 #endif 3451 if (RT_LIKELY(!BCR_DWIO(pThis))) 3452 { 3453 switch (addr & 0x0f) 3454 { 3455 case 0x00: /* RDP */ 3456 pcnetPollTimer(pThis); 3457 rc = pcnetCSRWriteU16(pThis, pThis->u32RAP, val); 3458 pcnetUpdateIrq(pThis); 3459 break; 3460 case 0x02: /* RAP */ 3461 pThis->u32RAP = val & 0x7f; 3462 break; 3463 case 0x06: /* BDP */ 3464 rc = pcnetBCRWriteU16(pThis, pThis->u32RAP, val); 3465 break; 3466 } 3467 } 3468 else 3469 Log(("#%d pcnetIoportWriteU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3470 3471 return rc; 3472 } 3473 3474 static uint32_t pcnetIoportReadU16(PCNetState *pThis, uint32_t addr, int *pRC) 3475 { 3476 uint32_t val = ~0U; 3477 3478 *pRC = VINF_SUCCESS; 3479 3480 if (RT_LIKELY(!BCR_DWIO(pThis))) 3481 { 3482 switch (addr & 0x0f) 3483 { 3484 case 0x00: /* RDP */ 3485 /** @note if we're not polling, then the guest will tell us when to poll by setting TDMD in CSR0 */ 3486 /** Polling is then useless here and possibly expensive. */ 3487 if (!CSR_DPOLL(pThis)) 3488 pcnetPollTimer(pThis); 3489 3490 val = pcnetCSRReadU16(pThis, pThis->u32RAP); 3491 if (pThis->u32RAP == 0) // pcnetUpdateIrq() already called by pcnetCSRReadU16() 3492 goto skip_update_irq; 3493 break; 3494 case 0x02: /* RAP */ 3495 val = pThis->u32RAP; 3496 goto skip_update_irq; 3497 case 0x04: /* RESET */ 3498 pcnetSoftReset(pThis); 3499 val = 0; 3500 break; 3501 case 0x06: /* BDP */ 3502 val = pcnetBCRReadU16(pThis, pThis->u32RAP); 3503 break; 3504 } 3505 } 3506 else 3507 Log(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xffff)); 3508 3509 pcnetUpdateIrq(pThis); 3510 3511 skip_update_irq: 3512 #ifdef PCNET_DEBUG_IO 3513 Log2(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xffff)); 3514 #endif 3515 return val; 3516 } 3517 3518 static int pcnetIoportWriteU32(PCNetState *pThis, uint32_t addr, uint32_t val) 3519 { 3520 int rc = VINF_SUCCESS; 3521 3522 #ifdef PCNET_DEBUG_IO 3523 Log2(("#%d pcnetIoportWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, 3524 addr, val)); 3525 #endif 3526 if (RT_LIKELY(BCR_DWIO(pThis))) 3527 { 3528 switch (addr & 0x0f) 3529 { 3530 case 0x00: /* RDP */ 3531 pcnetPollTimer(pThis); 3532 rc = pcnetCSRWriteU16(pThis, pThis->u32RAP, val & 0xffff); 3533 pcnetUpdateIrq(pThis); 3534 break; 3535 case 0x04: /* RAP */ 3536 pThis->u32RAP = val & 0x7f; 3537 break; 3538 case 0x0c: /* BDP */ 3539 rc = pcnetBCRWriteU16(pThis, pThis->u32RAP, val & 0xffff); 3540 break; 3541 } 3542 } 3543 else if ((addr & 0x0f) == 0) 3544 { 3545 /* switch device to dword I/O mode */ 3546 pcnetBCRWriteU16(pThis, BCR_BSBC, pcnetBCRReadU16(pThis, BCR_BSBC) | 0x0080); 3547 #ifdef PCNET_DEBUG_IO 3548 Log2(("device switched into dword i/o mode\n")); 3549 #endif 3550 } 3551 else 3552 Log(("#%d pcnetIoportWriteU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3553 3554 return rc; 3555 } 3556 3557 static uint32_t pcnetIoportReadU32(PCNetState *pThis, uint32_t addr, int *pRC) 3558 { 3559 uint32_t val = ~0U; 3560 3561 *pRC = VINF_SUCCESS; 3562 3563 if (RT_LIKELY(BCR_DWIO(pThis))) 3564 { 3565 switch (addr & 0x0f) 3566 { 3567 case 0x00: /* RDP */ 3568 /** @note if we're not polling, then the guest will tell us when to poll by setting TDMD in CSR0 */ 3569 /** Polling is then useless here and possibly expensive. */ 3570 if (!CSR_DPOLL(pThis)) 3571 pcnetPollTimer(pThis); 3572 3573 val = pcnetCSRReadU16(pThis, pThis->u32RAP); 3574 if (pThis->u32RAP == 0) // pcnetUpdateIrq() already called by pcnetCSRReadU16() 3575 goto skip_update_irq; 3576 break; 3577 case 0x04: /* RAP */ 3578 val = pThis->u32RAP; 3579 goto skip_update_irq; 3580 case 0x08: /* RESET */ 3581 pcnetSoftReset(pThis); 3582 val = 0; 3583 break; 3584 case 0x0c: /* BDP */ 3585 val = pcnetBCRReadU16(pThis, pThis->u32RAP); 3586 break; 3587 } 3588 } 3589 else 3590 Log(("#%d pcnetIoportReadU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3591 pcnetUpdateIrq(pThis); 3592 3593 skip_update_irq: 3594 #ifdef PCNET_DEBUG_IO 3595 Log2(("#%d pcnetIoportReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val)); 3596 #endif 3597 return val; 3598 } 3599 3600 static void pcnetMMIOWriteU8(PCNetState *pThis, RTGCPHYS addr, uint32_t val) 3601 { 3602 #ifdef PCNET_DEBUG_IO 3603 Log2(("#%d pcnetMMIOWriteU8: addr=%#010x val=%#04x\n", PCNET_INST_NR, addr, val)); 3604 #endif 3605 if (!(addr & 0x10)) 3606 pcnetAPROMWriteU8(pThis, addr, val); 3607 } 3608 3609 static uint32_t pcnetMMIOReadU8(PCNetState *pThis, RTGCPHYS addr) 3610 { 3611 uint32_t val = ~0U; 3612 if (!(addr & 0x10)) 3613 val = pcnetAPROMReadU8(pThis, addr); 3614 #ifdef PCNET_DEBUG_IO 3615 Log2(("#%d pcnetMMIOReadU8: addr=%#010x val=%#04x\n", PCNET_INST_NR, addr, val & 0xff)); 3616 #endif 3617 return val; 3618 } 3619 3620 static void pcnetMMIOWriteU16(PCNetState *pThis, RTGCPHYS addr, uint32_t val) 3621 { 3622 #ifdef PCNET_DEBUG_IO 3623 Log2(("#%d pcnetMMIOWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val)); 3624 #endif 3625 if (addr & 0x10) 3626 pcnetIoportWriteU16(pThis, addr & 0x0f, val); 3627 else 3628 { 3629 pcnetAPROMWriteU8(pThis, addr, val ); 3630 pcnetAPROMWriteU8(pThis, addr+1, val >> 8); 3631 } 3632 } 3633 3634 static uint32_t pcnetMMIOReadU16(PCNetState *pThis, RTGCPHYS addr) 3635 { 3636 uint32_t val = ~0U; 3637 int rc; 3638 3639 if (addr & 0x10) 3640 val = pcnetIoportReadU16(pThis, addr & 0x0f, &rc); 3641 else 3642 { 3643 val = pcnetAPROMReadU8(pThis, addr+1); 3644 val <<= 8; 3645 val |= pcnetAPROMReadU8(pThis, addr); 3646 } 3647 #ifdef PCNET_DEBUG_IO 3648 Log2(("#%d pcnetMMIOReadU16: addr=%#010x val = %#06x\n", PCNET_INST_NR, addr, val & 0xffff)); 3649 #endif 3650 return val; 3651 } 3652 3653 static void pcnetMMIOWriteU32(PCNetState *pThis, RTGCPHYS addr, uint32_t val) 3654 { 3655 #ifdef PCNET_DEBUG_IO 3656 Log2(("#%d pcnetMMIOWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val)); 3657 #endif 3658 if (addr & 0x10) 3659 pcnetIoportWriteU32(pThis, addr & 0x0f, val); 3660 else 3661 { 3662 pcnetAPROMWriteU8(pThis, addr, val ); 3663 pcnetAPROMWriteU8(pThis, addr+1, val >> 8); 3664 pcnetAPROMWriteU8(pThis, addr+2, val >> 16); 3665 pcnetAPROMWriteU8(pThis, addr+3, val >> 24); 3666 } 3667 } 3668 3669 static uint32_t pcnetMMIOReadU32(PCNetState *pThis, RTGCPHYS addr) 3670 { 3671 uint32_t val; 3672 int rc; 3673 3674 if (addr & 0x10) 3675 val = pcnetIoportReadU32(pThis, addr & 0x0f, &rc); 3676 else 3677 { 3678 val = pcnetAPROMReadU8(pThis, addr+3); 3679 val <<= 8; 3680 val |= pcnetAPROMReadU8(pThis, addr+2); 3681 val <<= 8; 3682 val |= pcnetAPROMReadU8(pThis, addr+1); 3683 val <<= 8; 3684 val |= pcnetAPROMReadU8(pThis, addr ); 3685 } 3686 #ifdef PCNET_DEBUG_IO 3687 Log2(("#%d pcnetMMIOReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val)); 3688 #endif 3689 return val; 3690 } 3691 3692 3693 /** 3694 * Port I/O Handler for IN operations. 3695 * 3696 * @returns VBox status code. 3697 * 3698 * @param pDevIns The device instance. 3699 * @param pvUser User argument. 3700 * @param Port Port number used for the IN operation. 3701 * @param pu32 Where to store the result. 3702 * @param cb Number of bytes read. 3703 */ 3704 PDMBOTHCBDECL(int) pcnetIOPortAPromRead(PPDMDEVINS pDevIns, void *pvUser, 3705 RTIOPORT Port, uint32_t *pu32, unsigned cb) 3706 { 3707 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 3396 /** 3397 * @callback_method_impl{FNIOMIOPORTIN, APROM} 3398 */ 3399 PDMBOTHCBDECL(int) pcnetIOPortAPromRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 3400 { 3401 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 3708 3402 int rc; 3709 3403 … … 3738 3432 3739 3433 /** 3740 * Port I/O Handler for OUT operations. 3741 * 3742 * @returns VBox status code. 3743 * 3744 * @param pDevIns The device instance. 3745 * @param pvUser User argument. 3746 * @param Port Port number used for the IN operation. 3747 * @param u32 The value to output. 3748 * @param cb The value size in bytes. 3749 */ 3750 PDMBOTHCBDECL(int) pcnetIOPortAPromWrite(PPDMDEVINS pDevIns, void *pvUser, 3751 RTIOPORT Port, uint32_t u32, unsigned cb) 3752 { 3753 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 3434 * @callback_method_impl{FNIOMIOPORTOUT, APROM} 3435 */ 3436 PDMBOTHCBDECL(int) pcnetIOPortAPromWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 3437 { 3438 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 3754 3439 int rc; 3755 3440 … … 3779 3464 3780 3465 3781 /** 3782 * Port I/O Handler for IN operations. 3783 * 3784 * @returns VBox status code. 3785 * 3786 * @param pDevIns The device instance. 3787 * @param pvUser User argument. 3788 * @param Port Port number used for the IN operation. 3789 * @param pu32 Where to store the result. 3790 * @param cb Number of bytes read. 3791 */ 3792 PDMBOTHCBDECL(int) pcnetIOPortRead(PPDMDEVINS pDevIns, void *pvUser, 3793 RTIOPORT Port, uint32_t *pu32, unsigned cb) 3794 { 3795 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 3466 /* -=-=-=-=-=- I/O Port access -=-=-=-=-=- */ 3467 3468 3469 static int pcnetIoportWriteU8(PPCNETSTATE pThis, uint32_t addr, uint32_t val) 3470 { 3471 int rc = VINF_SUCCESS; 3472 3473 #ifdef PCNET_DEBUG_IO 3474 Log2(("#%d pcnetIoportWriteU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, 3475 addr, val)); 3476 #endif 3477 if (RT_LIKELY(!BCR_DWIO(pThis))) 3478 { 3479 switch (addr & 0x0f) 3480 { 3481 case 0x04: /* RESET */ 3482 break; 3483 } 3484 } 3485 else 3486 Log(("#%d pcnetIoportWriteU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3487 3488 return rc; 3489 } 3490 3491 static uint32_t pcnetIoportReadU8(PPCNETSTATE pThis, uint32_t addr, int *pRC) 3492 { 3493 uint32_t val = ~0U; 3494 3495 *pRC = VINF_SUCCESS; 3496 3497 if (RT_LIKELY(!BCR_DWIO(pThis))) 3498 { 3499 switch (addr & 0x0f) 3500 { 3501 case 0x04: /* RESET */ 3502 pcnetSoftReset(pThis); 3503 val = 0; 3504 break; 3505 } 3506 } 3507 else 3508 Log(("#%d pcnetIoportReadU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xff)); 3509 3510 pcnetUpdateIrq(pThis); 3511 3512 #ifdef PCNET_DEBUG_IO 3513 Log2(("#%d pcnetIoportReadU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xff)); 3514 #endif 3515 return val; 3516 } 3517 3518 static int pcnetIoportWriteU16(PPCNETSTATE pThis, uint32_t addr, uint32_t val) 3519 { 3520 int rc = VINF_SUCCESS; 3521 3522 #ifdef PCNET_DEBUG_IO 3523 Log2(("#%d pcnetIoportWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, 3524 addr, val)); 3525 #endif 3526 if (RT_LIKELY(!BCR_DWIO(pThis))) 3527 { 3528 switch (addr & 0x0f) 3529 { 3530 case 0x00: /* RDP */ 3531 pcnetPollTimer(pThis); 3532 rc = pcnetCSRWriteU16(pThis, pThis->u32RAP, val); 3533 pcnetUpdateIrq(pThis); 3534 break; 3535 case 0x02: /* RAP */ 3536 pThis->u32RAP = val & 0x7f; 3537 break; 3538 case 0x06: /* BDP */ 3539 rc = pcnetBCRWriteU16(pThis, pThis->u32RAP, val); 3540 break; 3541 } 3542 } 3543 else 3544 Log(("#%d pcnetIoportWriteU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3545 3546 return rc; 3547 } 3548 3549 static uint32_t pcnetIoportReadU16(PPCNETSTATE pThis, uint32_t addr, int *pRC) 3550 { 3551 uint32_t val = ~0U; 3552 3553 *pRC = VINF_SUCCESS; 3554 3555 if (RT_LIKELY(!BCR_DWIO(pThis))) 3556 { 3557 switch (addr & 0x0f) 3558 { 3559 case 0x00: /* RDP */ 3560 /** @note if we're not polling, then the guest will tell us when to poll by setting TDMD in CSR0 */ 3561 /** Polling is then useless here and possibly expensive. */ 3562 if (!CSR_DPOLL(pThis)) 3563 pcnetPollTimer(pThis); 3564 3565 val = pcnetCSRReadU16(pThis, pThis->u32RAP); 3566 if (pThis->u32RAP == 0) // pcnetUpdateIrq() already called by pcnetCSRReadU16() 3567 goto skip_update_irq; 3568 break; 3569 case 0x02: /* RAP */ 3570 val = pThis->u32RAP; 3571 goto skip_update_irq; 3572 case 0x04: /* RESET */ 3573 pcnetSoftReset(pThis); 3574 val = 0; 3575 break; 3576 case 0x06: /* BDP */ 3577 val = pcnetBCRReadU16(pThis, pThis->u32RAP); 3578 break; 3579 } 3580 } 3581 else 3582 Log(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xffff)); 3583 3584 pcnetUpdateIrq(pThis); 3585 3586 skip_update_irq: 3587 #ifdef PCNET_DEBUG_IO 3588 Log2(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xffff)); 3589 #endif 3590 return val; 3591 } 3592 3593 static int pcnetIoportWriteU32(PPCNETSTATE pThis, uint32_t addr, uint32_t val) 3594 { 3595 int rc = VINF_SUCCESS; 3596 3597 #ifdef PCNET_DEBUG_IO 3598 Log2(("#%d pcnetIoportWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, 3599 addr, val)); 3600 #endif 3601 if (RT_LIKELY(BCR_DWIO(pThis))) 3602 { 3603 switch (addr & 0x0f) 3604 { 3605 case 0x00: /* RDP */ 3606 pcnetPollTimer(pThis); 3607 rc = pcnetCSRWriteU16(pThis, pThis->u32RAP, val & 0xffff); 3608 pcnetUpdateIrq(pThis); 3609 break; 3610 case 0x04: /* RAP */ 3611 pThis->u32RAP = val & 0x7f; 3612 break; 3613 case 0x0c: /* BDP */ 3614 rc = pcnetBCRWriteU16(pThis, pThis->u32RAP, val & 0xffff); 3615 break; 3616 } 3617 } 3618 else if ((addr & 0x0f) == 0) 3619 { 3620 /* switch device to dword I/O mode */ 3621 pcnetBCRWriteU16(pThis, BCR_BSBC, pcnetBCRReadU16(pThis, BCR_BSBC) | 0x0080); 3622 #ifdef PCNET_DEBUG_IO 3623 Log2(("device switched into dword i/o mode\n")); 3624 #endif 3625 } 3626 else 3627 Log(("#%d pcnetIoportWriteU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3628 3629 return rc; 3630 } 3631 3632 static uint32_t pcnetIoportReadU32(PPCNETSTATE pThis, uint32_t addr, int *pRC) 3633 { 3634 uint32_t val = ~0U; 3635 3636 *pRC = VINF_SUCCESS; 3637 3638 if (RT_LIKELY(BCR_DWIO(pThis))) 3639 { 3640 switch (addr & 0x0f) 3641 { 3642 case 0x00: /* RDP */ 3643 /** @note if we're not polling, then the guest will tell us when to poll by setting TDMD in CSR0 */ 3644 /** Polling is then useless here and possibly expensive. */ 3645 if (!CSR_DPOLL(pThis)) 3646 pcnetPollTimer(pThis); 3647 3648 val = pcnetCSRReadU16(pThis, pThis->u32RAP); 3649 if (pThis->u32RAP == 0) // pcnetUpdateIrq() already called by pcnetCSRReadU16() 3650 goto skip_update_irq; 3651 break; 3652 case 0x04: /* RAP */ 3653 val = pThis->u32RAP; 3654 goto skip_update_irq; 3655 case 0x08: /* RESET */ 3656 pcnetSoftReset(pThis); 3657 val = 0; 3658 break; 3659 case 0x0c: /* BDP */ 3660 val = pcnetBCRReadU16(pThis, pThis->u32RAP); 3661 break; 3662 } 3663 } 3664 else 3665 Log(("#%d pcnetIoportReadU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val)); 3666 pcnetUpdateIrq(pThis); 3667 3668 skip_update_irq: 3669 #ifdef PCNET_DEBUG_IO 3670 Log2(("#%d pcnetIoportReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val)); 3671 #endif 3672 return val; 3673 } 3674 3675 3676 /** 3677 * @callback_method_impl{FNIOMIOPORTIN} 3678 */ 3679 PDMBOTHCBDECL(int) pcnetIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 3680 { 3681 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 3796 3682 int rc = VINF_SUCCESS; 3797 3683 … … 3823 3709 3824 3710 /** 3825 * Port I/O Handler for OUT operations. 3826 * 3827 * @returns VBox status code. 3828 * 3829 * @param pDevIns The device instance. 3830 * @param pvUser User argument. 3831 * @param Port Port number used for the IN operation. 3832 * @param u32 The value to output. 3833 * @param cb The value size in bytes. 3834 */ 3835 PDMBOTHCBDECL(int) pcnetIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, 3836 RTIOPORT Port, uint32_t u32, unsigned cb) 3837 { 3838 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 3711 * @callback_method_impl{FNIOMIOPORTOUT} 3712 */ 3713 PDMBOTHCBDECL(int) pcnetIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 3714 { 3715 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 3839 3716 int rc = VINF_SUCCESS; 3840 3717 … … 3865 3742 3866 3743 3867 /** 3868 * Memory mapped I/O Handler for read operations. 3869 * 3870 * @returns VBox status code. 3871 * 3872 * @param pDevIns The device instance. 3873 * @param pvUser User argument. 3874 * @param GCPhysAddr Physical address (in GC) where the read starts. 3875 * @param pv Where to store the result. 3876 * @param cb Number of bytes read. 3877 */ 3878 PDMBOTHCBDECL(int) pcnetMMIORead(PPDMDEVINS pDevIns, void *pvUser, 3879 RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 3880 { 3881 PCNetState *pThis = (PCNetState *)pvUser; 3744 /* -=-=-=-=-=- MMIO -=-=-=-=-=- */ 3745 3746 static void pcnetMMIOWriteU8(PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val) 3747 { 3748 #ifdef PCNET_DEBUG_IO 3749 Log2(("#%d pcnetMMIOWriteU8: addr=%#010x val=%#04x\n", PCNET_INST_NR, addr, val)); 3750 #endif 3751 if (!(addr & 0x10)) 3752 pcnetAPROMWriteU8(pThis, addr, val); 3753 } 3754 3755 static uint32_t pcnetMMIOReadU8(PPCNETSTATE pThis, RTGCPHYS addr) 3756 { 3757 uint32_t val = ~0U; 3758 if (!(addr & 0x10)) 3759 val = pcnetAPROMReadU8(pThis, addr); 3760 #ifdef PCNET_DEBUG_IO 3761 Log2(("#%d pcnetMMIOReadU8: addr=%#010x val=%#04x\n", PCNET_INST_NR, addr, val & 0xff)); 3762 #endif 3763 return val; 3764 } 3765 3766 static void pcnetMMIOWriteU16(PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val) 3767 { 3768 #ifdef PCNET_DEBUG_IO 3769 Log2(("#%d pcnetMMIOWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val)); 3770 #endif 3771 if (addr & 0x10) 3772 pcnetIoportWriteU16(pThis, addr & 0x0f, val); 3773 else 3774 { 3775 pcnetAPROMWriteU8(pThis, addr, val ); 3776 pcnetAPROMWriteU8(pThis, addr+1, val >> 8); 3777 } 3778 } 3779 3780 static uint32_t pcnetMMIOReadU16(PPCNETSTATE pThis, RTGCPHYS addr) 3781 { 3782 uint32_t val = ~0U; 3783 int rc; 3784 3785 if (addr & 0x10) 3786 val = pcnetIoportReadU16(pThis, addr & 0x0f, &rc); 3787 else 3788 { 3789 val = pcnetAPROMReadU8(pThis, addr+1); 3790 val <<= 8; 3791 val |= pcnetAPROMReadU8(pThis, addr); 3792 } 3793 #ifdef PCNET_DEBUG_IO 3794 Log2(("#%d pcnetMMIOReadU16: addr=%#010x val = %#06x\n", PCNET_INST_NR, addr, val & 0xffff)); 3795 #endif 3796 return val; 3797 } 3798 3799 static void pcnetMMIOWriteU32(PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val) 3800 { 3801 #ifdef PCNET_DEBUG_IO 3802 Log2(("#%d pcnetMMIOWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val)); 3803 #endif 3804 if (addr & 0x10) 3805 pcnetIoportWriteU32(pThis, addr & 0x0f, val); 3806 else 3807 { 3808 pcnetAPROMWriteU8(pThis, addr, val ); 3809 pcnetAPROMWriteU8(pThis, addr+1, val >> 8); 3810 pcnetAPROMWriteU8(pThis, addr+2, val >> 16); 3811 pcnetAPROMWriteU8(pThis, addr+3, val >> 24); 3812 } 3813 } 3814 3815 static uint32_t pcnetMMIOReadU32(PPCNETSTATE pThis, RTGCPHYS addr) 3816 { 3817 uint32_t val; 3818 int rc; 3819 3820 if (addr & 0x10) 3821 val = pcnetIoportReadU32(pThis, addr & 0x0f, &rc); 3822 else 3823 { 3824 val = pcnetAPROMReadU8(pThis, addr+3); 3825 val <<= 8; 3826 val |= pcnetAPROMReadU8(pThis, addr+2); 3827 val <<= 8; 3828 val |= pcnetAPROMReadU8(pThis, addr+1); 3829 val <<= 8; 3830 val |= pcnetAPROMReadU8(pThis, addr ); 3831 } 3832 #ifdef PCNET_DEBUG_IO 3833 Log2(("#%d pcnetMMIOReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val)); 3834 #endif 3835 return val; 3836 } 3837 3838 3839 /** 3840 * @callback_method_impl{FNIOMMMIOREAD} 3841 */ 3842 PDMBOTHCBDECL(int) pcnetMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 3843 { 3844 PPCNETSTATE pThis = (PPCNETSTATE)pvUser; 3882 3845 int rc = VINF_SUCCESS; 3883 3846 3884 3847 /* 3885 * We have to check the range, because we're page aligning the MMIO stuff presently.3848 * We have to check the range, because we're page aligning the MMIO. 3886 3849 */ 3887 3850 if (GCPhysAddr - pThis->MMIOBase < PCNET_PNPMMIO_SIZE) … … 3919 3882 3920 3883 /** 3921 * Port I/O Handler for write operations. 3922 * 3923 * @returns VBox status code. 3924 * 3925 * @param pDevIns The device instance. 3926 * @param pvUser User argument. 3927 * @param GCPhysAddr Physical address (in GC) where the read starts. 3928 * @param pv Where to fetch the result. 3929 * @param cb Number of bytes to write. 3930 */ 3931 PDMBOTHCBDECL(int) pcnetMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, 3932 RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 3933 { 3934 PCNetState *pThis = (PCNetState *)pvUser; 3884 * @callback_method_impl{FNIOMMMIOWRITE} 3885 */ 3886 PDMBOTHCBDECL(int) pcnetMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 3887 { 3888 PPCNETSTATE pThis = (PPCNETSTATE)pvUser; 3935 3889 int rc = VINF_SUCCESS; 3936 3890 … … 3971 3925 3972 3926 #ifdef IN_RING3 3973 /** 3974 * Device timer callback function. 3975 * 3976 * @param pDevIns Device instance of the device which registered the timer. 3977 * @param pTimer The timer handle. 3978 * @thread EMT 3927 3928 /* -=-=-=-=-=- Timer Callbacks -=-=-=-=-=- */ 3929 3930 /** 3931 * @callback_method_impl{FNTMTIMERDEV, Poll timer} 3979 3932 */ 3980 3933 static DECLCALLBACK(void) pcnetTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 3981 3934 { 3982 P CNetState *pThis = (PCNetState *)pvUser;3935 PPCNETSTATE pThis = (PPCNETSTATE)pvUser; 3983 3936 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 3984 3937 … … 3990 3943 3991 3944 /** 3992 * Software interrupt timer callback function. 3993 * 3994 * @param pDevIns Device instance of the device which registered the timer. 3995 * @param pTimer The timer handle. 3996 * @thread EMT 3945 * @callback_method_impl{FNTMTIMERDEV, 3946 * Software interrupt timer callback function.} 3997 3947 */ 3998 3948 static DECLCALLBACK(void) pcnetTimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 3999 3949 { 4000 P CNetState *pThis = (PCNetState *)pvUser;3950 PPCNETSTATE pThis = (PPCNETSTATE)pvUser; 4001 3951 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 4002 3952 … … 4008 3958 4009 3959 /** 4010 * Restore timer callback.3960 * @callback_method_impl{FNTMTIMERDEV, Restore timer callback} 4011 3961 * 4012 3962 * This is only called when we restore a saved state and temporarily 4013 3963 * disconnected the network link to inform the guest that network connections 4014 3964 * should be considered lost. 4015 *4016 * @param pDevIns Device instance of the device which registered the timer.4017 * @param pTimer The timer handle.4018 3965 */ 4019 3966 static DECLCALLBACK(void) pcnetTimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 4020 3967 { 4021 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);3968 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4022 3969 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 4023 3970 AssertReleaseRC(rc); … … 4046 3993 } 4047 3994 4048 /** 4049 * Callback function for mapping an PCI I/O region. 4050 * 4051 * @return VBox status code. 4052 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance. 4053 * @param iRegion The region number. 4054 * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an 4055 * I/O port, else it's a physical address. 4056 * This address is *NOT* relative to pci_mem_base like earlier! 4057 * @param cb Region size. 4058 * @param enmType One of the PCI_ADDRESS_SPACE_* values. 3995 3996 /* -=-=-=-=-=- PCI Device Callbacks -=-=-=-=-=- */ 3997 3998 /** 3999 * @callback_method_impl{FNPCIIOREGIONMAP, For the PC-NET I/O Ports.} 4059 4000 */ 4060 4001 static DECLCALLBACK(int) pcnetIOPortMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, … … 4064 4005 PPDMDEVINS pDevIns = pPciDev->pDevIns; 4065 4006 RTIOPORT Port = (RTIOPORT)GCPhysAddress; 4066 P CNetState *pThis = PCIDEV_2_PCNETSTATE(pPciDev);4007 PPCNETSTATE pThis = PCIDEV_2_PCNETSTATE(pPciDev); 4067 4008 4068 4009 Assert(enmType == PCI_ADDRESS_SPACE_IO); … … 4107 4048 4108 4049 /** 4109 * Callback function for mapping the MMIO region. 4110 * 4111 * @return VBox status code. 4112 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance. 4113 * @param iRegion The region number. 4114 * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an 4115 * I/O port, else it's a physical address. 4116 * This address is *NOT* relative to pci_mem_base like earlier! 4117 * @param cb Region size. 4118 * @param enmType One of the PCI_ADDRESS_SPACE_* values. 4050 * @callback_method_impl{FNPCIIOREGIONMAP, For the PC-Net MMIO region.} 4119 4051 */ 4120 4052 static DECLCALLBACK(int) pcnetMMIOMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, 4121 4053 RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType) 4122 4054 { 4123 P CNetState *pThis = PCIDEV_2_PCNETSTATE(pPciDev);4055 PPCNETSTATE pThis = PCIDEV_2_PCNETSTATE(pPciDev); 4124 4056 int rc; 4125 4057 … … 4139 4071 4140 4072 /** 4141 * Callback function for mapping the MMIO region. 4142 * 4143 * @return VBox status code. 4144 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance. 4145 * @param iRegion The region number. 4146 * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an 4147 * I/O port, else it's a physical address. 4148 * This address is *NOT* relative to pci_mem_base like earlier! 4149 * @param cb Region size. 4150 * @param enmType One of the PCI_ADDRESS_SPACE_* values. 4073 * @callback_method_impl{FNPCIIOREGIONMAP, VBox specific MMIO2 interface.} 4151 4074 */ 4152 4075 static DECLCALLBACK(int) pcnetMMIOSharedMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, … … 4161 4084 4162 4085 4163 /** 4164 * PCNET status info callback. 4165 * 4166 * @param pDevIns The device instance. 4167 * @param pHlp The output helpers. 4168 * @param pszArgs The arguments. 4086 /* -=-=-=-=-=- Debug Info Handler -=-=-=-=-=- */ 4087 4088 /** 4089 * @callback_method_impl{FNDBGFHANDLERDEV} 4169 4090 */ 4170 4091 static DECLCALLBACK(void) pcnetInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4171 4092 { 4172 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4093 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4173 4094 bool fRcvRing = false; 4174 4095 bool fXmtRing = false; … … 4388 4309 4389 4310 4311 /* -=-=-=-=-=- Helper(s) -=-=-=-=-=- */ 4312 4390 4313 /** 4391 4314 * Takes down the link temporarily if it's current status is up. … … 4399 4322 * @param pThis The PCNet instance data. 4400 4323 */ 4401 static void pcnetTempLinkDown(P CNetState *pThis)4324 static void pcnetTempLinkDown(PPCNETSTATE pThis) 4402 4325 { 4403 4326 if (pThis->fLinkUp) … … 4413 4336 4414 4337 4338 /* -=-=-=-=-=- Saved State -=-=-=-=-=- */ 4339 4415 4340 /** 4416 4341 * Saves the configuration. … … 4419 4344 * @param pSSM The saved state handle. 4420 4345 */ 4421 static void pcnetSaveConfig(P CNetState *pThis, PSSMHANDLE pSSM)4346 static void pcnetSaveConfig(PPCNETSTATE pThis, PSSMHANDLE pSSM) 4422 4347 { 4423 4348 SSMR3PutMem(pSSM, &pThis->MacConfigured, sizeof(pThis->MacConfigured)); … … 4428 4353 4429 4354 /** 4430 * Live Save, pass 0. 4431 * 4432 * @returns VBox status code. 4433 * @param pDevIns The device instance. 4434 * @param pSSM The saved state handle. 4435 * @param uPass The pass number. 4355 * @callback_method_impl{FNSSMDEVLIVEEXEC, Pass 0 only.} 4436 4356 */ 4437 4357 static DECLCALLBACK(int) pcnetLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 4438 4358 { 4439 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4359 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4440 4360 pcnetSaveConfig(pThis, pSSM); 4441 4361 return VINF_SSM_DONT_CALL_AGAIN; … … 4444 4364 4445 4365 /** 4446 * Serializes the receive thread, it may be working inside the critsect. 4447 * 4448 * @returns VBox status code. 4449 * @param pDevIns The device instance. 4450 * @param pSSM The saved state handle. 4366 * @callback_method_impl{FNSSMDEVSAVEPREP, 4367 * Serializes the receive thread, it may be working inside the critsect.} 4451 4368 */ 4452 4369 static DECLCALLBACK(int) pcnetSavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4453 4370 { 4454 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4371 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4455 4372 4456 4373 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); … … 4463 4380 4464 4381 /** 4465 * Saves a state of the PC-Net II device. 4466 * 4467 * @returns VBox status code. 4468 * @param pDevIns The device instance. 4469 * @param pSSM The saved state handle. 4382 * @callback_method_impl{FNSSMDEVSAVEEXEC} 4470 4383 */ 4471 4384 static DECLCALLBACK(int) pcnetSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4472 4385 { 4473 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4386 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4474 4387 4475 4388 SSMR3PutBool(pSSM, pThis->fLinkUp); … … 4502 4415 4503 4416 /** 4504 * Serializes the receive thread, it may be working inside the critsect. 4505 * 4506 * @returns VBox status code. 4507 * @param pDevIns The device instance. 4508 * @param pSSM The saved state handle. 4417 * @callback_method_impl{FNSSMDEVLOADPREP, 4418 * Serializes the receive thread, it may be working inside the critsect.} 4509 4419 */ 4510 4420 static DECLCALLBACK(int) pcnetLoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4511 4421 { 4512 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4422 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4513 4423 4514 4424 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); … … 4521 4431 4522 4432 /** 4523 * Loads a saved PC-Net II device state. 4524 * 4525 * @returns VBox status code. 4526 * @param pDevIns The device instance. 4527 * @param pSSM The handle to the saved state. 4528 * @param uVersion The data unit version number. 4529 * @param uPass The data pass. 4433 * @callback_method_impl{FNSSMDEVLOADEXEC} 4530 4434 */ 4531 4435 static DECLCALLBACK(int) pcnetLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 4532 4436 { 4533 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4437 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4534 4438 4535 4439 if ( SSM_VERSION_MAJOR_CHANGED(uVersion, PCNET_SAVEDSTATE_VERSION) … … 4625 4529 4626 4530 4627 /** 4628 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 4629 */ 4630 static DECLCALLBACK(void *) pcnetQueryInterface(struct PDMIBASE *pInterface, const char *pszIID) 4631 { 4632 PCNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, IBase); 4633 Assert(&pThis->IBase == pInterface); 4634 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); 4635 PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown); 4636 PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig); 4637 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds); 4638 return NULL; 4639 } 4640 4641 4531 /* -=-=-=-=-=- PCNETSTATE::INetworkDown -=-=-=-=-=- */ 4642 4532 4643 4533 /** 4644 4534 * Check if the device/driver can receive data now. 4645 * This must be called before the pfnRecieve() method is called. 4535 * 4536 * Worker for pcnetNetworkDown_WaitReceiveAvail(). This must be called before 4537 * the pfnRecieve() method is called. 4646 4538 * 4647 4539 * @returns VBox status code. 4648 * @param p Interface Pointer to the interface structure containing the called function pointer.4649 */ 4650 static int pcnetCanReceive(P CNetState *pThis)4540 * @param pThis The PC-Net instance data. 4541 */ 4542 static int pcnetCanReceive(PPCNETSTATE pThis) 4651 4543 { 4652 4544 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); … … 4680 4572 static DECLCALLBACK(int) pcnetNetworkDown_WaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies) 4681 4573 { 4682 P CNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkDown);4574 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown); 4683 4575 4684 4576 int rc = pcnetCanReceive(pThis); … … 4722 4614 static DECLCALLBACK(int) pcnetNetworkDown_Receive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb) 4723 4615 { 4724 P CNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkDown);4616 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown); 4725 4617 int rc; 4726 4618 … … 4776 4668 static DECLCALLBACK(void) pcnetNetworkDown_XmitPending(PPDMINETWORKDOWN pInterface) 4777 4669 { 4778 P CNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkDown);4670 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown); 4779 4671 pcnetXmitPending(pThis, true /*fOnWorkerThread*/); 4780 4672 } 4781 4673 4782 4674 4783 4784 /** 4785 * Gets the current Media Access Control (MAC) address. 4786 * 4787 * @returns VBox status code. 4788 * @param pInterface Pointer to the interface structure containing the called function pointer. 4789 * @param pMac Where to store the MAC address. 4790 * @thread EMT 4675 /* -=-=-=-=-=- PCNETSTATE::INetworkConfig -=-=-=-=-=- */ 4676 4677 /** 4678 * @interface_method_impl{PDMINETWORKCONFIG,pfnGetMac} 4791 4679 */ 4792 4680 static DECLCALLBACK(int) pcnetGetMac(PPDMINETWORKCONFIG pInterface, PRTMAC pMac) 4793 4681 { 4794 P CNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkConfig);4682 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig); 4795 4683 memcpy(pMac, pThis->aPROM, sizeof(*pMac)); 4796 4684 return VINF_SUCCESS; … … 4799 4687 4800 4688 /** 4801 * Gets the new link state. 4802 * 4803 * @returns The current link state. 4804 * @param pInterface Pointer to the interface structure containing the called function pointer. 4805 * @thread EMT 4689 * @interface_method_impl{PDMINETWORKCONFIG,pfnGetLinkState} 4806 4690 */ 4807 4691 static DECLCALLBACK(PDMNETWORKLINKSTATE) pcnetGetLinkState(PPDMINETWORKCONFIG pInterface) 4808 4692 { 4809 P CNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkConfig);4693 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig); 4810 4694 if (pThis->fLinkUp && !pThis->fLinkTempDown) 4811 4695 return PDMNETWORKLINKSTATE_UP; … … 4820 4704 4821 4705 /** 4822 * Sets the new link state. 4823 * 4824 * @returns VBox status code. 4825 * @param pInterface Pointer to the interface structure containing the called function pointer. 4826 * @param enmState The new link state 4827 * @thread EMT 4706 * @interface_method_impl{PDMINETWORKCONFIG,pfnSetLinkState} 4828 4707 */ 4829 4708 static DECLCALLBACK(int) pcnetSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState) 4830 4709 { 4831 P CNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkConfig);4710 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig); 4832 4711 bool fLinkUp; 4833 4712 if ( enmState != PDMNETWORKLINKSTATE_DOWN … … 4868 4747 4869 4748 4870 /** 4871 * Gets the pointer to the status LED of a unit. 4872 * 4873 * @returns VBox status code. 4874 * @param pInterface Pointer to the interface structure containing the called function pointer. 4875 * @param iLUN The unit which status LED we desire. 4876 * @param ppLed Where to store the LED pointer. 4749 /* -=-=-=-=-=- PCNETSTATE::ILeds (LUN#0) -=-=-=-=-=- */ 4750 4751 /** 4752 * @interface_method_impl{PDMILEDPORTS,pfnQueryStatusLed} 4877 4753 */ 4878 4754 static DECLCALLBACK(int) pcnetQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed) 4879 4755 { 4880 P CNetState *pThis = (PCNetState *)( (uintptr_t)pInterface - RT_OFFSETOF(PCNetState, ILeds));4756 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, ILeds); 4881 4757 if (iLUN == 0) 4882 4758 { … … 4888 4764 4889 4765 4890 /** 4891 * @copydoc FNPDMDEVPOWEROFF 4766 /* -=-=-=-=-=- PCNETSTATE::IBase (LUN#0) -=-=-=-=-=- */ 4767 4768 /** 4769 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 4770 */ 4771 static DECLCALLBACK(void *) pcnetQueryInterface(struct PDMIBASE *pInterface, const char *pszIID) 4772 { 4773 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, IBase); 4774 Assert(&pThis->IBase == pInterface); 4775 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); 4776 PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown); 4777 PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig); 4778 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds); 4779 return NULL; 4780 } 4781 4782 4783 /* -=-=-=-=-=- PDMDEVREG -=-=-=-=-=- */ 4784 4785 /** 4786 * @interface_method_impl{PDMDEVREG,pfnPowerOff} 4892 4787 */ 4893 4788 static DECLCALLBACK(void) pcnetPowerOff(PPDMDEVINS pDevIns) … … 4899 4794 4900 4795 /** 4901 * Detach notification.4796 * @interface_method_impl{PDMDEVREG,pfnDetach} 4902 4797 * 4903 4798 * One port on the network card has been disconnected from the network. 4904 *4905 * @param pDevIns The device instance.4906 * @param iLUN The logical unit which is being detached.4907 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.4908 4799 */ 4909 4800 static DECLCALLBACK(void) pcnetDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 4910 4801 { 4911 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4802 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4912 4803 Log(("#%d pcnetDetach:\n", PCNET_INST_NR)); 4913 4804 … … 4933 4824 4934 4825 /** 4935 * Attach the Network attachment. 4936 * 4826 * @interface_method_impl{PDMDEVREG,pfnAttach} 4937 4827 * One port on the network card has been connected to a network. 4938 *4939 * @returns VBox status code.4940 * @param pDevIns The device instance.4941 * @param iLUN The logical unit which is being attached.4942 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.4943 *4944 * @remarks This code path is not used during construction.4945 4828 */ 4946 4829 static DECLCALLBACK(int) pcnetAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 4947 4830 { 4948 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4831 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 4949 4832 LogFlow(("#%d pcnetAttach:\n", PCNET_INST_NR)); 4950 4833 … … 4998 4881 4999 4882 /** 5000 * @ copydoc FNPDMDEVSUSPEND4883 * @interface_method_impl{PDMDEVREG,pfnSuspend} 5001 4884 */ 5002 4885 static DECLCALLBACK(void) pcnetSuspend(PPDMDEVINS pDevIns) … … 5008 4891 5009 4892 /** 5010 * @ copydoc FNPDMDEVRESET4893 * @interface_method_impl{PDMDEVREG,pfnReset} 5011 4894 */ 5012 4895 static DECLCALLBACK(void) pcnetReset(PPDMDEVINS pDevIns) 5013 4896 { 5014 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4897 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 5015 4898 if (pThis->fLinkTempDown) 5016 4899 { … … 5023 4906 5024 4907 /** @todo How to flush the queues? */ 5025 pcnet HardReset(pThis);5026 } 5027 5028 5029 /** 5030 * @ copydoc FNPDMDEVRELOCATE4908 pcnetR3HardReset(pThis); 4909 } 4910 4911 4912 /** 4913 * @interface_method_impl{PDMDEVREG,pfnRelocate} 5031 4914 */ 5032 4915 static DECLCALLBACK(void) pcnetRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 5033 4916 { 5034 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4917 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 5035 4918 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 5036 4919 pThis->pXmitQueueRC = PDMQueueRCPtr(pThis->pXmitQueueR3); … … 5049 4932 5050 4933 /** 5051 * Destruct a device instance. 5052 * 5053 * Most VM resources are freed by the VM. This callback is provided so that any non-VM 5054 * resources can be freed correctly. 5055 * 5056 * @returns VBox status. 5057 * @param pDevIns The device instance data. 4934 * @interface_method_impl{PDMDEVREG,pfnDestruct} 5058 4935 */ 5059 4936 static DECLCALLBACK(int) pcnetDestruct(PPDMDEVINS pDevIns) 5060 4937 { 5061 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4938 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 5062 4939 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 5063 4940 … … 5078 4955 static DECLCALLBACK(int) pcnetConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 5079 4956 { 5080 P CNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);4957 PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE); 5081 4958 PPDMIBASE pBase; 5082 4959 char szTmp[128]; … … 5374 5251 * Reset the device state. (Do after attaching.) 5375 5252 */ 5376 pcnet HardReset(pThis);5253 pcnetR3HardReset(pThis); 5377 5254 5378 5255 #ifdef VBOX_WITH_STATISTICS … … 5476 5353 ~0U, 5477 5354 /* cbInstance */ 5478 sizeof(PCN etState),5355 sizeof(PCNETSTATE), 5479 5356 /* pfnConstruct */ 5480 5357 pcnetConstruct, -
trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp
r44876 r44892 307 307 CHECK_MEMBER_ALIGNMENT(PCIBUS, devices, 16); 308 308 CHECK_MEMBER_ALIGNMENT(PCIGLOBALS, pci_irq_levels, 16); 309 CHECK_MEMBER_ALIGNMENT(PCN etState, u64LastPoll, 8);310 CHECK_MEMBER_ALIGNMENT(PCN etState, CritSect, 8);311 CHECK_MEMBER_ALIGNMENT(PCN etState, StatReceiveBytes, 8);309 CHECK_MEMBER_ALIGNMENT(PCNETSTATE, u64LastPoll, 8); 310 CHECK_MEMBER_ALIGNMENT(PCNETSTATE, CritSect, 8); 311 CHECK_MEMBER_ALIGNMENT(PCNETSTATE, StatReceiveBytes, 8); 312 312 #ifdef VBOX_WITH_STATISTICS 313 CHECK_MEMBER_ALIGNMENT(PCN etState, StatMMIOReadRZ, 8);313 CHECK_MEMBER_ALIGNMENT(PCNETSTATE, StatMMIOReadRZ, 8); 314 314 #endif 315 315 CHECK_MEMBER_ALIGNMENT(PITSTATE, StatPITIrq, 8); -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r44876 r44892 424 424 425 425 /* Network/DevPCNet.cpp */ 426 GEN_CHECK_SIZE(PCN etState);427 GEN_CHECK_OFF(PCN etState, PciDev);426 GEN_CHECK_SIZE(PCNETSTATE); 427 GEN_CHECK_OFF(PCNETSTATE, PciDev); 428 428 #ifndef PCNET_NO_POLLING 429 GEN_CHECK_OFF(PCN etState, pTimerPollR3);430 GEN_CHECK_OFF(PCN etState, pTimerPollR0);431 GEN_CHECK_OFF(PCN etState, pTimerPollRC);432 #endif 433 GEN_CHECK_OFF(PCN etState, pTimerSoftIntR3);434 GEN_CHECK_OFF(PCN etState, pTimerSoftIntR0);435 GEN_CHECK_OFF(PCN etState, pTimerSoftIntRC);436 GEN_CHECK_OFF(PCN etState, u32RAP);437 GEN_CHECK_OFF(PCN etState, iISR);438 GEN_CHECK_OFF(PCN etState, u32Lnkst);439 GEN_CHECK_OFF(PCN etState, GCRDRA);440 GEN_CHECK_OFF(PCN etState, GCTDRA);441 GEN_CHECK_OFF(PCN etState, aPROM);442 GEN_CHECK_OFF(PCN etState, aPROM[1]);443 GEN_CHECK_OFF(PCN etState, aCSR);444 GEN_CHECK_OFF(PCN etState, aCSR[1]);445 GEN_CHECK_OFF(PCN etState, aCSR[CSR_MAX_REG - 1]);446 GEN_CHECK_OFF(PCN etState, aBCR);447 GEN_CHECK_OFF(PCN etState, aBCR[1]);448 GEN_CHECK_OFF(PCN etState, aBCR[BCR_MAX_RAP - 1]);449 GEN_CHECK_OFF(PCN etState, aMII);450 GEN_CHECK_OFF(PCN etState, aMII[1]);451 GEN_CHECK_OFF(PCN etState, aMII[MII_MAX_REG - 1]);452 GEN_CHECK_OFF(PCN etState, u16CSR0LastSeenByGuest);453 GEN_CHECK_OFF(PCN etState, u64LastPoll);454 GEN_CHECK_OFF(PCN etState, abLoopBuf);455 GEN_CHECK_OFF(PCN etState, abRecvBuf);456 GEN_CHECK_OFF(PCN etState, iLog2DescSize);457 GEN_CHECK_OFF(PCN etState, GCUpperPhys);458 GEN_CHECK_OFF(PCN etState, pXmitQueueR3);459 GEN_CHECK_OFF(PCN etState, pXmitQueueR0);460 GEN_CHECK_OFF(PCN etState, pXmitQueueRC);461 GEN_CHECK_OFF(PCN etState, pCanRxQueueR3);462 GEN_CHECK_OFF(PCN etState, pCanRxQueueR0);463 GEN_CHECK_OFF(PCN etState, pCanRxQueueRC);464 GEN_CHECK_OFF(PCN etState, pTimerRestore);465 GEN_CHECK_OFF(PCN etState, pDevInsR3);466 GEN_CHECK_OFF(PCN etState, pDevInsR0);467 GEN_CHECK_OFF(PCN etState, pDevInsRC);468 GEN_CHECK_OFF(PCN etState, pDrvR3);469 GEN_CHECK_OFF(PCN etState, pDrvBase);470 GEN_CHECK_OFF(PCN etState, IBase);471 GEN_CHECK_OFF(PCN etState, INetworkDown);472 GEN_CHECK_OFF(PCN etState, INetworkConfig);473 GEN_CHECK_OFF(PCN etState, MMIOBase);474 GEN_CHECK_OFF(PCN etState, IOPortBase);475 GEN_CHECK_OFF(PCN etState, fLinkUp);476 GEN_CHECK_OFF(PCN etState, fLinkTempDown);477 GEN_CHECK_OFF(PCN etState, cLinkDownReported);478 GEN_CHECK_OFF(PCN etState, MacConfigured);479 GEN_CHECK_OFF(PCN etState, Led);480 GEN_CHECK_OFF(PCN etState, ILeds);481 GEN_CHECK_OFF(PCN etState, pLedsConnector);482 GEN_CHECK_OFF(PCN etState, CritSect);429 GEN_CHECK_OFF(PCNETSTATE, pTimerPollR3); 430 GEN_CHECK_OFF(PCNETSTATE, pTimerPollR0); 431 GEN_CHECK_OFF(PCNETSTATE, pTimerPollRC); 432 #endif 433 GEN_CHECK_OFF(PCNETSTATE, pTimerSoftIntR3); 434 GEN_CHECK_OFF(PCNETSTATE, pTimerSoftIntR0); 435 GEN_CHECK_OFF(PCNETSTATE, pTimerSoftIntRC); 436 GEN_CHECK_OFF(PCNETSTATE, u32RAP); 437 GEN_CHECK_OFF(PCNETSTATE, iISR); 438 GEN_CHECK_OFF(PCNETSTATE, u32Lnkst); 439 GEN_CHECK_OFF(PCNETSTATE, GCRDRA); 440 GEN_CHECK_OFF(PCNETSTATE, GCTDRA); 441 GEN_CHECK_OFF(PCNETSTATE, aPROM); 442 GEN_CHECK_OFF(PCNETSTATE, aPROM[1]); 443 GEN_CHECK_OFF(PCNETSTATE, aCSR); 444 GEN_CHECK_OFF(PCNETSTATE, aCSR[1]); 445 GEN_CHECK_OFF(PCNETSTATE, aCSR[CSR_MAX_REG - 1]); 446 GEN_CHECK_OFF(PCNETSTATE, aBCR); 447 GEN_CHECK_OFF(PCNETSTATE, aBCR[1]); 448 GEN_CHECK_OFF(PCNETSTATE, aBCR[BCR_MAX_RAP - 1]); 449 GEN_CHECK_OFF(PCNETSTATE, aMII); 450 GEN_CHECK_OFF(PCNETSTATE, aMII[1]); 451 GEN_CHECK_OFF(PCNETSTATE, aMII[MII_MAX_REG - 1]); 452 GEN_CHECK_OFF(PCNETSTATE, u16CSR0LastSeenByGuest); 453 GEN_CHECK_OFF(PCNETSTATE, u64LastPoll); 454 GEN_CHECK_OFF(PCNETSTATE, abLoopBuf); 455 GEN_CHECK_OFF(PCNETSTATE, abRecvBuf); 456 GEN_CHECK_OFF(PCNETSTATE, iLog2DescSize); 457 GEN_CHECK_OFF(PCNETSTATE, GCUpperPhys); 458 GEN_CHECK_OFF(PCNETSTATE, pXmitQueueR3); 459 GEN_CHECK_OFF(PCNETSTATE, pXmitQueueR0); 460 GEN_CHECK_OFF(PCNETSTATE, pXmitQueueRC); 461 GEN_CHECK_OFF(PCNETSTATE, pCanRxQueueR3); 462 GEN_CHECK_OFF(PCNETSTATE, pCanRxQueueR0); 463 GEN_CHECK_OFF(PCNETSTATE, pCanRxQueueRC); 464 GEN_CHECK_OFF(PCNETSTATE, pTimerRestore); 465 GEN_CHECK_OFF(PCNETSTATE, pDevInsR3); 466 GEN_CHECK_OFF(PCNETSTATE, pDevInsR0); 467 GEN_CHECK_OFF(PCNETSTATE, pDevInsRC); 468 GEN_CHECK_OFF(PCNETSTATE, pDrvR3); 469 GEN_CHECK_OFF(PCNETSTATE, pDrvBase); 470 GEN_CHECK_OFF(PCNETSTATE, IBase); 471 GEN_CHECK_OFF(PCNETSTATE, INetworkDown); 472 GEN_CHECK_OFF(PCNETSTATE, INetworkConfig); 473 GEN_CHECK_OFF(PCNETSTATE, MMIOBase); 474 GEN_CHECK_OFF(PCNETSTATE, IOPortBase); 475 GEN_CHECK_OFF(PCNETSTATE, fLinkUp); 476 GEN_CHECK_OFF(PCNETSTATE, fLinkTempDown); 477 GEN_CHECK_OFF(PCNETSTATE, cLinkDownReported); 478 GEN_CHECK_OFF(PCNETSTATE, MacConfigured); 479 GEN_CHECK_OFF(PCNETSTATE, Led); 480 GEN_CHECK_OFF(PCNETSTATE, ILeds); 481 GEN_CHECK_OFF(PCNETSTATE, pLedsConnector); 482 GEN_CHECK_OFF(PCNETSTATE, CritSect); 483 483 #ifdef PCNET_NO_POLLING 484 GEN_CHECK_OFF(PCN etState, TDRAPhysOld);485 GEN_CHECK_OFF(PCN etState, cbTDRAOld);486 GEN_CHECK_OFF(PCN etState, RDRAPhysOld);487 GEN_CHECK_OFF(PCN etState, cbRDRAOld);488 GEN_CHECK_OFF(PCN etState, pfnEMInterpretInstructionGC489 GEN_CHECK_OFF(PCN etState, pfnEMInterpretInstructionR0490 #endif 491 GEN_CHECK_OFF(PCN etState, pSharedMMIOR3);492 GEN_CHECK_OFF(PCN etState, pSharedMMIOR0);493 GEN_CHECK_OFF(PCN etState, pSharedMMIORC);494 GEN_CHECK_OFF(PCN etState, fPrivIfEnabled);495 GEN_CHECK_OFF(PCN etState, fGCEnabled);496 GEN_CHECK_OFF(PCN etState, fR0Enabled);497 GEN_CHECK_OFF(PCN etState, fAm79C973);498 GEN_CHECK_OFF(PCN etState, u32LinkSpeed);499 GEN_CHECK_OFF(PCN etState, StatReceiveBytes);500 GEN_CHECK_OFF(PCN etState, StatTransmitBytes);484 GEN_CHECK_OFF(PCNETSTATE, TDRAPhysOld); 485 GEN_CHECK_OFF(PCNETSTATE, cbTDRAOld); 486 GEN_CHECK_OFF(PCNETSTATE, RDRAPhysOld); 487 GEN_CHECK_OFF(PCNETSTATE, cbRDRAOld); 488 GEN_CHECK_OFF(PCNETSTATE, pfnEMInterpretInstructionGC 489 GEN_CHECK_OFF(PCNETSTATE, pfnEMInterpretInstructionR0 490 #endif 491 GEN_CHECK_OFF(PCNETSTATE, pSharedMMIOR3); 492 GEN_CHECK_OFF(PCNETSTATE, pSharedMMIOR0); 493 GEN_CHECK_OFF(PCNETSTATE, pSharedMMIORC); 494 GEN_CHECK_OFF(PCNETSTATE, fPrivIfEnabled); 495 GEN_CHECK_OFF(PCNETSTATE, fGCEnabled); 496 GEN_CHECK_OFF(PCNETSTATE, fR0Enabled); 497 GEN_CHECK_OFF(PCNETSTATE, fAm79C973); 498 GEN_CHECK_OFF(PCNETSTATE, u32LinkSpeed); 499 GEN_CHECK_OFF(PCNETSTATE, StatReceiveBytes); 500 GEN_CHECK_OFF(PCNETSTATE, StatTransmitBytes); 501 501 #ifdef VBOX_WITH_STATISTICS 502 GEN_CHECK_OFF(PCN etState, StatMMIOReadR3);503 GEN_CHECK_OFF(PCN etState, StatMMIOReadRZ);504 GEN_CHECK_OFF(PCN etState, StatMIIReads);502 GEN_CHECK_OFF(PCNETSTATE, StatMMIOReadR3); 503 GEN_CHECK_OFF(PCNETSTATE, StatMMIOReadRZ); 504 GEN_CHECK_OFF(PCNETSTATE, StatMIIReads); 505 505 # ifdef PCNET_NO_POLLING 506 GEN_CHECK_OFF(PCN etState, StatRCVRingWrite);507 GEN_CHECK_OFF(PCN etState, StatRingWriteOutsideRangeR3);506 GEN_CHECK_OFF(PCNETSTATE, StatRCVRingWrite); 507 GEN_CHECK_OFF(PCNETSTATE, StatRingWriteOutsideRangeR3); 508 508 # endif 509 509 #endif
Note:
See TracChangeset
for help on using the changeset viewer.