Changeset 99768 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- May 12, 2023 7:25:21 AM (22 months ago)
- svn:sync-xref-src-repo-rev:
- 157360
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevPit-i8254.cpp
r98103 r99768 231 231 /** Config: I/O port base. */ 232 232 RTIOPORT IOPortBaseCfg; 233 /** Config: Speaker enabled. */234 bool fSpeakerCfg;235 233 /** Disconnect PIT from the interrupt controllers if requested by HPET. */ 236 234 bool fDisabledByHpet; 237 /** Config: What to do with speaker activity. */238 PITSPEAKEREMU enmSpeakerEmu;239 #ifdef RT_OS_LINUX240 /** File handle for host speaker functionality. */241 int hHostSpeaker;242 int afAlignment2;243 #endif244 235 /** Number of IRQs that's been raised. */ 245 236 STAMCOUNTER StatPITIrq; … … 266 257 /** Pointer to the device instance. */ 267 258 PPDMDEVINSR3 pDevIns; 259 /** Config: Speaker enabled. */ 260 bool fSpeakerCfg; 261 /** Config: What to do with speaker activity. */ 262 PITSPEAKEREMU enmSpeakerEmu; 263 #ifdef RT_OS_LINUX 264 /** File handle for host speaker functionality. */ 265 int hHostSpeaker; 266 int afAlignment2; 267 #endif 268 268 } PITSTATER3; 269 269 /** Pointer to the ring-3 PIT device state. */ … … 881 881 * impact on VM execution. */ 882 882 # ifdef RT_OS_LINUX 883 if (pThis->enmSpeakerEmu != PIT_SPEAKER_EMU_NONE) 883 PPITSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PPITSTATER3); 884 885 if (pThisCC->enmSpeakerEmu != PIT_SPEAKER_EMU_NONE) 884 886 { 885 887 PPITCHANNEL pChan = &pThis->channels[2]; … … 887 889 { 888 890 Log2Func(("starting beep freq=%d\n", PIT_FREQ / pChan->count)); 889 switch (pThis ->enmSpeakerEmu)891 switch (pThisCC->enmSpeakerEmu) 890 892 { 891 893 case PIT_SPEAKER_EMU_CONSOLE: 892 894 { 893 895 int res; 894 res = ioctl(pThis ->hHostSpeaker, KIOCSOUND, pChan->count);896 res = ioctl(pThisCC->hHostSpeaker, KIOCSOUND, pChan->count); 895 897 if (res == -1) 896 898 { 897 899 LogRel(("PIT: speaker: ioctl failed errno=%d, disabling emulation\n", errno)); 898 pThis ->enmSpeakerEmu = PIT_SPEAKER_EMU_NONE;900 pThisCC->enmSpeakerEmu = PIT_SPEAKER_EMU_NONE; 899 901 } 900 902 break; … … 906 908 e.code = SND_TONE; 907 909 e.value = PIT_FREQ / pChan->count; 908 int res = write(pThis ->hHostSpeaker, &e, sizeof(struct input_event));910 int res = write(pThisCC->hHostSpeaker, &e, sizeof(struct input_event)); 909 911 NOREF(res); 910 912 break; … … 912 914 case PIT_SPEAKER_EMU_TTY: 913 915 { 914 int res = write(pThis ->hHostSpeaker, "\a", 1);916 int res = write(pThisCC->hHostSpeaker, "\a", 1); 915 917 NOREF(res); 916 918 break; … … 919 921 break; 920 922 default: 921 Log2Func(("unknown speaker emulation %d, disabling emulation\n", pThis ->enmSpeakerEmu));922 pThis ->enmSpeakerEmu = PIT_SPEAKER_EMU_NONE;923 Log2Func(("unknown speaker emulation %d, disabling emulation\n", pThisCC->enmSpeakerEmu)); 924 pThisCC->enmSpeakerEmu = PIT_SPEAKER_EMU_NONE; 923 925 } 924 926 } … … 926 928 { 927 929 Log2Func(("stopping beep\n")); 928 switch (pThis ->enmSpeakerEmu)930 switch (pThisCC->enmSpeakerEmu) 929 931 { 930 932 case PIT_SPEAKER_EMU_CONSOLE: … … 936 938 * disabled->disabled ones, but it's not worth the 937 939 * effort. */ 938 ioctl(pThis ->hHostSpeaker, KIOCSOUND, 0);940 ioctl(pThisCC->hHostSpeaker, KIOCSOUND, 0); 939 941 break; 940 942 case PIT_SPEAKER_EMU_EVDEV: … … 944 946 e.code = SND_TONE; 945 947 e.value = 0; 946 int res = write(pThis ->hHostSpeaker, &e, sizeof(struct input_event));948 int res = write(pThisCC->hHostSpeaker, &e, sizeof(struct input_event)); 947 949 NOREF(res); 948 950 break; … … 953 955 break; 954 956 default: 955 Log2Func(("unknown speaker emulation %d, disabling emulation\n", pThis ->enmSpeakerEmu));956 pThis ->enmSpeakerEmu = PIT_SPEAKER_EMU_NONE;957 Log2Func(("unknown speaker emulation %d, disabling emulation\n", pThisCC->enmSpeakerEmu)); 958 pThisCC->enmSpeakerEmu = PIT_SPEAKER_EMU_NONE; 957 959 } 958 960 } … … 974 976 static DECLCALLBACK(int) pitR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 975 977 { 976 PPITSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPITSTATE); 978 PPITSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPITSTATE); 979 PPITSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PPITSTATER3); 980 977 981 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 978 982 RT_NOREF(uPass); 979 983 pHlp->pfnSSMPutIOPort(pSSM, pThis->IOPortBaseCfg); 980 984 pHlp->pfnSSMPutU8( pSSM, pThis->channels[0].irq); 981 pHlp->pfnSSMPutBool( pSSM, pThis ->fSpeakerCfg);985 pHlp->pfnSSMPutBool( pSSM, pThisCC->fSpeakerCfg); 982 986 return VINF_SSM_DONT_CALL_AGAIN; 983 987 } … … 1040 1044 static DECLCALLBACK(int) pitR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1041 1045 { 1042 PPITSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPITSTATE); 1043 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1046 PPITSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPITSTATE); 1047 PPITSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PPITSTATER3); 1048 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1044 1049 int rc; 1045 1050 … … 1066 1071 bool fSpeakerCfg; 1067 1072 rc = pHlp->pfnSSMGetBool(pSSM, &fSpeakerCfg); AssertRCReturn(rc, rc); 1068 if (fSpeakerCfg != pThis ->fSpeakerCfg)1073 if (fSpeakerCfg != pThisCC->fSpeakerCfg) 1069 1074 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fSpeakerCfg: saved=%RTbool config=%RTbool"), 1070 fSpeakerCfg, pThis ->fSpeakerCfg);1075 fSpeakerCfg, pThisCC->fSpeakerCfg); 1071 1076 } 1072 1077 … … 1304 1309 1305 1310 /** 1311 * @interface_method_impl{PDMDEVREG,pfnDestruct} 1312 */ 1313 static DECLCALLBACK(int) pitR3Destruct(PPDMDEVINS pDevIns) 1314 { 1315 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 1316 1317 #ifdef RT_OS_LINUX 1318 PPITSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PPITSTATER3); 1319 1320 if (pThisCC->enmSpeakerEmu != PIT_SPEAKER_EMU_NONE) 1321 { 1322 Assert(pThisCC->hHostSpeaker != -1); 1323 close(pThisCC->hHostSpeaker); 1324 pThisCC->hHostSpeaker = -1; 1325 } 1326 #endif 1327 1328 return VINF_SUCCESS; 1329 } 1330 1331 1332 /** 1306 1333 * @interface_method_impl{PDMDEVREG,pfnConstruct} 1307 1334 */ … … 1358 1385 pThis->channels[i].iChan = i; 1359 1386 } 1360 pThis ->fSpeakerCfg= fSpeaker;1361 pThis ->enmSpeakerEmu= PIT_SPEAKER_EMU_NONE;1387 pThisCC->fSpeakerCfg = fSpeaker; 1388 pThisCC->enmSpeakerEmu = PIT_SPEAKER_EMU_NONE; 1362 1389 if (uPassthroughSpeaker) 1363 1390 { … … 1377 1404 if ((uPassthroughSpeaker == 9 || uPassthroughSpeaker == 100) && pszPassthroughSpeakerDevice && fd == -1) 1378 1405 fd = pitR3TryDeviceOpenSanitizeIoctl(pszPassthroughSpeakerDevice, O_WRONLY); 1379 if (pThis ->enmSpeakerEmu == PIT_SPEAKER_EMU_NONE && fd != -1)1406 if (pThisCC->enmSpeakerEmu == PIT_SPEAKER_EMU_NONE && fd != -1) 1380 1407 { 1381 pThis ->hHostSpeaker = fd;1408 pThisCC->hHostSpeaker = fd; 1382 1409 if (ioctl(fd, EVIOCGSND(0)) != -1) 1383 1410 { 1384 pThis ->enmSpeakerEmu = PIT_SPEAKER_EMU_EVDEV;1411 pThisCC->enmSpeakerEmu = PIT_SPEAKER_EMU_EVDEV; 1385 1412 LogRel(("PIT: speaker: emulation mode evdev\n")); 1386 1413 } 1387 1414 else 1388 1415 { 1389 pThis ->enmSpeakerEmu = PIT_SPEAKER_EMU_CONSOLE;1416 pThisCC->enmSpeakerEmu = PIT_SPEAKER_EMU_CONSOLE; 1390 1417 LogRel(("PIT: speaker: emulation mode console\n")); 1391 1418 } … … 1395 1422 if ((uPassthroughSpeaker == 79 || uPassthroughSpeaker == 100) && pszPassthroughSpeakerDevice && fd == -1) 1396 1423 fd = pitR3TryDeviceOpen(pszPassthroughSpeakerDevice, O_WRONLY); 1397 if (pThis ->enmSpeakerEmu == PIT_SPEAKER_EMU_NONE && fd != -1)1424 if (pThisCC->enmSpeakerEmu == PIT_SPEAKER_EMU_NONE && fd != -1) 1398 1425 { 1399 pThis ->hHostSpeaker = fd;1400 pThis ->enmSpeakerEmu = PIT_SPEAKER_EMU_TTY;1426 pThisCC->hHostSpeaker = fd; 1427 pThisCC->enmSpeakerEmu = PIT_SPEAKER_EMU_TTY; 1401 1428 LogRel(("PIT: speaker: emulation mode tty\n")); 1402 1429 } 1403 if (pThis ->enmSpeakerEmu == PIT_SPEAKER_EMU_NONE)1430 if (pThisCC->enmSpeakerEmu == PIT_SPEAKER_EMU_NONE) 1404 1431 { 1405 1432 Assert(fd == -1); … … 1526 1553 /* .pszR0Mod = */ "VBoxDDR0.r0", 1527 1554 /* .pfnConstruct = */ pitR3Construct, 1528 /* .pfnDestruct = */ NULL,1555 /* .pfnDestruct = */ pitR3Destruct, 1529 1556 /* .pfnRelocate = */ NULL, 1530 1557 /* .pfnMemSetup = */ NULL,
Note:
See TracChangeset
for help on using the changeset viewer.