Changeset 81902 in vbox for trunk/src/VBox/Devices/PC/DevPit-i8254.cpp
- Timestamp:
- Nov 17, 2019 10:38:54 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevPit-i8254.cpp
r81900 r81902 251 251 /** Critical section protecting the state. */ 252 252 PDMCRITSECT CritSect; 253 /** The primary I/O port range (0x40-0x43). */ 254 IOMIOPORTHANDLE hIoPorts; 255 /** The speaker I/O port range (0x40-0x43). */ 256 IOMIOPORTHANDLE hIoPortSpeaker; 253 257 } PITSTATE; 254 258 /** Pointer to the PIT device state. */ … … 643 647 644 648 /** 645 * @callback_method_impl{FNIOMIOPORT IN}646 */ 647 PDMBOTHCBDECL(int) pitIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb)648 { 649 Log2(("pitIOPortRead: uPort=%#x cb=%x\n", uPort, cb));649 * @callback_method_impl{FNIOMIOPORTNEWIN} 650 */ 651 static DECLCALLBACK(VBOXSTRICTRC) pitIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 652 { 653 Log2(("pitIOPortRead: offPort=%#x cb=%x\n", offPort, cb)); 650 654 NOREF(pvUser); 651 uPort &= 3;652 if (cb != 1 || uPort == 3)653 { 654 Log(("pitIOPortRead: uPort=%#x cb=%x *pu32=unused!\n", uPort, cb));655 Assert(offPort < 4); 656 if (cb != 1 || offPort == 3) 657 { 658 Log(("pitIOPortRead: offPort=%#x cb=%x *pu32=unused!\n", offPort, cb)); 655 659 return VERR_IOM_IOPORT_UNUSED; 656 660 } … … 658 662 659 663 PPITSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPITSTATE); 660 PPITCHANNEL pChan = &pThis->channels[ uPort];664 PPITCHANNEL pChan = &pThis->channels[offPort]; 661 665 int ret; 662 666 … … 719 723 720 724 *pu32 = ret; 721 Log2(("pitIOPortRead: uPort=%#x cb=%x *pu32=%#04x\n", uPort, cb, *pu32));725 Log2(("pitIOPortRead: offPort=%#x cb=%x *pu32=%#04x\n", offPort, cb, *pu32)); 722 726 return VINF_SUCCESS; 723 727 } … … 725 729 726 730 /** 727 * @callback_method_impl{FNIOMIOPORT OUT}728 */ 729 PDMBOTHCBDECL(int) pitIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb)730 { 731 Log2(("pitIOPortWrite: uPort=%#x cb=%x u32=%#04x\n", uPort, cb, u32));731 * @callback_method_impl{FNIOMIOPORTNEWOUT} 732 */ 733 static DECLCALLBACK(VBOXSTRICTRC) pitIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 734 { 735 Log2(("pitIOPortWrite: offPort=%#x cb=%x u32=%#04x\n", offPort, cb, u32)); 732 736 NOREF(pvUser); 737 Assert(offPort < 4); 738 733 739 if (cb != 1) 734 740 return VINF_SUCCESS; 735 741 736 742 PPITSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPITSTATE); 737 uPort &= 3; 738 if (uPort == 3) 743 if (offPort == 3) 739 744 { 740 745 /* … … 820 825 */ 821 826 RT_UNTRUSTED_VALIDATED_FENCE(); /* paranoia */ 822 PPITCHANNEL pChan = &pThis->channels[ uPort];827 PPITCHANNEL pChan = &pThis->channels[offPort]; 823 828 DEVPIT_LOCK_BOTH_RETURN(pDevIns, pThis, VINF_IOM_R3_IOPORT_WRITE); 824 829 switch (pChan->write_state) … … 848 853 849 854 /** 850 * @callback_method_impl{FNIOMIOPORTIN, Speaker} 851 */ 852 PDMBOTHCBDECL(int) pitIOPortSpeakerRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb) 853 { 854 RT_NOREF(pvUser, uPort); 855 * @callback_method_impl{FNIOMIOPORTNEWIN, Speaker} 856 */ 857 static DECLCALLBACK(VBOXSTRICTRC) 858 pitIOPortSpeakerRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 859 { 860 RT_NOREF(pvUser, offPort); 855 861 if (cb == 1) 856 862 { … … 884 890 | (fRefresh << 4) 885 891 | (fOut << 5); 886 Log(("pitIOPortSpeakerRead: uPort=%#x cb=%x *pu32=%#x\n", uPort, cb, *pu32));892 Log(("pitIOPortSpeakerRead: offPort=%#x cb=%x *pu32=%#x\n", offPort, cb, *pu32)); 887 893 return VINF_SUCCESS; 888 894 } 889 Log(("pitIOPortSpeakerRead: uPort=%#x cb=%x *pu32=unused!\n", uPort, cb));895 Log(("pitIOPortSpeakerRead: offPort=%#x cb=%x *pu32=unused!\n", offPort, cb)); 890 896 return VERR_IOM_IOPORT_UNUSED; 891 897 } … … 894 900 895 901 /** 896 * @callback_method_impl{FNIOMIOPORTOUT, Speaker} 897 */ 898 PDMBOTHCBDECL(int) pitIOPortSpeakerWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb) 899 { 900 RT_NOREF(pvUser, uPort); 902 * @callback_method_impl{FNIOMIOPORTNEWOUT, Speaker} 903 */ 904 static DECLCALLBACK(VBOXSTRICTRC) 905 pitR3IOPortSpeakerWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 906 { 907 RT_NOREF(pvUser, offPort); 901 908 if (cb == 1) 902 909 { … … 992 999 DEVPIT_UNLOCK_BOTH(pDevIns, pThis); 993 1000 } 994 Log(("pit IOPortSpeakerWrite: uPort=%#x cb=%x u32=%#x\n", uPort, cb, u32));1001 Log(("pitR3IOPortSpeakerWrite: offPort=%#x cb=%x u32=%#x\n", offPort, cb, u32)); 995 1002 return VINF_SUCCESS; 996 1003 } … … 1428 1435 * Register I/O ports. 1429 1436 */ 1430 rc = PDMDevHlpIOPortRegister(pDevIns, u16Base, 4, NULL, pitIOPortWrite, pitIOPortRead, NULL, NULL, "i8254 Programmable Interval Timer"); 1431 if (RT_FAILURE(rc)) 1432 return rc; 1433 if (pDevIns->fRCEnabled) 1434 { 1435 rc = PDMDevHlpIOPortRegisterRC(pDevIns, u16Base, 4, 0, "pitIOPortWrite", "pitIOPortRead", NULL, NULL, "i8254 Programmable Interval Timer"); 1436 if (RT_FAILURE(rc)) 1437 return rc; 1438 } 1439 if (pDevIns->fR0Enabled) 1440 { 1441 rc = PDMDevHlpIOPortRegisterR0(pDevIns, u16Base, 4, 0, "pitIOPortWrite", "pitIOPortRead", NULL, NULL, "i8254 Programmable Interval Timer"); 1442 if (RT_FAILURE(rc)) 1443 return rc; 1444 } 1437 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, u16Base, 4 /*cPorts*/, pitIOPortWrite, pitIOPortRead, 1438 "i8254 Programmable Interval Timer", NULL /*paExtDescs*/, &pThis->hIoPorts); 1439 AssertRCReturn(rc, rc); 1445 1440 1446 1441 if (fSpeaker) 1447 1442 { 1448 rc = PDMDevHlpIOPortRegister(pDevIns, 0x61, 1, NULL, pitIOPortSpeakerWrite, pitIOPortSpeakerRead, NULL, NULL, "PC Speaker"); 1449 if (RT_FAILURE(rc)) 1450 return rc; 1451 if (pDevIns->fRCEnabled) 1452 { 1453 rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x61, 1, 0, NULL, "pitIOPortSpeakerRead", NULL, NULL, "PC Speaker"); 1454 if (RT_FAILURE(rc)) 1455 return rc; 1456 } 1443 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, 0x61, 1 /*cPorts*/, pitR3IOPortSpeakerWrite, pitIOPortSpeakerRead, 1444 "PC Speaker", NULL /*paExtDescs*/, &pThis->hIoPortSpeaker); 1445 AssertRCReturn(rc, rc); 1457 1446 } 1458 1447 … … 1480 1469 } 1481 1470 1482 #endif /* IN_RING3 */ 1471 #else /* !IN_RING3 */ 1472 1473 /** 1474 * @callback_method_impl{PDMDEVREGR0,pfnConstruct} 1475 */ 1476 static DECLCALLBACK(int) picRZConstruct(PPDMDEVINS pDevIns) 1477 { 1478 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 1479 PPITSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPITSTATE); 1480 1481 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns)); 1482 AssertRCReturn(rc, rc); 1483 1484 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPorts, pitIOPortWrite, pitIOPortRead, NULL /*pvUser*/); 1485 AssertRCReturn(rc, rc); 1486 1487 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortSpeaker, NULL /*pfnWrite*/, pitIOPortSpeakerRead, NULL /*pvUser*/); 1488 AssertRCReturn(rc, rc); 1489 1490 return VINF_SUCCESS; 1491 } 1492 1493 #endif /* !IN_RING3 */ 1483 1494 1484 1495 /** … … 1527 1538 #elif defined(IN_RING0) 1528 1539 /* .pfnEarlyConstruct = */ NULL, 1529 /* .pfnConstruct = */ NULL,1540 /* .pfnConstruct = */ picRZConstruct, 1530 1541 /* .pfnDestruct = */ NULL, 1531 1542 /* .pfnFinalDestruct = */ NULL, … … 1540 1551 /* .pfnReserved7 = */ NULL, 1541 1552 #elif defined(IN_RC) 1542 /* .pfnConstruct = */ NULL,1553 /* .pfnConstruct = */ picRZConstruct, 1543 1554 /* .pfnReserved0 = */ NULL, 1544 1555 /* .pfnReserved1 = */ NULL,
Note:
See TracChangeset
for help on using the changeset viewer.