Changeset 82134 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Nov 23, 2019 11:03:32 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134944
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r82129 r82134 328 328 /** LUN\#0: The network config port interface. */ 329 329 PDMINETWORKCONFIG INetworkConfig; 330 /** Software Interrupt timer - R3. */331 PTMTIMERR3 pTimerSoftIntR3;332 #ifndef PCNET_NO_POLLING333 /** Poll timer - R3. */334 PTMTIMERR3 pTimerPollR3;335 #endif336 /** Restore timer.337 * This is used to disconnect and reconnect the link after a restore. */338 PTMTIMERR3 pTimerRestore;339 330 340 331 /** Pointer to the device instance - R0. */ … … 346 337 /** Pointer to the connector of the attached network driver - R0. */ 347 338 PPDMINETWORKUPR0 pDrvR0; 348 /** Software Interrupt timer - R0. */349 PTMTIMERR0 pTimerSoftIntR0;350 #ifndef PCNET_NO_POLLING351 /** Poll timer - R0. */352 PTMTIMERR0 pTimerPollR0;353 #endif354 339 355 340 /** Pointer to the device instance - RC. */ … … 361 346 /** Pointer to the connector of the attached network driver - RC. */ 362 347 PPDMINETWORKUPRC pDrvRC; 363 /** Software Interrupt timer - RC. */ 364 PTMTIMERRC pTimerSoftIntRC; 348 349 /** Software Interrupt timer - R3. */ 350 TMTIMERHANDLE hTimerSoftInt; 365 351 #ifndef PCNET_NO_POLLING 366 /** Poll timer - R C. */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; 372 358 373 359 /** Register Address Pointer */ … … 691 677 692 678 #ifndef PCNET_NO_POLLING 693 static void pcnetPollTimerStart(PP CNETSTATE pThis);679 static void pcnetPollTimerStart(PPDMDEVINS pDevIns, PPCNETSTATE pThis); 694 680 #endif 695 681 static int pcnetXmitPending(PPCNETSTATE pThis, bool fOnWorkerThread); … … 1166 1152 1167 1153 static void pcnetPollRxTx(PPCNETSTATE pThis); 1168 static void pcnetPollTimer(PP CNETSTATE pThis);1154 static void pcnetPollTimer(PPDMDEVINS pDevIns, PPCNETSTATE pThis); 1169 1155 static void pcnetUpdateIrq(PPCNETSTATE pThis); 1170 1156 static uint32_t pcnetBCRReadU16(PPCNETSTATE pThis, uint32_t u32RAP); 1171 static int pcnetBCRWriteU16(PP CNETSTATE pThis, uint32_t u32RAP, uint32_t val);1157 static int pcnetBCRWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val); 1172 1158 1173 1159 … … 1422 1408 1423 1409 #ifdef IN_RING3 1424 #ifdef PCNET_NO_POLLING 1425 static void pcnetUpdateRingHandlers(PPCNETSTATE pThis) 1410 1411 # ifdef PCNET_NO_POLLING 1412 static void pcnetR3UpdateRingHandlers(PPCNETSTATE pThis) 1426 1413 { 1427 1414 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); 1428 1415 int rc; 1429 1416 1430 Log(("pcnet UpdateRingHandlers TD %RX32 size %#x -> %RX32 ?size? %#x\n", pThis->TDRAPhysOld, pThis->cbTDRAOld, pThis->GCTDRA, pcnetTdraAddr(pThis, 0)));1431 Log(("pcnet UpdateRingHandlers 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))); 1432 1419 1433 1420 /** @todo unregister order not correct! */ 1434 1421 1435 # ifdef PCNET_MONITOR_RECEIVE_RING1422 # ifdef PCNET_MONITOR_RECEIVE_RING 1436 1423 if (pThis->GCRDRA != pThis->RDRAPhysOld || CSR_RCVRL(pThis) != pThis->cbRDRAOld) 1437 1424 { … … 1452 1439 pThis->cbRDRAOld = pcnetRdraAddr(pThis, 0); 1453 1440 } 1454 # endif /* PCNET_MONITOR_RECEIVE_RING */1455 1456 # ifdef PCNET_MONITOR_RECEIVE_RING1441 # endif /* PCNET_MONITOR_RECEIVE_RING */ 1442 1443 # ifdef PCNET_MONITOR_RECEIVE_RING 1457 1444 /* 3 possibilities: 1458 1445 * 1) TDRA on different physical page as RDRA … … 1468 1455 || TDRAPageStart > RDRAPageEnd) 1469 1456 { 1470 # endif /* PCNET_MONITOR_RECEIVE_RING */1457 # endif /* PCNET_MONITOR_RECEIVE_RING */ 1471 1458 /* 1) */ 1472 1459 if (pThis->GCTDRA != pThis->TDRAPhysOld || CSR_XMTRL(pThis) != pThis->cbTDRAOld) … … 1489 1476 pThis->cbTDRAOld = pcnetTdraAddr(pThis, 0); 1490 1477 } 1491 # ifdef PCNET_MONITOR_RECEIVE_RING1478 # ifdef PCNET_MONITOR_RECEIVE_RING 1492 1479 } 1493 1480 else … … 1502 1489 } 1503 1490 /* else 2) */ 1504 # endif1505 } 1506 # endif /* PCNET_NO_POLLING */1507 1508 static void pcnet Init(PPCNETSTATE pThis)1491 # endif 1492 } 1493 # endif /* PCNET_NO_POLLING */ 1494 1495 static void pcnetR3Init(PPCNETSTATE pThis) 1509 1496 { 1510 1497 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); 1511 Log(("#%d pcnet Init: 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)))); 1512 1499 1513 1500 /** @todo Documentation says that RCVRL and XMTRL are stored as two's complement! 1514 1501 * 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) 1532 1519 1533 1520 if (BCR_SSIZE32(pThis)) … … 1548 1535 } 1549 1536 1550 # undef PCNET_INIT1537 # undef PCNET_INIT 1551 1538 1552 1539 size_t cbRxBuffers = 0; … … 1588 1575 CSR_XMTRC(pThis) = CSR_XMTRL(pThis); 1589 1576 1590 # ifdef PCNET_NO_POLLING1591 pcnet UpdateRingHandlers(pThis);1592 # endif1577 # ifdef PCNET_NO_POLLING 1578 pcnetR3UpdateRingHandlers(pThis); 1579 # endif 1593 1580 1594 1581 /* Reset cached RX and TX states */ … … 1609 1596 pThis->aCSR[0] &= ~0x0004; /* clear STOP bit */ 1610 1597 } 1598 1611 1599 #endif /* IN_RING3 */ 1612 1600 … … 1614 1602 * Start RX/TX operation. 1615 1603 */ 1616 static void pcnetStart(PP CNETSTATE pThis)1604 static void pcnetStart(PPDMDEVINS pDevIns, PPCNETSTATE pThis) 1617 1605 { 1618 1606 Log(("#%d pcnetStart:\n", PCNET_INST_NR)); … … 1629 1617 pThis->aCSR[0] |= 0x0002; /* STRT */ 1630 1618 #ifndef PCNET_NO_POLLING 1631 pcnetPollTimerStart(p This);/* start timer if it was stopped */1619 pcnetPollTimerStart(pDevIns, pThis); /* start timer if it was stopped */ 1632 1620 #endif 1633 1621 } … … 1636 1624 * Stop RX/TX operation. 1637 1625 */ 1638 static void pcnetStop(PP CNETSTATE pThis)1626 static void pcnetStop(PPDMDEVINS pDevIns, PPCNETSTATE pThis) 1639 1627 { 1640 1628 Log(("#%d pcnetStop:\n", PCNET_INST_NR)); … … 1642 1630 pThis->aCSR[4] &= ~0x02c2; 1643 1631 pThis->aCSR[5] &= ~0x0011; 1644 pcnetPollTimer(p This);1632 pcnetPollTimer(pDevIns, pThis); 1645 1633 } 1646 1634 … … 2819 2807 * @thread EMT, TAP. 2820 2808 */ 2821 static void pcnetPollTimerStart(PP CNETSTATE pThis)2822 { 2823 TMTimerSetMillies(pThis->CTX_SUFF(pTimerPoll), 2);2809 static void pcnetPollTimerStart(PPDMDEVINS pDevIns, PPCNETSTATE pThis) 2810 { 2811 PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerPoll, 2); 2824 2812 } 2825 2813 #endif … … 2830 2818 * @thread EMT. 2831 2819 */ 2832 static void pcnetPollTimer(PP CNETSTATE pThis)2820 static void pcnetPollTimer(PPDMDEVINS pDevIns, PPCNETSTATE pThis) 2833 2821 { 2834 2822 STAM_PROFILE_ADV_START(&pThis->StatPollTimer, a); … … 2877 2865 pcnetPollRxTx(pThis); 2878 2866 #else 2879 uint64_t u64Now = TMTimerGet(pThis->CTX_SUFF(pTimerPoll));2867 uint64_t u64Now = PDMDevHlpTimerGet(pDevIns, pThis->hTimerPoll); 2880 2868 if (RT_UNLIKELY(u64Now - pThis->u64LastPoll > 200000)) 2881 2869 { … … 2883 2871 pcnetPollRxTx(pThis); 2884 2872 } 2885 if (! TMTimerIsActive(pThis->CTX_SUFF(pTimerPoll)))2886 pcnetPollTimerStart(p This);2873 if (!PDMDevHlpTimerIsActive(pDevIns, pThis->hTimerPoll)) 2874 pcnetPollTimerStart(pDevIns, pThis); 2887 2875 #endif 2888 2876 } … … 2891 2879 2892 2880 2893 static int pcnetCSRWriteU16(PP CNETSTATE pThis, uint32_t u32RAP, uint32_t val)2881 static int pcnetCSRWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val) 2894 2882 { 2895 2883 int rc = VINF_SUCCESS; … … 2917 2905 if (!(csr0 & 0x0001/*init*/) && (val & 1)) 2918 2906 { 2919 Log(("#%d pcnetCSRWriteU16: pcnet Init requested => HC\n", PCNET_INST_NR));2907 Log(("#%d pcnetCSRWriteU16: pcnetR3Init requested => HC\n", PCNET_INST_NR)); 2920 2908 return VINF_IOM_R3_IOPORT_WRITE; 2921 2909 } … … 2924 2912 2925 2913 if (!CSR_STOP(pThis) && (val & 4)) 2926 pcnetStop(p This);2914 pcnetStop(pDevIns, pThis); 2927 2915 2928 2916 #ifdef IN_RING3 2929 2917 if (!CSR_INIT(pThis) && (val & 1)) 2930 pcnet Init(pThis);2918 pcnetR3Init(pThis); 2931 2919 #endif 2932 2920 2933 2921 if (!CSR_STRT(pThis) && (val & 2)) 2934 pcnetStart(p This);2922 pcnetStart(pDevIns, pThis); 2935 2923 2936 2924 if (CSR_TDMD(pThis)) … … 3022 3010 break; 3023 3011 case 16: /* IADRL */ 3024 return pcnetCSRWriteU16(p This, 1, val);3012 return pcnetCSRWriteU16(pDevIns, pThis, 1, val); 3025 3013 case 17: /* IADRH */ 3026 return pcnetCSRWriteU16(p This, 2, val);3014 return pcnetCSRWriteU16(pDevIns, pThis, 2, val); 3027 3015 3028 3016 /* … … 3067 3055 3068 3056 case 58: /* Software Style */ 3069 rc = pcnetBCRWriteU16(p This, BCR_SWS, val);3057 rc = pcnetBCRWriteU16(pDevIns, pThis, BCR_SWS, val); 3070 3058 break; 3071 3059 … … 3074 3062 * try fix that right now. So, as a quick hack for 'alt init' I'll just correct them here. 3075 3063 */ 3076 case 76: /* RCVRL */ /** @todo call pcnet UpdateRingHandlers */3064 case 76: /* RCVRL */ /** @todo call pcnetR3UpdateRingHandlers */ 3077 3065 /** @todo receive ring length is stored in two's complement! */ 3078 case 78: /* XMTRL */ /** @todo call pcnet UpdateRingHandlers */3066 case 78: /* XMTRL */ /** @todo call pcnetR3UpdateRingHandlers */ 3079 3067 /** @todo transmit ring length is stored in two's complement! */ 3080 3068 if (!CSR_STOP(pThis) && !CSR_SPND(pThis)) … … 3148 3136 } 3149 3137 3150 static int pcnetBCRWriteU16(PP CNETSTATE pThis, uint32_t u32RAP, uint32_t val)3138 static int pcnetBCRWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t u32RAP, uint32_t val) 3151 3139 { 3152 3140 int rc = VINF_SUCCESS; … … 3204 3192 pThis->aBCR[BCR_STVAL] = val; 3205 3193 if (pThis->uDevType == DEV_AM79C973) 3206 TMTimerSetNano(pThis->CTX_SUFF(pTimerSoftInt), 12800U * val);3194 PDMDevHlpTimerSetNano(pDevIns, pThis->hTimerSoftInt, 12800U * val); 3207 3195 break; 3208 3196 … … 3576 3564 3577 3565 3578 static int pcnetIo portWriteU8(PPCNETSTATE pThis, uint32_t addr, uint32_t val)3566 static int pcnetIoPortWriteU8(PPCNETSTATE pThis, uint32_t addr, uint32_t val) 3579 3567 { 3580 3568 RT_NOREF1(val); 3581 3569 #ifdef PCNET_DEBUG_IO 3582 Log2(("#%d pcnetIo portWriteU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val));3570 Log2(("#%d pcnetIoPortWriteU8: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val)); 3583 3571 #endif 3584 3572 if (RT_LIKELY(!BCR_DWIO(pThis))) … … 3591 3579 } 3592 3580 else 3593 Log(("#%d pcnetIo portWriteU8: 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)); 3594 3582 3595 3583 return VINF_SUCCESS; 3596 3584 } 3597 3585 3598 static uint32_t pcnetIo portReadU8(PPCNETSTATE pThis, uint32_t addr, int *pRC)3586 static uint32_t pcnetIoPortReadU8(PPCNETSTATE pThis, uint32_t addr, int *pRC) 3599 3587 { 3600 3588 uint32_t val = UINT32_MAX; … … 3613 3601 } 3614 3602 else 3615 Log(("#%d pcnetIo portReadU8: 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)); 3616 3604 3617 3605 pcnetUpdateIrq(pThis); 3618 3606 3619 3607 #ifdef PCNET_DEBUG_IO 3620 Log2(("#%d pcnetIo portReadU8: 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)); 3621 3609 #endif 3622 3610 return val; 3623 3611 } 3624 3612 3625 static int pcnetIo portWriteU16(PPCNETSTATE pThis, uint32_t addr, uint32_t val)3613 static int pcnetIoPortWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, uint32_t val) 3626 3614 { 3627 3615 int rc = VINF_SUCCESS; 3628 3616 3629 3617 #ifdef PCNET_DEBUG_IO 3630 Log2(("#%d pcnetIo portWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val));3618 Log2(("#%d pcnetIoPortWriteU16: addr=%#010x val=%#06x\n", PCNET_INST_NR, addr, val)); 3631 3619 #endif 3632 3620 if (RT_LIKELY(!BCR_DWIO(pThis))) … … 3635 3623 { 3636 3624 case 0x00: /* RDP */ 3637 pcnetPollTimer(p This);3638 rc = pcnetCSRWriteU16(p This, pThis->u32RAP, val);3625 pcnetPollTimer(pDevIns, pThis); 3626 rc = pcnetCSRWriteU16(pDevIns, pThis, pThis->u32RAP, val); 3639 3627 pcnetUpdateIrq(pThis); 3640 3628 break; … … 3643 3631 break; 3644 3632 case 0x06: /* BDP */ 3645 rc = pcnetBCRWriteU16(p This, pThis->u32RAP, val);3633 rc = pcnetBCRWriteU16(pDevIns, pThis, pThis->u32RAP, val); 3646 3634 break; 3647 3635 } 3648 3636 } 3649 3637 else 3650 Log(("#%d pcnetIo portWriteU16: 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)); 3651 3639 3652 3640 return rc; 3653 3641 } 3654 3642 3655 static uint32_t pcnetIo portReadU16(PPCNETSTATE pThis, uint32_t addr, int *pRC)3643 static uint32_t pcnetIoPortReadU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, int *pRC) 3656 3644 { 3657 3645 uint32_t val = ~0U; … … 3667 3655 /** Polling is then useless here and possibly expensive. */ 3668 3656 if (!CSR_DPOLL(pThis)) 3669 pcnetPollTimer(p This);3657 pcnetPollTimer(pDevIns, pThis); 3670 3658 3671 3659 val = pcnetCSRReadU16(pThis, pThis->u32RAP); … … 3686 3674 } 3687 3675 else 3688 Log(("#%d pcnetIo portReadU16: 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)); 3689 3677 3690 3678 pcnetUpdateIrq(pThis); … … 3692 3680 skip_update_irq: 3693 3681 #ifdef PCNET_DEBUG_IO 3694 Log2(("#%d pcnetIo portReadU16: 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)); 3695 3683 #endif 3696 3684 return val; 3697 3685 } 3698 3686 3699 static int pcnetIo portWriteU32(PPCNETSTATE pThis, uint32_t addr, uint32_t val)3687 static int pcnetIoPortWriteU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, uint32_t val) 3700 3688 { 3701 3689 int rc = VINF_SUCCESS; 3702 3690 3703 3691 #ifdef PCNET_DEBUG_IO 3704 Log2(("#%d pcnetIo portWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR,3692 Log2(("#%d pcnetIoPortWriteU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, 3705 3693 addr, val)); 3706 3694 #endif … … 3710 3698 { 3711 3699 case 0x00: /* RDP */ 3712 pcnetPollTimer(p This);3713 rc = pcnetCSRWriteU16(p This, pThis->u32RAP, val & 0xffff);3700 pcnetPollTimer(pDevIns, pThis); 3701 rc = pcnetCSRWriteU16(pDevIns, pThis, pThis->u32RAP, val & 0xffff); 3714 3702 pcnetUpdateIrq(pThis); 3715 3703 break; … … 3718 3706 break; 3719 3707 case 0x0c: /* BDP */ 3720 rc = pcnetBCRWriteU16(p This, pThis->u32RAP, val & 0xffff);3708 rc = pcnetBCRWriteU16(pDevIns, pThis, pThis->u32RAP, val & 0xffff); 3721 3709 break; 3722 3710 } … … 3725 3713 { 3726 3714 /* switch device to dword I/O mode */ 3727 pcnetBCRWriteU16(p This, BCR_BSBC, pcnetBCRReadU16(pThis, BCR_BSBC) | 0x0080);3715 pcnetBCRWriteU16(pDevIns, pThis, BCR_BSBC, pcnetBCRReadU16(pThis, BCR_BSBC) | 0x0080); 3728 3716 #ifdef PCNET_DEBUG_IO 3729 3717 Log2(("device switched into dword i/o mode\n")); … … 3731 3719 } 3732 3720 else 3733 Log(("#%d pcnetIo portWriteU32: 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)); 3734 3722 3735 3723 return rc; 3736 3724 } 3737 3725 3738 static uint32_t pcnetIo portReadU32(PPCNETSTATE pThis, uint32_t addr, int *pRC)3726 static uint32_t pcnetIoPortReadU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, uint32_t addr, int *pRC) 3739 3727 { 3740 3728 uint32_t val = ~0U; … … 3750 3738 /** Polling is then useless here and possibly expensive. */ 3751 3739 if (!CSR_DPOLL(pThis)) 3752 pcnetPollTimer(p This);3740 pcnetPollTimer(pDevIns, pThis); 3753 3741 3754 3742 val = pcnetCSRReadU16(pThis, pThis->u32RAP); … … 3769 3757 } 3770 3758 else 3771 Log(("#%d pcnetIo portReadU32: 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)); 3772 3760 pcnetUpdateIrq(pThis); 3773 3761 3774 3762 skip_update_irq: 3775 3763 #ifdef PCNET_DEBUG_IO 3776 Log2(("#%d pcnetIo portReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val));3764 Log2(("#%d pcnetIoPortReadU32: addr=%#010x val=%#010x\n", PCNET_INST_NR, addr, val)); 3777 3765 #endif 3778 3766 return val; … … 3793 3781 switch (cb) 3794 3782 { 3795 case 1: *pu32 = pcnetIo portReadU8(pThis, Port, &rc); break;3796 case 2: *pu32 = pcnetIo portReadU16(pThis, Port, &rc); break;3797 case 4: *pu32 = pcnetIo portReadU32(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; 3798 3786 default: 3799 3787 rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS, … … 3821 3809 switch (cb) 3822 3810 { 3823 case 1: rc = pcnetIo portWriteU8(pThis, Port, u32); break;3824 case 2: rc = pcnetIo portWriteU16(pThis, Port, u32); break;3825 case 4: rc = pcnetIo portWriteU32(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; 3826 3814 default: 3827 3815 rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS, … … 3858 3846 } 3859 3847 3860 static void pcnetMMIOWriteU16(PP CNETSTATE pThis, RTGCPHYS addr, uint32_t val)3848 static void pcnetMMIOWriteU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val) 3861 3849 { 3862 3850 #ifdef PCNET_DEBUG_IO … … 3864 3852 #endif 3865 3853 if (addr & 0x10) 3866 pcnetIo portWriteU16(pThis, addr & 0x0f, val);3854 pcnetIoPortWriteU16(pDevIns, pThis, addr & 0x0f, val); 3867 3855 else 3868 3856 { … … 3872 3860 } 3873 3861 3874 static uint32_t pcnetMMIOReadU16(PP CNETSTATE pThis, RTGCPHYS addr)3862 static uint32_t pcnetMMIOReadU16(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr) 3875 3863 { 3876 3864 uint32_t val = ~0U; … … 3878 3866 3879 3867 if (addr & 0x10) 3880 val = pcnetIo portReadU16(pThis, addr & 0x0f, &rc);3868 val = pcnetIoPortReadU16(pDevIns, pThis, addr & 0x0f, &rc); 3881 3869 else 3882 3870 { … … 3891 3879 } 3892 3880 3893 static void pcnetMMIOWriteU32(PP CNETSTATE pThis, RTGCPHYS addr, uint32_t val)3881 static void pcnetMMIOWriteU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr, uint32_t val) 3894 3882 { 3895 3883 #ifdef PCNET_DEBUG_IO … … 3897 3885 #endif 3898 3886 if (addr & 0x10) 3899 pcnetIo portWriteU32(pThis, addr & 0x0f, val);3887 pcnetIoPortWriteU32(pDevIns, pThis, addr & 0x0f, val); 3900 3888 else 3901 3889 { … … 3907 3895 } 3908 3896 3909 static uint32_t pcnetMMIOReadU32(PP CNETSTATE pThis, RTGCPHYS addr)3897 static uint32_t pcnetMMIOReadU32(PPDMDEVINS pDevIns, PPCNETSTATE pThis, RTGCPHYS addr) 3910 3898 { 3911 3899 uint32_t val; … … 3913 3901 3914 3902 if (addr & 0x10) 3915 val = pcnetIo portReadU32(pThis, addr & 0x0f, &rc);3903 val = pcnetIoPortReadU32(pDevIns, pThis, addr & 0x0f, &rc); 3916 3904 else 3917 3905 { … … 3950 3938 { 3951 3939 case 1: *(uint8_t *)pv = pcnetMMIOReadU8 (pThis, GCPhysAddr); break; 3952 case 2: *(uint16_t *)pv = pcnetMMIOReadU16(p This, GCPhysAddr); break;3953 case 4: *(uint32_t *)pv = pcnetMMIOReadU32(p This, GCPhysAddr); break;3940 case 2: *(uint16_t *)pv = pcnetMMIOReadU16(pDevIns, pThis, GCPhysAddr); break; 3941 case 4: *(uint32_t *)pv = pcnetMMIOReadU32(pDevIns, pThis, GCPhysAddr); break; 3954 3942 default: 3955 3943 rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS, … … 3987 3975 { 3988 3976 case 1: pcnetMMIOWriteU8 (pThis, GCPhysAddr, *(uint8_t *)pv); break; 3989 case 2: pcnetMMIOWriteU16(p This, GCPhysAddr, *(uint16_t *)pv); break;3990 case 4: pcnetMMIOWriteU32(p This, 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; 3991 3979 default: 3992 3980 rc = PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS, … … 4010 3998 * @callback_method_impl{FNTMTIMERDEV, Poll timer} 4011 3999 */ 4012 static DECLCALLBACK(void) pcnetTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 4013 { 4014 RT_NOREF(pDevIns, pTimer); 4015 PPCNETSTATE pThis = (PPCNETSTATE)pvUser; 4000 static DECLCALLBACK(void) pcnetR3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 4001 { 4002 PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE); 4016 4003 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 4004 RT_NOREF(pvUser, pTimer); 4017 4005 4018 4006 STAM_PROFILE_ADV_START(&pThis->StatTimer, a); 4019 pcnetPollTimer(p This);4007 pcnetPollTimer(pDevIns, pThis); 4020 4008 STAM_PROFILE_ADV_STOP(&pThis->StatTimer, a); 4021 4009 } … … 4026 4014 * Software interrupt timer callback function.} 4027 4015 */ 4028 static DECLCALLBACK(void) pcnetTimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 4029 { 4030 RT_NOREF(pDevIns, pTimer); 4031 PPCNETSTATE pThis = (PPCNETSTATE)pvUser; 4016 static DECLCALLBACK(void) pcnetR3TimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 4017 { 4018 PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE); 4032 4019 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 4020 RT_NOREF(pvUser, pTimer); 4033 4021 4034 4022 pThis->aCSR[7] |= 0x0800; /* STINT */ 4035 4023 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)); 4037 4025 } 4038 4026 … … 4045 4033 * should be considered lost. 4046 4034 */ 4047 static DECLCALLBACK(void) pcnetTimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 4048 { 4035 static DECLCALLBACK(void) pcnetR3TimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 4036 { 4037 PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE); 4049 4038 RT_NOREF(pTimer, pvUser); 4050 PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE); 4051 int 4039 4040 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 4052 4041 AssertReleaseRC(rc); 4053 4042 4054 4043 rc = VERR_GENERAL_FAILURE; 4055 4044 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 } 4057 4049 if (RT_FAILURE(rc)) 4058 4050 { … … 4060 4052 if (pThis->fLinkUp) 4061 4053 { 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", 4065 4056 pDevIns->iInstance, pThis->cLinkDownReported)); 4066 4057 pThis->aCSR[0] &= ~(RT_BIT(15) | RT_BIT(13)); /* ERR | CERR - probably not 100% correct either... */ … … 4069 4060 } 4070 4061 else 4071 Log(("#%d pcnet TimerRestore: cLinkDownReported=%d, wait another 1500ms...\n",4062 Log(("#%d pcnetR3TimerRestore: cLinkDownReported=%d, wait another 1500ms...\n", 4072 4063 pDevIns->iInstance, pThis->cLinkDownReported)); 4073 4064 … … 4432 4423 * @param pThis The PCnet shared instance data. 4433 4424 */ 4434 static void pcnetTempLinkDown(PP CNETSTATE pThis)4425 static void pcnetTempLinkDown(PPDMDEVINS pDevIns, PPCNETSTATE pThis) 4435 4426 { 4436 4427 if (pThis->fLinkUp) … … 4440 4431 pThis->aCSR[0] |= RT_BIT(15) | RT_BIT(13); /* ERR | CERR (this is probably wrong) */ 4441 4432 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); 4443 4434 AssertRC(rc); 4444 4435 } … … 4518 4509 int rc = VINF_SUCCESS; 4519 4510 #ifndef PCNET_NO_POLLING 4520 rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerPoll), pSSM);4511 rc = PDMDevHlpTimerSave(pDevIns, pThis->hTimerPoll, pSSM); 4521 4512 if (RT_FAILURE(rc)) 4522 4513 return rc; 4523 4514 #endif 4524 4515 if (pThis->uDevType == DEV_AM79C973) 4525 rc = TMR3TimerSave(pThis->CTX_SUFF(pTimerSoftInt), pSSM);4516 rc = PDMDevHlpTimerSave(pDevIns, pThis->hTimerSoftInt, pSSM); 4526 4517 return rc; 4527 4518 } … … 4630 4621 /* restore timers and stuff */ 4631 4622 #ifndef PCNET_NO_POLLING 4632 TMR3TimerLoad(pThis->CTX_SUFF(pTimerPoll), pSSM);4623 PDMDevHlpTimerLoad(pDevIns, pThis->hTimerPoll, pSSM); 4633 4624 #endif 4634 4625 if (pThis->uDevType == DEV_AM79C973) … … 4636 4627 if ( SSM_VERSION_MAJOR(uVersion) > 0 4637 4628 || SSM_VERSION_MINOR(uVersion) >= 8) 4638 TMR3TimerLoad(pThis->CTX_SUFF(pTimerSoftInt), pSSM);4629 PDMDevHlpTimerLoad(pDevIns, pThis->hTimerSoftInt, pSSM); 4639 4630 } 4640 4631 … … 4652 4643 #ifdef PCNET_NO_POLLING 4653 4644 /* Enable physical monitoring again (!) */ 4654 pcnet UpdateRingHandlers(pThis);4645 pcnetR3UpdateRingHandlers(pThis); 4655 4646 #endif 4656 4647 /* Indicate link down to the guest OS that all network connections have 4657 4648 been lost, unless we've been teleported here. */ 4658 4649 if (!PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns)) 4659 pcnetTempLinkDown(p This);4650 pcnetTempLinkDown(pDevIns, pThis); 4660 4651 } 4661 4652 … … 4724 4715 { 4725 4716 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkDown); 4717 PPDMDEVINS pDevIns = pThis->pDevInsR3; 4726 4718 4727 4719 int rc = pcnetCanReceive(pThis); … … 4750 4742 AssertReleaseRC(rc2); 4751 4743 #ifndef PCNET_NO_POLLING 4752 pcnetPollTimerStart(p This);4744 pcnetPollTimerStart(pDevIns, pThis); 4753 4745 #endif 4754 4746 PDMCritSectLeave(&pThis->CritSect); … … 4861 4853 static DECLCALLBACK(int) pcnetSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState) 4862 4854 { 4863 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig); 4855 PPCNETSTATE pThis = RT_FROM_MEMBER(pInterface, PCNETSTATE, INetworkConfig); 4856 PPDMDEVINS pDevIns = pThis->pDevInsR3; 4864 4857 bool fLinkUp; 4865 4858 … … 4869 4862 if (enmState == PDMNETWORKLINKSTATE_DOWN_RESUME) 4870 4863 { 4871 pcnetTempLinkDown(p This);4864 pcnetTempLinkDown(pDevIns, pThis); 4872 4865 /* 4873 4866 * Note that we do not notify the driver about the link state change because … … 4889 4882 pThis->aCSR[0] |= RT_BIT(15) | RT_BIT(13); /* ERR | CERR (this is probably wrong) */ 4890 4883 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); 4892 4885 AssertRC(rc); 4893 4886 } … … 5024 5017 */ 5025 5018 if (RT_SUCCESS(rc)) 5026 pcnetTempLinkDown(p This);5019 pcnetTempLinkDown(pDevIns, pThis); 5027 5020 5028 5021 PDMCritSectLeave(&pThis->CritSect); … … 5051 5044 { 5052 5045 pThis->cLinkDownReported = 0x10000; 5053 TMTimerStop(pThis->pTimerRestore);5054 pcnet TimerRestore(pDevIns, pThis->pTimerRestore, pThis);5046 PDMDevHlpTimerStop(pDevIns, pThis->hTimerRestore); 5047 pcnetR3TimerRestore(pDevIns, NULL /* pTimer - not used */, pThis); 5055 5048 } 5056 5049 … … 5072 5065 #ifdef PCNET_NO_POLLING 5073 5066 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 5079 5068 } 5080 5069 … … 5338 5327 5339 5328 #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); 5347 5334 #endif 5348 5335 if (pThis->uDevType == DEV_AM79C973) 5349 5336 { 5350 5337 /* Software Interrupt timer */ 5351 rc = PDMDevHlpT MTimerCreate(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); 5353 5340 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); 5360 5346 AssertRCReturn(rc, rc); 5361 5347
Note:
See TracChangeset
for help on using the changeset viewer.