Changeset 82232 in vbox
- Timestamp:
- Nov 27, 2019 12:52:28 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r82231 r82232 56 56 #include <VBox/vmm/pdmdev.h> 57 57 #include <VBox/vmm/pdmaudioifs.h> 58 #include <VBox/AssertGuest.h> 58 59 59 60 #include "VBoxDD.h" … … 199 200 int align; 200 201 201 RTLISTANCHOR 202 RTLISTANCHOR lstDrv; 202 203 /** IRQ timer */ 203 TMTIMERHANDLE 204 TMTIMERHANDLE hTimerIRQ; 204 205 /** The base interface for LUN\#0. */ 205 PDMIBASE 206 PDMIBASE IBase; 206 207 /** Output stream. */ 207 SB16STREAM 208 SB16STREAM Out; 208 209 209 210 /** The timer for pumping data thru the attached LUN drivers. */ 210 TMTIMERHANDLE 211 TMTIMERHANDLE hTimerIO; 211 212 /** The timer interval for pumping data thru the LUN drivers in timer ticks. */ 212 uint64_t 213 uint64_t cTicksTimerIOInterval; 213 214 /** Timestamp of the last timer callback (sb16TimerIO). 214 215 * Used to calculate the time actually elapsed between two timer callbacks. */ 215 uint64_t 216 uint64_t tsTimerIO; 216 217 /** Number of active (running) SDn streams. */ 217 uint8_t 218 uint8_t cStreamsActive; 218 219 /** Flag indicating whether the timer is active or not. */ 219 bool volatile fTimerActive; 220 uint8_t u8Padding1[5]; 220 bool volatile fTimerActive; 221 uint8_t u8Padding1[5]; 222 223 /** The two mixer I/O ports (port + 4). */ 224 IOMIOPORTHANDLE hIoPortsMixer; 225 /** The 10 DSP I/O ports (port + 6). */ 226 IOMIOPORTHANDLE hIoPortsDsp; 221 227 222 228 /* mixer state */ … … 945 951 946 952 /** 947 * @callback_method_impl{PFNIOMIOPORTOUT} 948 */ 949 static DECLCALLBACK(int) dsp_write(PPDMDEVINS pDevIns, void *opaque, RTIOPORT nport, uint32_t val, unsigned cb) 950 { 951 RT_NOREF(pDevIns, cb); 952 PSB16STATE pThis = (PSB16STATE)opaque; 953 int iport = nport - pThis->port; 954 955 LogFlowFunc(("write %#x <- %#x\n", nport, val)); 956 switch (iport) 957 { 958 case 0x06: 959 switch (val) 953 * @callback_method_impl{PFNIOMIOPORTNEWOUT} 954 */ 955 static DECLCALLBACK(VBOXSTRICTRC) sb16IoPortDspWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 956 { 957 PSB16STATE pThis = PDMDEVINS_2_DATA(pDevIns, PSB16STATE); 958 RT_NOREF(pvUser, cb); 959 960 LogFlowFunc(("write %#x <- %#x\n", offPort, u32)); 961 switch (offPort) 962 { 963 case 0: 964 switch (u32) 960 965 { 961 966 case 0x00: … … 996 1001 997 1002 default: 998 pThis->v2x6 = val;1003 pThis->v2x6 = u32; 999 1004 break; 1000 1005 } 1001 1006 break; 1002 1007 1003 case 0x0c:/* Write data or command | write status */1008 case 6: /* Write data or command | write status */ 1004 1009 #if 0 1005 1010 if (pThis->highspeed) … … 1008 1013 if (0 == pThis->needed_bytes) 1009 1014 { 1010 sb16HandleCommand(pDevIns, pThis, val);1015 sb16HandleCommand(pDevIns, pThis, u32); 1011 1016 #if 0 1012 1017 if (0 == pThis->needed_bytes) { … … 1023 1028 else 1024 1029 { 1025 pThis->in2_data[pThis->in_index++] = val;1030 pThis->in2_data[pThis->in_index++] = u32; 1026 1031 if (pThis->in_index == pThis->needed_bytes) 1027 1032 { … … 1037 1042 1038 1043 default: 1039 LogFlowFunc((" nport=%#x, val=%#x)\n", nport, val));1044 LogFlowFunc(("offPort=%#x, u32=%#x)\n", offPort, u32)); 1040 1045 break; 1041 1046 } … … 1046 1051 1047 1052 /** 1048 * @callback_method_impl{PFNIOMIOPORT IN}1049 */ 1050 static DECLCALLBACK( int) dsp_read(PPDMDEVINS pDevIns, void *opaque, RTIOPORT nport, uint32_t *pu32, unsigned cb)1051 { 1052 RT_NOREF(pDevIns, cb);1053 PSB16STATE pThis = (PSB16STATE)opaque;1054 int iport, retval,ack = 0;1055 1056 iport = nport - pThis->port; 1053 * @callback_method_impl{PFNIOMIOPORTNEWIN} 1054 */ 1055 static DECLCALLBACK(VBOXSTRICTRC) sb16IoPortDspRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 1056 { 1057 PSB16STATE pThis = PDMDEVINS_2_DATA(pDevIns, PSB16STATE); 1058 uint32_t retval; 1059 int ack = 0; 1060 RT_NOREF(pvUser, cb); 1061 1057 1062 1058 1063 /** @todo reject non-byte access? 1059 1064 * The spec does not mention a non-byte access so we should check how real hardware behaves. */ 1060 1065 1061 switch ( iport)1062 { 1063 case 0 x06:/* reset */1066 switch (offPort) 1067 { 1068 case 0: /* reset */ 1064 1069 retval = 0xff; 1065 1070 break; 1066 1071 1067 case 0x0a:/* read data */1072 case 4: /* read data */ 1068 1073 if (pThis->out_data_len) 1069 1074 { … … 1080 1085 break; 1081 1086 1082 case 0x0c:/* 0 can write */1087 case 6: /* 0 can write */ 1083 1088 retval = pThis->can_write ? 0 : 0x80; 1084 1089 break; 1085 1090 1086 case 0x0d:/* timer interrupt clear */1091 case 7: /* timer interrupt clear */ 1087 1092 /* LogFlowFunc(("timer interrupt clear\n")); */ 1088 1093 retval = 0; … … 1099 1104 break; 1100 1105 1101 case 0x0f:/* irq 16 ack */1106 case 9: /* irq 16 ack */ 1102 1107 retval = 0xff; 1103 1108 if (pThis->mixer_regs[0x82] & 2) … … 1110 1115 1111 1116 default: 1112 goto error; 1117 LogFlowFunc(("warning: sb16IoPortDspRead %#x error\n", offPort)); 1118 return VERR_IOM_IOPORT_UNUSED; 1113 1119 } 1114 1120 1115 1121 if (!ack) 1116 LogFlowFunc(("read %#x -> %#x\n", nport, retval));1122 LogFlowFunc(("read %#x -> %#x\n", offPort, retval)); 1117 1123 1118 1124 *pu32 = retval; 1119 1125 return VINF_SUCCESS; 1120 1121 error:1122 LogFlowFunc(("warning: dsp_read %#x error\n", nport));1123 return VERR_IOM_IOPORT_UNUSED;1124 1126 } 1125 1127 … … 1337 1339 bool fUpdateStream = false; 1338 1340 1339 LogFlowFunc((" mixer_write [%#x] <- %#x\n", pThis->mixer_nreg, val));1341 LogFlowFunc(("sb16IoPortMixerWrite [%#x] <- %#x\n", pThis->mixer_nreg, val)); 1340 1342 1341 1343 switch (pThis->mixer_nreg) … … 1462 1464 1463 1465 /** 1464 * @callback_method_impl{PFNIOMIOPORT OUT}1465 */ 1466 static DECLCALLBACK( int) mixer_write(PPDMDEVINS pDevIns, void *opaque, RTIOPORT nport, uint32_t val, unsigned cb)1467 { 1468 RT_NOREF(pDevIns);1469 PSB16STATE pThis = (PSB16STATE)opaque;1470 int iport = nport - pThis->port; 1466 * @callback_method_impl{PFNIOMIOPORTNEWOUT} 1467 */ 1468 static DECLCALLBACK(VBOXSTRICTRC) sb16IoPortMixerWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 1469 { 1470 PSB16STATE pThis = PDMDEVINS_2_DATA(pDevIns, PSB16STATE); 1471 RT_NOREF(pvUser); 1472 1471 1473 switch (cb) 1472 1474 { 1473 1475 case 1: 1474 switch ( iport)1476 switch (offPort) 1475 1477 { 1476 case 4:1477 mixer_write_indexb(pThis, val);1478 case 0: 1479 mixer_write_indexb(pThis, u32); 1478 1480 break; 1479 case 5:1480 mixer_write_datab(pThis, val);1481 case 1: 1482 mixer_write_datab(pThis, u32); 1481 1483 break; 1484 default: 1485 AssertFailed(); 1482 1486 } 1483 1487 break; 1484 1488 case 2: 1485 mixer_write_indexb(pThis, val& 0xff);1486 mixer_write_datab(pThis, ( val>> 8) & 0xff);1489 mixer_write_indexb(pThis, u32 & 0xff); 1490 mixer_write_datab(pThis, (u32 >> 8) & 0xff); 1487 1491 break; 1488 1492 default: 1489 A ssertMsgFailed(("Port=%#x cb=%d u32=%#x\n", nport, cb, val));1493 ASSERT_GUEST_MSG_FAILED(("offPort=%#x cb=%d u32=%#x\n", offPort, cb, u32)); 1490 1494 break; 1491 1495 } … … 1494 1498 1495 1499 /** 1496 * @callback_method_impl{PFNIOMIOPORT IN}1497 */ 1498 static DECLCALLBACK( int) mixer_read(PPDMDEVINS pDevIns, void *opaque, RTIOPORT nport, uint32_t *pu32, unsigned cb)1499 { 1500 RT_NOREF(pDevIns, cb, nport);1501 PSB16STATE pThis = (PSB16STATE)opaque;1500 * @callback_method_impl{PFNIOMIOPORTNEWIN} 1501 */ 1502 static DECLCALLBACK(VBOXSTRICTRC) sb16IoPortMixerRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 1503 { 1504 PSB16STATE pThis = PDMDEVINS_2_DATA(pDevIns, PSB16STATE); 1505 RT_NOREF(pvUser, cb, offPort); 1502 1506 1503 1507 #ifndef DEBUG_SB16_MOST 1504 1508 if (pThis->mixer_nreg != 0x82) 1505 LogFlowFunc((" mixer_read[%#x] -> %#x\n", pThis->mixer_nreg, pThis->mixer_regs[pThis->mixer_nreg]));1509 LogFlowFunc(("sb16IoPortMixerRead[%#x] -> %#x\n", pThis->mixer_nreg, pThis->mixer_regs[pThis->mixer_nreg])); 1506 1510 #else 1507 LogFlowFunc((" mixer_read[%#x] -> %#x\n", pThis->mixer_nreg, pThis->mixer_regs[pThis->mixer_nreg]));1511 LogFlowFunc(("sb16IoPortMixerRead[%#x] -> %#x\n", pThis->mixer_nreg, pThis->mixer_regs[pThis->mixer_nreg])); 1508 1512 #endif 1509 1513 *pu32 = pThis->mixer_regs[pThis->mixer_nreg]; … … 2446 2450 * Register I/O and DMA. 2447 2451 */ 2448 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->port + 0x04, 2, pThis, mixer_write, mixer_read, NULL, NULL, "SB16"); 2452 static const IOMIOPORTDESC s_aAllDescs[] = 2453 { 2454 { "FM Music Status Port", "FM Music Register Address Port", NULL, NULL }, // 00h 2455 { NULL, "FM Music Data Port", NULL, NULL }, // 01h 2456 { "Advanced FM Music Status Port", "Advanced FM Music Register Address Port", NULL, NULL }, // 02h 2457 { NULL, "Advanced FM Music Data Port", NULL, NULL }, // 03h 2458 { NULL, "Mixer chip Register Address Port", NULL, NULL }, // 04h 2459 { "Mixer chip Data Port", NULL, NULL, NULL }, // 05h 2460 { NULL, "DSP Reset", NULL, NULL }, // 06h 2461 { "Unused7", "Unused7", NULL, NULL }, // 07h 2462 { "FM Music Status Port", "FM Music Register Port", NULL, NULL }, // 08h 2463 { NULL, "FM Music Data Port", NULL, NULL }, // 09h 2464 { "DSP Read Data Port", NULL, NULL, NULL }, // 0Ah 2465 { "UnusedB", "UnusedB", NULL, NULL }, // 0Bh 2466 { "DSP Write-Buffer Status", "DSP Write Command/Data", NULL, NULL }, // 0Ch 2467 { "UnusedD", "UnusedD", NULL, NULL }, // 0Dh 2468 { "DSP Read-Buffer Status", NULL, NULL, NULL }, // 0Eh 2469 { "IRQ16ACK", NULL, NULL, NULL }, // 0Fh 2470 { "CD-ROM Data Register", "CD-ROM Command Register", NULL, NULL }, // 10h 2471 { "CD-ROM Status Register", NULL, NULL, NULL }, // 11h 2472 { NULL, "CD-ROM Reset Register", NULL, NULL }, // 12h 2473 { NULL, "CD-ROM Enable Register", NULL, NULL }, // 13h 2474 { NULL, NULL, NULL, NULL }, 2475 }; 2476 2477 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, pThis->port + 0x04 /*uPort*/, 2 /*cPorts*/, 2478 sb16IoPortMixerWrite, sb16IoPortMixerRead, 2479 "SB16 - Mixer", &s_aAllDescs[4], &pThis->hIoPortsMixer); 2449 2480 AssertRCReturn(rc, rc); 2450 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->port + 0x06, 10, pThis, dsp_write, dsp_read, NULL, NULL, "SB16"); 2481 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, pThis->port + 0x06 /*uPort*/, 10 /*cPorts*/, 2482 sb16IoPortDspWrite, sb16IoPortDspRead, 2483 "SB16 - DSP", &s_aAllDescs[6], &pThis->hIoPortsDsp); 2451 2484 AssertRCReturn(rc, rc); 2452 2485
Note:
See TracChangeset
for help on using the changeset viewer.