VirtualBox

Changeset 82134 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Nov 23, 2019 11:03:32 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134944
Message:

DevPCNet: Converted timers. bugref:9218

File:
1 edited

Legend:

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

    r82129 r82134  
    328328    /** LUN\#0: The network config port interface. */
    329329    PDMINETWORKCONFIG                   INetworkConfig;
    330     /** Software Interrupt timer - R3. */
    331     PTMTIMERR3                          pTimerSoftIntR3;
    332 #ifndef PCNET_NO_POLLING
    333     /** Poll timer - R3. */
    334     PTMTIMERR3                          pTimerPollR3;
    335 #endif
    336     /** Restore timer.
    337      *  This is used to disconnect and reconnect the link after a restore. */
    338     PTMTIMERR3                          pTimerRestore;
    339330
    340331    /** Pointer to the device instance - R0. */
     
    346337    /** Pointer to the connector of the attached network driver - R0. */
    347338    PPDMINETWORKUPR0                    pDrvR0;
    348     /** Software Interrupt timer - R0. */
    349     PTMTIMERR0                          pTimerSoftIntR0;
    350 #ifndef PCNET_NO_POLLING
    351     /** Poll timer - R0. */
    352     PTMTIMERR0                          pTimerPollR0;
    353 #endif
    354339
    355340    /** Pointer to the device instance - RC. */
     
    361346    /** Pointer to the connector of the attached network driver - RC. */
    362347    PPDMINETWORKUPRC                    pDrvRC;
    363     /** Software Interrupt timer - RC. */
    364     PTMTIMERRC                          pTimerSoftIntRC;
     348
     349    /** Software Interrupt timer - R3. */
     350    TMTIMERHANDLE                       hTimerSoftInt;
    365351#ifndef PCNET_NO_POLLING
    366     /** Poll timer - RC. */
    367     PTMTIMERRC                          pTimerPollRC;
    368 #endif
    369 
    370     /** Alignment padding. */
    371     uint32_t                            Alignment1;
     352    /** Poll timer - R3. */
     353    TMTIMERHANDLE                       hTimerPoll;
     354#endif
     355    /** Restore timer.
     356     *  This is used to disconnect and reconnect the link after a restore. */
     357    TMTIMERHANDLE                       hTimerRestore;
    372358
    373359    /** Register Address Pointer */
     
    691677
    692678#ifndef PCNET_NO_POLLING
    693 static void pcnetPollTimerStart(PPCNETSTATE pThis);
     679static void pcnetPollTimerStart(PPDMDEVINS pDevIns, PPCNETSTATE pThis);
    694680#endif
    695681static int  pcnetXmitPending(PPCNETSTATE pThis, bool fOnWorkerThread);
     
    11661152
    11671153static void     pcnetPollRxTx(PPCNETSTATE pThis);
    1168 static void     pcnetPollTimer(PPCNETSTATE pThis);
     1154static void     pcnetPollTimer(PPDMDEVINS pDevIns, PPCNETSTATE pThis);
    11691155static void     pcnetUpdateIrq(PPCNETSTATE pThis);
    11701156static uint32_t pcnetBCRReadU16(PPCNETSTATE pThis, uint32_t u32RAP);
    1171 static int      pcnetBCRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val);
     1157static int      pcnetBCRWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val);
    11721158
    11731159
     
    14221408
    14231409#ifdef IN_RING3
    1424 #ifdef PCNET_NO_POLLING
    1425 static void pcnetUpdateRingHandlers(PPCNETSTATE pThis)
     1410
     1411# ifdef PCNET_NO_POLLING
     1412static void pcnetR3UpdateRingHandlers(PPCNETSTATE pThis)
    14261413{
    14271414    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
    14281415    int rc;
    14291416
    1430     Log(("pcnetUpdateRingHandlers TD %RX32 size %#x -> %RX32 ?size? %#x\n", pThis->TDRAPhysOld, pThis->cbTDRAOld, pThis->GCTDRA, pcnetTdraAddr(pThis, 0)));
    1431     Log(("pcnetUpdateRingHandlers RX %RX32 size %#x -> %RX32 ?size? %#x\n", pThis->RDRAPhysOld, pThis->cbRDRAOld, pThis->GCRDRA, pcnetRdraAddr(pThis, 0)));
     1417    Log(("pcnetR3UpdateRingHandlers TD %RX32 size %#x -> %RX32 ?size? %#x\n", pThis->TDRAPhysOld, pThis->cbTDRAOld, pThis->GCTDRA, pcnetTdraAddr(pThis, 0)));
     1418    Log(("pcnetR3UpdateRingHandlers RX %RX32 size %#x -> %RX32 ?size? %#x\n", pThis->RDRAPhysOld, pThis->cbRDRAOld, pThis->GCRDRA, pcnetRdraAddr(pThis, 0)));
    14321419
    14331420    /** @todo unregister order not correct! */
    14341421
    1435 #ifdef PCNET_MONITOR_RECEIVE_RING
     1422#  ifdef PCNET_MONITOR_RECEIVE_RING
    14361423    if (pThis->GCRDRA != pThis->RDRAPhysOld || CSR_RCVRL(pThis) != pThis->cbRDRAOld)
    14371424    {
     
    14521439        pThis->cbRDRAOld   = pcnetRdraAddr(pThis, 0);
    14531440    }
    1454 #endif /* PCNET_MONITOR_RECEIVE_RING */
    1455 
    1456 #ifdef PCNET_MONITOR_RECEIVE_RING
     1441#  endif /* PCNET_MONITOR_RECEIVE_RING */
     1442
     1443#  ifdef PCNET_MONITOR_RECEIVE_RING
    14571444    /* 3 possibilities:
    14581445     * 1) TDRA on different physical page as RDRA
     
    14681455        ||  TDRAPageStart > RDRAPageEnd)
    14691456    {
    1470 #endif /* PCNET_MONITOR_RECEIVE_RING */
     1457#  endif /* PCNET_MONITOR_RECEIVE_RING */
    14711458        /* 1) */
    14721459        if (pThis->GCTDRA != pThis->TDRAPhysOld || CSR_XMTRL(pThis) != pThis->cbTDRAOld)
     
    14891476            pThis->cbTDRAOld   = pcnetTdraAddr(pThis, 0);
    14901477        }
    1491 #ifdef PCNET_MONITOR_RECEIVE_RING
     1478#  ifdef PCNET_MONITOR_RECEIVE_RING
    14921479    }
    14931480    else
     
    15021489    }
    15031490    /* else 2) */
    1504 #endif
    1505 }
    1506 #endif /* PCNET_NO_POLLING */
    1507 
    1508 static void pcnetInit(PPCNETSTATE pThis)
     1491#  endif
     1492}
     1493# endif /* PCNET_NO_POLLING */
     1494
     1495static void pcnetR3Init(PPCNETSTATE pThis)
    15091496{
    15101497    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis);
    1511     Log(("#%d pcnetInit: init_addr=%#010x\n", PCNET_INST_NR, PHYSADDR(pThis, CSR_IADR(pThis))));
     1498    Log(("#%d pcnetR3Init: init_addr=%#010x\n", PCNET_INST_NR, PHYSADDR(pThis, CSR_IADR(pThis))));
    15121499
    15131500    /** @todo Documentation says that RCVRL and XMTRL are stored as two's complement!
    15141501     *        Software is allowed to write these registers directly. */
    1515 #define PCNET_INIT() do { \
    1516         PDMDevHlpPhysRead(pDevIns, PHYSADDR(pThis, CSR_IADR(pThis)),         \
    1517                           (uint8_t *)&initblk, sizeof(initblk));             \
    1518         pThis->aCSR[15]  = RT_LE2H_U16(initblk.mode);                        \
    1519         CSR_RCVRL(pThis) = (initblk.rlen < 9) ? (1 << initblk.rlen) : 512;   \
    1520         CSR_XMTRL(pThis) = (initblk.tlen < 9) ? (1 << initblk.tlen) : 512;   \
    1521         pThis->aCSR[ 6]  = (initblk.tlen << 12) | (initblk.rlen << 8);       \
    1522         pThis->aCSR[ 8]  = RT_LE2H_U16(initblk.ladrf1);                      \
    1523         pThis->aCSR[ 9]  = RT_LE2H_U16(initblk.ladrf2);                      \
    1524         pThis->aCSR[10]  = RT_LE2H_U16(initblk.ladrf3);                      \
    1525         pThis->aCSR[11]  = RT_LE2H_U16(initblk.ladrf4);                      \
    1526         pThis->aCSR[12]  = RT_LE2H_U16(initblk.padr1);                       \
    1527         pThis->aCSR[13]  = RT_LE2H_U16(initblk.padr2);                       \
    1528         pThis->aCSR[14]  = RT_LE2H_U16(initblk.padr3);                       \
    1529         pThis->GCRDRA    = PHYSADDR(pThis, initblk.rdra);                    \
    1530         pThis->GCTDRA    = PHYSADDR(pThis, initblk.tdra);                    \
    1531 } while (0)
     1502# define PCNET_INIT() do { \
     1503            PDMDevHlpPhysRead(pDevIns, PHYSADDR(pThis, CSR_IADR(pThis)),         \
     1504                              (uint8_t *)&initblk, sizeof(initblk));             \
     1505            pThis->aCSR[15]  = RT_LE2H_U16(initblk.mode);                        \
     1506            CSR_RCVRL(pThis) = (initblk.rlen < 9) ? (1 << initblk.rlen) : 512;   \
     1507            CSR_XMTRL(pThis) = (initblk.tlen < 9) ? (1 << initblk.tlen) : 512;   \
     1508            pThis->aCSR[ 6]  = (initblk.tlen << 12) | (initblk.rlen << 8);       \
     1509            pThis->aCSR[ 8]  = RT_LE2H_U16(initblk.ladrf1);                      \
     1510            pThis->aCSR[ 9]  = RT_LE2H_U16(initblk.ladrf2);                      \
     1511            pThis->aCSR[10]  = RT_LE2H_U16(initblk.ladrf3);                      \
     1512            pThis->aCSR[11]  = RT_LE2H_U16(initblk.ladrf4);                      \
     1513            pThis->aCSR[12]  = RT_LE2H_U16(initblk.padr1);                       \
     1514            pThis->aCSR[13]  = RT_LE2H_U16(initblk.padr2);                       \
     1515            pThis->aCSR[14]  = RT_LE2H_U16(initblk.padr3);                       \
     1516            pThis->GCRDRA    = PHYSADDR(pThis, initblk.rdra);                    \
     1517            pThis->GCTDRA    = PHYSADDR(pThis, initblk.tdra);                    \
     1518        } while (0)
    15321519
    15331520    if (BCR_SSIZE32(pThis))
     
    15481535    }
    15491536
    1550 #undef PCNET_INIT
     1537# undef PCNET_INIT
    15511538
    15521539    size_t cbRxBuffers = 0;
     
    15881575    CSR_XMTRC(pThis) = CSR_XMTRL(pThis);
    15891576
    1590 #ifdef PCNET_NO_POLLING
    1591     pcnetUpdateRingHandlers(pThis);
    1592 #endif
     1577# ifdef PCNET_NO_POLLING
     1578    pcnetR3UpdateRingHandlers(pThis);
     1579# endif
    15931580
    15941581    /* Reset cached RX and TX states */
     
    16091596    pThis->aCSR[0] &= ~0x0004;       /* clear STOP bit */
    16101597}
     1598
    16111599#endif /* IN_RING3 */
    16121600
     
    16141602 * Start RX/TX operation.
    16151603 */
    1616 static void pcnetStart(PPCNETSTATE pThis)
     1604static void pcnetStart(PPDMDEVINS pDevIns, PPCNETSTATE pThis)
    16171605{
    16181606    Log(("#%d pcnetStart:\n", PCNET_INST_NR));
     
    16291617    pThis->aCSR[0] |=  0x0002;       /* STRT */
    16301618#ifndef PCNET_NO_POLLING
    1631     pcnetPollTimerStart(pThis);      /* start timer if it was stopped */
     1619    pcnetPollTimerStart(pDevIns, pThis); /* start timer if it was stopped */
    16321620#endif
    16331621}
     
    16361624 * Stop RX/TX operation.
    16371625 */
    1638 static void pcnetStop(PPCNETSTATE pThis)
     1626static void pcnetStop(PPDMDEVINS pDevIns, PPCNETSTATE pThis)
    16391627{
    16401628    Log(("#%d pcnetStop:\n", PCNET_INST_NR));
     
    16421630    pThis->aCSR[4] &= ~0x02c2;
    16431631    pThis->aCSR[5] &= ~0x0011;
    1644     pcnetPollTimer(pThis);
     1632    pcnetPollTimer(pDevIns, pThis);
    16451633}
    16461634
     
    28192807 * @thread EMT, TAP.
    28202808 */
    2821 static void pcnetPollTimerStart(PPCNETSTATE pThis)
    2822 {
    2823     TMTimerSetMillies(pThis->CTX_SUFF(pTimerPoll), 2);
     2809static void pcnetPollTimerStart(PPDMDEVINS pDevIns, PPCNETSTATE pThis)
     2810{
     2811    PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerPoll, 2);
    28242812}
    28252813#endif
     
    28302818 * @thread EMT.
    28312819 */
    2832 static void pcnetPollTimer(PPCNETSTATE pThis)
     2820static void pcnetPollTimer(PPDMDEVINS pDevIns, PPCNETSTATE pThis)
    28332821{
    28342822    STAM_PROFILE_ADV_START(&pThis->StatPollTimer, a);
     
    28772865        pcnetPollRxTx(pThis);
    28782866#else
    2879         uint64_t u64Now = TMTimerGet(pThis->CTX_SUFF(pTimerPoll));
     2867        uint64_t u64Now = PDMDevHlpTimerGet(pDevIns, pThis->hTimerPoll);
    28802868        if (RT_UNLIKELY(u64Now - pThis->u64LastPoll > 200000))
    28812869        {
     
    28832871            pcnetPollRxTx(pThis);
    28842872        }
    2885         if (!TMTimerIsActive(pThis->CTX_SUFF(pTimerPoll)))
    2886             pcnetPollTimerStart(pThis);
     2873        if (!PDMDevHlpTimerIsActive(pDevIns, pThis->hTimerPoll))
     2874            pcnetPollTimerStart(pDevIns, pThis);
    28872875#endif
    28882876    }
     
    28912879
    28922880
    2893 static int pcnetCSRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val)
     2881static int pcnetCSRWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val)
    28942882{
    28952883    int      rc  = VINF_SUCCESS;
     
    29172905                if (!(csr0 & 0x0001/*init*/) && (val & 1))
    29182906                {
    2919                     Log(("#%d pcnetCSRWriteU16: pcnetInit requested => HC\n", PCNET_INST_NR));
     2907                    Log(("#%d pcnetCSRWriteU16: pcnetR3Init requested => HC\n", PCNET_INST_NR));
    29202908                    return VINF_IOM_R3_IOPORT_WRITE;
    29212909                }
     
    29242912
    29252913                if (!CSR_STOP(pThis) && (val & 4))
    2926                     pcnetStop(pThis);
     2914                    pcnetStop(pDevIns, pThis);
    29272915
    29282916#ifdef IN_RING3
    29292917                if (!CSR_INIT(pThis) && (val & 1))
    2930                     pcnetInit(pThis);
     2918                    pcnetR3Init(pThis);
    29312919#endif
    29322920
    29332921                if (!CSR_STRT(pThis) && (val & 2))
    2934                     pcnetStart(pThis);
     2922                    pcnetStart(pDevIns, pThis);
    29352923
    29362924                if (CSR_TDMD(pThis))
     
    30223010            break;
    30233011        case 16: /* IADRL */
    3024             return pcnetCSRWriteU16(pThis, 1, val);
     3012            return pcnetCSRWriteU16(pDevIns, pThis, 1, val);
    30253013        case 17: /* IADRH */
    3026             return pcnetCSRWriteU16(pThis, 2, val);
     3014            return pcnetCSRWriteU16(pDevIns, pThis, 2, val);
    30273015
    30283016        /*
     
    30673055
    30683056        case 58: /* Software Style */
    3069             rc = pcnetBCRWriteU16(pThis, BCR_SWS, val);
     3057            rc = pcnetBCRWriteU16(pDevIns, pThis, BCR_SWS, val);
    30703058            break;
    30713059
     
    30743062         * try fix that right now. So, as a quick hack for 'alt init' I'll just correct them here.
    30753063         */
    3076         case 76: /* RCVRL */ /** @todo call pcnetUpdateRingHandlers */
     3064        case 76: /* RCVRL */ /** @todo call pcnetR3UpdateRingHandlers */
    30773065                             /** @todo receive ring length is stored in two's complement! */
    3078         case 78: /* XMTRL */ /** @todo call pcnetUpdateRingHandlers */
     3066        case 78: /* XMTRL */ /** @todo call pcnetR3UpdateRingHandlers */
    30793067                             /** @todo transmit ring length is stored in two's complement! */
    30803068            if (!CSR_STOP(pThis) && !CSR_SPND(pThis))
     
    31483136}
    31493137
    3150 static int pcnetBCRWriteU16(PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val)
     3138static int pcnetBCRWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val)
    31513139{
    31523140    int rc = VINF_SUCCESS;
     
    32043192            pThis->aBCR[BCR_STVAL] = val;
    32053193            if (pThis->uDevType == DEV_AM79C973)
    3206                 TMTimerSetNano(pThis->CTX_SUFF(pTimerSoftInt), 12800U * val);
     3194                PDMDevHlpTimerSetNano(pDevIns, pThis->hTimerSoftInt, 12800U * val);
    32073195            break;
    32083196
     
    35763564
    35773565
    3578 static int pcnetIoportWriteU8(PPCNETSTATE pThis, uint32_t addr, uint32_t val)
     3566static int pcnetIoPortWriteU8(PPCNETSTATE pThis, uint32_t addr, uint32_t val)
    35793567{
    35803568    RT_NOREF1(val);
    35813569#ifdef PCNET_DEBUG_IO
    3582     Log2(("#%d pcnetIoportWriteU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val));
     3570    Log2(("#%d pcnetIoPortWriteU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val));
    35833571#endif
    35843572    if (RT_LIKELY(!BCR_DWIO(pThis)))
     
    35913579    }
    35923580    else
    3593         Log(("#%d pcnetIoportWriteU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
     3581        Log(("#%d pcnetIoPortWriteU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
    35943582
    35953583    return VINF_SUCCESS;
    35963584}
    35973585
    3598 static uint32_t pcnetIoportReadU8(PPCNETSTATE pThis, uint32_t addr, int *pRC)
     3586static uint32_t pcnetIoPortReadU8(PPCNETSTATE pThis, uint32_t addr, int *pRC)
    35993587{
    36003588    uint32_t val = UINT32_MAX;
     
    36133601    }
    36143602    else
    3615         Log(("#%d pcnetIoportReadU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xff));
     3603        Log(("#%d pcnetIoPortReadU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xff));
    36163604
    36173605    pcnetUpdateIrq(pThis);
    36183606
    36193607#ifdef PCNET_DEBUG_IO
    3620     Log2(("#%d pcnetIoportReadU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xff));
     3608    Log2(("#%d pcnetIoPortReadU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xff));
    36213609#endif
    36223610    return val;
    36233611}
    36243612
    3625 static int pcnetIoportWriteU16(PPCNETSTATE pThis, uint32_t addr, uint32_t val)
     3613static int pcnetIoPortWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, uint32_t val)
    36263614{
    36273615    int rc = VINF_SUCCESS;
    36283616
    36293617#ifdef PCNET_DEBUG_IO
    3630     Log2(("#%d pcnetIoportWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val));
     3618    Log2(("#%d pcnetIoPortWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val));
    36313619#endif
    36323620    if (RT_LIKELY(!BCR_DWIO(pThis)))
     
    36353623        {
    36363624            case 0x00: /* RDP */
    3637                 pcnetPollTimer(pThis);
    3638                 rc = pcnetCSRWriteU16(pThis, pThis->u32RAP, val);
     3625                pcnetPollTimer(pDevIns, pThis);
     3626                rc = pcnetCSRWriteU16(pDevIns, pThis, pThis->u32RAP, val);
    36393627                pcnetUpdateIrq(pThis);
    36403628                break;
     
    36433631                break;
    36443632            case 0x06: /* BDP */
    3645                 rc = pcnetBCRWriteU16(pThis, pThis->u32RAP, val);
     3633                rc = pcnetBCRWriteU16(pDevIns, pThis, pThis->u32RAP, val);
    36463634                break;
    36473635        }
    36483636    }
    36493637    else
    3650         Log(("#%d pcnetIoportWriteU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
     3638        Log(("#%d pcnetIoPortWriteU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
    36513639
    36523640    return rc;
    36533641}
    36543642
    3655 static uint32_t pcnetIoportReadU16(PPCNETSTATE pThis, uint32_t addr, int *pRC)
     3643static uint32_t pcnetIoPortReadU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, int *pRC)
    36563644{
    36573645    uint32_t val = ~0U;
     
    36673655                /** Polling is then useless here and possibly expensive. */
    36683656                if (!CSR_DPOLL(pThis))
    3669                     pcnetPollTimer(pThis);
     3657                    pcnetPollTimer(pDevIns, pThis);
    36703658
    36713659                val = pcnetCSRReadU16(pThis, pThis->u32RAP);
     
    36863674    }
    36873675    else
    3688         Log(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xffff));
     3676        Log(("#%d pcnetIoPortReadU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xffff));
    36893677
    36903678    pcnetUpdateIrq(pThis);
     
    36923680skip_update_irq:
    36933681#ifdef PCNET_DEBUG_IO
    3694     Log2(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xffff));
     3682    Log2(("#%d pcnetIoPortReadU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val & 0xffff));
    36953683#endif
    36963684    return val;
    36973685}
    36983686
    3699 static int pcnetIoportWriteU32(PPCNETSTATE pThis, uint32_t addr, uint32_t val)
     3687static int pcnetIoPortWriteU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, uint32_t val)
    37003688{
    37013689    int rc = VINF_SUCCESS;
    37023690
    37033691#ifdef PCNET_DEBUG_IO
    3704     Log2(("#%d pcnetIoportWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR,
     3692    Log2(("#%d pcnetIoPortWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR,
    37053693         addr, val));
    37063694#endif
     
    37103698        {
    37113699            case 0x00: /* RDP */
    3712                 pcnetPollTimer(pThis);
    3713                 rc = pcnetCSRWriteU16(pThis, pThis->u32RAP, val & 0xffff);
     3700                pcnetPollTimer(pDevIns, pThis);
     3701                rc = pcnetCSRWriteU16(pDevIns, pThis, pThis->u32RAP, val & 0xffff);
    37143702                pcnetUpdateIrq(pThis);
    37153703                break;
     
    37183706                break;
    37193707            case 0x0c: /* BDP */
    3720                 rc = pcnetBCRWriteU16(pThis, pThis->u32RAP, val & 0xffff);
     3708                rc = pcnetBCRWriteU16(pDevIns, pThis, pThis->u32RAP, val & 0xffff);
    37213709                break;
    37223710        }
     
    37253713    {
    37263714        /* switch device to dword I/O mode */
    3727         pcnetBCRWriteU16(pThis, BCR_BSBC, pcnetBCRReadU16(pThis, BCR_BSBC) | 0x0080);
     3715        pcnetBCRWriteU16(pDevIns, pThis, BCR_BSBC, pcnetBCRReadU16(pThis, BCR_BSBC) | 0x0080);
    37283716#ifdef PCNET_DEBUG_IO
    37293717        Log2(("device switched into dword i/o mode\n"));
     
    37313719    }
    37323720    else
    3733         Log(("#%d pcnetIoportWriteU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
     3721        Log(("#%d pcnetIoPortWriteU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
    37343722
    37353723    return rc;
    37363724}
    37373725
    3738 static uint32_t pcnetIoportReadU32(PPCNETSTATE pThis, uint32_t addr, int *pRC)
     3726static uint32_t pcnetIoPortReadU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, int *pRC)
    37393727{
    37403728    uint32_t val = ~0U;
     
    37503738                /** Polling is then useless here and possibly expensive. */
    37513739                if (!CSR_DPOLL(pThis))
    3752                     pcnetPollTimer(pThis);
     3740                    pcnetPollTimer(pDevIns, pThis);
    37533741
    37543742                val = pcnetCSRReadU16(pThis, pThis->u32RAP);
     
    37693757    }
    37703758    else
    3771         Log(("#%d pcnetIoportReadU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
     3759        Log(("#%d pcnetIoPortReadU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNET_INST_NR, addr, val));
    37723760    pcnetUpdateIrq(pThis);
    37733761
    37743762skip_update_irq:
    37753763#ifdef PCNET_DEBUG_IO
    3776     Log2(("#%d pcnetIoportReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val));
     3764    Log2(("#%d pcnetIoPortReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val));
    37773765#endif
    37783766    return val;
     
    37933781    switch (cb)
    37943782    {
    3795         case 1: *pu32 = pcnetIoportReadU8(pThis, Port, &rc); break;
    3796         case 2: *pu32 = pcnetIoportReadU16(pThis, Port, &rc); break;
    3797         case 4: *pu32 = pcnetIoportReadU32(pThis, Port, &rc); break;
     3783        case 1: *pu32 = pcnetIoPortReadU8(pThis, Port, &rc); break;
     3784        case 2: *pu32 = pcnetIoPortReadU16(pDevIns, pThis, Port, &rc); break;
     3785        case 4: *pu32 = pcnetIoPortReadU32(pDevIns, pThis, Port, &rc); break;
    37983786        default:
    37993787            rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS,
     
    38213809    switch (cb)
    38223810    {
    3823         case 1: rc = pcnetIoportWriteU8(pThis, Port, u32); break;
    3824         case 2: rc = pcnetIoportWriteU16(pThis, Port, u32); break;
    3825         case 4: rc = pcnetIoportWriteU32(pThis, Port, u32); break;
     3811        case 1: rc = pcnetIoPortWriteU8(pThis, Port, u32); break;
     3812        case 2: rc = pcnetIoPortWriteU16(pDevIns, pThis, Port, u32); break;
     3813        case 4: rc = pcnetIoPortWriteU32(pDevIns, pThis, Port, u32); break;
    38263814        default:
    38273815            rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS,
     
    38583846}
    38593847
    3860 static void pcnetMMIOWriteU16(PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val)
     3848static void pcnetMMIOWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val)
    38613849{
    38623850#ifdef PCNET_DEBUG_IO
     
    38643852#endif
    38653853    if (addr & 0x10)
    3866         pcnetIoportWriteU16(pThis, addr & 0x0f, val);
     3854        pcnetIoPortWriteU16(pDevIns, pThis, addr & 0x0f, val);
    38673855    else
    38683856    {
     
    38723860}
    38733861
    3874 static uint32_t pcnetMMIOReadU16(PPCNETSTATE pThis, RTGCPHYS addr)
     3862static uint32_t pcnetMMIOReadU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr)
    38753863{
    38763864    uint32_t val = ~0U;
     
    38783866
    38793867    if (addr & 0x10)
    3880         val = pcnetIoportReadU16(pThis, addr & 0x0f, &rc);
     3868        val = pcnetIoPortReadU16(pDevIns, pThis, addr & 0x0f, &rc);
    38813869    else
    38823870    {
     
    38913879}
    38923880
    3893 static void pcnetMMIOWriteU32(PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val)
     3881static void pcnetMMIOWriteU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val)
    38943882{
    38953883#ifdef PCNET_DEBUG_IO
     
    38973885#endif
    38983886    if (addr & 0x10)
    3899         pcnetIoportWriteU32(pThis, addr & 0x0f, val);
     3887        pcnetIoPortWriteU32(pDevIns, pThis, addr & 0x0f, val);
    39003888    else
    39013889    {
     
    39073895}
    39083896
    3909 static uint32_t pcnetMMIOReadU32(PPCNETSTATE pThis, RTGCPHYS addr)
     3897static uint32_t pcnetMMIOReadU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr)
    39103898{
    39113899    uint32_t val;
     
    39133901
    39143902    if (addr & 0x10)
    3915         val = pcnetIoportReadU32(pThis, addr & 0x0f, &rc);
     3903        val = pcnetIoPortReadU32(pDevIns, pThis, addr & 0x0f, &rc);
    39163904    else
    39173905    {
     
    39503938        {
    39513939            case 1:  *(uint8_t  *)pv = pcnetMMIOReadU8 (pThis, GCPhysAddr); break;
    3952             case 2:  *(uint16_t *)pv = pcnetMMIOReadU16(pThis, GCPhysAddr); break;
    3953             case 4:  *(uint32_t *)pv = pcnetMMIOReadU32(pThis, GCPhysAddr); break;
     3940            case 2:  *(uint16_t *)pv = pcnetMMIOReadU16(pDevIns, pThis, GCPhysAddr); break;
     3941            case 4:  *(uint32_t *)pv = pcnetMMIOReadU32(pDevIns, pThis, GCPhysAddr); break;
    39543942            default:
    39553943                rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS,
     
    39873975        {
    39883976            case 1:  pcnetMMIOWriteU8 (pThis, GCPhysAddr, *(uint8_t  *)pv); break;
    3989             case 2:  pcnetMMIOWriteU16(pThis, GCPhysAddr, *(uint16_t *)pv); break;
    3990             case 4:  pcnetMMIOWriteU32(pThis, GCPhysAddr, *(uint32_t *)pv); break;
     3977            case 2:  pcnetMMIOWriteU16(pDevIns, pThis, GCPhysAddr, *(uint16_t *)pv); break;
     3978            case 4:  pcnetMMIOWriteU32(pDevIns, pThis, GCPhysAddr, *(uint32_t *)pv); break;
    39913979            default:
    39923980                rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS,
     
    40103998 * @callback_method_impl{FNTMTIMERDEV, Poll timer}
    40113999 */
    4012 static DECLCALLBACK(void) pcnetTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    4013 {
    4014     RT_NOREF(pDevIns, pTimer);
    4015     PPCNETSTATE pThis = (PPCNETSTATE)pvUser;
     4000static DECLCALLBACK(void) pcnetR3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
     4001{
     4002    PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
    40164003    Assert(PDMCritSectIsOwner(&pThis->CritSect));
     4004    RT_NOREF(pvUser, pTimer);
    40174005
    40184006    STAM_PROFILE_ADV_START(&pThis->StatTimer, a);
    4019     pcnetPollTimer(pThis);
     4007    pcnetPollTimer(pDevIns, pThis);
    40204008    STAM_PROFILE_ADV_STOP(&pThis->StatTimer, a);
    40214009}
     
    40264014 *      Software interrupt timer callback function.}
    40274015 */
    4028 static DECLCALLBACK(void) pcnetTimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    4029 {
    4030     RT_NOREF(pDevIns, pTimer);
    4031     PPCNETSTATE pThis = (PPCNETSTATE)pvUser;
     4016static DECLCALLBACK(void) pcnetR3TimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
     4017{
     4018    PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
    40324019    Assert(PDMCritSectIsOwner(&pThis->CritSect));
     4020    RT_NOREF(pvUser, pTimer);
    40334021
    40344022    pThis->aCSR[7] |= 0x0800; /* STINT */
    40354023    pcnetUpdateIrq(pThis);
    4036     TMTimerSetNano(pThis->CTX_SUFF(pTimerSoftInt), 12800U * (pThis->aBCR[BCR_STVAL] & 0xffff));
     4024    PDMDevHlpTimerSetNano(pDevIns, pThis->hTimerSoftInt, 12800U * (pThis->aBCR[BCR_STVAL] & 0xffff));
    40374025}
    40384026
     
    40454033 * should be considered lost.
    40464034 */
    4047 static DECLCALLBACK(void) pcnetTimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    4048 {
     4035static DECLCALLBACK(void) pcnetR3TimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
     4036{
     4037    PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
    40494038    RT_NOREF(pTimer, pvUser);
    4050     PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
    4051     int         rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     4039
     4040    int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
    40524041    AssertReleaseRC(rc);
    40534042
    40544043    rc = VERR_GENERAL_FAILURE;
    40554044    if (pThis->cLinkDownReported <= PCNET_MAX_LINKDOWN_REPORTED)
    4056         rc = TMTimerSetMillies(pThis->pTimerRestore, 1500);
     4045    {
     4046        rc = PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerRestore, 1500);
     4047        AssertRC(rc);
     4048    }
    40574049    if (RT_FAILURE(rc))
    40584050    {
     
    40604052        if (pThis->fLinkUp)
    40614053        {
    4062             LogRel(("PCnet#%d: The link is back up again after the restore.\n",
    4063                     pDevIns->iInstance));
    4064             Log(("#%d pcnetTimerRestore: Clearing ERR and CERR after load. cLinkDownReported=%d\n",
     4054            LogRel(("PCnet#%d: The link is back up again after the restore.\n", pDevIns->iInstance));
     4055            Log(("#%d pcnetR3TimerRestore: Clearing ERR and CERR after load. cLinkDownReported=%d\n",
    40654056                 pDevIns->iInstance, pThis->cLinkDownReported));
    40664057            pThis->aCSR[0] &= ~(RT_BIT(15) | RT_BIT(13)); /* ERR | CERR - probably not 100% correct either... */
     
    40694060    }
    40704061    else
    4071         Log(("#%d pcnetTimerRestore: cLinkDownReported=%d, wait another 1500ms...\n",
     4062        Log(("#%d pcnetR3TimerRestore: cLinkDownReported=%d, wait another 1500ms...\n",
    40724063             pDevIns->iInstance, pThis->cLinkDownReported));
    40734064
     
    44324423 * @param  pThis        The PCnet shared instance data.
    44334424 */
    4434 static void pcnetTempLinkDown(PPCNETSTATE pThis)
     4425static void pcnetTempLinkDown(PPDMDEVINS pDevIns, PPCNETSTATE pThis)
    44354426{
    44364427    if (pThis->fLinkUp)
     
    44404431        pThis->aCSR[0] |= RT_BIT(15) | RT_BIT(13); /* ERR | CERR (this is probably wrong) */
    44414432        pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1;
    4442         int rc = TMTimerSetMillies(pThis->pTimerRestore, pThis->cMsLinkUpDelay);
     4433        int rc = PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerRestore, pThis->cMsLinkUpDelay);
    44434434        AssertRC(rc);
    44444435    }
     
    45184509    int rc = VINF_SUCCESS;
    45194510#ifndef PCNET_NO_POLLING
    4520     rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerPoll), pSSM);
     4511    rc = PDMDevHlpTimerSave(pDevIns, pThis->hTimerPoll, pSSM);
    45214512    if (RT_FAILURE(rc))
    45224513        return rc;
    45234514#endif
    45244515    if (pThis->uDevType == DEV_AM79C973)
    4525         rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerSoftInt), pSSM);
     4516        rc = PDMDevHlpTimerSave(pDevIns, pThis->hTimerSoftInt, pSSM);
    45264517    return rc;
    45274518}
     
    46304621        /* restore timers and stuff */
    46314622#ifndef PCNET_NO_POLLING
    4632         TMR3TimerLoad(pThis->CTX_SUFF(pTimerPoll), pSSM);
     4623        PDMDevHlpTimerLoad(pDevIns, pThis->hTimerPoll, pSSM);
    46334624#endif
    46344625        if (pThis->uDevType == DEV_AM79C973)
     
    46364627            if (   SSM_VERSION_MAJOR(uVersion) >  0
    46374628                || SSM_VERSION_MINOR(uVersion) >= 8)
    4638                 TMR3TimerLoad(pThis->CTX_SUFF(pTimerSoftInt), pSSM);
     4629                PDMDevHlpTimerLoad(pDevIns, pThis->hTimerSoftInt, pSSM);
    46394630        }
    46404631
     
    46524643#ifdef PCNET_NO_POLLING
    46534644        /* Enable physical monitoring again (!) */
    4654         pcnetUpdateRingHandlers(pThis);
     4645        pcnetR3UpdateRingHandlers(pThis);
    46554646#endif
    46564647        /* Indicate link down to the guest OS that all network connections have
    46574648           been lost, unless we've been teleported here. */
    46584649        if (!PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns))
    4659             pcnetTempLinkDown(pThis);
     4650            pcnetTempLinkDown(pDevIns, pThis);
    46604651    }
    46614652
     
    47244715{
    47254716    PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown);
     4717    PPDMDEVINS  pDevIns = pThis->pDevInsR3;
    47264718
    47274719    int rc = pcnetCanReceive(pThis);
     
    47504742        AssertReleaseRC(rc2);
    47514743#ifndef PCNET_NO_POLLING
    4752         pcnetPollTimerStart(pThis);
     4744        pcnetPollTimerStart(pDevIns, pThis);
    47534745#endif
    47544746        PDMCritSectLeave(&pThis->CritSect);
     
    48614853static DECLCALLBACK(int) pcnetSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState)
    48624854{
    4863     PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig);
     4855    PPCNETSTATE     pThis   = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig);
     4856    PPDMDEVINS      pDevIns = pThis->pDevInsR3;
    48644857    bool fLinkUp;
    48654858
     
    48694862    if (enmState == PDMNETWORKLINKSTATE_DOWN_RESUME)
    48704863    {
    4871         pcnetTempLinkDown(pThis);
     4864        pcnetTempLinkDown(pDevIns, pThis);
    48724865        /*
    48734866         * Note that we do not notify the driver about the link state change because
     
    48894882            pThis->aCSR[0] |= RT_BIT(15) | RT_BIT(13); /* ERR | CERR (this is probably wrong) */
    48904883            pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1;
    4891             int rc = TMTimerSetMillies(pThis->pTimerRestore, pThis->cMsLinkUpDelay);
     4884            int rc = PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerRestore, pThis->cMsLinkUpDelay);
    48924885            AssertRC(rc);
    48934886        }
     
    50245017     */
    50255018    if (RT_SUCCESS(rc))
    5026         pcnetTempLinkDown(pThis);
     5019        pcnetTempLinkDown(pDevIns, pThis);
    50275020
    50285021    PDMCritSectLeave(&pThis->CritSect);
     
    50515044    {
    50525045        pThis->cLinkDownReported = 0x10000;
    5053         TMTimerStop(pThis->pTimerRestore);
    5054         pcnetTimerRestore(pDevIns, pThis->pTimerRestore, pThis);
     5046        PDMDevHlpTimerStop(pDevIns, pThis->hTimerRestore);
     5047        pcnetR3TimerRestore(pDevIns, NULL /* pTimer - not used */, pThis);
    50555048    }
    50565049
     
    50725065#ifdef PCNET_NO_POLLING
    50735066    pThis->pfnEMInterpretInstructionRC += offDelta;
    5074 #else
    5075     pThis->pTimerPollRC  = TMTimerRCPtr(pThis->pTimerPollR3);
    5076 #endif
    5077     if (pThis->uDevType == DEV_AM79C973)
    5078         pThis->pTimerSoftIntRC = TMTimerRCPtr(pThis->pTimerSoftIntR3);
     5067#endif
    50795068}
    50805069
     
    53385327
    53395328#else
    5340     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimer, pThis,
    5341                                 TMTIMER_FLAGS_NO_CRIT_SECT, "PCnet Poll Timer", &pThis->pTimerPollR3);
    5342     if (RT_FAILURE(rc))
    5343         return rc;
    5344     pThis->pTimerPollR0 = TMTimerR0Ptr(pThis->pTimerPollR3);
    5345     pThis->pTimerPollRC = TMTimerRCPtr(pThis->pTimerPollR3);
    5346     TMR3TimerSetCritSect(pThis->pTimerPollR3, &pThis->CritSect);
     5329    rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetR3Timer, NULL, TMTIMER_FLAGS_NO_CRIT_SECT,
     5330                              "PCnet Poll Timer", &pThis->hTimerPoll);
     5331    AssertRCReturn(rc, rc);
     5332    rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->hTimerPoll, &pThis->CritSect);
     5333    AssertRCReturn(rc, rc);
    53475334#endif
    53485335    if (pThis->uDevType == DEV_AM79C973)
    53495336    {
    53505337        /* Software Interrupt timer */
    5351         rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimerSoftInt, pThis, /** @todo r=bird: the locking here looks bogus now with SMP... */
    5352                                     TMTIMER_FLAGS_NO_CRIT_SECT, "PCnet SoftInt Timer", &pThis->pTimerSoftIntR3);
     5338        rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetR3TimerSoftInt, NULL, TMTIMER_FLAGS_NO_CRIT_SECT,
     5339                                  "PCnet SoftInt Timer", &pThis->hTimerSoftInt);
    53535340        AssertRCReturn(rc, rc);
    5354         pThis->pTimerSoftIntR0 = TMTimerR0Ptr(pThis->pTimerSoftIntR3);
    5355         pThis->pTimerSoftIntRC = TMTimerRCPtr(pThis->pTimerSoftIntR3);
    5356         TMR3TimerSetCritSect(pThis->pTimerSoftIntR3, &pThis->CritSect);
    5357     }
    5358     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimerRestore, pThis,
    5359                                 TMTIMER_FLAGS_NO_CRIT_SECT, "PCnet Restore Timer", &pThis->pTimerRestore);
     5341        rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->hTimerSoftInt, &pThis->CritSect);
     5342        AssertRCReturn(rc, rc);
     5343    }
     5344    rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetR3TimerRestore, pThis, TMTIMER_FLAGS_NO_CRIT_SECT,
     5345                              "PCnet Restore Timer", &pThis->hTimerRestore);
    53605346    AssertRCReturn(rc, rc);
    53615347
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