VirtualBox

Changeset 44892 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 1, 2013 6:40:50 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84061
Message:

DevPCNet.cpp: More cleanup.

Location:
trunk/src/VBox/Devices
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r44890 r44892  
    1111
    1212/*
    13  * Copyright (C) 2006-2012 Oracle Corporation
     13 * Copyright (C) 2006-2013 Oracle Corporation
    1414 *
    1515 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    253253 * @implements  PDMILEDPORTS
    254254 */
    255 typedef struct PCNetState_st
     255typedef struct PCNETSTATE
    256256{
    257257    PCIDEVICE                           PciDev;
     
    468468# endif
    469469#endif /* VBOX_WITH_STATISTICS */
    470 } PCNetState, PCNETSTATE;
    471 //AssertCompileMemberAlignment(PCNetState, StatReceiveBytes, 8);
     470} PCNETSTATE;
     471//AssertCompileMemberAlignment(PCNETSTATE, StatReceiveBytes, 8);
    472472/** Pointer to a PC-Net state structure. */
    473473typedef PCNETSTATE *PPCNETSTATE;
     
    634634        (R)->rmd2.zeros))
    635635
    636 static void pcnetPollTimerStart(PCNetState *pThis);
    637 static int  pcnetXmitPending(PCNetState *pThis, bool fOnWorkerThread);
     636static void pcnetPollTimerStart(PPCNETSTATE pThis);
     637static int  pcnetXmitPending(PPCNETSTATE pThis, bool fOnWorkerThread);
    638638
    639639
     
    644644 * @returns false if the link is down.
    645645 */
    646 DECLINLINE(bool) pcnetIsLinkUp(PCNetState *pThis)
     646DECLINLINE(bool) pcnetIsLinkUp(PPCNETSTATE pThis)
    647647{
    648648    return pThis->pDrvR3 && !pThis->fLinkTempDown && pThis->fLinkUp;
     
    658658 * @return              true if we own the descriptor, false otherwise
    659659 */
    660 DECLINLINE(bool) pcnetTmdLoad(PCNetState *pThis, TMD *tmd, RTGCPHYS32 addr, bool fRetIfNotOwn)
     660DECLINLINE(bool) pcnetTmdLoad(PPCNETSTATE pThis, TMD *tmd, RTGCPHYS32 addr, bool fRetIfNotOwn)
    661661{
    662662    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
     
    721721 * Make sure that all data are transmitted before we clear the own flag.
    722722 */
    723 DECLINLINE(void) pcnetTmdStorePassHost(PCNetState *pThis, TMD *tmd, RTGCPHYS32 addr)
     723DECLINLINE(void) pcnetTmdStorePassHost(PPCNETSTATE pThis, TMD *tmd, RTGCPHYS32 addr)
    724724{
    725725    STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatTmdStore), a);
     
    777777 * @return              true if we own the descriptor, false otherwise
    778778 */
    779 DECLINLINE(int) pcnetRmdLoad(PCNetState *pThis, RMD *rmd, RTGCPHYS32 addr, bool fRetIfNotOwn)
     779DECLINLINE(int) pcnetRmdLoad(PPCNETSTATE pThis, RMD *rmd, RTGCPHYS32 addr, bool fRetIfNotOwn)
    780780{
    781781    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
     
    840840 * Make sure that all data are transmitted before we clear the own flag.
    841841 */
    842 DECLINLINE(void) pcnetRmdStorePassHost(PCNetState *pThis, RMD *rmd, RTGCPHYS32 addr)
     842DECLINLINE(void) pcnetRmdStorePassHost(PPCNETSTATE pThis, RMD *rmd, RTGCPHYS32 addr)
    843843{
    844844    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
     
    890890 * pages later when we shouldn't schedule to EMT. Temporarily hack.
    891891 */
    892 static void pcnetDescTouch(PCNetState *pThis, RTGCPHYS32 addr)
     892static void pcnetDescTouch(PPCNETSTATE pThis, RTGCPHYS32 addr)
    893893{
    894894    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
     
    952952 * @note Changing this layout will break SSM for guests using the private guest interface!
    953953 */
    954 static void pcnetInitSharedMemory(PCNetState *pThis)
     954static void pcnetInitSharedMemory(PPCNETSTATE pThis)
    955955{
    956956    /* Clear the entire block for pcnetReset usage. */
     
    10871087};
    10881088
    1089 DECLINLINE(int) padr_match(PCNetState *pThis, const uint8_t *buf, size_t size)
     1089DECLINLINE(int) padr_match(PPCNETSTATE pThis, const uint8_t *buf, size_t size)
    10901090{
    10911091    struct ether_header *hdr = (struct ether_header *)buf;
     
    11141114}
    11151115
    1116 DECLINLINE(int) padr_bcast(PCNetState *pThis, const uint8_t *buf, size_t size)
     1116DECLINLINE(int) padr_bcast(PPCNETSTATE pThis, const uint8_t *buf, size_t size)
    11171117{
    11181118    static uint8_t aBCAST[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
     
    11251125}
    11261126
    1127 static int ladr_match(PCNetState *pThis, const uint8_t *buf, size_t size)
     1127static int ladr_match(PPCNETSTATE pThis, const uint8_t *buf, size_t size)
    11281128{
    11291129    struct ether_header *hdr = (struct ether_header *)buf;
     
    11551155 * Get the receive descriptor ring address with a given index.
    11561156 */
    1157 DECLINLINE(RTGCPHYS32) pcnetRdraAddr(PCNetState *pThis, int idx)
     1157DECLINLINE(RTGCPHYS32) pcnetRdraAddr(PPCNETSTATE pThis, int idx)
    11581158{
    11591159    return pThis->GCRDRA + ((CSR_RCVRL(pThis) - idx) << pThis->iLog2DescSize);
     
    11631163 * Get the transmit descriptor ring address with a given index.
    11641164 */
    1165 DECLINLINE(RTGCPHYS32) pcnetTdraAddr(PCNetState *pThis, int idx)
     1165DECLINLINE(RTGCPHYS32) pcnetTdraAddr(PPCNETSTATE pThis, int idx)
    11661166{
    11671167    return pThis->GCTDRA + ((CSR_XMTRL(pThis) - idx) << pThis->iLog2DescSize);
     
    11801180#define htons(x)    ( (((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8) )
    11811181
    1182 static void     pcnetPollRxTx(PCNetState *pThis);
    1183 static void     pcnetPollTimer(PCNetState *pThis);
    1184 static void     pcnetUpdateIrq(PCNetState *pThis);
    1185 static uint32_t pcnetBCRReadU16(PCNetState *pThis, uint32_t u32RAP);
    1186 static int      pcnetBCRWriteU16(PCNetState *pThis, uint32_t u32RAP, uint32_t val);
     1182static void     pcnetPollRxTx(PPCNETSTATE pThis);
     1183static void     pcnetPollTimer(PPCNETSTATE pThis);
     1184static void     pcnetUpdateIrq(PPCNETSTATE pThis);
     1185static uint32_t pcnetBCRReadU16(PPCNETSTATE pThis, uint32_t u32RAP);
     1186static int      pcnetBCRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val);
    11871187
    11881188
     
    12041204                                     RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser)
    12051205{
    1206     PCNetState *pThis   = (PCNetState *)pvUser;
     1206    PPCNETSTATE pThis   = (PPCNETSTATE)pvUser;
    12071207
    12081208    Log(("#%d pcnetHandleRingWriteGC: write to %#010x\n", PCNET_INST_NR, GCPhysFault));
     
    12651265{
    12661266    PPDMDEVINS  pDevIns = (PPDMDEVINS)pvUser;
    1267     PCNetState *pThis   = PDMINS_2_DATA(pDevIns, PCNetState *);
     1267    PPCNETSTATE pThis   = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    12681268
    12691269    Log(("#%d pcnetHandleRingWrite: write to %#010x\n", PCNET_INST_NR, GCPhys));
     
    13001300#endif /* PCNET_NO_POLLING */
    13011301
    1302 static void pcnetSoftReset(PCNetState *pThis)
     1302static void pcnetSoftReset(PPCNETSTATE pThis)
    13031303{
    13041304    Log(("#%d pcnetSoftReset:\n", PCNET_INST_NR));
     
    13451345 * - csr5 (only written by pcnetSoftReset(), pcnetStop or by the driver guest)
    13461346 */
    1347 static void pcnetUpdateIrq(PCNetState *pThis)
     1347static void pcnetUpdateIrq(PPCNETSTATE pThis)
    13481348{
    13491349    register int      iISR = 0;
     
    14341434 * Enable/disable the private guest interface.
    14351435 */
    1436 static void pcnetEnablePrivateIf(PCNetState *pThis)
     1436static void pcnetEnablePrivateIf(PPCNETSTATE pThis)
    14371437{
    14381438    bool fPrivIfEnabled =       pThis->pSharedMMIOR3
     
    14471447#ifdef IN_RING3
    14481448#ifdef PCNET_NO_POLLING
    1449 static void pcnetUpdateRingHandlers(PCNetState *pThis)
     1449static void pcnetUpdateRingHandlers(PPCNETSTATE pThis)
    14501450{
    14511451    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
     
    15351535#endif /* PCNET_NO_POLLING */
    15361536
    1537 static void pcnetInit(PCNetState *pThis)
     1537static void pcnetInit(PPCNETSTATE pThis)
    15381538{
    15391539    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
     
    16401640 * Start RX/TX operation.
    16411641 */
    1642 static void pcnetStart(PCNetState *pThis)
     1642static void pcnetStart(PPCNETSTATE pThis)
    16431643{
    16441644    Log(("#%d pcnetStart:\n", PCNET_INST_NR));
     
    16561656 * Stop RX/TX operation.
    16571657 */
    1658 static void pcnetStop(PCNetState *pThis)
     1658static void pcnetStop(PPCNETSTATE pThis)
    16591659{
    16601660    Log(("#%d pcnetStop:\n", PCNET_INST_NR));
     
    16701670static DECLCALLBACK(void) pcnetWakeupReceive(PPDMDEVINS pDevIns)
    16711671{
    1672     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     1672    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    16731673    STAM_COUNTER_INC(&pThis->StatRxOverflowWakeup);
    16741674    if (pThis->hEventOutOfRxSpace != NIL_RTSEMEVENT)
     
    16911691 * @param  fSkipCurrent       if true, don't scan the current RDTE.
    16921692 */
    1693 static void pcnetRdtePoll(PCNetState *pThis, bool fSkipCurrent=false)
     1693static void pcnetRdtePoll(PPCNETSTATE pThis, bool fSkipCurrent=false)
    16941694{
    16951695    STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatRdtePoll), a);
     
    17991799 * @return true if transmit descriptors available
    18001800 */
    1801 static int pcnetTdtePoll(PCNetState *pThis, TMD *tmd)
     1801static int pcnetTdtePoll(PPCNETSTATE pThis, TMD *tmd)
    18021802{
    18031803    STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatTdtePoll), a);
     
    18471847 * @return true if transmit descriptors available
    18481848 */
    1849 static int pcnetCalcPacketLen(PCNetState *pThis, unsigned cb)
     1849static int pcnetCalcPacketLen(PPCNETSTATE pThis, unsigned cb)
    18501850{
    18511851    TMD tmd;
     
    18951895 * Write data into guest receive buffers.
    18961896 */
    1897 static void pcnetReceiveNoSync(PCNetState *pThis, const uint8_t *buf, size_t cbToRecv, bool fAddFCS)
     1897static void pcnetReceiveNoSync(PPCNETSTATE pThis, const uint8_t *buf, size_t cbToRecv, bool fAddFCS)
    18981898{
    18991899    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
     
    19351935            /* Not owned by controller. This should not be possible as
    19361936             * 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)));
    19391938            /* Dump the status of all RX descriptors */
    19401939            const unsigned  cb = 1 << pThis->iLog2DescSize;
     
    21242123static DECLCALLBACK(bool) pcnetXmitQueueConsumer(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem)
    21252124{
    2126     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     2125    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    21272126    NOREF(pItem);
    21282127
     
    21472146 *                      Always set.
    21482147 */
    2149 DECLINLINE(int) pcnetXmitAllocBuf(PCNetState *pThis, size_t cbMin, bool fLoopback,
     2148DECLINLINE(int) pcnetXmitAllocBuf(PPCNETSTATE pThis, size_t cbMin, bool fLoopback,
    21502149                                  PPDMSCATTERGATHER pSgLoop, PPPDMSCATTERGATHER ppSgBuf)
    21512150{
     
    21922191 * @param   pSgBuf          The SG to free.  Can be NULL.
    21932192 */
    2194 DECLINLINE(void) pcnetXmitFreeBuf(PCNetState *pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf)
     2193DECLINLINE(void) pcnetXmitFreeBuf(PPCNETSTATE pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf)
    21952194{
    21962195    if (pSgBuf)
     
    22202219 *                          if an EMT.
    22212220 */
    2222 DECLINLINE(int) pcnetXmitSendBuf(PCNetState *pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf, bool fOnWorkerThread)
     2221DECLINLINE(int) pcnetXmitSendBuf(PPCNETSTATE pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf, bool fOnWorkerThread)
    22232222{
    22242223    int rc;
     
    22652264 * path.
    22662265 */
    2267 static void pcnetXmitRead1stSlow(PCNetState *pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame,
     2266static void pcnetXmitRead1stSlow(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame,
    22682267                                 PPDMSCATTERGATHER pSgBuf)
    22692268{
     
    22882287 * path.
    22892288 */
    2290 static void pcnetXmitReadMoreSlow(PCNetState *pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame,
     2289static void pcnetXmitReadMoreSlow(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, unsigned cbFrame,
    22912290                                  PPDMSCATTERGATHER pSgBuf)
    22922291{
     
    23392338 * Reads the first part of a frame into the scatter gather buffer.
    23402339 */
    2341 DECLINLINE(void) pcnetXmitRead1st(PCNetState *pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,
     2340DECLINLINE(void) pcnetXmitRead1st(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,
    23422341                                  PPDMSCATTERGATHER pSgBuf)
    23432342{
     
    23572356 * Reads more into the current frame.
    23582357 */
    2359 DECLINLINE(void) pcnetXmitReadMore(PCNetState *pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,
     2358DECLINLINE(void) pcnetXmitReadMore(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,
    23602359                                   PPDMSCATTERGATHER pSgBuf)
    23612360{
     
    23772376 * Fails a TMD with a link down error.
    23782377 */
    2379 static void pcnetXmitFailTMDLinkDown(PCNetState *pThis, TMD *pTmd)
     2378static void pcnetXmitFailTMDLinkDown(PPCNETSTATE pThis, TMD *pTmd)
    23802379{
    23812380    /* make carrier error - hope this is correct. */
     
    23912390 * Fails a TMD with a generic error.
    23922391 */
    2393 static void pcnetXmitFailTMDGeneric(PCNetState *pThis, TMD *pTmd)
     2392static void pcnetXmitFailTMDGeneric(PPCNETSTATE pThis, TMD *pTmd)
    23942393{
    23952394    /* make carrier error - hope this is correct. */
     
    24052404 * Try to transmit frames
    24062405 */
    2407 static void pcnetTransmit(PCNetState *pThis)
     2406static void pcnetTransmit(PPCNETSTATE pThis)
    24082407{
    24092408    if (RT_UNLIKELY(!CSR_TXON(pThis)))
     
    24522451 * @threads TX or EMT.
    24532452 */
    2454 static int pcnetAsyncTransmit(PCNetState *pThis, bool fOnWorkerThread)
     2453static int pcnetAsyncTransmit(PPCNETSTATE pThis, bool fOnWorkerThread)
    24552454{
    24562455    Assert(PDMCritSectIsOwner(&pThis->CritSect));
     
    27222721 * @param   fOnWorkerThread     Whether we're on a worker thread or on an EMT.
    27232722 */
    2724 static int pcnetXmitPending(PCNetState *pThis, bool fOnWorkerThread)
     2723static int pcnetXmitPending(PPCNETSTATE pThis, bool fOnWorkerThread)
    27252724{
    27262725    int rc = VINF_SUCCESS;
     
    27632762 * Poll for changes in RX and TX descriptor rings.
    27642763 */
    2765 static void pcnetPollRxTx(PCNetState *pThis)
     2764static void pcnetPollRxTx(PPCNETSTATE pThis)
    27662765{
    27672766    if (CSR_RXON(pThis))
     
    27872786 * @thread EMT, TAP.
    27882787 */
    2789 static void pcnetPollTimerStart(PCNetState *pThis)
     2788static void pcnetPollTimerStart(PPCNETSTATE pThis)
    27902789{
    27912790    TMTimerSetMillies(pThis->CTX_SUFF(pTimerPoll), 2);
     
    27972796 * @thread EMT.
    27982797 */
    2799 static void pcnetPollTimer(PCNetState *pThis)
     2798static void pcnetPollTimer(PPCNETSTATE pThis)
    28002799{
    28012800    STAM_PROFILE_ADV_START(&pThis->StatPollTimer, a);
     
    28582857
    28592858
    2860 static int pcnetCSRWriteU16(PCNetState *pThis, uint32_t u32RAP, uint32_t val)
     2859static int pcnetCSRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val)
    28612860{
    28622861    int      rc  = VINF_SUCCESS;
     
    30703069}
    30713070
    3072 static uint32_t pcnetCSRReadU16(PCNetState *pThis, uint32_t u32RAP)
     3071static uint32_t pcnetCSRReadU16(PPCNETSTATE pThis, uint32_t u32RAP)
    30733072{
    30743073    uint32_t val;
     
    31033102}
    31043103
    3105 static int pcnetBCRWriteU16(PCNetState *pThis, uint32_t u32RAP, uint32_t val)
     3104static int pcnetBCRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val)
    31063105{
    31073106    int rc = VINF_SUCCESS;
     
    31753174}
    31763175
    3177 static uint32_t pcnetMIIReadU16(PCNetState *pThis, uint32_t miiaddr)
     3176static uint32_t pcnetMIIReadU16(PPCNETSTATE pThis, uint32_t miiaddr)
    31783177{
    31793178    uint32_t val;
     
    32893288}
    32903289
    3291 static uint32_t pcnetBCRReadU16(PCNetState *pThis, uint32_t u32RAP)
     3290static uint32_t pcnetBCRReadU16(PPCNETSTATE pThis, uint32_t u32RAP)
    32923291{
    32933292    uint32_t val;
     
    33313330
    33323331#ifdef IN_RING3 /* move down */
    3333 static void pcnetHardReset(PCNetState *pThis)
     3332static void pcnetR3HardReset(PPCNETSTATE pThis)
    33343333{
    33353334    int      i;
     
    33753374#endif /* IN_RING3 */
    33763375
    3377 static void pcnetAPROMWriteU8(PCNetState *pThis, uint32_t addr, uint32_t val)
     3376
     3377/* -=-=-=-=-=- APROM I/O Port access -=-=-=-=-=- */
     3378
     3379static void pcnetAPROMWriteU8(PPCNETSTATE pThis, uint32_t addr, uint32_t val)
    33783380{
    33793381    addr &= 0x0f;
     
    33853387}
    33863388
    3387 static uint32_t pcnetAPROMReadU8(PCNetState *pThis, uint32_t addr)
     3389static uint32_t pcnetAPROMReadU8(PPCNETSTATE pThis, uint32_t addr)
    33883390{
    33893391    uint32_t val = pThis->aPROM[addr &= 0x0f];
     
    33923394}
    33933395
    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 */
     3399PDMBOTHCBDECL(int) pcnetIOPortAPromRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     3400{
     3401    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    37083402    int        rc;
    37093403
     
    37383432
    37393433/**
    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 */
     3436PDMBOTHCBDECL(int) pcnetIOPortAPromWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     3437{
     3438    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    37543439    int        rc;
    37553440
     
    37793464
    37803465
    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
     3469static 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
     3491static 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
     3518static 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
     3549static 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
     3586skip_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
     3593static 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
     3632static 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
     3668skip_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 */
     3679PDMBOTHCBDECL(int) pcnetIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     3680{
     3681    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    37963682    int         rc    = VINF_SUCCESS;
    37973683
     
    38233709
    38243710/**
    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 */
     3713PDMBOTHCBDECL(int) pcnetIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     3714{
     3715    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    38393716    int         rc    = VINF_SUCCESS;
    38403717
     
    38653742
    38663743
    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
     3746static 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
     3755static 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
     3766static 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
     3780static 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
     3799static 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
     3815static 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 */
     3842PDMBOTHCBDECL(int) pcnetMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
     3843{
     3844    PPCNETSTATE pThis = (PPCNETSTATE)pvUser;
    38823845    int         rc    = VINF_SUCCESS;
    38833846
    38843847    /*
    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.
    38863849     */
    38873850    if (GCPhysAddr - pThis->MMIOBase < PCNET_PNPMMIO_SIZE)
     
    39193882
    39203883/**
    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 */
     3886PDMBOTHCBDECL(int) pcnetMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
     3887{
     3888    PPCNETSTATE pThis = (PPCNETSTATE)pvUser;
    39353889    int         rc    = VINF_SUCCESS;
    39363890
     
    39713925
    39723926#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}
    39793932 */
    39803933static DECLCALLBACK(void) pcnetTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    39813934{
    3982     PCNetState *pThis = (PCNetState *)pvUser;
     3935    PPCNETSTATE pThis = (PPCNETSTATE)pvUser;
    39833936    Assert(PDMCritSectIsOwner(&pThis->CritSect));
    39843937
     
    39903943
    39913944/**
    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.}
    39973947 */
    39983948static DECLCALLBACK(void) pcnetTimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    39993949{
    4000     PCNetState *pThis = (PCNetState *)pvUser;
     3950    PPCNETSTATE pThis = (PPCNETSTATE)pvUser;
    40013951    Assert(PDMCritSectIsOwner(&pThis->CritSect));
    40023952
     
    40083958
    40093959/**
    4010  * Restore timer callback.
     3960 * @callback_method_impl{FNTMTIMERDEV, Restore timer callback}
    40113961 *
    40123962 * This is only called when we restore a saved state and temporarily
    40133963 * disconnected the network link to inform the guest that network connections
    40143964 * should be considered lost.
    4015  *
    4016  * @param   pDevIns         Device instance of the device which registered the timer.
    4017  * @param   pTimer          The timer handle.
    40183965 */
    40193966static DECLCALLBACK(void) pcnetTimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    40203967{
    4021     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     3968    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    40223969    int         rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
    40233970    AssertReleaseRC(rc);
     
    40463993}
    40473994
    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.}
    40594000 */
    40604001static DECLCALLBACK(int) pcnetIOPortMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion,
     
    40644005    PPDMDEVINS  pDevIns = pPciDev->pDevIns;
    40654006    RTIOPORT    Port    = (RTIOPORT)GCPhysAddress;
    4066     PCNetState *pThis   = PCIDEV_2_PCNETSTATE(pPciDev);
     4007    PPCNETSTATE pThis   = PCIDEV_2_PCNETSTATE(pPciDev);
    40674008
    40684009    Assert(enmType == PCI_ADDRESS_SPACE_IO);
     
    41074048
    41084049/**
    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.}
    41194051 */
    41204052static DECLCALLBACK(int) pcnetMMIOMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion,
    41214053                                      RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
    41224054{
    4123     PCNetState *pThis = PCIDEV_2_PCNETSTATE(pPciDev);
     4055    PPCNETSTATE pThis = PCIDEV_2_PCNETSTATE(pPciDev);
    41244056    int         rc;
    41254057
     
    41394071
    41404072/**
    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.}
    41514074 */
    41524075static DECLCALLBACK(int) pcnetMMIOSharedMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion,
     
    41614084
    41624085
    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}
    41694090 */
    41704091static DECLCALLBACK(void) pcnetInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    41714092{
    4172     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4093    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    41734094    bool        fRcvRing = false;
    41744095    bool        fXmtRing = false;
     
    43884309
    43894310
     4311/* -=-=-=-=-=- Helper(s) -=-=-=-=-=- */
     4312
    43904313/**
    43914314 * Takes down the link temporarily if it's current status is up.
     
    43994322 * @param  pThis        The PCNet instance data.
    44004323 */
    4401 static void pcnetTempLinkDown(PCNetState *pThis)
     4324static void pcnetTempLinkDown(PPCNETSTATE pThis)
    44024325{
    44034326    if (pThis->fLinkUp)
     
    44134336
    44144337
     4338/* -=-=-=-=-=- Saved State -=-=-=-=-=- */
     4339
    44154340/**
    44164341 * Saves the configuration.
     
    44194344 * @param   pSSM        The saved state handle.
    44204345 */
    4421 static void pcnetSaveConfig(PCNetState *pThis, PSSMHANDLE pSSM)
     4346static void pcnetSaveConfig(PPCNETSTATE pThis, PSSMHANDLE pSSM)
    44224347{
    44234348    SSMR3PutMem(pSSM, &pThis->MacConfigured, sizeof(pThis->MacConfigured));
     
    44284353
    44294354/**
    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.}
    44364356 */
    44374357static DECLCALLBACK(int) pcnetLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
    44384358{
    4439     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4359    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    44404360    pcnetSaveConfig(pThis, pSSM);
    44414361    return VINF_SSM_DONT_CALL_AGAIN;
     
    44444364
    44454365/**
    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.}
    44514368 */
    44524369static DECLCALLBACK(int) pcnetSavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    44534370{
    4454     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4371    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    44554372
    44564373    int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     
    44634380
    44644381/**
    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}
    44704383 */
    44714384static DECLCALLBACK(int) pcnetSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    44724385{
    4473     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4386    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    44744387
    44754388    SSMR3PutBool(pSSM, pThis->fLinkUp);
     
    45024415
    45034416/**
    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.}
    45094419 */
    45104420static DECLCALLBACK(int) pcnetLoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    45114421{
    4512     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4422    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    45134423
    45144424    int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     
    45214431
    45224432/**
    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}
    45304434 */
    45314435static DECLCALLBACK(int) pcnetLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    45324436{
    4533     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4437    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    45344438
    45354439    if (   SSM_VERSION_MAJOR_CHANGED(uVersion, PCNET_SAVEDSTATE_VERSION)
     
    46254529
    46264530
    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 -=-=-=-=-=- */
    46424532
    46434533/**
    46444534 * 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.
    46464538 *
    46474539 * @returns VBox status code.
    4648  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    4649  */
    4650 static int pcnetCanReceive(PCNetState *pThis)
     4540 * @param   pThis           The PC-Net instance data.
     4541 */
     4542static int pcnetCanReceive(PPCNETSTATE pThis)
    46514543{
    46524544    int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     
    46804572static DECLCALLBACK(int) pcnetNetworkDown_WaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
    46814573{
    4682     PCNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkDown);
     4574    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown);
    46834575
    46844576    int rc = pcnetCanReceive(pThis);
     
    47224614static DECLCALLBACK(int) pcnetNetworkDown_Receive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
    47234615{
    4724     PCNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkDown);
     4616    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown);
    47254617    int         rc;
    47264618
     
    47764668static DECLCALLBACK(void) pcnetNetworkDown_XmitPending(PPDMINETWORKDOWN pInterface)
    47774669{
    4778     PCNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkDown);
     4670    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown);
    47794671    pcnetXmitPending(pThis, true /*fOnWorkerThread*/);
    47804672}
    47814673
    47824674
    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}
    47914679 */
    47924680static DECLCALLBACK(int) pcnetGetMac(PPDMINETWORKCONFIG pInterface, PRTMAC pMac)
    47934681{
    4794     PCNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkConfig);
     4682    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig);
    47954683    memcpy(pMac, pThis->aPROM, sizeof(*pMac));
    47964684    return VINF_SUCCESS;
     
    47994687
    48004688/**
    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}
    48064690 */
    48074691static DECLCALLBACK(PDMNETWORKLINKSTATE) pcnetGetLinkState(PPDMINETWORKCONFIG pInterface)
    48084692{
    4809     PCNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkConfig);
     4693    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig);
    48104694    if (pThis->fLinkUp && !pThis->fLinkTempDown)
    48114695        return PDMNETWORKLINKSTATE_UP;
     
    48204704
    48214705/**
    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}
    48284707 */
    48294708static DECLCALLBACK(int) pcnetSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState)
    48304709{
    4831     PCNetState *pThis = RT_FROM_MEMBER(pInterface, PCNetState, INetworkConfig);
     4710    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig);
    48324711    bool fLinkUp;
    48334712    if (    enmState != PDMNETWORKLINKSTATE_DOWN
     
    48684747
    48694748
    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}
    48774753 */
    48784754static DECLCALLBACK(int) pcnetQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    48794755{
    4880     PCNetState *pThis = (PCNetState *)( (uintptr_t)pInterface - RT_OFFSETOF(PCNetState, ILeds) );
     4756    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, ILeds);
    48814757    if (iLUN == 0)
    48824758    {
     
    48884764
    48894765
    4890 /**
    4891  * @copydoc FNPDMDEVPOWEROFF
     4766/* -=-=-=-=-=- PCNETSTATE::IBase (LUN#0) -=-=-=-=-=- */
     4767
     4768/**
     4769 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     4770 */
     4771static 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}
    48924787 */
    48934788static DECLCALLBACK(void) pcnetPowerOff(PPDMDEVINS pDevIns)
     
    48994794
    49004795/**
    4901  * Detach notification.
     4796 * @interface_method_impl{PDMDEVREG,pfnDetach}
    49024797 *
    49034798 * 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.
    49084799 */
    49094800static DECLCALLBACK(void) pcnetDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    49104801{
    4911     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4802    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    49124803    Log(("#%d pcnetDetach:\n", PCNET_INST_NR));
    49134804
     
    49334824
    49344825/**
    4935  * Attach the Network attachment.
    4936  *
     4826 * @interface_method_impl{PDMDEVREG,pfnAttach}
    49374827 * 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.
    49454828 */
    49464829static DECLCALLBACK(int) pcnetAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    49474830{
    4948     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4831    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    49494832    LogFlow(("#%d pcnetAttach:\n", PCNET_INST_NR));
    49504833
     
    49984881
    49994882/**
    5000  * @copydoc FNPDMDEVSUSPEND
     4883 * @interface_method_impl{PDMDEVREG,pfnSuspend}
    50014884 */
    50024885static DECLCALLBACK(void) pcnetSuspend(PPDMDEVINS pDevIns)
     
    50084891
    50094892/**
    5010  * @copydoc FNPDMDEVRESET
     4893 * @interface_method_impl{PDMDEVREG,pfnReset}
    50114894 */
    50124895static DECLCALLBACK(void) pcnetReset(PPDMDEVINS pDevIns)
    50134896{
    5014     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4897    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    50154898    if (pThis->fLinkTempDown)
    50164899    {
     
    50234906
    50244907    /** @todo How to flush the queues? */
    5025     pcnetHardReset(pThis);
    5026 }
    5027 
    5028 
    5029 /**
    5030  * @copydoc FNPDMDEVRELOCATE
     4908    pcnetR3HardReset(pThis);
     4909}
     4910
     4911
     4912/**
     4913 * @interface_method_impl{PDMDEVREG,pfnRelocate}
    50314914 */
    50324915static DECLCALLBACK(void) pcnetRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    50334916{
    5034     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4917    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    50354918    pThis->pDevInsRC     = PDMDEVINS_2_RCPTR(pDevIns);
    50364919    pThis->pXmitQueueRC  = PDMQueueRCPtr(pThis->pXmitQueueR3);
     
    50494932
    50504933/**
    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}
    50584935 */
    50594936static DECLCALLBACK(int) pcnetDestruct(PPDMDEVINS pDevIns)
    50604937{
    5061     PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4938    PPCNETSTATE pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    50624939    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    50634940
     
    50784955static DECLCALLBACK(int) pcnetConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    50794956{
    5080     PCNetState     *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);
     4957    PPCNETSTATE     pThis = PDMINS_2_DATA(pDevIns, PPCNETSTATE);
    50814958    PPDMIBASE       pBase;
    50824959    char            szTmp[128];
     
    53745251     * Reset the device state. (Do after attaching.)
    53755252     */
    5376     pcnetHardReset(pThis);
     5253    pcnetR3HardReset(pThis);
    53775254
    53785255#ifdef VBOX_WITH_STATISTICS
     
    54765353    ~0U,
    54775354    /* cbInstance */
    5478     sizeof(PCNetState),
     5355    sizeof(PCNETSTATE),
    54795356    /* pfnConstruct */
    54805357    pcnetConstruct,
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp

    r44876 r44892  
    307307    CHECK_MEMBER_ALIGNMENT(PCIBUS, devices, 16);
    308308    CHECK_MEMBER_ALIGNMENT(PCIGLOBALS, pci_irq_levels, 16);
    309     CHECK_MEMBER_ALIGNMENT(PCNetState, u64LastPoll, 8);
    310     CHECK_MEMBER_ALIGNMENT(PCNetState, CritSect, 8);
    311     CHECK_MEMBER_ALIGNMENT(PCNetState, StatReceiveBytes, 8);
     309    CHECK_MEMBER_ALIGNMENT(PCNETSTATE, u64LastPoll, 8);
     310    CHECK_MEMBER_ALIGNMENT(PCNETSTATE, CritSect, 8);
     311    CHECK_MEMBER_ALIGNMENT(PCNETSTATE, StatReceiveBytes, 8);
    312312#ifdef VBOX_WITH_STATISTICS
    313     CHECK_MEMBER_ALIGNMENT(PCNetState, StatMMIOReadRZ, 8);
     313    CHECK_MEMBER_ALIGNMENT(PCNETSTATE, StatMMIOReadRZ, 8);
    314314#endif
    315315    CHECK_MEMBER_ALIGNMENT(PITSTATE, StatPITIrq, 8);
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r44876 r44892  
    424424
    425425    /* Network/DevPCNet.cpp */
    426     GEN_CHECK_SIZE(PCNetState);
    427     GEN_CHECK_OFF(PCNetState, PciDev);
     426    GEN_CHECK_SIZE(PCNETSTATE);
     427    GEN_CHECK_OFF(PCNETSTATE, PciDev);
    428428#ifndef PCNET_NO_POLLING
    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);
     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);
    483483#ifdef PCNET_NO_POLLING
    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);
     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);
    501501#ifdef VBOX_WITH_STATISTICS
    502     GEN_CHECK_OFF(PCNetState, StatMMIOReadR3);
    503     GEN_CHECK_OFF(PCNetState, StatMMIOReadRZ);
    504     GEN_CHECK_OFF(PCNetState, StatMIIReads);
     502    GEN_CHECK_OFF(PCNETSTATE, StatMMIOReadR3);
     503    GEN_CHECK_OFF(PCNETSTATE, StatMMIOReadRZ);
     504    GEN_CHECK_OFF(PCNETSTATE, StatMIIReads);
    505505# ifdef PCNET_NO_POLLING
    506     GEN_CHECK_OFF(PCNetState, StatRCVRingWrite);
    507     GEN_CHECK_OFF(PCNetState, StatRingWriteOutsideRangeR3);
     506    GEN_CHECK_OFF(PCNETSTATE, StatRCVRingWrite);
     507    GEN_CHECK_OFF(PCNETSTATE, StatRingWriteOutsideRangeR3);
    508508# endif
    509509#endif
Note: See TracChangeset for help on using the changeset viewer.

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