- Timestamp:
- Feb 14, 2013 8:07:57 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83798
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DevOHCI.cpp
r44698 r44699 766 766 static DECLCALLBACK(bool) ohciRhXferError(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb); 767 767 768 static int ohci_in_flight_find(POHCI p Ohci, uint32_t GCPhysTD);768 static int ohci_in_flight_find(POHCI pThis, uint32_t GCPhysTD); 769 769 # if defined(VBOX_STRICT) || defined(LOG_ENABLED) 770 static int ohci_in_done_queue_find(POHCI p Ohci, uint32_t GCPhysTD);770 static int ohci_in_done_queue_find(POHCI pThis, uint32_t GCPhysTD); 771 771 # endif 772 772 static DECLCALLBACK(void) ohciR3LoadReattachDevices(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); … … 817 817 818 818 /* Carry out a hardware remote wakeup */ 819 static void ohci_remote_wakeup(POHCI p Ohci)820 { 821 if ((p Ohci->ctl & OHCI_CTL_HCFS) != OHCI_USB_SUSPEND)819 static void ohci_remote_wakeup(POHCI pThis) 820 { 821 if ((pThis->ctl & OHCI_CTL_HCFS) != OHCI_USB_SUSPEND) 822 822 return; 823 if (!(p Ohci->RootHub.status & OHCI_RHS_DRWE))823 if (!(pThis->RootHub.status & OHCI_RHS_DRWE)) 824 824 return; 825 ohciBusResume(p Ohci, true /* hardware */);825 ohciBusResume(pThis, true /* hardware */); 826 826 } 827 827 … … 849 849 static DECLCALLBACK(int) ohciRhQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed) 850 850 { 851 POHCI p Ohci= (POHCI)((uintptr_t)pInterface - RT_OFFSETOF(OHCI, RootHub.ILeds));851 POHCI pThis = (POHCI)((uintptr_t)pInterface - RT_OFFSETOF(OHCI, RootHub.ILeds)); 852 852 if (iLUN == 0) 853 853 { 854 *ppLed = &p Ohci->RootHub.Led;854 *ppLed = &pThis->RootHub.Led; 855 855 return VINF_SUCCESS; 856 856 } … … 872 872 static DECLCALLBACK(unsigned) ohciRhGetAvailablePorts(PVUSBIROOTHUBPORT pInterface, PVUSBPORTBITMAP pAvailable) 873 873 { 874 POHCI p Ohci= VUSBIROOTHUBPORT_2_OHCI(pInterface);874 POHCI pThis = VUSBIROOTHUBPORT_2_OHCI(pInterface); 875 875 unsigned iPort; 876 876 unsigned cPorts = 0; … … 878 878 memset(pAvailable, 0, sizeof(*pAvailable)); 879 879 880 PDMCritSectEnter(p Ohci->pDevInsR3->pCritSectRoR3, VERR_IGNORED);881 for (iPort = 0; iPort < RT_ELEMENTS(p Ohci->RootHub.aPorts); iPort++)882 { 883 if (!p Ohci->RootHub.aPorts[iPort].pDev)880 PDMCritSectEnter(pThis->pDevInsR3->pCritSectRoR3, VERR_IGNORED); 881 for (iPort = 0; iPort < RT_ELEMENTS(pThis->RootHub.aPorts); iPort++) 882 { 883 if (!pThis->RootHub.aPorts[iPort].pDev) 884 884 { 885 885 cPorts++; … … 887 887 } 888 888 } 889 PDMCritSectLeave(p Ohci->pDevInsR3->pCritSectRoR3);889 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); 890 890 891 891 return cPorts; … … 914 914 static DECLCALLBACK(int) ohciRhAttach(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort) 915 915 { 916 POHCI p Ohci= VUSBIROOTHUBPORT_2_OHCI(pInterface);916 POHCI pThis = VUSBIROOTHUBPORT_2_OHCI(pInterface); 917 917 LogFlow(("ohciRhAttach: pDev=%p uPort=%u\n", pDev, uPort)); 918 PDMCritSectEnter(p Ohci->pDevInsR3->pCritSectRoR3, VERR_IGNORED);918 PDMCritSectEnter(pThis->pDevInsR3->pCritSectRoR3, VERR_IGNORED); 919 919 920 920 /* 921 921 * Validate and adjust input. 922 922 */ 923 Assert(uPort >= 1 && uPort <= RT_ELEMENTS(p Ohci->RootHub.aPorts));923 Assert(uPort >= 1 && uPort <= RT_ELEMENTS(pThis->RootHub.aPorts)); 924 924 uPort--; 925 Assert(!p Ohci->RootHub.aPorts[uPort].pDev);925 Assert(!pThis->RootHub.aPorts[uPort].pDev); 926 926 927 927 /* 928 928 * Attach it. 929 929 */ 930 p Ohci->RootHub.aPorts[uPort].fReg = OHCI_PORT_R_CURRENT_CONNECT_STATUS | OHCI_PORT_R_CONNECT_STATUS_CHANGE;931 p Ohci->RootHub.aPorts[uPort].pDev = pDev;932 rhport_power(&p Ohci->RootHub, uPort, 1 /* power on */);933 934 ohci_remote_wakeup(p Ohci);935 ohciSetInterrupt(p Ohci, OHCI_INTR_ROOT_HUB_STATUS_CHANGE);936 937 PDMCritSectLeave(p Ohci->pDevInsR3->pCritSectRoR3);930 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_R_CURRENT_CONNECT_STATUS | OHCI_PORT_R_CONNECT_STATUS_CHANGE; 931 pThis->RootHub.aPorts[uPort].pDev = pDev; 932 rhport_power(&pThis->RootHub, uPort, 1 /* power on */); 933 934 ohci_remote_wakeup(pThis); 935 ohciSetInterrupt(pThis, OHCI_INTR_ROOT_HUB_STATUS_CHANGE); 936 937 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); 938 938 return VINF_SUCCESS; 939 939 } … … 949 949 static DECLCALLBACK(void) ohciRhDetach(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort) 950 950 { 951 POHCI p Ohci= VUSBIROOTHUBPORT_2_OHCI(pInterface);951 POHCI pThis = VUSBIROOTHUBPORT_2_OHCI(pInterface); 952 952 LogFlow(("ohciRhDetach: pDev=%p uPort=%u\n", pDev, uPort)); 953 PDMCritSectEnter(p Ohci->pDevInsR3->pCritSectRoR3, VERR_IGNORED);953 PDMCritSectEnter(pThis->pDevInsR3->pCritSectRoR3, VERR_IGNORED); 954 954 955 955 /* 956 956 * Validate and adjust input. 957 957 */ 958 Assert(uPort >= 1 && uPort <= RT_ELEMENTS(p Ohci->RootHub.aPorts));958 Assert(uPort >= 1 && uPort <= RT_ELEMENTS(pThis->RootHub.aPorts)); 959 959 uPort--; 960 Assert(p Ohci->RootHub.aPorts[uPort].pDev == pDev);960 Assert(pThis->RootHub.aPorts[uPort].pDev == pDev); 961 961 962 962 /* 963 963 * Detach it. 964 964 */ 965 p Ohci->RootHub.aPorts[uPort].pDev = NULL;966 if (p Ohci->RootHub.aPorts[uPort].fReg & OHCI_PORT_PES)967 p Ohci->RootHub.aPorts[uPort].fReg = OHCI_PORT_R_CONNECT_STATUS_CHANGE | OHCI_PORT_PESC;965 pThis->RootHub.aPorts[uPort].pDev = NULL; 966 if (pThis->RootHub.aPorts[uPort].fReg & OHCI_PORT_PES) 967 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_R_CONNECT_STATUS_CHANGE | OHCI_PORT_PESC; 968 968 else 969 p Ohci->RootHub.aPorts[uPort].fReg = OHCI_PORT_R_CONNECT_STATUS_CHANGE;970 971 ohci_remote_wakeup(p Ohci);972 ohciSetInterrupt(p Ohci, OHCI_INTR_ROOT_HUB_STATUS_CHANGE);973 974 PDMCritSectLeave(p Ohci->pDevInsR3->pCritSectRoR3);969 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_R_CONNECT_STATUS_CHANGE; 970 971 ohci_remote_wakeup(pThis); 972 ohciSetInterrupt(pThis, OHCI_INTR_ROOT_HUB_STATUS_CHANGE); 973 974 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); 975 975 } 976 976 … … 1009 1009 static DECLCALLBACK(int) ohciRhReset(PVUSBIROOTHUBPORT pInterface, bool fResetOnLinux) 1010 1010 { 1011 POHCI p Ohci= VUSBIROOTHUBPORT_2_OHCI(pInterface);1012 PDMCritSectEnter(p Ohci->pDevInsR3->pCritSectRoR3, VERR_IGNORED);1013 1014 p Ohci->RootHub.status = 0;1015 p Ohci->RootHub.desc_a = OHCI_RHA_NPS | OHCI_NDP;1016 p Ohci->RootHub.desc_b = 0x0; /* Impl. specific */1011 POHCI pThis = VUSBIROOTHUBPORT_2_OHCI(pInterface); 1012 PDMCritSectEnter(pThis->pDevInsR3->pCritSectRoR3, VERR_IGNORED); 1013 1014 pThis->RootHub.status = 0; 1015 pThis->RootHub.desc_a = OHCI_RHA_NPS | OHCI_NDP; 1016 pThis->RootHub.desc_b = 0x0; /* Impl. specific */ 1017 1017 1018 1018 /* … … 1028 1028 * into this. For the time being we stick with simple. 1029 1029 */ 1030 for (unsigned iPort = 0; iPort < RT_ELEMENTS(p Ohci->RootHub.aPorts); iPort++)1031 { 1032 if (p Ohci->RootHub.aPorts[iPort].pDev)1030 for (unsigned iPort = 0; iPort < RT_ELEMENTS(pThis->RootHub.aPorts); iPort++) 1031 { 1032 if (pThis->RootHub.aPorts[iPort].pDev) 1033 1033 { 1034 p Ohci->RootHub.aPorts[iPort].fReg = OHCI_PORT_R_CURRENT_CONNECT_STATUS | OHCI_PORT_R_CONNECT_STATUS_CHANGE;1034 pThis->RootHub.aPorts[iPort].fReg = OHCI_PORT_R_CURRENT_CONNECT_STATUS | OHCI_PORT_R_CONNECT_STATUS_CHANGE; 1035 1035 if (fResetOnLinux) 1036 1036 { 1037 PVM pVM = PDMDevHlpGetVM(p Ohci->CTX_SUFF(pDevIns));1038 VUSBIDevReset(p Ohci->RootHub.aPorts[iPort].pDev, fResetOnLinux, ohciRhResetDoneOneDev, pOhci, pVM);1037 PVM pVM = PDMDevHlpGetVM(pThis->CTX_SUFF(pDevIns)); 1038 VUSBIDevReset(pThis->RootHub.aPorts[iPort].pDev, fResetOnLinux, ohciRhResetDoneOneDev, pThis, pVM); 1039 1039 } 1040 1040 } 1041 1041 else 1042 p Ohci->RootHub.aPorts[iPort].fReg = 0;1043 } 1044 1045 PDMCritSectLeave(p Ohci->pDevInsR3->pCritSectRoR3);1042 pThis->RootHub.aPorts[iPort].fReg = 0; 1043 } 1044 1045 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); 1046 1046 return VINF_SUCCESS; 1047 1047 } … … 1054 1054 * and device construction. 1055 1055 * 1056 * @param p OhciThe ohci instance data.1056 * @param pThis The ohci instance data. 1057 1057 * @param fNewMode The new mode of operation. This is UsbSuspend if it's a 1058 1058 * software reset, and UsbReset if it's a hardware reset / cold boot. … … 1067 1067 * @remark This hasn't got anything to do with software setting the mode to UsbReset. 1068 1068 */ 1069 static void ohciDoReset(POHCI p Ohci, uint32_t fNewMode, bool fResetOnLinux)1069 static void ohciDoReset(POHCI pThis, uint32_t fNewMode, bool fResetOnLinux) 1070 1070 { 1071 1071 Log(("ohci: %s reset%s\n", fNewMode == OHCI_USB_RESET ? "hardware" : "software", … … 1079 1079 * any more when a reset has been signaled. 1080 1080 */ 1081 p Ohci->RootHub.pIRhConn->pfnCancelAllUrbs(pOhci->RootHub.pIRhConn);1081 pThis->RootHub.pIRhConn->pfnCancelAllUrbs(pThis->RootHub.pIRhConn); 1082 1082 1083 1083 /* … … 1085 1085 */ 1086 1086 if (fNewMode == OHCI_USB_RESET) 1087 p Ohci->ctl |= OHCI_CTL_RWC; /* We're the firmware, set RemoteWakeupConnected. */1087 pThis->ctl |= OHCI_CTL_RWC; /* We're the firmware, set RemoteWakeupConnected. */ 1088 1088 else 1089 p Ohci->ctl &= OHCI_CTL_IR | OHCI_CTL_RWC; /* IR and RWC are preserved on software reset. */1090 p Ohci->ctl |= fNewMode;1091 p Ohci->status = 0;1092 p Ohci->intr_status = 0;1093 p Ohci->intr = OHCI_INTR_MASTER_INTERRUPT_ENABLED; /* (We follow the text and the not reset value column,) */1094 1095 p Ohci->hcca = 0;1096 p Ohci->per_cur = 0;1097 p Ohci->ctrl_head = pOhci->ctrl_cur = 0;1098 p Ohci->bulk_head = pOhci->bulk_cur = 0;1099 p Ohci->done = 0;1100 1101 p Ohci->fsmps = 0x2778; /* To-Be-Defined, use the value linux sets...*/1102 p Ohci->fit = 0;1103 p Ohci->fi = 11999; /* (12MHz ticks, one frame is 1ms) */1104 p Ohci->frt = 0;1105 p Ohci->HcFmNumber = 0;1106 p Ohci->pstart = 0;1107 1108 p Ohci->dqic = 0x7;1109 p Ohci->fno = 0;1089 pThis->ctl &= OHCI_CTL_IR | OHCI_CTL_RWC; /* IR and RWC are preserved on software reset. */ 1090 pThis->ctl |= fNewMode; 1091 pThis->status = 0; 1092 pThis->intr_status = 0; 1093 pThis->intr = OHCI_INTR_MASTER_INTERRUPT_ENABLED; /* (We follow the text and the not reset value column,) */ 1094 1095 pThis->hcca = 0; 1096 pThis->per_cur = 0; 1097 pThis->ctrl_head = pThis->ctrl_cur = 0; 1098 pThis->bulk_head = pThis->bulk_cur = 0; 1099 pThis->done = 0; 1100 1101 pThis->fsmps = 0x2778; /* To-Be-Defined, use the value linux sets...*/ 1102 pThis->fit = 0; 1103 pThis->fi = 11999; /* (12MHz ticks, one frame is 1ms) */ 1104 pThis->frt = 0; 1105 pThis->HcFmNumber = 0; 1106 pThis->pstart = 0; 1107 1108 pThis->dqic = 0x7; 1109 pThis->fno = 0; 1110 1110 1111 1111 /* … … 1116 1116 */ 1117 1117 if (fNewMode == OHCI_USB_RESET) 1118 VUSBIDevReset(p Ohci->RootHub.pIDev, fResetOnLinux, NULL, NULL, NULL);1118 VUSBIDevReset(pThis->RootHub.pIDev, fResetOnLinux, NULL, NULL, NULL); 1119 1119 } 1120 1120 #endif /* IN_RING3 */ … … 1123 1123 * Reads physical memory. 1124 1124 */ 1125 DECLINLINE(void) ohciPhysRead(POHCI p Ohci, uint32_t Addr, void *pvBuf, size_t cbBuf)1125 DECLINLINE(void) ohciPhysRead(POHCI pThis, uint32_t Addr, void *pvBuf, size_t cbBuf) 1126 1126 { 1127 1127 if (cbBuf) 1128 PDMDevHlpPhysRead(p Ohci->CTX_SUFF(pDevIns), Addr, pvBuf, cbBuf);1128 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), Addr, pvBuf, cbBuf); 1129 1129 } 1130 1130 … … 1132 1132 * Writes physical memory. 1133 1133 */ 1134 DECLINLINE(void) ohciPhysWrite(POHCI p Ohci, uint32_t Addr, const void *pvBuf, size_t cbBuf)1134 DECLINLINE(void) ohciPhysWrite(POHCI pThis, uint32_t Addr, const void *pvBuf, size_t cbBuf) 1135 1135 { 1136 1136 if (cbBuf) 1137 PDMDevHlpPhysWrite(p Ohci->CTX_SUFF(pDevIns), Addr, pvBuf, cbBuf);1137 PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), Addr, pvBuf, cbBuf); 1138 1138 } 1139 1139 … … 1141 1141 * Read an array of dwords from physical memory and correct endianness. 1142 1142 */ 1143 DECLINLINE(void) ohciGetDWords(POHCI p Ohci, uint32_t Addr, uint32_t *pau32s, int c32s)1144 { 1145 ohciPhysRead(p Ohci, Addr, pau32s, c32s * sizeof(uint32_t));1143 DECLINLINE(void) ohciGetDWords(POHCI pThis, uint32_t Addr, uint32_t *pau32s, int c32s) 1144 { 1145 ohciPhysRead(pThis, Addr, pau32s, c32s * sizeof(uint32_t)); 1146 1146 #if BYTE_ORDER != LITTLE_ENDIAN 1147 1147 for(int i = 0; i < c32s; i++) … … 1153 1153 * Write an array of dwords from physical memory and correct endianness. 1154 1154 */ 1155 DECLINLINE(void) ohciPutDWords(POHCI p Ohci, uint32_t Addr, const uint32_t *pau32s, int cu32s)1155 DECLINLINE(void) ohciPutDWords(POHCI pThis, uint32_t Addr, const uint32_t *pau32s, int cu32s) 1156 1156 { 1157 1157 #if BYTE_ORDER == LITTLE_ENDIAN 1158 ohciPhysWrite(p Ohci, Addr, pau32s, cu32s << 2);1158 ohciPhysWrite(pThis, Addr, pau32s, cu32s << 2); 1159 1159 #else 1160 1160 for (int i = 0; i < c32s; i++, pau32s++, Addr += sizeof(*pau32s)) 1161 1161 { 1162 1162 uint32_t u32Tmp = RT_H2LE_U32(*pau32s); 1163 ohciPhysWrite(p Ohci, Addr, (uint8_t *)&u32Tmp, sizeof(u32Tmp));1163 ohciPhysWrite(pThis, Addr, (uint8_t *)&u32Tmp, sizeof(u32Tmp)); 1164 1164 } 1165 1165 #endif … … 1172 1172 * Reads an OHCIED. 1173 1173 */ 1174 DECLINLINE(void) ohciReadEd(POHCI p Ohci, uint32_t EdAddr, POHCIED pEd)1175 { 1176 ohciGetDWords(p Ohci, EdAddr, (uint32_t *)pEd, sizeof(*pEd) >> 2);1174 DECLINLINE(void) ohciReadEd(POHCI pThis, uint32_t EdAddr, POHCIED pEd) 1175 { 1176 ohciGetDWords(pThis, EdAddr, (uint32_t *)pEd, sizeof(*pEd) >> 2); 1177 1177 } 1178 1178 … … 1180 1180 * Reads an OHCITD. 1181 1181 */ 1182 DECLINLINE(void) ohciReadTd(POHCI p Ohci, uint32_t TdAddr, POHCITD pTd)1183 { 1184 ohciGetDWords(p Ohci, TdAddr, (uint32_t *)pTd, sizeof(*pTd) >> 2);1182 DECLINLINE(void) ohciReadTd(POHCI pThis, uint32_t TdAddr, POHCITD pTd) 1183 { 1184 ohciGetDWords(pThis, TdAddr, (uint32_t *)pTd, sizeof(*pTd) >> 2); 1185 1185 #ifdef LOG_ENABLED 1186 1186 if (LogIs3Enabled()) … … 1216 1216 */ 1217 1217 uint8_t abXpTd[0x80]; 1218 ohciPhysRead(p Ohci, TdAddr, abXpTd, sizeof(abXpTd));1218 ohciPhysRead(pThis, TdAddr, abXpTd, sizeof(abXpTd)); 1219 1219 Log3(("WinXpTd: alloc=%d PhysSelf=%RX32 s2=%RX32 magic=%RX32 s4=%RX32 s5=%RX32\n" 1220 1220 "%.*Rhxd\n", … … 1233 1233 * Reads an OHCIITD. 1234 1234 */ 1235 DECLINLINE(void) ohciReadITd(POHCI p Ohci, uint32_t ITdAddr, POHCIITD pITd)1236 { 1237 ohciGetDWords(p Ohci, ITdAddr, (uint32_t *)pITd, sizeof(*pITd) / sizeof(uint32_t));1235 DECLINLINE(void) ohciReadITd(POHCI pThis, uint32_t ITdAddr, POHCIITD pITd) 1236 { 1237 ohciGetDWords(pThis, ITdAddr, (uint32_t *)pITd, sizeof(*pITd) / sizeof(uint32_t)); 1238 1238 #ifdef LOG_ENABLED 1239 1239 if (LogIs3Enabled()) … … 1241 1241 Log3(("ohciReadITd(,%#010x,): SF=%#06x (%#RX32) DI=%#x FC=%d CC=%#x BP0=%#010x NextTD=%#010x BE=%#010x\n", 1242 1242 ITdAddr, 1243 pITd->HwInfo & 0xffff, p Ohci->HcFmNumber,1243 pITd->HwInfo & 0xffff, pThis->HcFmNumber, 1244 1244 (pITd->HwInfo >> 21) & 7, 1245 1245 (pITd->HwInfo >> 24) & 7, … … 1265 1265 * Writes an OHCIED. 1266 1266 */ 1267 DECLINLINE(void) ohciWriteEd(POHCI p Ohci, uint32_t EdAddr, PCOHCIED pEd)1267 DECLINLINE(void) ohciWriteEd(POHCI pThis, uint32_t EdAddr, PCOHCIED pEd) 1268 1268 { 1269 1269 #ifdef LOG_ENABLED … … 1273 1273 uint32_t hichg; 1274 1274 1275 ohciGetDWords(p Ohci, EdAddr, (uint32_t *)&EdOld, sizeof(EdOld) >> 2);1275 ohciGetDWords(pThis, EdAddr, (uint32_t *)&EdOld, sizeof(EdOld) >> 2); 1276 1276 hichg = EdOld.hwinfo ^ pEd->hwinfo; 1277 1277 Log3(("ohciWriteEd(,%#010x,): %sFA=%#x %sEN=%#x %sD=%#x %sS=%d %sK=%d %sF=%d %sMPS=%#x %sTailP=%#010x %sHeadP=%#010x %sH=%d %sC=%d %sNextED=%#010x\n", … … 1292 1292 #endif 1293 1293 1294 ohciPutDWords(p Ohci, EdAddr, (uint32_t *)pEd, sizeof(*pEd) >> 2);1294 ohciPutDWords(pThis, EdAddr, (uint32_t *)pEd, sizeof(*pEd) >> 2); 1295 1295 } 1296 1296 … … 1299 1299 * Writes an OHCITD. 1300 1300 */ 1301 DECLINLINE(void) ohciWriteTd(POHCI p Ohci, uint32_t TdAddr, PCOHCITD pTd, const char *pszLogMsg)1301 DECLINLINE(void) ohciWriteTd(POHCI pThis, uint32_t TdAddr, PCOHCITD pTd, const char *pszLogMsg) 1302 1302 { 1303 1303 #ifdef LOG_ENABLED … … 1305 1305 { 1306 1306 OHCITD TdOld; 1307 ohciGetDWords(p Ohci, TdAddr, (uint32_t *)&TdOld, sizeof(TdOld) >> 2);1307 ohciGetDWords(pThis, TdAddr, (uint32_t *)&TdOld, sizeof(TdOld) >> 2); 1308 1308 uint32_t hichg = TdOld.hwinfo ^ pTd->hwinfo; 1309 1309 Log3(("ohciWriteTd(,%#010x,): %sR=%d %sDP=%d %sDI=%#x %sT=%d %sEC=%d %sCC=%#x %sCBP=%#010x %sNextTD=%#010x %sBE=%#010x (%s)\n", … … 1321 1321 } 1322 1322 #endif 1323 ohciPutDWords(p Ohci, TdAddr, (uint32_t *)pTd, sizeof(*pTd) >> 2);1323 ohciPutDWords(pThis, TdAddr, (uint32_t *)pTd, sizeof(*pTd) >> 2); 1324 1324 } 1325 1325 … … 1327 1327 * Writes an OHCIITD. 1328 1328 */ 1329 DECLINLINE(void) ohciWriteITd(POHCI p Ohci, uint32_t ITdAddr, PCOHCIITD pITd, const char *pszLogMsg)1329 DECLINLINE(void) ohciWriteITd(POHCI pThis, uint32_t ITdAddr, PCOHCIITD pITd, const char *pszLogMsg) 1330 1330 { 1331 1331 #ifdef LOG_ENABLED … … 1333 1333 { 1334 1334 OHCIITD ITdOld; 1335 ohciGetDWords(p Ohci, ITdAddr, (uint32_t *)&ITdOld, sizeof(ITdOld) / sizeof(uint32_t));1335 ohciGetDWords(pThis, ITdAddr, (uint32_t *)&ITdOld, sizeof(ITdOld) / sizeof(uint32_t)); 1336 1336 uint32_t HIChg = ITdOld.HwInfo ^ pITd->HwInfo; 1337 1337 Log3(("ohciWriteITd(,%#010x,): %sSF=%#x (now=%#RX32) %sDI=%#x %sFC=%d %sCC=%#x %sBP0=%#010x %sNextTD=%#010x %sBE=%#010x (%s)\n", 1338 1338 ITdAddr, 1339 (HIChg & 0xffff) & 1 ? "*" : "", pITd->HwInfo & 0xffff, p Ohci->HcFmNumber,1339 (HIChg & 0xffff) & 1 ? "*" : "", pITd->HwInfo & 0xffff, pThis->HcFmNumber, 1340 1340 (HIChg >> 21) & 7 ? "*" : "", (pITd->HwInfo >> 21) & 7, 1341 1341 (HIChg >> 24) & 7 ? "*" : "", (pITd->HwInfo >> 24) & 7, … … 1356 1356 } 1357 1357 #endif 1358 ohciPutDWords(p Ohci, ITdAddr, (uint32_t *)pITd, sizeof(*pITd) / sizeof(uint32_t));1358 ohciPutDWords(pThis, ITdAddr, (uint32_t *)pITd, sizeof(*pITd) / sizeof(uint32_t)); 1359 1359 } 1360 1360 … … 1365 1365 * Core TD queue dumper. LOG_ENABLED builds only. 1366 1366 */ 1367 DECLINLINE(void) ohciDumpTdQueueCore(POHCI p Ohci, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull)1367 DECLINLINE(void) ohciDumpTdQueueCore(POHCI pThis, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull) 1368 1368 { 1369 1369 uint32_t GCPhys = GCPhysHead; … … 1373 1373 OHCITD Td; 1374 1374 Log4(("%#010x%s%s", GCPhys, 1375 GCPhys && ohci_in_flight_find(p Ohci, GCPhys) >= 0 ? "~" : "",1376 GCPhys && ohci_in_done_queue_find(p Ohci, GCPhys) >= 0 ? "^" : ""));1375 GCPhys && ohci_in_flight_find(pThis, GCPhys) >= 0 ? "~" : "", 1376 GCPhys && ohci_in_done_queue_find(pThis, GCPhys) >= 0 ? "^" : "")); 1377 1377 if (GCPhys == 0 || GCPhys == GCPhysTail) 1378 1378 break; 1379 1379 1380 1380 /* can't use ohciReadTd() because of Log4. */ 1381 ohciGetDWords(p Ohci, GCPhys, (uint32_t *)&Td, sizeof(Td) >> 2);1381 ohciGetDWords(pThis, GCPhys, (uint32_t *)&Td, sizeof(Td) >> 2); 1382 1382 if (fFull) 1383 1383 Log4((" [R=%d DP=%d DI=%d T=%d EC=%d CC=%#x CBP=%#010x NextTD=%#010x BE=%#010x] -> ", … … 1402 1402 * Dumps a TD queue. LOG_ENABLED builds only. 1403 1403 */ 1404 DECLINLINE(void) ohciDumpTdQueue(POHCI p Ohci, uint32_t GCPhysHead, const char *pszMsg)1404 DECLINLINE(void) ohciDumpTdQueue(POHCI pThis, uint32_t GCPhysHead, const char *pszMsg) 1405 1405 { 1406 1406 if (pszMsg) 1407 1407 Log4(("%s: ", pszMsg)); 1408 ohciDumpTdQueueCore(p Ohci, GCPhysHead, 0, true);1408 ohciDumpTdQueueCore(pThis, GCPhysHead, 0, true); 1409 1409 Log4(("\n")); 1410 1410 } … … 1413 1413 * Core ITD queue dumper. LOG_ENABLED builds only. 1414 1414 */ 1415 DECLINLINE(void) ohciDumpITdQueueCore(POHCI p Ohci, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull)1415 DECLINLINE(void) ohciDumpITdQueueCore(POHCI pThis, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull) 1416 1416 { 1417 1417 uint32_t GCPhys = GCPhysHead; … … 1421 1421 OHCIITD ITd; 1422 1422 Log4(("%#010x%s%s", GCPhys, 1423 GCPhys && ohci_in_flight_find(p Ohci, GCPhys) >= 0 ? "~" : "",1424 GCPhys && ohci_in_done_queue_find(p Ohci, GCPhys) >= 0 ? "^" : ""));1423 GCPhys && ohci_in_flight_find(pThis, GCPhys) >= 0 ? "~" : "", 1424 GCPhys && ohci_in_done_queue_find(pThis, GCPhys) >= 0 ? "^" : "")); 1425 1425 if (GCPhys == 0 || GCPhys == GCPhysTail) 1426 1426 break; 1427 1427 1428 1428 /* can't use ohciReadTd() because of Log4. */ 1429 ohciGetDWords(p Ohci, GCPhys, (uint32_t *)&ITd, sizeof(ITd) / sizeof(uint32_t));1429 ohciGetDWords(pThis, GCPhys, (uint32_t *)&ITd, sizeof(ITd) / sizeof(uint32_t)); 1430 1430 /*if (fFull) 1431 1431 Log4((" [R=%d DP=%d DI=%d T=%d EC=%d CC=%#x CBP=%#010x NextTD=%#010x BE=%#010x] -> ", … … 1450 1450 * Dumps a ED list. LOG_ENABLED builds only. 1451 1451 */ 1452 DECLINLINE(void) ohciDumpEdList(POHCI p Ohci, uint32_t GCPhysHead, const char *pszMsg, bool fTDs)1452 DECLINLINE(void) ohciDumpEdList(POHCI pThis, uint32_t GCPhysHead, const char *pszMsg, bool fTDs) 1453 1453 { 1454 1454 uint32_t GCPhys = GCPhysHead; … … 1468 1468 1469 1469 /* TDs */ 1470 ohciReadEd(p Ohci, GCPhys, &Ed);1470 ohciReadEd(pThis, GCPhys, &Ed); 1471 1471 if (Ed.hwinfo & ED_HWINFO_ISO) 1472 1472 Log4(("[I]")); … … 1483 1483 { 1484 1484 if (Ed.hwinfo & ED_HWINFO_ISO) 1485 ohciDumpITdQueueCore(p Ohci, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false);1485 ohciDumpITdQueueCore(pThis, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false); 1486 1486 else 1487 ohciDumpTdQueueCore(p Ohci, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false);1487 ohciDumpTdQueueCore(pThis, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false); 1488 1488 Log4(("}")); 1489 1489 } … … 1499 1499 1500 1500 1501 DECLINLINE(int) ohci_in_flight_find_free(POHCI p Ohci, const int iStart)1501 DECLINLINE(int) ohci_in_flight_find_free(POHCI pThis, const int iStart) 1502 1502 { 1503 1503 unsigned i = iStart; 1504 while (i < RT_ELEMENTS(p Ohci->aInFlight))1505 { 1506 if (p Ohci->aInFlight[i].GCPhysTD == 0)1504 while (i < RT_ELEMENTS(pThis->aInFlight)) 1505 { 1506 if (pThis->aInFlight[i].GCPhysTD == 0) 1507 1507 return i; 1508 1508 i++; … … 1511 1511 while (i-- > 0) 1512 1512 { 1513 if (p Ohci->aInFlight[i].GCPhysTD == 0)1513 if (pThis->aInFlight[i].GCPhysTD == 0) 1514 1514 return i; 1515 1515 } … … 1521 1521 * Record an in-flight TD. 1522 1522 * 1523 * @param p OhciOHCI instance data.1523 * @param pThis OHCI instance data. 1524 1524 * @param GCPhysTD Physical address of the TD. 1525 1525 * @param pUrb The URB. 1526 1526 */ 1527 static void ohci_in_flight_add(POHCI p Ohci, uint32_t GCPhysTD, PVUSBURB pUrb)1528 { 1529 int i = ohci_in_flight_find_free(p Ohci, (GCPhysTD >> 4) % RT_ELEMENTS(pOhci->aInFlight));1527 static void ohci_in_flight_add(POHCI pThis, uint32_t GCPhysTD, PVUSBURB pUrb) 1528 { 1529 int i = ohci_in_flight_find_free(pThis, (GCPhysTD >> 4) % RT_ELEMENTS(pThis->aInFlight)); 1530 1530 if (i >= 0) 1531 1531 { 1532 1532 #ifdef LOG_ENABLED 1533 pUrb->Hci.u32FrameNo = p Ohci->HcFmNumber;1533 pUrb->Hci.u32FrameNo = pThis->HcFmNumber; 1534 1534 #endif 1535 p Ohci->aInFlight[i].GCPhysTD = GCPhysTD;1536 p Ohci->aInFlight[i].pUrb = pUrb;1537 p Ohci->cInFlight++;1535 pThis->aInFlight[i].GCPhysTD = GCPhysTD; 1536 pThis->aInFlight[i].pUrb = pUrb; 1537 pThis->cInFlight++; 1538 1538 return; 1539 1539 } 1540 AssertMsgFailed(("Out of space cInFlight=%d!\n", p Ohci->cInFlight));1540 AssertMsgFailed(("Out of space cInFlight=%d!\n", pThis->cInFlight)); 1541 1541 } 1542 1542 … … 1545 1545 * Record in-flight TDs for an URB. 1546 1546 * 1547 * @param p OhciOHCI instance data.1547 * @param pThis OHCI instance data. 1548 1548 * @param pUrb The URB. 1549 1549 */ 1550 static void ohci_in_flight_add_urb(POHCI p Ohci, PVUSBURB pUrb)1550 static void ohci_in_flight_add_urb(POHCI pThis, PVUSBURB pUrb) 1551 1551 { 1552 1552 for (unsigned iTd = 0; iTd < pUrb->Hci.cTds; iTd++) 1553 ohci_in_flight_add(p Ohci, pUrb->Hci.paTds[iTd].TdAddr, pUrb);1553 ohci_in_flight_add(pThis, pUrb->Hci.paTds[iTd].TdAddr, pUrb); 1554 1554 } 1555 1555 … … 1560 1560 * @returns Index of the record. 1561 1561 * @returns -1 if not found. 1562 * @param p OhciOHCI instance data.1562 * @param pThis OHCI instance data. 1563 1563 * @param GCPhysTD Physical address of the TD. 1564 1564 * @remark This has to be fast. 1565 1565 */ 1566 static int ohci_in_flight_find(POHCI p Ohci, uint32_t GCPhysTD)1567 { 1568 unsigned cLeft = p Ohci->cInFlight;1569 unsigned i = (GCPhysTD >> 4) % RT_ELEMENTS(p Ohci->aInFlight);1566 static int ohci_in_flight_find(POHCI pThis, uint32_t GCPhysTD) 1567 { 1568 unsigned cLeft = pThis->cInFlight; 1569 unsigned i = (GCPhysTD >> 4) % RT_ELEMENTS(pThis->aInFlight); 1570 1570 const int iLast = i; 1571 while (i < RT_ELEMENTS(p Ohci->aInFlight))1572 { 1573 if (p Ohci->aInFlight[i].GCPhysTD == GCPhysTD)1571 while (i < RT_ELEMENTS(pThis->aInFlight)) 1572 { 1573 if (pThis->aInFlight[i].GCPhysTD == GCPhysTD) 1574 1574 return i; 1575 if (p Ohci->aInFlight[i].GCPhysTD)1575 if (pThis->aInFlight[i].GCPhysTD) 1576 1576 if (cLeft-- <= 1) 1577 1577 return -1; … … 1581 1581 while (i-- > 0) 1582 1582 { 1583 if (p Ohci->aInFlight[i].GCPhysTD == GCPhysTD)1583 if (pThis->aInFlight[i].GCPhysTD == GCPhysTD) 1584 1584 return i; 1585 if (p Ohci->aInFlight[i].GCPhysTD)1585 if (pThis->aInFlight[i].GCPhysTD) 1586 1586 if (cLeft-- <= 1) 1587 1587 return -1; … … 1595 1595 * 1596 1596 * @returns true if in flight, false if not. 1597 * @param p OhciOHCI instance data.1597 * @param pThis OHCI instance data. 1598 1598 * @param GCPhysTD Physical address of the TD. 1599 1599 */ 1600 static bool ohciIsTdInFlight(POHCI p Ohci, uint32_t GCPhysTD)1601 { 1602 return ohci_in_flight_find(p Ohci, GCPhysTD) >= 0;1600 static bool ohciIsTdInFlight(POHCI pThis, uint32_t GCPhysTD) 1601 { 1602 return ohci_in_flight_find(pThis, GCPhysTD) >= 0; 1603 1603 } 1604 1604 … … 1608 1608 * @returns pointer to URB if TD is in flight. 1609 1609 * @returns NULL if not in flight. 1610 * @param p OhciOHCI instance data.1610 * @param pThis OHCI instance data. 1611 1611 * @param GCPhysTD Physical address of the TD. 1612 1612 */ 1613 static PVUSBURB ohciTdInFlightUrb(POHCI p Ohci, uint32_t GCPhysTD)1613 static PVUSBURB ohciTdInFlightUrb(POHCI pThis, uint32_t GCPhysTD) 1614 1614 { 1615 1615 int i; 1616 1616 1617 i = ohci_in_flight_find(p Ohci, GCPhysTD);1617 i = ohci_in_flight_find(pThis, GCPhysTD); 1618 1618 if ( i >= 0 ) 1619 return p Ohci->aInFlight[i].pUrb;1619 return pThis->aInFlight[i].pUrb; 1620 1620 return NULL; 1621 1621 } … … 1626 1626 * @returns 0 if found. For logged builds this is the number of frames the TD has been in-flight. 1627 1627 * @returns -1 if not found. 1628 * @param p OhciOHCI instance data.1628 * @param pThis OHCI instance data. 1629 1629 * @param GCPhysTD Physical address of the TD. 1630 1630 */ 1631 static int ohci_in_flight_remove(POHCI p Ohci, uint32_t GCPhysTD)1632 { 1633 int i = ohci_in_flight_find(p Ohci, GCPhysTD);1631 static int ohci_in_flight_remove(POHCI pThis, uint32_t GCPhysTD) 1632 { 1633 int i = ohci_in_flight_find(pThis, GCPhysTD); 1634 1634 if (i >= 0) 1635 1635 { 1636 1636 #ifdef LOG_ENABLED 1637 const int cFramesInFlight = p Ohci->HcFmNumber - pOhci->aInFlight[i].pUrb->Hci.u32FrameNo;1637 const int cFramesInFlight = pThis->HcFmNumber - pThis->aInFlight[i].pUrb->Hci.u32FrameNo; 1638 1638 #else 1639 1639 const int cFramesInFlight = 0; 1640 1640 #endif 1641 1641 Log2(("ohci_in_flight_remove: reaping TD=%#010x %d frames (%#010x-%#010x)\n", 1642 GCPhysTD, cFramesInFlight, p Ohci->aInFlight[i].pUrb->Hci.u32FrameNo, pOhci->HcFmNumber));1643 p Ohci->aInFlight[i].GCPhysTD = 0;1644 p Ohci->aInFlight[i].pUrb = NULL;1645 p Ohci->cInFlight--;1642 GCPhysTD, cFramesInFlight, pThis->aInFlight[i].pUrb->Hci.u32FrameNo, pThis->HcFmNumber)); 1643 pThis->aInFlight[i].GCPhysTD = 0; 1644 pThis->aInFlight[i].pUrb = NULL; 1645 pThis->cInFlight--; 1646 1646 return cFramesInFlight; 1647 1647 } … … 1656 1656 * @returns 0 if found. For logged builds this is the number of frames the TD has been in-flight. 1657 1657 * @returns -1 if not found. 1658 * @param p OhciOHCI instance data.1658 * @param pThis OHCI instance data. 1659 1659 * @param pUrb The URB. 1660 1660 */ 1661 static int ohci_in_flight_remove_urb(POHCI p Ohci, PVUSBURB pUrb)1662 { 1663 int cFramesInFlight = ohci_in_flight_remove(p Ohci, pUrb->Hci.paTds[0].TdAddr);1661 static int ohci_in_flight_remove_urb(POHCI pThis, PVUSBURB pUrb) 1662 { 1663 int cFramesInFlight = ohci_in_flight_remove(pThis, pUrb->Hci.paTds[0].TdAddr); 1664 1664 if (pUrb->Hci.cTds > 1) 1665 1665 { 1666 1666 for (unsigned iTd = 1; iTd < pUrb->Hci.cTds; iTd++) 1667 if (ohci_in_flight_remove(p Ohci, pUrb->Hci.paTds[iTd].TdAddr) < 0)1667 if (ohci_in_flight_remove(pThis, pUrb->Hci.paTds[iTd].TdAddr) < 0) 1668 1668 cFramesInFlight = -1; 1669 1669 } … … 1676 1676 /** 1677 1677 * Empties the in-done-queue. 1678 * @param p OhciOHCI instance data.1679 */ 1680 static void ohci_in_done_queue_zap(POHCI p Ohci)1681 { 1682 p Ohci->cInDoneQueue = 0;1678 * @param pThis OHCI instance data. 1679 */ 1680 static void ohci_in_done_queue_zap(POHCI pThis) 1681 { 1682 pThis->cInDoneQueue = 0; 1683 1683 } 1684 1684 … … 1687 1687 * @returns >= 0 on success. 1688 1688 * @returns -1 if not found. 1689 * @param p OhciOHCI instance data.1689 * @param pThis OHCI instance data. 1690 1690 * @param GCPhysTD Physical address of the TD. 1691 1691 */ 1692 static int ohci_in_done_queue_find(POHCI p Ohci, uint32_t GCPhysTD)1693 { 1694 unsigned i = p Ohci->cInDoneQueue;1692 static int ohci_in_done_queue_find(POHCI pThis, uint32_t GCPhysTD) 1693 { 1694 unsigned i = pThis->cInDoneQueue; 1695 1695 while (i-- > 0) 1696 if (p Ohci->aInDoneQueue[i].GCPhysTD == GCPhysTD)1696 if (pThis->aInDoneQueue[i].GCPhysTD == GCPhysTD) 1697 1697 return i; 1698 1698 return -1; … … 1701 1701 /** 1702 1702 * Checks that the specified TD is not in the done queue. 1703 * @param p OhciOHCI instance data.1703 * @param pThis OHCI instance data. 1704 1704 * @param GCPhysTD Physical address of the TD. 1705 1705 */ 1706 static bool ohci_in_done_queue_check(POHCI p Ohci, uint32_t GCPhysTD)1707 { 1708 int i = ohci_in_done_queue_find(p Ohci, GCPhysTD);1706 static bool ohci_in_done_queue_check(POHCI pThis, uint32_t GCPhysTD) 1707 { 1708 int i = ohci_in_done_queue_find(pThis, GCPhysTD); 1709 1709 #if 0 1710 1710 /* This condition has been observed with the USB tablet emulation or with … … 1727 1727 /** 1728 1728 * Adds a TD to the in-done-queue tracking, checking that it's not there already. 1729 * @param p OhciOHCI instance data.1729 * @param pThis OHCI instance data. 1730 1730 * @param GCPhysTD Physical address of the TD. 1731 1731 */ 1732 static void ohci_in_done_queue_add(POHCI p Ohci, uint32_t GCPhysTD)1733 { 1734 Assert(p Ohci->cInDoneQueue + 1 <= RT_ELEMENTS(pOhci->aInDoneQueue));1735 if (ohci_in_done_queue_check(p Ohci, GCPhysTD))1736 p Ohci->aInDoneQueue[pOhci->cInDoneQueue++].GCPhysTD = GCPhysTD;1732 static void ohci_in_done_queue_add(POHCI pThis, uint32_t GCPhysTD) 1733 { 1734 Assert(pThis->cInDoneQueue + 1 <= RT_ELEMENTS(pThis->aInDoneQueue)); 1735 if (ohci_in_done_queue_check(pThis, GCPhysTD)) 1736 pThis->aInDoneQueue[pThis->cInDoneQueue++].GCPhysTD = GCPhysTD; 1737 1737 } 1738 1738 # endif /* VBOX_STRICT */ … … 1822 1822 1823 1823 /** A worker for ohciUnlinkTds(). */ 1824 static bool ohciUnlinkIsochronousTdInList(POHCI p Ohci, uint32_t TdAddr, POHCIITD pITd, POHCIED pEd)1824 static bool ohciUnlinkIsochronousTdInList(POHCI pThis, uint32_t TdAddr, POHCIITD pITd, POHCIED pEd) 1825 1825 { 1826 1826 const uint32_t LastTdAddr = pEd->TailP & ED_PTR_MASK; … … 1835 1835 { 1836 1836 OHCIITD ITd; 1837 ohciReadITd(p Ohci, CurTdAddr, &ITd);1837 ohciReadITd(pThis, CurTdAddr, &ITd); 1838 1838 if ((ITd.NextTD & ED_PTR_MASK) == TdAddr) 1839 1839 { 1840 1840 ITd.NextTD = (pITd->NextTD & ED_PTR_MASK) | (ITd.NextTD & ~ED_PTR_MASK); 1841 ohciWriteITd(p Ohci, CurTdAddr, &ITd, "ohciUnlinkIsocTdInList");1841 ohciWriteITd(pThis, CurTdAddr, &ITd, "ohciUnlinkIsocTdInList"); 1842 1842 pITd->NextTD &= ~ED_PTR_MASK; 1843 1843 return true; … … 1854 1854 1855 1855 /** A worker for ohciUnlinkTds(). */ 1856 static bool ohciUnlinkGeneralTdInList(POHCI p Ohci, uint32_t TdAddr, POHCITD pTd, POHCIED pEd)1856 static bool ohciUnlinkGeneralTdInList(POHCI pThis, uint32_t TdAddr, POHCITD pTd, POHCIED pEd) 1857 1857 { 1858 1858 const uint32_t LastTdAddr = pEd->TailP & ED_PTR_MASK; … … 1867 1867 { 1868 1868 OHCITD Td; 1869 ohciReadTd(p Ohci, CurTdAddr, &Td);1869 ohciReadTd(pThis, CurTdAddr, &Td); 1870 1870 if ((Td.NextTD & ED_PTR_MASK) == TdAddr) 1871 1871 { 1872 1872 Td.NextTD = (pTd->NextTD & ED_PTR_MASK) | (Td.NextTD & ~ED_PTR_MASK); 1873 ohciWriteTd(p Ohci, CurTdAddr, &Td, "ohciUnlinkGeneralTdInList");1873 ohciWriteTd(pThis, CurTdAddr, &Td, "ohciUnlinkGeneralTdInList"); 1874 1874 pTd->NextTD &= ~ED_PTR_MASK; 1875 1875 return true; … … 1891 1891 * @returns false if the TD was not found in the list. 1892 1892 */ 1893 static bool ohciUnlinkTds(POHCI p Ohci, PVUSBURB pUrb, POHCIED pEd)1893 static bool ohciUnlinkTds(POHCI pThis, PVUSBURB pUrb, POHCIED pEd) 1894 1894 { 1895 1895 /* … … 1923 1923 * the current isochronous code. 1924 1924 */ 1925 if (!ohciUnlinkIsochronousTdInList(p Ohci, ITdAddr, pITd, pEd))1925 if (!ohciUnlinkIsochronousTdInList(pThis, ITdAddr, pITd, pEd)) 1926 1926 return false; 1927 1927 } … … 1979 1979 * solution. For now we'll hope the HCD handles it... 1980 1980 */ 1981 if (!ohciUnlinkGeneralTdInList(p Ohci, TdAddr, pTd, pEd))1981 if (!ohciUnlinkGeneralTdInList(pThis, TdAddr, pTd, pEd)) 1982 1982 return false; 1983 1983 } … … 2003 2003 * 2004 2004 * @returns true if the URB has been canceled, otherwise false. 2005 * @param p OhciThe OHCI instance.2005 * @param pThis The OHCI instance. 2006 2006 * @param pUrb The URB in question. 2007 2007 * @param pEd The ED pointer (optional). 2008 2008 */ 2009 static bool ohciHasUrbBeenCanceled(POHCI p Ohci, PVUSBURB pUrb, PCOHCIED pEd)2009 static bool ohciHasUrbBeenCanceled(POHCI pThis, PVUSBURB pUrb, PCOHCIED pEd) 2010 2010 { 2011 2011 if (!pUrb) … … 2019 2019 if (!pEd) 2020 2020 { 2021 ohciReadEd(p Ohci, pUrb->Hci.EdAddr, &Ed);2021 ohciReadEd(pThis, pUrb->Hci.EdAddr, &Ed); 2022 2022 pEd = &Ed; 2023 2023 } … … 2037 2037 Log(("%s: ohciHasUrbBeenCanceled: iTd=%d cTds=%d TdAddr=%#010RX32 canceled (tail)! [iso]\n", 2038 2038 pUrb->pszDesc, iTd, pUrb->Hci.cTds, pUrb->Hci.paTds[iTd].TdAddr)); 2039 STAM_COUNTER_INC(&p Ohci->StatCanceledIsocUrbs);2039 STAM_COUNTER_INC(&pThis->StatCanceledIsocUrbs); 2040 2040 return true; 2041 2041 } 2042 ohciReadITd(p Ohci, pUrb->Hci.paTds[iTd].TdAddr, &u.ITd);2042 ohciReadITd(pThis, pUrb->Hci.paTds[iTd].TdAddr, &u.ITd); 2043 2043 if ( u.au32[0] != pUrb->Hci.paTds[iTd].TdCopy[0] /* hwinfo */ 2044 2044 || u.au32[1] != pUrb->Hci.paTds[iTd].TdCopy[1] /* bp0 */ … … 2057 2057 "!= %.*Rhxs (copy)\n", 2058 2058 sizeof(u.ITd), &u.ITd, sizeof(u.ITd), &pUrb->Hci.paTds[iTd].TdCopy[0])); 2059 STAM_COUNTER_INC(&p Ohci->StatCanceledIsocUrbs);2059 STAM_COUNTER_INC(&pThis->StatCanceledIsocUrbs); 2060 2060 return true; 2061 2061 } … … 2077 2077 Log(("%s: ohciHasUrbBeenCanceled: iTd=%d cTds=%d TdAddr=%#010RX32 canceled (tail)!\n", 2078 2078 pUrb->pszDesc, iTd, pUrb->Hci.cTds, pUrb->Hci.paTds[iTd].TdAddr)); 2079 STAM_COUNTER_INC(&p Ohci->StatCanceledGenUrbs);2079 STAM_COUNTER_INC(&pThis->StatCanceledGenUrbs); 2080 2080 return true; 2081 2081 } 2082 ohciReadTd(p Ohci, pUrb->Hci.paTds[iTd].TdAddr, &u.Td);2082 ohciReadTd(pThis, pUrb->Hci.paTds[iTd].TdAddr, &u.Td); 2083 2083 if ( u.au32[0] != pUrb->Hci.paTds[iTd].TdCopy[0] /* hwinfo */ 2084 2084 || u.au32[1] != pUrb->Hci.paTds[iTd].TdCopy[1] /* cbp */ … … 2093 2093 "!= %.*Rhxs (copy)\n", 2094 2094 sizeof(u.Td), &u.Td, sizeof(u.Td), &pUrb->Hci.paTds[iTd].TdCopy[0])); 2095 STAM_COUNTER_INC(&p Ohci->StatCanceledGenUrbs);2095 STAM_COUNTER_INC(&pThis->StatCanceledGenUrbs); 2096 2096 return true; 2097 2097 } … … 2132 2132 * In general, all URBs should have status OK. 2133 2133 */ 2134 static void ohciRhXferCompleteIsochronousURB(POHCI p Ohci, PVUSBURB pUrb, POHCIED pEd, int cFmAge)2134 static void ohciRhXferCompleteIsochronousURB(POHCI pThis, PVUSBURB pUrb, POHCIED pEd, int cFmAge) 2135 2135 { 2136 2136 /* … … 2192 2192 /* both */ 2193 2193 const unsigned cb0 = 0x1000 - off; 2194 ohciPhysWrite(p Ohci, (pITd->BP0 & ITD_BP0_MASK) + off, pb, cb0);2195 ohciPhysWrite(p Ohci, pITd->BE & ITD_BP0_MASK, pb + cb0, cb - cb0);2194 ohciPhysWrite(pThis, (pITd->BP0 & ITD_BP0_MASK) + off, pb, cb0); 2195 ohciPhysWrite(pThis, pITd->BE & ITD_BP0_MASK, pb + cb0, cb - cb0); 2196 2196 } 2197 2197 else /* only in the 2nd page */ 2198 ohciPhysWrite(p Ohci, (pITd->BE & ITD_BP0_MASK) + (off & ITD_BP0_MASK), pb, cb);2198 ohciPhysWrite(pThis, (pITd->BE & ITD_BP0_MASK) + (off & ITD_BP0_MASK), pb, cb); 2199 2199 } 2200 2200 else /* only in the 1st page */ 2201 ohciPhysWrite(p Ohci, (pITd->BP0 & ITD_BP0_MASK) + off, pb, cb);2201 ohciPhysWrite(pThis, (pITd->BP0 & ITD_BP0_MASK) + off, pb, cb); 2202 2202 Log5(("packet %d: off=%#x cb=%#x pb=%p (%#x)\n" 2203 2203 "%.*Rhxd\n", … … 2244 2244 DoneInt = 0; /* It's cleared on error. */ 2245 2245 if ( DoneInt != 0x7 2246 && DoneInt < p Ohci->dqic)2247 p Ohci->dqic = DoneInt;2246 && DoneInt < pThis->dqic) 2247 pThis->dqic = DoneInt; 2248 2248 2249 2249 /* … … 2251 2251 */ 2252 2252 #ifdef LOG_ENABLED 2253 if (!p Ohci->done)2254 p Ohci->u32FmDoneQueueTail = pOhci->HcFmNumber;2253 if (!pThis->done) 2254 pThis->u32FmDoneQueueTail = pThis->HcFmNumber; 2255 2255 # ifdef VBOX_STRICT 2256 ohci_in_done_queue_add(p Ohci, ITdAddr);2256 ohci_in_done_queue_add(pThis, ITdAddr); 2257 2257 # endif 2258 2258 #endif 2259 pITd->NextTD = p Ohci->done;2260 p Ohci->done = ITdAddr;2259 pITd->NextTD = pThis->done; 2260 pThis->done = ITdAddr; 2261 2261 2262 2262 Log(("%s: ohciRhXferCompleteIsochronousURB: ITdAddr=%#010x EdAddr=%#010x SF=%#x (%#x) CC=%#x FC=%d " … … 2264 2264 pUrb->pszDesc, ITdAddr, 2265 2265 pUrb->Hci.EdAddr, 2266 pITd->HwInfo & ITD_HWINFO_SF, p Ohci->HcFmNumber,2266 pITd->HwInfo & ITD_HWINFO_SF, pThis->HcFmNumber, 2267 2267 (pITd->HwInfo & ITD_HWINFO_CC) >> ITD_HWINFO_CC_SHIFT, 2268 2268 (pITd->HwInfo & ITD_HWINFO_FC) >> ITD_HWINFO_FC_SHIFT, … … 2276 2276 pITd->aPSW[7] >> ITD_PSW_CC_SHIFT, pITd->aPSW[7] & ITD_PSW_SIZE, 2277 2277 R)); 2278 ohciWriteITd(p Ohci, ITdAddr, pITd, "retired");2278 ohciWriteITd(pThis, ITdAddr, pITd, "retired"); 2279 2279 } 2280 2280 } … … 2285 2285 * a URB made up of general TDs. 2286 2286 */ 2287 static void ohciRhXferCompleteGeneralURB(POHCI p Ohci, PVUSBURB pUrb, POHCIED pEd, int cFmAge)2287 static void ohciRhXferCompleteGeneralURB(POHCI pThis, PVUSBURB pUrb, POHCIED pEd, int cFmAge) 2288 2288 { 2289 2289 /* … … 2324 2324 { 2325 2325 Assert(Buf.cVecs > 0); 2326 ohciPhysWrite(p Ohci, Buf.aVecs[0].Addr, pb, Buf.aVecs[0].cb);2326 ohciPhysWrite(pThis, Buf.aVecs[0].Addr, pb, Buf.aVecs[0].cb); 2327 2327 if (Buf.cVecs > 1) 2328 ohciPhysWrite(p Ohci, Buf.aVecs[1].Addr, pb + Buf.aVecs[0].cb, Buf.aVecs[1].cb);2328 ohciPhysWrite(pThis, Buf.aVecs[1].Addr, pb + Buf.aVecs[0].cb, Buf.aVecs[1].cb); 2329 2329 } 2330 2330 … … 2348 2348 uint32_t DoneInt = (pTd->hwinfo & TD_HWINFO_DI) >> 21; 2349 2349 if ( DoneInt != 0x7 2350 && DoneInt < p Ohci->dqic)2351 p Ohci->dqic = DoneInt;2350 && DoneInt < pThis->dqic) 2351 pThis->dqic = DoneInt; 2352 2352 Log(("%s: ohciRhXferCompleteGeneralURB: ED=%#010x TD=%#010x Age=%d cbTotal=%#x NewCbp=%#010RX32 dqic=%d\n", 2353 pUrb->pszDesc, pUrb->Hci.EdAddr, TdAddr, cFmAge, pUrb->enmStatus, Buf.cbTotal, NewCbp, p Ohci->dqic));2353 pUrb->pszDesc, pUrb->Hci.EdAddr, TdAddr, cFmAge, pUrb->enmStatus, Buf.cbTotal, NewCbp, pThis->dqic)); 2354 2354 } 2355 2355 else … … 2358 2358 pUrb->pszDesc, pUrb->Hci.EdAddr, TdAddr, cFmAge, pUrb->enmStatus)); 2359 2359 pEd->HeadP |= ED_HEAD_HALTED; 2360 p Ohci->dqic = 0; /* "If the Transfer Descriptor is being retired with an error,2360 pThis->dqic = 0; /* "If the Transfer Descriptor is being retired with an error, 2361 2361 * then the Done Queue Interrupt Counter is cleared as if the 2362 2362 * InterruptDelay field were zero." … … 2388 2388 */ 2389 2389 #ifdef LOG_ENABLED 2390 if (!p Ohci->done)2391 p Ohci->u32FmDoneQueueTail = pOhci->HcFmNumber;2390 if (!pThis->done) 2391 pThis->u32FmDoneQueueTail = pThis->HcFmNumber; 2392 2392 # ifdef VBOX_STRICT 2393 ohci_in_done_queue_add(p Ohci, TdAddr);2393 ohci_in_done_queue_add(pThis, TdAddr); 2394 2394 # endif 2395 2395 #endif 2396 pTd->NextTD = p Ohci->done;2397 p Ohci->done = TdAddr;2398 2399 ohciWriteTd(p Ohci, TdAddr, pTd, "retired");2396 pTd->NextTD = pThis->done; 2397 pThis->done = TdAddr; 2398 2399 ohciWriteTd(pThis, TdAddr, pTd, "retired"); 2400 2400 2401 2401 /* … … 2425 2425 static DECLCALLBACK(void) ohciRhXferCompletion(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb) 2426 2426 { 2427 POHCI p Ohci= VUSBIROOTHUBPORT_2_OHCI(pInterface);2427 POHCI pThis = VUSBIROOTHUBPORT_2_OHCI(pInterface); 2428 2428 LogFlow(("%s: ohciRhXferCompletion: EdAddr=%#010RX32 cTds=%d TdAddr0=%#010RX32\n", 2429 2429 pUrb->pszDesc, pUrb->Hci.EdAddr, pUrb->Hci.cTds, pUrb->Hci.paTds[0].TdAddr)); 2430 Assert(PDMCritSectIsOwner(p Ohci->pDevInsR3->pCritSectRoR3));2431 2432 p Ohci->fIdle = false; /* Mark as active */2430 Assert(PDMCritSectIsOwner(pThis->pDevInsR3->pCritSectRoR3)); 2431 2432 pThis->fIdle = false; /* Mark as active */ 2433 2433 2434 2434 /* get the current end point descriptor. */ 2435 2435 OHCIED Ed; 2436 ohciReadEd(p Ohci, pUrb->Hci.EdAddr, &Ed);2436 ohciReadEd(pThis, pUrb->Hci.EdAddr, &Ed); 2437 2437 2438 2438 /* … … 2446 2446 * with the data copying, buffer pointer advancing and error handling. 2447 2447 */ 2448 int cFmAge = ohci_in_flight_remove_urb(p Ohci, pUrb);2448 int cFmAge = ohci_in_flight_remove_urb(pThis, pUrb); 2449 2449 if (pUrb->enmStatus == VUSBSTATUS_UNDO) 2450 2450 { … … 2452 2452 Log(("%s: ohciRhXferCompletion: CANCELED {ED=%#010x cTds=%d TD0=%#010x age %d}\n", 2453 2453 pUrb->pszDesc, pUrb->Hci.EdAddr, pUrb->Hci.cTds, pUrb->Hci.paTds[0].TdAddr, cFmAge)); 2454 STAM_COUNTER_INC(&p Ohci->StatDroppedUrbs);2454 STAM_COUNTER_INC(&pThis->StatDroppedUrbs); 2455 2455 return; 2456 2456 } … … 2459 2459 || (Ed.hwinfo & ED_HWINFO_SKIP) 2460 2460 || cFmAge < 0 2461 || (fHasBeenCanceled = ohciHasUrbBeenCanceled(p Ohci, pUrb, &Ed))2462 || !ohciUnlinkTds(p Ohci, pUrb, &Ed)2461 || (fHasBeenCanceled = ohciHasUrbBeenCanceled(pThis, pUrb, &Ed)) 2462 || !ohciUnlinkTds(pThis, pUrb, &Ed) 2463 2463 ) 2464 2464 { … … 2471 2471 fHasBeenCanceled ? " td canceled" : "")); 2472 2472 NOREF(fHasBeenCanceled); 2473 STAM_COUNTER_INC(&p Ohci->StatDroppedUrbs);2473 STAM_COUNTER_INC(&pThis->StatDroppedUrbs); 2474 2474 return; 2475 2475 } … … 2480 2480 */ 2481 2481 if (pUrb->enmType == VUSBXFERTYPE_ISOC) 2482 ohciRhXferCompleteIsochronousURB(p Ohci, pUrb, &Ed, cFmAge);2482 ohciRhXferCompleteIsochronousURB(pThis, pUrb, &Ed, cFmAge); 2483 2483 else 2484 ohciRhXferCompleteGeneralURB(p Ohci, pUrb, &Ed, cFmAge);2484 ohciRhXferCompleteGeneralURB(pThis, pUrb, &Ed, cFmAge); 2485 2485 2486 2486 /* finally write back the endpoint descriptor. */ 2487 ohciWriteEd(p Ohci, pUrb->Hci.EdAddr, &Ed);2487 ohciWriteEd(pThis, pUrb->Hci.EdAddr, &Ed); 2488 2488 } 2489 2489 … … 2502 2502 static DECLCALLBACK(bool) ohciRhXferError(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb) 2503 2503 { 2504 POHCI p Ohci= VUSBIROOTHUBPORT_2_OHCI(pInterface);2505 Assert(PDMCritSectIsOwner(p Ohci->pDevInsR3->pCritSectRoR3));2504 POHCI pThis = VUSBIROOTHUBPORT_2_OHCI(pInterface); 2505 Assert(PDMCritSectIsOwner(pThis->pDevInsR3->pCritSectRoR3)); 2506 2506 2507 2507 /* … … 2526 2526 const uint32_t TdAddr = pUrb->Hci.paTds[0].TdAddr; 2527 2527 /** @todo IMPORTANT! we must check if the ED is still valid at this point!!! */ 2528 if (ohciHasUrbBeenCanceled(p Ohci, pUrb, NULL))2528 if (ohciHasUrbBeenCanceled(pThis, pUrb, NULL)) 2529 2529 { 2530 2530 Log(("%s: ohciRhXferError: TdAddr0=%#x canceled!\n", pUrb->pszDesc, TdAddr)); … … 2540 2540 cErrs++; 2541 2541 pTd->hwinfo |= (cErrs % TD_ERRORS_MAX) << TD_ERRORS_SHIFT; 2542 ohciWriteTd(p Ohci, TdAddr, pTd, "ohciRhXferError");2542 ohciWriteTd(pThis, TdAddr, pTd, "ohciRhXferError"); 2543 2543 2544 2544 if (cErrs >= TD_ERRORS_MAX - 1) … … 2555 2555 * Service a general transport descriptor. 2556 2556 */ 2557 static bool ohciServiceTd(POHCI p Ohci, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr, uint32_t TdAddr, uint32_t *pNextTdAddr, const char *pszListName)2557 static bool ohciServiceTd(POHCI pThis, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr, uint32_t TdAddr, uint32_t *pNextTdAddr, const char *pszListName) 2558 2558 { 2559 2559 /* … … 2561 2561 */ 2562 2562 OHCITD Td; 2563 ohciReadTd(p Ohci, TdAddr, &Td);2563 ohciReadTd(pThis, TdAddr, &Td); 2564 2564 OHCIBUF Buf; 2565 2565 ohciBufInit(&Buf, Td.cbp, Td.be); … … 2589 2589 } 2590 2590 2591 p Ohci->fIdle = false; /* Mark as active */2591 pThis->fIdle = false; /* Mark as active */ 2592 2592 2593 2593 /* 2594 2594 * Allocate and initialize a new URB. 2595 2595 */ 2596 PVUSBURB pUrb = VUSBIRhNewUrb(p Ohci->RootHub.pIRhConn, pEd->hwinfo & ED_HWINFO_FUNCTION, Buf.cbTotal, 1);2596 PVUSBURB pUrb = VUSBIRhNewUrb(pThis->RootHub.pIRhConn, pEd->hwinfo & ED_HWINFO_FUNCTION, Buf.cbTotal, 1); 2597 2597 if (!pUrb) 2598 2598 return false; /* retry later... */ … … 2607 2607 pUrb->Hci.fUnlinked = false; 2608 2608 pUrb->Hci.paTds[0].TdAddr = TdAddr; 2609 pUrb->Hci.u32FrameNo = p Ohci->HcFmNumber;2609 pUrb->Hci.u32FrameNo = pThis->HcFmNumber; 2610 2610 AssertCompile(sizeof(pUrb->Hci.paTds[0].TdCopy) >= sizeof(Td)); 2611 2611 memcpy(pUrb->Hci.paTds[0].TdCopy, &Td, sizeof(Td)); … … 2623 2623 && enmDir != VUSBDIRECTION_IN) 2624 2624 { 2625 ohciPhysRead(p Ohci, Buf.aVecs[0].Addr, pUrb->abData, Buf.aVecs[0].cb);2625 ohciPhysRead(pThis, Buf.aVecs[0].Addr, pUrb->abData, Buf.aVecs[0].cb); 2626 2626 if (Buf.cVecs > 1) 2627 ohciPhysRead(p Ohci, Buf.aVecs[1].Addr, &pUrb->abData[Buf.aVecs[0].cb], Buf.aVecs[1].cb);2627 ohciPhysRead(pThis, Buf.aVecs[1].Addr, &pUrb->abData[Buf.aVecs[0].cb], Buf.aVecs[1].cb); 2628 2628 } 2629 2629 … … 2631 2631 * Submit the URB. 2632 2632 */ 2633 ohci_in_flight_add(p Ohci, TdAddr, pUrb);2633 ohci_in_flight_add(pThis, TdAddr, pUrb); 2634 2634 Log(("%s: ohciServiceTd: submitting TdAddr=%#010x EdAddr=%#010x cbData=%#x\n", 2635 2635 pUrb->pszDesc, TdAddr, EdAddr, pUrb->cbData)); 2636 2636 2637 int rc = VUSBIRhSubmitUrb(p Ohci->RootHub.pIRhConn, pUrb, &pOhci->RootHub.Led);2637 int rc = VUSBIRhSubmitUrb(pThis->RootHub.pIRhConn, pUrb, &pThis->RootHub.Led); 2638 2638 if (RT_SUCCESS(rc)) 2639 2639 return true; … … 2642 2642 Log(("ohciServiceTd: failed submitting TdAddr=%#010x EdAddr=%#010x pUrb=%p!!\n", 2643 2643 TdAddr, EdAddr, pUrb)); 2644 ohci_in_flight_remove(p Ohci, TdAddr);2644 ohci_in_flight_remove(pThis, TdAddr); 2645 2645 return false; 2646 2646 } … … 2650 2650 * Service a the head TD of an endpoint. 2651 2651 */ 2652 static bool ohciServiceHeadTd(POHCI p Ohci, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr, const char *pszListName)2652 static bool ohciServiceHeadTd(POHCI pThis, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr, const char *pszListName) 2653 2653 { 2654 2654 /* … … 2656 2656 */ 2657 2657 uint32_t TdAddr = pEd->HeadP & ED_PTR_MASK; 2658 if (ohciIsTdInFlight(p Ohci, TdAddr))2658 if (ohciIsTdInFlight(pThis, TdAddr)) 2659 2659 return false; 2660 2660 #if defined(VBOX_STRICT) || defined(LOG_ENABLED) 2661 ohci_in_done_queue_check(p Ohci, TdAddr);2661 ohci_in_done_queue_check(pThis, TdAddr); 2662 2662 #endif 2663 return ohciServiceTd(p Ohci, enmType, pEd, EdAddr, TdAddr, &TdAddr, pszListName);2663 return ohciServiceTd(pThis, enmType, pEd, EdAddr, TdAddr, &TdAddr, pszListName); 2664 2664 } 2665 2665 … … 2668 2668 * Service one or more general transport descriptors (bulk or interrupt). 2669 2669 */ 2670 static bool ohciServiceTdMultiple(POHCI p Ohci, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr,2670 static bool ohciServiceTdMultiple(POHCI pThis, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr, 2671 2671 uint32_t TdAddr, uint32_t *pNextTdAddr, const char *pszListName) 2672 2672 { … … 2687 2687 2688 2688 /* read the head */ 2689 ohciReadTd(p Ohci, TdAddr, &Head.Td);2689 ohciReadTd(pThis, TdAddr, &Head.Td); 2690 2690 ohciBufInit(&Head.Buf, Head.Td.cbp, Head.Td.be); 2691 2691 Head.TdAddr = TdAddr; … … 2705 2705 pCur->pNext = NULL; 2706 2706 pCur->TdAddr = pTail->Td.NextTD & ED_PTR_MASK; 2707 ohciReadTd(p Ohci, pCur->TdAddr, &pCur->Td);2707 ohciReadTd(pThis, pCur->TdAddr, &pCur->Td); 2708 2708 ohciBufInit(&pCur->Buf, pCur->Td.cbp, pCur->Td.be); 2709 2709 … … 2744 2744 } 2745 2745 2746 p Ohci->fIdle = false; /* Mark as active */2746 pThis->fIdle = false; /* Mark as active */ 2747 2747 2748 2748 /* 2749 2749 * Allocate and initialize a new URB. 2750 2750 */ 2751 PVUSBURB pUrb = VUSBIRhNewUrb(p Ohci->RootHub.pIRhConn, pEd->hwinfo & ED_HWINFO_FUNCTION, cbTotal, cTds);2751 PVUSBURB pUrb = VUSBIRhNewUrb(pThis->RootHub.pIRhConn, pEd->hwinfo & ED_HWINFO_FUNCTION, cbTotal, cTds); 2752 2752 if (!pUrb) 2753 2753 /* retry later... */ … … 2763 2763 pUrb->Hci.EdAddr = EdAddr; 2764 2764 pUrb->Hci.fUnlinked = false; 2765 pUrb->Hci.u32FrameNo = p Ohci->HcFmNumber;2765 pUrb->Hci.u32FrameNo = pThis->HcFmNumber; 2766 2766 #ifdef LOG_ENABLED 2767 2767 static unsigned s_iSerial = 0; … … 2781 2781 && pCur->Buf.cVecs > 0) 2782 2782 { 2783 ohciPhysRead(p Ohci, pCur->Buf.aVecs[0].Addr, pb, pCur->Buf.aVecs[0].cb);2783 ohciPhysRead(pThis, pCur->Buf.aVecs[0].Addr, pb, pCur->Buf.aVecs[0].cb); 2784 2784 if (pCur->Buf.cVecs > 1) 2785 ohciPhysRead(p Ohci, pCur->Buf.aVecs[1].Addr, pb + pCur->Buf.aVecs[0].cb, pCur->Buf.aVecs[1].cb);2785 ohciPhysRead(pThis, pCur->Buf.aVecs[1].Addr, pb + pCur->Buf.aVecs[0].cb, pCur->Buf.aVecs[1].cb); 2786 2786 } 2787 2787 pb += pCur->Buf.cbTotal; … … 2796 2796 * Submit the URB. 2797 2797 */ 2798 ohci_in_flight_add_urb(p Ohci, pUrb);2798 ohci_in_flight_add_urb(pThis, pUrb); 2799 2799 Log(("%s: ohciServiceTdMultiple: submitting cbData=%#x EdAddr=%#010x cTds=%d TdAddr0=%#010x\n", 2800 2800 pUrb->pszDesc, pUrb->cbData, EdAddr, cTds, TdAddr)); 2801 int rc = VUSBIRhSubmitUrb(p Ohci->RootHub.pIRhConn, pUrb, &pOhci->RootHub.Led);2801 int rc = VUSBIRhSubmitUrb(pThis->RootHub.pIRhConn, pUrb, &pThis->RootHub.Led); 2802 2802 if (RT_SUCCESS(rc)) 2803 2803 return true; … … 2807 2807 pUrb, cbTotal, EdAddr, cTds, TdAddr, rc)); 2808 2808 for (struct OHCITDENTRY *pCur = &Head; pCur; pCur = pCur->pNext, iTd++) 2809 ohci_in_flight_remove(p Ohci, pCur->TdAddr);2809 ohci_in_flight_remove(pThis, pCur->TdAddr); 2810 2810 return false; 2811 2811 } … … 2815 2815 * Service the head TD of an endpoint. 2816 2816 */ 2817 static bool ohciServiceHeadTdMultiple(POHCI p Ohci, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr, const char *pszListName)2817 static bool ohciServiceHeadTdMultiple(POHCI pThis, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr, const char *pszListName) 2818 2818 { 2819 2819 /* … … 2821 2821 */ 2822 2822 uint32_t TdAddr = pEd->HeadP & ED_PTR_MASK; 2823 if (ohciIsTdInFlight(p Ohci, TdAddr))2823 if (ohciIsTdInFlight(pThis, TdAddr)) 2824 2824 return false; 2825 2825 #if defined(VBOX_STRICT) || defined(LOG_ENABLED) 2826 ohci_in_done_queue_check(p Ohci, TdAddr);2826 ohci_in_done_queue_check(pThis, TdAddr); 2827 2827 #endif 2828 return ohciServiceTdMultiple(p Ohci, enmType, pEd, EdAddr, TdAddr, &TdAddr, pszListName);2828 return ohciServiceTdMultiple(pThis, enmType, pEd, EdAddr, TdAddr, &TdAddr, pszListName); 2829 2829 } 2830 2830 … … 2834 2834 * that belongs to the past. 2835 2835 */ 2836 static bool ohciServiceIsochronousTdUnlink(POHCI p Ohci, POHCIITD pITd, uint32_t ITdAddr, uint32_t ITdAddrPrev,2836 static bool ohciServiceIsochronousTdUnlink(POHCI pThis, POHCIITD pITd, uint32_t ITdAddr, uint32_t ITdAddrPrev, 2837 2837 PVUSBURB pUrb, POHCIED pEd, uint32_t EdAddr) 2838 2838 { … … 2847 2847 { 2848 2848 /* Get validate the previous TD */ 2849 int iInFlightPrev = ohci_in_flight_find(p Ohci, ITdAddr);2849 int iInFlightPrev = ohci_in_flight_find(pThis, ITdAddr); 2850 2850 AssertMsgReturn(iInFlightPrev >= 0, ("ITdAddr=%#RX32\n", ITdAddr), false); 2851 PVUSBURB pUrbPrev = p Ohci->aInFlight[iInFlightPrev].pUrb;2852 if (ohciHasUrbBeenCanceled(p Ohci, pUrbPrev, pEd)) /* ensures the copy is correct. */2851 PVUSBURB pUrbPrev = pThis->aInFlight[iInFlightPrev].pUrb; 2852 if (ohciHasUrbBeenCanceled(pThis, pUrbPrev, pEd)) /* ensures the copy is correct. */ 2853 2853 return false; 2854 2854 … … 2856 2856 POHCIITD pITdPrev = ((POHCIITD)pUrbPrev->Hci.paTds[0].TdCopy); 2857 2857 pITdPrev->NextTD = (pITdPrev->NextTD & ~ED_PTR_MASK) | ITdAddrNext; 2858 ohciWriteITd(p Ohci, ITdAddrPrev, pITdPrev, "ohciServiceIsochronousEndpoint");2858 ohciWriteITd(pThis, ITdAddrPrev, pITdPrev, "ohciServiceIsochronousEndpoint"); 2859 2859 } 2860 2860 else … … 2862 2862 /* It's the head node. update the copy from the caller and write it back. */ 2863 2863 pEd->HeadP = (pEd->HeadP & ~ED_PTR_MASK) | ITdAddrNext; 2864 ohciWriteEd(p Ohci, EdAddr, pEd);2864 ohciWriteEd(pThis, EdAddr, pEd); 2865 2865 } 2866 2866 … … 2872 2872 { 2873 2873 pUrb->Hci.fUnlinked = true; 2874 if (ohciHasUrbBeenCanceled(p Ohci, pUrb, pEd)) /* ensures the copy is correct (paranoia). */2874 if (ohciHasUrbBeenCanceled(pThis, pUrb, pEd)) /* ensures the copy is correct (paranoia). */ 2875 2875 return false; 2876 2876 … … 2883 2883 pITd->HwInfo |= OHCI_CC_DATA_OVERRUN; 2884 2884 2885 pITd->NextTD = p Ohci->done;2886 p Ohci->done = ITdAddr;2887 2888 p Ohci->dqic = 0;2889 } 2890 2891 ohciWriteITd(p Ohci, ITdAddr, pITd, "ohciServiceIsochronousTdUnlink");2885 pITd->NextTD = pThis->done; 2886 pThis->done = ITdAddr; 2887 2888 pThis->dqic = 0; 2889 } 2890 2891 ohciWriteITd(pThis, ITdAddr, pITd, "ohciServiceIsochronousTdUnlink"); 2892 2892 return true; 2893 2893 } … … 2901 2901 * @param R The start packet (frame) relative to the start of frame in HwInfo. 2902 2902 */ 2903 static bool ohciServiceIsochronousTd(POHCI p Ohci, POHCIITD pITd, uint32_t ITdAddr, const unsigned R, PCOHCIED pEd, uint32_t EdAddr)2903 static bool ohciServiceIsochronousTd(POHCI pThis, POHCIITD pITd, uint32_t ITdAddr, const unsigned R, PCOHCIED pEd, uint32_t EdAddr) 2904 2904 { 2905 2905 /* … … 2955 2955 Assert(cbTotal <= 0x2000); 2956 2956 2957 p Ohci->fIdle = false; /* Mark as active */2957 pThis->fIdle = false; /* Mark as active */ 2958 2958 2959 2959 /* 2960 2960 * Allocate and initialize a new URB. 2961 2961 */ 2962 PVUSBURB pUrb = VUSBIRhNewUrb(p Ohci->RootHub.pIRhConn, pEd->hwinfo & ED_HWINFO_FUNCTION, cbTotal, 1);2962 PVUSBURB pUrb = VUSBIRhNewUrb(pThis->RootHub.pIRhConn, pEd->hwinfo & ED_HWINFO_FUNCTION, cbTotal, 1); 2963 2963 if (!pUrb) 2964 2964 /* retry later... */ … … 2972 2972 pUrb->Hci.EdAddr = EdAddr; 2973 2973 pUrb->Hci.fUnlinked = false; 2974 pUrb->Hci.u32FrameNo = p Ohci->HcFmNumber;2974 pUrb->Hci.u32FrameNo = pThis->HcFmNumber; 2975 2975 pUrb->Hci.paTds[0].TdAddr = ITdAddr; 2976 2976 AssertCompile(sizeof(pUrb->Hci.paTds[0].TdCopy) >= sizeof(*pITd)); … … 2996 2996 /* both pages. */ 2997 2997 const unsigned cb0 = 0x1000 - off0; 2998 ohciPhysRead(p Ohci, (pITd->BP0 & ITD_BP0_MASK) + off0, &pUrb->abData[0], cb0);2999 ohciPhysRead(p Ohci, pITd->BE & ITD_BP0_MASK, &pUrb->abData[cb0], offEnd & 0xfff);2998 ohciPhysRead(pThis, (pITd->BP0 & ITD_BP0_MASK) + off0, &pUrb->abData[0], cb0); 2999 ohciPhysRead(pThis, pITd->BE & ITD_BP0_MASK, &pUrb->abData[cb0], offEnd & 0xfff); 3000 3000 } 3001 3001 else /* a portion of the 1st page. */ 3002 ohciPhysRead(p Ohci, (pITd->BP0 & ITD_BP0_MASK) + off0, pUrb->abData, offEnd - off0);3002 ohciPhysRead(pThis, (pITd->BP0 & ITD_BP0_MASK) + off0, pUrb->abData, offEnd - off0); 3003 3003 } 3004 3004 else /* a portion of the 2nd page. */ 3005 ohciPhysRead(p Ohci, (pITd->BE & UINT32_C(0xfffff000)) + (off0 & 0xfff), pUrb->abData, cbTotal);3005 ohciPhysRead(pThis, (pITd->BE & UINT32_C(0xfffff000)) + (off0 & 0xfff), pUrb->abData, cbTotal); 3006 3006 } 3007 3007 … … 3020 3020 * Submit the URB. 3021 3021 */ 3022 ohci_in_flight_add_urb(p Ohci, pUrb);3022 ohci_in_flight_add_urb(pThis, pUrb); 3023 3023 Log(("%s: ohciServiceIsochronousTd: submitting cbData=%#x cIsocPkts=%d EdAddr=%#010x TdAddr=%#010x SF=%#x (%#x)\n", 3024 pUrb->pszDesc, pUrb->cbData, pUrb->cIsocPkts, EdAddr, ITdAddr, pITd->HwInfo & ITD_HWINFO_SF, p Ohci->HcFmNumber));3025 int rc = VUSBIRhSubmitUrb(p Ohci->RootHub.pIRhConn, pUrb, &pOhci->RootHub.Led);3024 pUrb->pszDesc, pUrb->cbData, pUrb->cIsocPkts, EdAddr, ITdAddr, pITd->HwInfo & ITD_HWINFO_SF, pThis->HcFmNumber)); 3025 int rc = VUSBIRhSubmitUrb(pThis->RootHub.pIRhConn, pUrb, &pThis->RootHub.Led); 3026 3026 if (RT_SUCCESS(rc)) 3027 3027 return true; … … 3030 3030 Log(("ohciServiceIsochronousTd: failed submitting pUrb=%p cbData=%#x EdAddr=%#010x cTds=%d ITdAddr0=%#010x - rc=%Rrc\n", 3031 3031 pUrb, cbTotal, EdAddr, 1, ITdAddr, rc)); 3032 ohci_in_flight_remove(p Ohci, ITdAddr);3032 ohci_in_flight_remove(pThis, ITdAddr); 3033 3033 return false; 3034 3034 } … … 3038 3038 * Service an isochronous endpoint. 3039 3039 */ 3040 static void ohciServiceIsochronousEndpoint(POHCI p Ohci, POHCIED pEd, uint32_t EdAddr)3040 static void ohciServiceIsochronousEndpoint(POHCI pThis, POHCIED pEd, uint32_t EdAddr) 3041 3041 { 3042 3042 /* … … 3062 3062 uint32_t ITdAddrPrev = 0; 3063 3063 uint32_t u32NextFrame = UINT32_MAX; 3064 const uint16_t u16CurFrame = p Ohci->HcFmNumber;3064 const uint16_t u16CurFrame = pThis->HcFmNumber; 3065 3065 for (;;) 3066 3066 { … … 3074 3074 * is difficult enough as it is. 3075 3075 */ 3076 p Ohci->fIdle = false;3076 pThis->fIdle = false; 3077 3077 3078 3078 /* 3079 3079 * Read the current ITD and check what we're supposed to do about it. 3080 3080 */ 3081 ohciReadITd(p Ohci, ITdAddr, &ITd);3081 ohciReadITd(pThis, ITdAddr, &ITd); 3082 3082 const uint32_t ITdAddrNext = ITd.NextTD & ED_PTR_MASK; 3083 3083 const int16_t R = u16CurFrame - (uint16_t)(ITd.HwInfo & ITD_HWINFO_SF); /* 4.3.2.3 */ … … 3096 3096 && (uint16_t)u32NextFrame != (uint16_t)(ITd.HwInfo & ITD_HWINFO_SF)) 3097 3097 break; 3098 if (ohci_in_flight_find(p Ohci, ITdAddr) < 0)3099 if (!ohciServiceIsochronousTd(p Ohci, &ITd, ITdAddr, R < 0 ? 0 : R, pEd, EdAddr))3098 if (ohci_in_flight_find(pThis, ITdAddr) < 0) 3099 if (!ohciServiceIsochronousTd(pThis, &ITd, ITdAddr, R < 0 ? 0 : R, pEd, EdAddr)) 3100 3100 break; 3101 3101 … … 3118 3118 * time will show. 3119 3119 */ 3120 int iInFlight = ohci_in_flight_find(p Ohci, ITdAddr);3120 int iInFlight = ohci_in_flight_find(pThis, ITdAddr); 3121 3121 if (iInFlight >= 0) 3122 3122 ITdAddrPrev = ITdAddr; 3123 else if (!ohciServiceIsochronousTdUnlink(p Ohci, &ITd, ITdAddr, ITdAddrPrev,3123 else if (!ohciServiceIsochronousTdUnlink(pThis, &ITd, ITdAddr, ITdAddrPrev, 3124 3124 NULL, pEd, EdAddr)) 3125 3125 { … … 3136 3136 * are successful with the first URB but then it goes too slowly... 3137 3137 */ 3138 int iInFlight = ohci_in_flight_find(p Ohci, ITdAddr);3139 if (!ohciServiceIsochronousTdUnlink(p Ohci, &ITd, ITdAddr, ITdAddrPrev,3140 iInFlight < 0 ? NULL : p Ohci->aInFlight[iInFlight].pUrb,3138 int iInFlight = ohci_in_flight_find(pThis, ITdAddr); 3139 if (!ohciServiceIsochronousTdUnlink(pThis, &ITd, ITdAddr, ITdAddrPrev, 3140 iInFlight < 0 ? NULL : pThis->aInFlight[iInFlight].pUrb, 3141 3141 pEd, EdAddr)) 3142 3142 { … … 3187 3187 * derived from USB tracing done in the guests and guest source code (when available). 3188 3188 */ 3189 static void ohciServiceBulkList(POHCI p Ohci)3189 static void ohciServiceBulkList(POHCI pThis) 3190 3190 { 3191 3191 #ifdef LOG_ENABLED 3192 3192 if (g_fLogBulkEPs) 3193 ohciDumpEdList(p Ohci, pOhci->bulk_head, "Bulk before", true);3194 if (p Ohci->bulk_cur)3195 Log(("ohciServiceBulkList: bulk_cur=%#010x before listprocessing!!! HCD have positioned us!!!\n", p Ohci->bulk_cur));3193 ohciDumpEdList(pThis, pThis->bulk_head, "Bulk before", true); 3194 if (pThis->bulk_cur) 3195 Log(("ohciServiceBulkList: bulk_cur=%#010x before listprocessing!!! HCD have positioned us!!!\n", pThis->bulk_cur)); 3196 3196 #endif 3197 3197 … … 3201 3201 * our way thru to the end each time. 3202 3202 */ 3203 p Ohci->status &= ~OHCI_STATUS_BLF;3204 p Ohci->fBulkNeedsCleaning = false;3205 p Ohci->bulk_cur = 0;3206 3207 uint32_t EdAddr = p Ohci->bulk_head;3203 pThis->status &= ~OHCI_STATUS_BLF; 3204 pThis->fBulkNeedsCleaning = false; 3205 pThis->bulk_cur = 0; 3206 3207 uint32_t EdAddr = pThis->bulk_head; 3208 3208 while (EdAddr) 3209 3209 { 3210 3210 OHCIED Ed; 3211 ohciReadEd(p Ohci, EdAddr, &Ed);3211 ohciReadEd(pThis, EdAddr, &Ed); 3212 3212 Assert(!(Ed.hwinfo & ED_HWINFO_ISO)); /* the guest is screwing us */ 3213 3213 if (ohciIsEdReady(&Ed)) 3214 3214 { 3215 p Ohci->status |= OHCI_STATUS_BLF;3216 p Ohci->fBulkNeedsCleaning = true;3215 pThis->status |= OHCI_STATUS_BLF; 3216 pThis->fBulkNeedsCleaning = true; 3217 3217 3218 3218 #if 1 … … 3225 3225 * on a bulk endpoint. 3226 3226 */ 3227 ohciServiceHeadTdMultiple(p Ohci, VUSBXFERTYPE_BULK, &Ed, EdAddr, "Bulk");3227 ohciServiceHeadTdMultiple(pThis, VUSBXFERTYPE_BULK, &Ed, EdAddr, "Bulk"); 3228 3228 #else 3229 3229 /* … … 3232 3232 */ 3233 3233 uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK; 3234 if (!ohciIsTdInFlight(p Ohci, TdAddr))3234 if (!ohciIsTdInFlight(pThis, TdAddr)) 3235 3235 { 3236 3236 do 3237 3237 { 3238 if (!ohciServiceTdMultiple(p Ohci, VUSBXFERTYPE_BULK, &Ed, EdAddr, TdAddr, &TdAddr, "Bulk"))3238 if (!ohciServiceTdMultiple(pThis, VUSBXFERTYPE_BULK, &Ed, EdAddr, TdAddr, &TdAddr, "Bulk")) 3239 3239 { 3240 3240 LogFlow(("ohciServiceBulkList: ohciServiceTdMultiple -> false\n")); … … 3248 3248 } 3249 3249 3250 ohciReadEd(p Ohci, EdAddr, &Ed); /* It might have been updated on URB completion. */3250 ohciReadEd(pThis, EdAddr, &Ed); /* It might have been updated on URB completion. */ 3251 3251 } while (ohciIsEdReady(&Ed)); 3252 3252 } … … 3262 3262 */ 3263 3263 uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK; 3264 PVUSBURB pUrb = ohciTdInFlightUrb(p Ohci, TdAddr);3264 PVUSBURB pUrb = ohciTdInFlightUrb(pThis, TdAddr); 3265 3265 if (pUrb) 3266 p Ohci->RootHub.pIRhConn->pfnCancelUrbsEp(pOhci->RootHub.pIRhConn, pUrb);3266 pThis->RootHub.pIRhConn->pfnCancelUrbsEp(pThis->RootHub.pIRhConn, pUrb); 3267 3267 } 3268 3268 } … … 3275 3275 #ifdef LOG_ENABLED 3276 3276 if (g_fLogBulkEPs) 3277 ohciDumpEdList(p Ohci, pOhci->bulk_head, "Bulk after ", true);3277 ohciDumpEdList(pThis, pThis->bulk_head, "Bulk after ", true); 3278 3278 #endif 3279 3279 } … … 3287 3287 * and would block further communication. 3288 3288 */ 3289 static void ohciUndoBulkList(POHCI p Ohci)3289 static void ohciUndoBulkList(POHCI pThis) 3290 3290 { 3291 3291 #ifdef LOG_ENABLED 3292 3292 if (g_fLogBulkEPs) 3293 ohciDumpEdList(p Ohci, pOhci->bulk_head, "Bulk before", true);3294 if (p Ohci->bulk_cur)3295 Log(("ohciUndoBulkList: bulk_cur=%#010x before list processing!!! HCD has positioned us!!!\n", p Ohci->bulk_cur));3293 ohciDumpEdList(pThis, pThis->bulk_head, "Bulk before", true); 3294 if (pThis->bulk_cur) 3295 Log(("ohciUndoBulkList: bulk_cur=%#010x before list processing!!! HCD has positioned us!!!\n", pThis->bulk_cur)); 3296 3296 #endif 3297 3297 3298 3298 /* This flag follows OHCI_STATUS_BLF, but BLF doesn't change when list processing is disabled. */ 3299 p Ohci->fBulkNeedsCleaning = false;3300 3301 uint32_t EdAddr = p Ohci->bulk_head;3299 pThis->fBulkNeedsCleaning = false; 3300 3301 uint32_t EdAddr = pThis->bulk_head; 3302 3302 while (EdAddr) 3303 3303 { 3304 3304 OHCIED Ed; 3305 ohciReadEd(p Ohci, EdAddr, &Ed);3305 ohciReadEd(pThis, EdAddr, &Ed); 3306 3306 Assert(!(Ed.hwinfo & ED_HWINFO_ISO)); /* the guest is screwing us */ 3307 3307 if (ohciIsEdPresent(&Ed)) 3308 3308 { 3309 3309 uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK; 3310 if (ohciIsTdInFlight(p Ohci, TdAddr))3310 if (ohciIsTdInFlight(pThis, TdAddr)) 3311 3311 { 3312 3312 LogFlow(("ohciUndoBulkList: Ed=%#010RX32 Ed.TailP=%#010RX32 UNDO\n", EdAddr, Ed.TailP)); 3313 PVUSBURB pUrb = ohciTdInFlightUrb(p Ohci, TdAddr);3313 PVUSBURB pUrb = ohciTdInFlightUrb(pThis, TdAddr); 3314 3314 if (pUrb) 3315 p Ohci->RootHub.pIRhConn->pfnCancelUrbsEp(pOhci->RootHub.pIRhConn, pUrb);3315 pThis->RootHub.pIRhConn->pfnCancelUrbsEp(pThis->RootHub.pIRhConn, pUrb); 3316 3316 } 3317 3317 } … … 3328 3328 * care of at VUSB level (unlike the other transfer types). 3329 3329 */ 3330 static void ohciServiceCtrlList(POHCI p Ohci)3330 static void ohciServiceCtrlList(POHCI pThis) 3331 3331 { 3332 3332 #ifdef LOG_ENABLED 3333 3333 if (g_fLogControlEPs) 3334 ohciDumpEdList(p Ohci, pOhci->ctrl_head, "Ctrl before", true);3335 if (p Ohci->ctrl_cur)3336 Log(("ohciServiceCtrlList: ctrl_cur=%010x before list processing!!! HCD have positioned us!!!\n", p Ohci->ctrl_cur));3334 ohciDumpEdList(pThis, pThis->ctrl_head, "Ctrl before", true); 3335 if (pThis->ctrl_cur) 3336 Log(("ohciServiceCtrlList: ctrl_cur=%010x before list processing!!! HCD have positioned us!!!\n", pThis->ctrl_cur)); 3337 3337 #endif 3338 3338 … … 3342 3342 * our way thru to the end each time. 3343 3343 */ 3344 p Ohci->status &= ~OHCI_STATUS_CLF;3345 p Ohci->ctrl_cur = 0;3346 3347 uint32_t EdAddr = p Ohci->ctrl_head;3344 pThis->status &= ~OHCI_STATUS_CLF; 3345 pThis->ctrl_cur = 0; 3346 3347 uint32_t EdAddr = pThis->ctrl_head; 3348 3348 while (EdAddr) 3349 3349 { 3350 3350 OHCIED Ed; 3351 ohciReadEd(p Ohci, EdAddr, &Ed);3351 ohciReadEd(pThis, EdAddr, &Ed); 3352 3352 Assert(!(Ed.hwinfo & ED_HWINFO_ISO)); /* the guest is screwing us */ 3353 3353 if (ohciIsEdReady(&Ed)) … … 3362 3362 do 3363 3363 { 3364 if ( !ohciServiceHeadTd(p Ohci, VUSBXFERTYPE_CTRL, &Ed, EdAddr, "Control")3365 || ohciIsTdInFlight(p Ohci, Ed.HeadP & ED_PTR_MASK))3364 if ( !ohciServiceHeadTd(pThis, VUSBXFERTYPE_CTRL, &Ed, EdAddr, "Control") 3365 || ohciIsTdInFlight(pThis, Ed.HeadP & ED_PTR_MASK)) 3366 3366 { 3367 p Ohci->status |= OHCI_STATUS_CLF;3367 pThis->status |= OHCI_STATUS_CLF; 3368 3368 break; 3369 3369 } 3370 ohciReadEd(p Ohci, EdAddr, &Ed); /* It might have been updated on URB completion. */3370 ohciReadEd(pThis, EdAddr, &Ed); /* It might have been updated on URB completion. */ 3371 3371 } while (ohciIsEdReady(&Ed)); 3372 3372 #else 3373 3373 /* Simplistic, for debugging. */ 3374 ohciServiceHeadTd(p Ohci, VUSBXFERTYPE_CTRL, &Ed, EdAddr, "Control");3375 p Ohci->status |= OHCI_STATUS_CLF;3374 ohciServiceHeadTd(pThis, VUSBXFERTYPE_CTRL, &Ed, EdAddr, "Control"); 3375 pThis->status |= OHCI_STATUS_CLF; 3376 3376 #endif 3377 3377 } … … 3383 3383 #ifdef LOG_ENABLED 3384 3384 if (g_fLogControlEPs) 3385 ohciDumpEdList(p Ohci, pOhci->ctrl_head, "Ctrl after ", true);3385 ohciDumpEdList(pThis, pThis->ctrl_head, "Ctrl after ", true); 3386 3386 #endif 3387 3387 } … … 3395 3395 * code (when available). 3396 3396 */ 3397 static void ohciServicePeriodicList(POHCI p Ohci)3397 static void ohciServicePeriodicList(POHCI pThis) 3398 3398 { 3399 3399 /* 3400 3400 * Read the list head from the HCCA. 3401 3401 */ 3402 const unsigned iList = p Ohci->HcFmNumber % OHCI_HCCA_NUM_INTR;3402 const unsigned iList = pThis->HcFmNumber % OHCI_HCCA_NUM_INTR; 3403 3403 uint32_t EdAddr; 3404 ohciGetDWords(p Ohci, pOhci->hcca + iList * sizeof(EdAddr), &EdAddr, 1);3404 ohciGetDWords(pThis, pThis->hcca + iList * sizeof(EdAddr), &EdAddr, 1); 3405 3405 3406 3406 #ifdef LOG_ENABLED … … 3410 3410 char sz[48]; 3411 3411 RTStrPrintf(sz, sizeof(sz), "Int%02x before", iList); 3412 ohciDumpEdList(p Ohci, EdAddrHead, sz, true);3412 ohciDumpEdList(pThis, EdAddrHead, sz, true); 3413 3413 } 3414 3414 #endif … … 3420 3420 { 3421 3421 OHCIED Ed; 3422 ohciReadEd(p Ohci, EdAddr, &Ed);3422 ohciReadEd(pThis, EdAddr, &Ed); 3423 3423 3424 3424 if (ohciIsEdReady(&Ed)) … … 3434 3434 * Presently we will only process the head URB on an interrupt endpoint. 3435 3435 */ 3436 ohciServiceHeadTdMultiple(p Ohci, VUSBXFERTYPE_INTR, &Ed, EdAddr, "Periodic");3436 ohciServiceHeadTdMultiple(pThis, VUSBXFERTYPE_INTR, &Ed, EdAddr, "Periodic"); 3437 3437 } 3438 else if (p Ohci->ctl & OHCI_CTL_IE)3438 else if (pThis->ctl & OHCI_CTL_IE) 3439 3439 { 3440 3440 /* 3441 3441 * Presently only the head ITD. 3442 3442 */ 3443 ohciServiceIsochronousEndpoint(p Ohci, &Ed, EdAddr);3443 ohciServiceIsochronousEndpoint(pThis, &Ed, EdAddr); 3444 3444 } 3445 3445 else … … 3456 3456 char sz[48]; 3457 3457 RTStrPrintf(sz, sizeof(sz), "Int%02x after ", iList); 3458 ohciDumpEdList(p Ohci, EdAddrHead, sz, true);3458 ohciDumpEdList(pThis, EdAddrHead, sz, true); 3459 3459 } 3460 3460 #endif … … 3465 3465 * Update the HCCA. 3466 3466 * 3467 * @param p OhciThe OHCI instance data.3468 */ 3469 static void ohciUpdateHCCA(POHCI p Ohci)3467 * @param pThis The OHCI instance data. 3468 */ 3469 static void ohciUpdateHCCA(POHCI pThis) 3470 3470 { 3471 3471 struct ohci_hcca hcca; 3472 ohciPhysRead(p Ohci, pOhci->hcca + OHCI_HCCA_OFS, &hcca, sizeof(hcca));3473 3474 hcca.frame = RT_H2LE_U16((uint16_t)p Ohci->HcFmNumber);3472 ohciPhysRead(pThis, pThis->hcca + OHCI_HCCA_OFS, &hcca, sizeof(hcca)); 3473 3474 hcca.frame = RT_H2LE_U16((uint16_t)pThis->HcFmNumber); 3475 3475 hcca.pad = 0; 3476 3476 3477 3477 bool fWriteDoneHeadInterrupt = false; 3478 if ( p Ohci->dqic == 03479 && (p Ohci->intr_status & OHCI_INTR_WRITE_DONE_HEAD) == 0)3480 { 3481 uint32_t done = p Ohci->done;3482 3483 if (p Ohci->intr_status & ~( OHCI_INTR_MASTER_INTERRUPT_ENABLED | OHCI_INTR_OWNERSHIP_CHANGE3478 if ( pThis->dqic == 0 3479 && (pThis->intr_status & OHCI_INTR_WRITE_DONE_HEAD) == 0) 3480 { 3481 uint32_t done = pThis->done; 3482 3483 if (pThis->intr_status & ~( OHCI_INTR_MASTER_INTERRUPT_ENABLED | OHCI_INTR_OWNERSHIP_CHANGE 3484 3484 | OHCI_INTR_WRITE_DONE_HEAD) ) 3485 3485 done |= 0x1; 3486 3486 3487 3487 hcca.done = RT_H2LE_U32(done); 3488 p Ohci->done = 0;3489 p Ohci->dqic = 0x7;3488 pThis->done = 0; 3489 pThis->dqic = 0x7; 3490 3490 3491 3491 Log(("ohci: Writeback Done (%#010x) on frame %#x (age %#x)\n", hcca.done, 3492 p Ohci->HcFmNumber, pOhci->HcFmNumber - pOhci->u32FmDoneQueueTail));3492 pThis->HcFmNumber, pThis->HcFmNumber - pThis->u32FmDoneQueueTail)); 3493 3493 #ifdef LOG_ENABLED 3494 ohciDumpTdQueue(p Ohci, hcca.done & ED_PTR_MASK, "DoneQueue");3494 ohciDumpTdQueue(pThis, hcca.done & ED_PTR_MASK, "DoneQueue"); 3495 3495 #endif 3496 3496 Assert(RT_OFFSETOF(struct ohci_hcca, done) == 4); 3497 3497 #if defined(VBOX_STRICT) || defined(LOG_ENABLED) 3498 ohci_in_done_queue_zap(p Ohci);3498 ohci_in_done_queue_zap(pThis); 3499 3499 #endif 3500 3500 fWriteDoneHeadInterrupt = true; 3501 3501 } 3502 3502 3503 ohciPhysWrite(p Ohci, pOhci->hcca + OHCI_HCCA_OFS, (uint8_t *)&hcca, sizeof(hcca));3503 ohciPhysWrite(pThis, pThis->hcca + OHCI_HCCA_OFS, (uint8_t *)&hcca, sizeof(hcca)); 3504 3504 if (fWriteDoneHeadInterrupt) 3505 ohciSetInterrupt(p Ohci, OHCI_INTR_WRITE_DONE_HEAD);3505 ohciSetInterrupt(pThis, OHCI_INTR_WRITE_DONE_HEAD); 3506 3506 } 3507 3507 … … 3510 3510 * Calculate frame timer variables given a frame rate (1,000 Hz is the full speed). 3511 3511 */ 3512 static void ohciCalcTimerIntervals(POHCI p Ohci, uint32_t u32FrameRate)3512 static void ohciCalcTimerIntervals(POHCI pThis, uint32_t u32FrameRate) 3513 3513 { 3514 3514 Assert(u32FrameRate <= OHCI_DEFAULT_TIMER_FREQ); 3515 3515 3516 3516 3517 p Ohci->cTicksPerFrame = pOhci->u64TimerHz / u32FrameRate;3518 if (!p Ohci->cTicksPerFrame)3519 p Ohci->cTicksPerFrame = 1;3520 p Ohci->cTicksPerUsbTick = pOhci->u64TimerHz >= VUSB_BUS_HZ ? pOhci->u64TimerHz / VUSB_BUS_HZ : 1;3521 p Ohci->uFrameRate = u32FrameRate;3517 pThis->cTicksPerFrame = pThis->u64TimerHz / u32FrameRate; 3518 if (!pThis->cTicksPerFrame) 3519 pThis->cTicksPerFrame = 1; 3520 pThis->cTicksPerUsbTick = pThis->u64TimerHz >= VUSB_BUS_HZ ? pThis->u64TimerHz / VUSB_BUS_HZ : 1; 3521 pThis->uFrameRate = u32FrameRate; 3522 3522 } 3523 3523 … … 3526 3526 * Generate a Start-Of-Frame event, and set a timer for End-Of-Frame. 3527 3527 */ 3528 static void ohciStartOfFrame(POHCI p Ohci)3529 { 3530 uint32_t uNewFrameRate = p Ohci->uFrameRate;3528 static void ohciStartOfFrame(POHCI pThis) 3529 { 3530 uint32_t uNewFrameRate = pThis->uFrameRate; 3531 3531 #ifdef LOG_ENABLED 3532 const uint32_t status_old = p Ohci->status;3532 const uint32_t status_old = pThis->status; 3533 3533 #endif 3534 3534 … … 3536 3536 * Update HcFmRemaining.FRT and re-arm the timer. 3537 3537 */ 3538 p Ohci->frt = pOhci->fit;3538 pThis->frt = pThis->fit; 3539 3539 #if 1 /* This is required for making the quickcam work on the mac. Should really look 3540 3540 into that adaptive polling stuff... */ 3541 p Ohci->SofTime += pOhci->cTicksPerFrame;3542 const uint64_t u64Now = TMTimerGet(p Ohci->CTX_SUFF(pEndOfFrameTimer));3543 if (p Ohci->SofTime + pOhci->cTicksPerFrame < u64Now)3544 p Ohci->SofTime = u64Now - pOhci->cTicksPerFrame / 2;3541 pThis->SofTime += pThis->cTicksPerFrame; 3542 const uint64_t u64Now = TMTimerGet(pThis->CTX_SUFF(pEndOfFrameTimer)); 3543 if (pThis->SofTime + pThis->cTicksPerFrame < u64Now) 3544 pThis->SofTime = u64Now - pThis->cTicksPerFrame / 2; 3545 3545 #else 3546 p Ohci->SofTime = TMTimerGet(pOhci->CTX_SUFF(pEndOfFrameTimer));3546 pThis->SofTime = TMTimerGet(pThis->CTX_SUFF(pEndOfFrameTimer)); 3547 3547 #endif 3548 TMTimerSet(p Ohci->CTX_SUFF(pEndOfFrameTimer), pOhci->SofTime + pOhci->cTicksPerFrame);3548 TMTimerSet(pThis->CTX_SUFF(pEndOfFrameTimer), pThis->SofTime + pThis->cTicksPerFrame); 3549 3549 3550 3550 /* … … 3552 3552 * the bus with a hcca of 0 to work around problem with a specific controller. 3553 3553 */ 3554 bool fValidHCCA = !( p Ohci->hcca >= OHCI_HCCA_MASK3555 || p Ohci->hcca < ~OHCI_HCCA_MASK);3554 bool fValidHCCA = !( pThis->hcca >= OHCI_HCCA_MASK 3555 || pThis->hcca < ~OHCI_HCCA_MASK); 3556 3556 3557 3557 #if 0 /* moved down for higher speed. */ … … 3561 3561 */ 3562 3562 if (fValidHCCA) 3563 ohciUpdateHCCA(p Ohci);3563 ohciUpdateHCCA(pThis); 3564 3564 #endif 3565 3565 3566 3566 /* "After writing to HCCA, HC will set SF in HcInterruptStatus" - guest isn't executing, so ignore the order! */ 3567 ohciSetInterrupt(p Ohci, OHCI_INTR_START_OF_FRAME);3568 3569 if (p Ohci->fno)3570 { 3571 ohciSetInterrupt(p Ohci, OHCI_INTR_FRAMENUMBER_OVERFLOW);3572 p Ohci->fno = 0;3567 ohciSetInterrupt(pThis, OHCI_INTR_START_OF_FRAME); 3568 3569 if (pThis->fno) 3570 { 3571 ohciSetInterrupt(pThis, OHCI_INTR_FRAMENUMBER_OVERFLOW); 3572 pThis->fno = 0; 3573 3573 } 3574 3574 … … 3577 3577 { 3578 3578 Log(("ohciStartOfFrame: skipping hcca part because hcca=%RX32 (our 'valid' range: %RX32-%RX32)\n", 3579 p Ohci->hcca, ~OHCI_HCCA_MASK, OHCI_HCCA_MASK));3579 pThis->hcca, ~OHCI_HCCA_MASK, OHCI_HCCA_MASK)); 3580 3580 return; 3581 3581 } … … 3584 3584 * Periodic EPs. 3585 3585 */ 3586 if (p Ohci->ctl & OHCI_CTL_PLE)3587 ohciServicePeriodicList(p Ohci);3586 if (pThis->ctl & OHCI_CTL_PLE) 3587 ohciServicePeriodicList(pThis); 3588 3588 3589 3589 /* 3590 3590 * Control EPs. 3591 3591 */ 3592 if ( (p Ohci->ctl & OHCI_CTL_CLE)3593 && (p Ohci->status & OHCI_STATUS_CLF) )3594 ohciServiceCtrlList(p Ohci);3592 if ( (pThis->ctl & OHCI_CTL_CLE) 3593 && (pThis->status & OHCI_STATUS_CLF) ) 3594 ohciServiceCtrlList(pThis); 3595 3595 3596 3596 /* 3597 3597 * Bulk EPs. 3598 3598 */ 3599 if ( (p Ohci->ctl & OHCI_CTL_BLE)3600 && (p Ohci->status & OHCI_STATUS_BLF))3601 ohciServiceBulkList(p Ohci);3602 else if ((p Ohci->status & OHCI_STATUS_BLF)3603 && p Ohci->fBulkNeedsCleaning)3604 ohciUndoBulkList(p Ohci); /* If list disabled but not empty, abort endpoints. */3599 if ( (pThis->ctl & OHCI_CTL_BLE) 3600 && (pThis->status & OHCI_STATUS_BLF)) 3601 ohciServiceBulkList(pThis); 3602 else if ((pThis->status & OHCI_STATUS_BLF) 3603 && pThis->fBulkNeedsCleaning) 3604 ohciUndoBulkList(pThis); /* If list disabled but not empty, abort endpoints. */ 3605 3605 3606 3606 #if 1 … … 3618 3618 * as it was submitted. 3619 3619 */ 3620 ohciUpdateHCCA(p Ohci);3620 ohciUpdateHCCA(pThis); 3621 3621 #endif 3622 3622 3623 3623 #ifdef LOG_ENABLED 3624 if (p Ohci->status ^ status_old)3625 { 3626 uint32_t val = p Ohci->status;3624 if (pThis->status ^ status_old) 3625 { 3626 uint32_t val = pThis->status; 3627 3627 uint32_t chg = val ^ status_old; NOREF(chg); 3628 3628 Log2(("ohciStartOfFrame: HcCommandStatus=%#010x: %sHCR=%d %sCLF=%d %sBLF=%d %sOCR=%d %sSOC=%d\n", … … 3639 3639 * Adjust the frame timer interval based on idle detection. 3640 3640 */ 3641 if (p Ohci->fIdle)3642 { 3643 p Ohci->cIdleCycles++;3641 if (pThis->fIdle) 3642 { 3643 pThis->cIdleCycles++; 3644 3644 /* Set the new frame rate based on how long we've been idle. Tunable. */ 3645 switch (p Ohci->cIdleCycles)3645 switch (pThis->cIdleCycles) 3646 3646 { 3647 3647 case 4: uNewFrameRate = 500; break; /* 2ms interval */ … … 3651 3651 } 3652 3652 /* Avoid overflow. */ 3653 if (p Ohci->cIdleCycles > 60000)3654 p Ohci->cIdleCycles = 20000;3653 if (pThis->cIdleCycles > 60000) 3654 pThis->cIdleCycles = 20000; 3655 3655 } 3656 3656 else 3657 3657 { 3658 if (p Ohci->cIdleCycles)3658 if (pThis->cIdleCycles) 3659 3659 { 3660 p Ohci->cIdleCycles = 0;3660 pThis->cIdleCycles = 0; 3661 3661 uNewFrameRate = OHCI_DEFAULT_TIMER_FREQ; 3662 3662 } 3663 3663 } 3664 if (uNewFrameRate != p Ohci->uFrameRate)3665 { 3666 ohciCalcTimerIntervals(p Ohci, uNewFrameRate);3664 if (uNewFrameRate != pThis->uFrameRate) 3665 { 3666 ohciCalcTimerIntervals(pThis, uNewFrameRate); 3667 3667 if (uNewFrameRate == OHCI_DEFAULT_TIMER_FREQ) 3668 3668 { 3669 3669 /* If we're switching back to full speed, re-program the timer immediately to minimize latency. */ 3670 TMTimerSet(p Ohci->CTX_SUFF(pEndOfFrameTimer), pOhci->SofTime + pOhci->cTicksPerFrame);3670 TMTimerSet(pThis->CTX_SUFF(pEndOfFrameTimer), pThis->SofTime + pThis->cTicksPerFrame); 3671 3671 } 3672 3672 } … … 3676 3676 * Updates the HcFmNumber and FNO registers. 3677 3677 */ 3678 static void bump_frame_number(POHCI p Ohci)3679 { 3680 const uint16_t u16OldFmNumber = p Ohci->HcFmNumber++;3681 if ((u16OldFmNumber ^ p Ohci->HcFmNumber) & RT_BIT(15))3682 p Ohci->fno = 1;3678 static void bump_frame_number(POHCI pThis) 3679 { 3680 const uint16_t u16OldFmNumber = pThis->HcFmNumber++; 3681 if ((u16OldFmNumber ^ pThis->HcFmNumber) & RT_BIT(15)) 3682 pThis->fno = 1; 3683 3683 } 3684 3684 … … 3688 3688 static void ohciFrameBoundaryTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 3689 3689 { 3690 POHCI p Ohci= (POHCI)pvUser;3691 STAM_PROFILE_START(&p Ohci->StatTimer, a);3690 POHCI pThis = (POHCI)pvUser; 3691 STAM_PROFILE_START(&pThis->StatTimer, a); 3692 3692 3693 3693 /* Reset idle detection flag */ 3694 p Ohci->fIdle = true;3695 3696 VUSBIRhReapAsyncUrbs(p Ohci->RootHub.pIRhConn, 0);3694 pThis->fIdle = true; 3695 3696 VUSBIRhReapAsyncUrbs(pThis->RootHub.pIRhConn, 0); 3697 3697 3698 3698 /* Frame boundary, so do EOF stuff here */ 3699 bump_frame_number(p Ohci);3700 if ( (p Ohci->dqic != 0x7) && (pOhci->dqic != 0) )3701 p Ohci->dqic--;3699 bump_frame_number(pThis); 3700 if ( (pThis->dqic != 0x7) && (pThis->dqic != 0) ) 3701 pThis->dqic--; 3702 3702 3703 3703 /* Start the next frame */ 3704 ohciStartOfFrame(p Ohci);3705 3706 STAM_PROFILE_STOP(&p Ohci->StatTimer, a);3704 ohciStartOfFrame(pThis); 3705 3706 STAM_PROFILE_STOP(&pThis->StatTimer, a); 3707 3707 } 3708 3708 … … 3711 3711 * next frame 3712 3712 */ 3713 static void ohciBusStart(POHCI p Ohci)3714 { 3715 VUSBIDevPowerOn(p Ohci->RootHub.pIDev);3716 bump_frame_number(p Ohci);3717 p Ohci->dqic = 0x7;3718 3719 Log(("ohci: %s: Bus started\n", p Ohci->PciDev.name));3720 3721 p Ohci->SofTime = TMTimerGet(pOhci->CTX_SUFF(pEndOfFrameTimer)) - pOhci->cTicksPerFrame;3722 p Ohci->fIdle = false; /* Assume we won't be idle */3723 ohciStartOfFrame(p Ohci);3713 static void ohciBusStart(POHCI pThis) 3714 { 3715 VUSBIDevPowerOn(pThis->RootHub.pIDev); 3716 bump_frame_number(pThis); 3717 pThis->dqic = 0x7; 3718 3719 Log(("ohci: %s: Bus started\n", pThis->PciDev.name)); 3720 3721 pThis->SofTime = TMTimerGet(pThis->CTX_SUFF(pEndOfFrameTimer)) - pThis->cTicksPerFrame; 3722 pThis->fIdle = false; /* Assume we won't be idle */ 3723 ohciStartOfFrame(pThis); 3724 3724 } 3725 3725 … … 3727 3727 * Stop sending SOF tokens on the bus 3728 3728 */ 3729 static void ohciBusStop(POHCI p Ohci)3730 { 3731 if (p Ohci->CTX_SUFF(pEndOfFrameTimer))3732 TMTimerStop(p Ohci->CTX_SUFF(pEndOfFrameTimer));3733 VUSBIDevPowerOff(p Ohci->RootHub.pIDev);3729 static void ohciBusStop(POHCI pThis) 3730 { 3731 if (pThis->CTX_SUFF(pEndOfFrameTimer)) 3732 TMTimerStop(pThis->CTX_SUFF(pEndOfFrameTimer)); 3733 VUSBIDevPowerOff(pThis->RootHub.pIDev); 3734 3734 } 3735 3735 … … 3737 3737 * Move in to resume state 3738 3738 */ 3739 static void ohciBusResume(POHCI p Ohci, bool fHardware)3740 { 3741 p Ohci->ctl &= ~OHCI_CTL_HCFS;3742 p Ohci->ctl |= OHCI_USB_RESUME;3743 3744 Log(("p Ohci: ohciBusResume fHardware=%RTbool RWE=%s\n",3745 fHardware, (p Ohci->ctl & OHCI_CTL_RWE) ? "on" : "off"));3746 3747 if (fHardware && (p Ohci->ctl & OHCI_CTL_RWE))3748 ohciSetInterrupt(p Ohci, OHCI_INTR_RESUME_DETECT);3749 3750 ohciBusStart(p Ohci);3739 static void ohciBusResume(POHCI pThis, bool fHardware) 3740 { 3741 pThis->ctl &= ~OHCI_CTL_HCFS; 3742 pThis->ctl |= OHCI_USB_RESUME; 3743 3744 Log(("pThis: ohciBusResume fHardware=%RTbool RWE=%s\n", 3745 fHardware, (pThis->ctl & OHCI_CTL_RWE) ? "on" : "off")); 3746 3747 if (fHardware && (pThis->ctl & OHCI_CTL_RWE)) 3748 ohciSetInterrupt(pThis, OHCI_INTR_RESUME_DETECT); 3749 3750 ohciBusStart(pThis); 3751 3751 } 3752 3752 … … 3784 3784 * Read the HcRevision register. 3785 3785 */ 3786 static int HcRevision_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)3786 static int HcRevision_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 3787 3787 { 3788 3788 Log2(("HcRevision_r() -> 0x10\n")); … … 3794 3794 * Write to the HcRevision register. 3795 3795 */ 3796 static int HcRevision_w(POHCI p Ohci, uint32_t iReg, uint32_t u32Value)3796 static int HcRevision_w(POHCI pThis, uint32_t iReg, uint32_t u32Value) 3797 3797 { 3798 3798 Log2(("HcRevision_w(%#010x) - denied\n", u32Value)); … … 3804 3804 * Read the HcControl register. 3805 3805 */ 3806 static int HcControl_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)3807 { 3808 uint32_t ctl = p Ohci->ctl;3806 static int HcControl_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 3807 { 3808 uint32_t ctl = pThis->ctl; 3809 3809 Log2(("HcControl_r -> %#010x - CBSR=%d PLE=%d IE=%d CLE=%d BLE=%d HCFS=%#x IR=%d RWC=%d RWE=%d\n", 3810 3810 ctl, ctl & 3, (ctl >> 2) & 1, (ctl >> 3) & 1, (ctl >> 4) & 1, (ctl >> 5) & 1, (ctl >> 6) & 3, (ctl >> 8) & 1, … … 3817 3817 * Write the HcControl register. 3818 3818 */ 3819 static int HcControl_w(POHCI p Ohci, uint32_t iReg, uint32_t val)3819 static int HcControl_w(POHCI pThis, uint32_t iReg, uint32_t val) 3820 3820 { 3821 3821 /* log it. */ 3822 uint32_t chg = p Ohci->ctl ^ val; NOREF(chg);3822 uint32_t chg = pThis->ctl ^ val; NOREF(chg); 3823 3823 Log2(("HcControl_w(%#010x) => %sCBSR=%d %sPLE=%d %sIE=%d %sCLE=%d %sBLE=%d %sHCFS=%#x %sIR=%d %sRWC=%d %sRWE=%d\n", 3824 3824 val, … … 3836 3836 3837 3837 /* see what changed and take action on that. */ 3838 uint32_t old_state = p Ohci->ctl & OHCI_CTL_HCFS;3838 uint32_t old_state = pThis->ctl & OHCI_CTL_HCFS; 3839 3839 uint32_t new_state = val & OHCI_CTL_HCFS; 3840 3840 3841 3841 #ifdef IN_RING3 3842 p Ohci->ctl = val;3842 pThis->ctl = val; 3843 3843 if (new_state != old_state) 3844 3844 { … … 3847 3847 case OHCI_USB_OPERATIONAL: 3848 3848 LogRel(("OHCI: USB Operational\n")); 3849 ohciBusStart(p Ohci);3849 ohciBusStart(pThis); 3850 3850 break; 3851 3851 case OHCI_USB_SUSPEND: 3852 ohciBusStop(p Ohci);3852 ohciBusStop(pThis); 3853 3853 LogRel(("OHCI: USB Suspended\n")); 3854 3854 break; 3855 3855 case OHCI_USB_RESUME: 3856 3856 LogRel(("OHCI: USB Resume\n")); 3857 ohciBusResume(p Ohci, false /* not hardware */);3857 ohciBusResume(pThis, false /* not hardware */); 3858 3858 break; 3859 3859 case OHCI_USB_RESET: 3860 3860 { 3861 3861 LogRel(("OHCI: USB Reset\n")); 3862 ohciBusStop(p Ohci);3862 ohciBusStop(pThis); 3863 3863 /** @todo This should probably do a real reset, but we don't implement 3864 3864 * that correctly in the roothub reset callback yet. check it's 3865 3865 * comments and argument for more details. */ 3866 VUSBIDevReset(p Ohci->RootHub.pIDev, false /* don't do a real reset */, NULL, NULL, NULL);3866 VUSBIDevReset(pThis->RootHub.pIDev, false /* don't do a real reset */, NULL, NULL, NULL); 3867 3867 break; 3868 3868 } … … 3875 3875 return VINF_IOM_R3_MMIO_WRITE; 3876 3876 } 3877 p Ohci->ctl = val;3877 pThis->ctl = val; 3878 3878 #endif /* !IN_RING3 */ 3879 3879 … … 3884 3884 * Read the HcCommandStatus register. 3885 3885 */ 3886 static int HcCommandStatus_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)3887 { 3888 uint32_t status = p Ohci->status;3886 static int HcCommandStatus_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 3887 { 3888 uint32_t status = pThis->status; 3889 3889 Log2(("HcCommandStatus_r() -> %#010x - HCR=%d CLF=%d BLF=%d OCR=%d SOC=%d\n", 3890 3890 status, status & 1, (status >> 1) & 1, (status >> 2) & 1, (status >> 3) & 1, (status >> 16) & 3)); … … 3896 3896 * Write to the HcCommandStatus register. 3897 3897 */ 3898 static int HcCommandStatus_w(POHCI p Ohci, uint32_t iReg, uint32_t val)3898 static int HcCommandStatus_w(POHCI pThis, uint32_t iReg, uint32_t val) 3899 3899 { 3900 3900 /* log */ 3901 uint32_t chg = p Ohci->status ^ val; NOREF(chg);3901 uint32_t chg = pThis->status ^ val; NOREF(chg); 3902 3902 Log2(("HcCommandStatus_w(%#010x) => %sHCR=%d %sCLF=%d %sBLF=%d %sOCR=%d %sSOC=%d\n", 3903 3903 val, … … 3906 3906 chg & RT_BIT(2) ? "*" : "", (val >> 2) & 1, 3907 3907 chg & RT_BIT(3) ? "*" : "", (val >> 3) & 1, 3908 chg & (3<<16)? "!!!":"", (p Ohci->status >> 16) & 3));3908 chg & (3<<16)? "!!!":"", (pThis->status >> 16) & 3)); 3909 3909 if (val & ~0x0003000f) 3910 3910 Log2(("Unknown bits %#x are set!!!\n", val & ~0x0003000f)); … … 3915 3915 #ifdef IN_RING3 3916 3916 /* "bits written as '0' remain unchanged in the register" */ 3917 p Ohci->status |= val;3918 if (p Ohci->status & OHCI_STATUS_HCR)3917 pThis->status |= val; 3918 if (pThis->status & OHCI_STATUS_HCR) 3919 3919 { 3920 3920 LogRel(("OHCI: Software reset\n")); 3921 ohciDoReset(p Ohci, OHCI_USB_SUSPEND, false /* N/A */);3921 ohciDoReset(pThis, OHCI_USB_SUSPEND, false /* N/A */); 3922 3922 } 3923 3923 #else 3924 if ((p Ohci->status | val) & OHCI_STATUS_HCR)3924 if ((pThis->status | val) & OHCI_STATUS_HCR) 3925 3925 { 3926 3926 LogFlow(("HcCommandStatus_w: reset -> VINF_IOM_R3_MMIO_WRITE\n")); 3927 3927 return VINF_IOM_R3_MMIO_WRITE; 3928 3928 } 3929 p Ohci->status |= val;3929 pThis->status |= val; 3930 3930 #endif 3931 3931 return VINF_SUCCESS; … … 3935 3935 * Read the HcInterruptStatus register. 3936 3936 */ 3937 static int HcInterruptStatus_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)3938 { 3939 uint32_t val = p Ohci->intr_status;3937 static int HcInterruptStatus_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 3938 { 3939 uint32_t val = pThis->intr_status; 3940 3940 Log2(("HcInterruptStatus_r() -> %#010x - SO=%d WDH=%d SF=%d RD=%d UE=%d FNO=%d RHSC=%d OC=%d\n", 3941 3941 val, val & 1, (val >> 1) & 1, (val >> 2) & 1, (val >> 3) & 1, (val >> 4) & 1, (val >> 5) & 1, … … 3948 3948 * Write to the HcInterruptStatus register. 3949 3949 */ 3950 static int HcInterruptStatus_w(POHCI p Ohci, uint32_t iReg, uint32_t val)3951 { 3952 uint32_t res = p Ohci->intr_status & ~val;3953 uint32_t chg = p Ohci->intr_status ^ res; NOREF(chg);3950 static int HcInterruptStatus_w(POHCI pThis, uint32_t iReg, uint32_t val) 3951 { 3952 uint32_t res = pThis->intr_status & ~val; 3953 uint32_t chg = pThis->intr_status ^ res; NOREF(chg); 3954 3954 Log2(("HcInterruptStatus_w(%#010x) => %sSO=%d %sWDH=%d %sSF=%d %sRD=%d %sUE=%d %sFNO=%d %sRHSC=%d %sOC=%d\n", 3955 3955 val, … … 3969 3969 * register by writing '1' to bit positions to be cleared" 3970 3970 */ 3971 p Ohci->intr_status &= ~val;3972 ohciUpdateInterrupt(p Ohci, "HcInterruptStatus_w");3971 pThis->intr_status &= ~val; 3972 ohciUpdateInterrupt(pThis, "HcInterruptStatus_w"); 3973 3973 return VINF_SUCCESS; 3974 3974 } … … 3977 3977 * Read the HcInterruptEnable register 3978 3978 */ 3979 static int HcInterruptEnable_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)3980 { 3981 uint32_t val = p Ohci->intr;3979 static int HcInterruptEnable_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 3980 { 3981 uint32_t val = pThis->intr; 3982 3982 Log2(("HcInterruptEnable_r() -> %#010x - SO=%d WDH=%d SF=%d RD=%d UE=%d FNO=%d RHSC=%d OC=%d MIE=%d\n", 3983 3983 val, val & 1, (val >> 1) & 1, (val >> 2) & 1, (val >> 3) & 1, (val >> 4) & 1, (val >> 5) & 1, … … 3990 3990 * Writes to the HcInterruptEnable register. 3991 3991 */ 3992 static int HcInterruptEnable_w(POHCI p Ohci, uint32_t iReg, uint32_t val)3993 { 3994 uint32_t res = p Ohci->intr | val;3995 uint32_t chg = p Ohci->intr ^ res; NOREF(chg);3992 static int HcInterruptEnable_w(POHCI pThis, uint32_t iReg, uint32_t val) 3993 { 3994 uint32_t res = pThis->intr | val; 3995 uint32_t chg = pThis->intr ^ res; NOREF(chg); 3996 3996 Log2(("HcInterruptEnable_w(%#010x) => %sSO=%d %sWDH=%d %sSF=%d %sRD=%d %sUE=%d %sFNO=%d %sRHSC=%d %sOC=%d %sMIE=%d\n", 3997 3997 val, … … 4008 4008 Log2(("Uknown bits %#x are set!!!\n", val & ~0xc000007f)); 4009 4009 4010 p Ohci->intr |= val;4011 ohciUpdateInterrupt(p Ohci, "HcInterruptEnable_w");4010 pThis->intr |= val; 4011 ohciUpdateInterrupt(pThis, "HcInterruptEnable_w"); 4012 4012 return VINF_SUCCESS; 4013 4013 } … … 4016 4016 * Reads the HcInterruptDisable register. 4017 4017 */ 4018 static int HcInterruptDisable_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4018 static int HcInterruptDisable_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4019 4019 { 4020 4020 #if 1 /** @todo r=bird: "On read, the current value of the HcInterruptEnable register is returned." */ 4021 uint32_t val = p Ohci->intr;4021 uint32_t val = pThis->intr; 4022 4022 #else /* old code. */ 4023 uint32_t val = ~p Ohci->intr;4023 uint32_t val = ~pThis->intr; 4024 4024 #endif 4025 4025 Log2(("HcInterruptDisable_r() -> %#010x - SO=%d WDH=%d SF=%d RD=%d UE=%d FNO=%d RHSC=%d OC=%d MIE=%d\n", … … 4034 4034 * Writes to the HcInterruptDisable register. 4035 4035 */ 4036 static int HcInterruptDisable_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4037 { 4038 uint32_t res = p Ohci->intr & ~val;4039 uint32_t chg = p Ohci->intr ^ res; NOREF(chg);4036 static int HcInterruptDisable_w(POHCI pThis, uint32_t iReg, uint32_t val) 4037 { 4038 uint32_t res = pThis->intr & ~val; 4039 uint32_t chg = pThis->intr ^ res; NOREF(chg); 4040 4040 Log2(("HcInterruptDisable_w(%#010x) => %sSO=%d %sWDH=%d %sSF=%d %sRD=%d %sUE=%d %sFNO=%d %sRHSC=%d %sOC=%d %sMIE=%d\n", 4041 4041 val, … … 4052 4052 * interrupts you don't know about. */ 4053 4053 4054 p Ohci->intr &= ~val;4055 ohciUpdateInterrupt(p Ohci, "HcInterruptDisable_w");4054 pThis->intr &= ~val; 4055 ohciUpdateInterrupt(pThis, "HcInterruptDisable_w"); 4056 4056 return VINF_SUCCESS; 4057 4057 } … … 4060 4060 * Read the HcHCCA register (Host Controller Communications Area physical address). 4061 4061 */ 4062 static int HcHCCA_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4063 { 4064 Log2(("HcHCCA_r() -> %#010x\n", p Ohci->hcca));4065 *pu32Value = p Ohci->hcca;4062 static int HcHCCA_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4063 { 4064 Log2(("HcHCCA_r() -> %#010x\n", pThis->hcca)); 4065 *pu32Value = pThis->hcca; 4066 4066 return VINF_SUCCESS; 4067 4067 } … … 4070 4070 * Write to the HcHCCA register (Host Controller Communications Area physical address). 4071 4071 */ 4072 static int HcHCCA_w(POHCI p Ohci, uint32_t iReg, uint32_t Value)4073 { 4074 Log2(("HcHCCA_w(%#010x) - old=%#010x new=%#010x\n", Value, p Ohci->hcca, Value & OHCI_HCCA_MASK));4075 p Ohci->hcca = Value & OHCI_HCCA_MASK;4072 static int HcHCCA_w(POHCI pThis, uint32_t iReg, uint32_t Value) 4073 { 4074 Log2(("HcHCCA_w(%#010x) - old=%#010x new=%#010x\n", Value, pThis->hcca, Value & OHCI_HCCA_MASK)); 4075 pThis->hcca = Value & OHCI_HCCA_MASK; 4076 4076 return VINF_SUCCESS; 4077 4077 } … … 4080 4080 * Read the HcPeriodCurrentED register. 4081 4081 */ 4082 static int HcPeriodCurrentED_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4083 { 4084 Log2(("HcPeriodCurrentED_r() -> %#010x\n", p Ohci->per_cur));4085 *pu32Value = p Ohci->per_cur;4082 static int HcPeriodCurrentED_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4083 { 4084 Log2(("HcPeriodCurrentED_r() -> %#010x\n", pThis->per_cur)); 4085 *pu32Value = pThis->per_cur; 4086 4086 return VINF_SUCCESS; 4087 4087 } … … 4090 4090 * Write to the HcPeriodCurrentED register. 4091 4091 */ 4092 static int HcPeriodCurrentED_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4092 static int HcPeriodCurrentED_w(POHCI pThis, uint32_t iReg, uint32_t val) 4093 4093 { 4094 4094 Log(("HcPeriodCurrentED_w(%#010x) - old=%#010x new=%#010x (This is a read only register, only the linux guys don't respect that!)\n", 4095 val, p Ohci->per_cur, val & ~7));4096 //AssertMsgFailed(("HCD (Host Controller Driver) should not write to HcPeriodCurrentED! val=%#010x (old=%#010x)\n", val, p Ohci->per_cur));4095 val, pThis->per_cur, val & ~7)); 4096 //AssertMsgFailed(("HCD (Host Controller Driver) should not write to HcPeriodCurrentED! val=%#010x (old=%#010x)\n", val, pThis->per_cur)); 4097 4097 AssertMsg(!(val & 7), ("Invalid alignment, val=%#010x\n", val)); 4098 p Ohci->per_cur = val & ~7;4098 pThis->per_cur = val & ~7; 4099 4099 return VINF_SUCCESS; 4100 4100 } … … 4103 4103 * Read the HcControlHeadED register. 4104 4104 */ 4105 static int HcControlHeadED_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4106 { 4107 Log2(("HcControlHeadED_r() -> %#010x\n", p Ohci->ctrl_head));4108 *pu32Value = p Ohci->ctrl_head;4105 static int HcControlHeadED_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4106 { 4107 Log2(("HcControlHeadED_r() -> %#010x\n", pThis->ctrl_head)); 4108 *pu32Value = pThis->ctrl_head; 4109 4109 return VINF_SUCCESS; 4110 4110 } … … 4113 4113 * Write to the HcControlHeadED register. 4114 4114 */ 4115 static int HcControlHeadED_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4116 { 4117 Log2(("HcControlHeadED_w(%#010x) - old=%#010x new=%#010x\n", val, p Ohci->ctrl_head, val & ~7));4115 static int HcControlHeadED_w(POHCI pThis, uint32_t iReg, uint32_t val) 4116 { 4117 Log2(("HcControlHeadED_w(%#010x) - old=%#010x new=%#010x\n", val, pThis->ctrl_head, val & ~7)); 4118 4118 AssertMsg(!(val & 7), ("Invalid alignment, val=%#010x\n", val)); 4119 p Ohci->ctrl_head = val & ~7;4119 pThis->ctrl_head = val & ~7; 4120 4120 return VINF_SUCCESS; 4121 4121 } … … 4124 4124 * Read the HcControlCurrentED register. 4125 4125 */ 4126 static int HcControlCurrentED_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4127 { 4128 Log2(("HcControlCurrentED_r() -> %#010x\n", p Ohci->ctrl_cur));4129 *pu32Value = p Ohci->ctrl_cur;4126 static int HcControlCurrentED_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4127 { 4128 Log2(("HcControlCurrentED_r() -> %#010x\n", pThis->ctrl_cur)); 4129 *pu32Value = pThis->ctrl_cur; 4130 4130 return VINF_SUCCESS; 4131 4131 } … … 4134 4134 * Write to the HcControlCurrentED register. 4135 4135 */ 4136 static int HcControlCurrentED_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4137 { 4138 Log2(("HcControlCurrentED_w(%#010x) - old=%#010x new=%#010x\n", val, p Ohci->ctrl_cur, val & ~7));4139 AssertMsg(!(p Ohci->ctl & OHCI_CTL_CLE), ("Illegal write! HcControl.ControlListEnabled is set! val=%#010x\n", val));4136 static int HcControlCurrentED_w(POHCI pThis, uint32_t iReg, uint32_t val) 4137 { 4138 Log2(("HcControlCurrentED_w(%#010x) - old=%#010x new=%#010x\n", val, pThis->ctrl_cur, val & ~7)); 4139 AssertMsg(!(pThis->ctl & OHCI_CTL_CLE), ("Illegal write! HcControl.ControlListEnabled is set! val=%#010x\n", val)); 4140 4140 AssertMsg(!(val & 7), ("Invalid alignment, val=%#010x\n", val)); 4141 p Ohci->ctrl_cur = val & ~7;4141 pThis->ctrl_cur = val & ~7; 4142 4142 return VINF_SUCCESS; 4143 4143 } … … 4146 4146 * Read the HcBulkHeadED register. 4147 4147 */ 4148 static int HcBulkHeadED_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4149 { 4150 Log2(("HcBulkHeadED_r() -> %#010x\n", p Ohci->bulk_head));4151 *pu32Value = p Ohci->bulk_head;4148 static int HcBulkHeadED_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4149 { 4150 Log2(("HcBulkHeadED_r() -> %#010x\n", pThis->bulk_head)); 4151 *pu32Value = pThis->bulk_head; 4152 4152 return VINF_SUCCESS; 4153 4153 } … … 4156 4156 * Write to the HcBulkHeadED register. 4157 4157 */ 4158 static int HcBulkHeadED_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4159 { 4160 Log2(("HcBulkHeadED_w(%#010x) - old=%#010x new=%#010x\n", val, p Ohci->bulk_head, val & ~7));4158 static int HcBulkHeadED_w(POHCI pThis, uint32_t iReg, uint32_t val) 4159 { 4160 Log2(("HcBulkHeadED_w(%#010x) - old=%#010x new=%#010x\n", val, pThis->bulk_head, val & ~7)); 4161 4161 AssertMsg(!(val & 7), ("Invalid alignment, val=%#010x\n", val)); 4162 p Ohci->bulk_head = val & ~7; /** @todo The ATI OHCI controller on my machine enforces 16-byte address alignment. */4162 pThis->bulk_head = val & ~7; /** @todo The ATI OHCI controller on my machine enforces 16-byte address alignment. */ 4163 4163 return VINF_SUCCESS; 4164 4164 } … … 4167 4167 * Read the HcBulkCurrentED register. 4168 4168 */ 4169 static int HcBulkCurrentED_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4170 { 4171 Log2(("HcBulkCurrentED_r() -> %#010x\n", p Ohci->bulk_cur));4172 *pu32Value = p Ohci->bulk_cur;4169 static int HcBulkCurrentED_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4170 { 4171 Log2(("HcBulkCurrentED_r() -> %#010x\n", pThis->bulk_cur)); 4172 *pu32Value = pThis->bulk_cur; 4173 4173 return VINF_SUCCESS; 4174 4174 } … … 4177 4177 * Write to the HcBulkCurrentED register. 4178 4178 */ 4179 static int HcBulkCurrentED_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4180 { 4181 Log2(("HcBulkCurrentED_w(%#010x) - old=%#010x new=%#010x\n", val, p Ohci->bulk_cur, val & ~7));4182 AssertMsg(!(p Ohci->ctl & OHCI_CTL_BLE), ("Illegal write! HcControl.BulkListEnabled is set! val=%#010x\n", val));4179 static int HcBulkCurrentED_w(POHCI pThis, uint32_t iReg, uint32_t val) 4180 { 4181 Log2(("HcBulkCurrentED_w(%#010x) - old=%#010x new=%#010x\n", val, pThis->bulk_cur, val & ~7)); 4182 AssertMsg(!(pThis->ctl & OHCI_CTL_BLE), ("Illegal write! HcControl.BulkListEnabled is set! val=%#010x\n", val)); 4183 4183 AssertMsg(!(val & 7), ("Invalid alignment, val=%#010x\n", val)); 4184 p Ohci->bulk_cur = val & ~7;4184 pThis->bulk_cur = val & ~7; 4185 4185 return VINF_SUCCESS; 4186 4186 } … … 4190 4190 * Read the HcDoneHead register. 4191 4191 */ 4192 static int HcDoneHead_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4193 { 4194 Log2(("HcDoneHead_r() -> 0x%#08x\n", p Ohci->done));4195 *pu32Value = p Ohci->done;4192 static int HcDoneHead_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4193 { 4194 Log2(("HcDoneHead_r() -> 0x%#08x\n", pThis->done)); 4195 *pu32Value = pThis->done; 4196 4196 return VINF_SUCCESS; 4197 4197 } … … 4200 4200 * Write to the HcDoneHead register. 4201 4201 */ 4202 static int HcDoneHead_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4202 static int HcDoneHead_w(POHCI pThis, uint32_t iReg, uint32_t val) 4203 4203 { 4204 4204 Log2(("HcDoneHead_w(0x%#08x) - denied!!!\n", val)); … … 4211 4211 * Read the HcFmInterval (Fm=Frame) register. 4212 4212 */ 4213 static int HcFmInterval_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4214 { 4215 uint32_t val = (p Ohci->fit << 31) | (pOhci->fsmps << 16) | (pOhci->fi);4213 static int HcFmInterval_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4214 { 4215 uint32_t val = (pThis->fit << 31) | (pThis->fsmps << 16) | (pThis->fi); 4216 4216 Log2(("HcFmInterval_r() -> 0x%#08x - FI=%d FSMPS=%d FIT=%d\n", 4217 4217 val, val & 0x3fff, (val >> 16) & 0x7fff, val >> 31)); … … 4223 4223 * Write to the HcFmInterval (Fm = Frame) register. 4224 4224 */ 4225 static int HcFmInterval_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4225 static int HcFmInterval_w(POHCI pThis, uint32_t iReg, uint32_t val) 4226 4226 { 4227 4227 /* log */ 4228 uint32_t chg = val ^ ((p Ohci->fit << 31) | (pOhci->fsmps << 16) | pOhci->fi); NOREF(chg);4228 uint32_t chg = val ^ ((pThis->fit << 31) | (pThis->fsmps << 16) | pThis->fi); NOREF(chg); 4229 4229 Log2(("HcFmInterval_w(%#010x) => %sFI=%d %sFSMPS=%d %sFIT=%d\n", 4230 4230 val, … … 4232 4232 chg & 0x7fff0000 ? "*" : "", (val >> 16) & 0x7fff, 4233 4233 chg >> 31 ? "*" : "", (val >> 31) & 1)); 4234 if ( p Ohci->fi != (val & OHCI_FMI_FI) )4235 { 4236 Log(("ohci: FrameInterval: %#010x -> %#010x\n", p Ohci->fi, val & OHCI_FMI_FI));4237 AssertMsg(p Ohci->fit != ((val >> OHCI_FMI_FIT_SHIFT) & 1), ("HCD didn't toggle the FIT bit!!!\n"));4234 if ( pThis->fi != (val & OHCI_FMI_FI) ) 4235 { 4236 Log(("ohci: FrameInterval: %#010x -> %#010x\n", pThis->fi, val & OHCI_FMI_FI)); 4237 AssertMsg(pThis->fit != ((val >> OHCI_FMI_FIT_SHIFT) & 1), ("HCD didn't toggle the FIT bit!!!\n")); 4238 4238 } 4239 4239 4240 4240 /* update */ 4241 p Ohci->fi = val & OHCI_FMI_FI;4242 p Ohci->fit = (val & OHCI_FMI_FIT) >> OHCI_FMI_FIT_SHIFT;4243 p Ohci->fsmps = (val & OHCI_FMI_FSMPS) >> OHCI_FMI_FSMPS_SHIFT;4241 pThis->fi = val & OHCI_FMI_FI; 4242 pThis->fit = (val & OHCI_FMI_FIT) >> OHCI_FMI_FIT_SHIFT; 4243 pThis->fsmps = (val & OHCI_FMI_FSMPS) >> OHCI_FMI_FSMPS_SHIFT; 4244 4244 return VINF_SUCCESS; 4245 4245 } … … 4248 4248 * Read the HcFmRemaining (Fm = Frame) register. 4249 4249 */ 4250 static int HcFmRemaining_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4251 { 4252 uint32_t Value = p Ohci->frt << 31;4253 if ((p Ohci->ctl & OHCI_CTL_HCFS) == OHCI_USB_OPERATIONAL)4250 static int HcFmRemaining_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4251 { 4252 uint32_t Value = pThis->frt << 31; 4253 if ((pThis->ctl & OHCI_CTL_HCFS) == OHCI_USB_OPERATIONAL) 4254 4254 { 4255 4255 /* 4256 4256 * Being in USB operational state guarantees SofTime was set already. 4257 4257 */ 4258 uint64_t tks = TMTimerGet(p Ohci->CTX_SUFF(pEndOfFrameTimer)) - pOhci->SofTime;4259 if (tks < p Ohci->cTicksPerFrame) /* avoid muldiv if possible */4258 uint64_t tks = TMTimerGet(pThis->CTX_SUFF(pEndOfFrameTimer)) - pThis->SofTime; 4259 if (tks < pThis->cTicksPerFrame) /* avoid muldiv if possible */ 4260 4260 { 4261 4261 uint16_t fr; 4262 tks = ASMMultU64ByU32DivByU32(1, tks, p Ohci->cTicksPerUsbTick);4263 fr = (uint16_t)(p Ohci->fi - tks);4262 tks = ASMMultU64ByU32DivByU32(1, tks, pThis->cTicksPerUsbTick); 4263 fr = (uint16_t)(pThis->fi - tks); 4264 4264 Value |= fr; 4265 4265 } … … 4274 4274 * Write to the HcFmRemaining (Fm = Frame) register. 4275 4275 */ 4276 static int HcFmRemaining_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4276 static int HcFmRemaining_w(POHCI pThis, uint32_t iReg, uint32_t val) 4277 4277 { 4278 4278 Log2(("HcFmRemaining_w(%#010x) - denied\n", val)); … … 4284 4284 * Read the HcFmNumber (Fm = Frame) register. 4285 4285 */ 4286 static int HcFmNumber_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4287 { 4288 uint32_t val = (uint16_t)p Ohci->HcFmNumber;4289 Log2(("HcFmNumber_r() -> %#010x - FN=%#x(%d) (32-bit=%#x(%d))\n", val, val, val, p Ohci->HcFmNumber, pOhci->HcFmNumber));4286 static int HcFmNumber_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4287 { 4288 uint32_t val = (uint16_t)pThis->HcFmNumber; 4289 Log2(("HcFmNumber_r() -> %#010x - FN=%#x(%d) (32-bit=%#x(%d))\n", val, val, val, pThis->HcFmNumber, pThis->HcFmNumber)); 4290 4290 *pu32Value = val; 4291 4291 return VINF_SUCCESS; … … 4295 4295 * Write to the HcFmNumber (Fm = Frame) register. 4296 4296 */ 4297 static int HcFmNumber_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4297 static int HcFmNumber_w(POHCI pThis, uint32_t iReg, uint32_t val) 4298 4298 { 4299 4299 Log2(("HcFmNumber_w(%#010x) - denied\n", val)); … … 4306 4306 * The register determines when in a frame to switch from control&bulk to periodic lists. 4307 4307 */ 4308 static int HcPeriodicStart_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4309 { 4310 Log2(("HcPeriodicStart_r() -> %#010x - PS=%d\n", p Ohci->pstart, pOhci->pstart & 0x3fff));4311 *pu32Value = p Ohci->pstart;4308 static int HcPeriodicStart_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4309 { 4310 Log2(("HcPeriodicStart_r() -> %#010x - PS=%d\n", pThis->pstart, pThis->pstart & 0x3fff)); 4311 *pu32Value = pThis->pstart; 4312 4312 return VINF_SUCCESS; 4313 4313 } … … 4317 4317 * The register determines when in a frame to switch from control&bulk to periodic lists. 4318 4318 */ 4319 static int HcPeriodicStart_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4319 static int HcPeriodicStart_w(POHCI pThis, uint32_t iReg, uint32_t val) 4320 4320 { 4321 4321 Log2(("HcPeriodicStart_w(%#010x) => PS=%d\n", val, val & 0x3fff)); 4322 4322 if (val & ~0x3fff) 4323 4323 Log2(("Unknown bits %#x are set!!!\n", val & ~0x3fff)); 4324 p Ohci->pstart = val; /** @todo r=bird: should we support setting the other bits? */4324 pThis->pstart = val; /** @todo r=bird: should we support setting the other bits? */ 4325 4325 return VINF_SUCCESS; 4326 4326 } … … 4329 4329 * Read the HcLSThreshold register. 4330 4330 */ 4331 static int HcLSThreshold_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4331 static int HcLSThreshold_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4332 4332 { 4333 4333 Log2(("HcLSThreshold_r() -> %#010x\n", OHCI_LS_THRESH)); … … 4348 4348 * 4349 4349 */ 4350 static int HcLSThreshold_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4350 static int HcLSThreshold_w(POHCI pThis, uint32_t iReg, uint32_t val) 4351 4351 { 4352 4352 Log2(("HcLSThreshold_w(%#010x) => LST=0x%03x(%d)\n", val, val & 0x0fff)); … … 4360 4360 * Read the HcRhDescriptorA register. 4361 4361 */ 4362 static int HcRhDescriptorA_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4363 { 4364 uint32_t val = p Ohci->RootHub.desc_a;4362 static int HcRhDescriptorA_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4363 { 4364 uint32_t val = pThis->RootHub.desc_a; 4365 4365 #if 0 /* annoying */ 4366 4366 Log2(("HcRhDescriptorA_r() -> %#010x - NDP=%d PSM=%d NPS=%d DT=%d OCPM=%d NOCP=%d POTGT=%#x\n", … … 4375 4375 * Write to the HcRhDescriptorA register. 4376 4376 */ 4377 static int HcRhDescriptorA_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4378 { 4379 uint32_t chg = val ^ p Ohci->RootHub.desc_a; NOREF(chg);4377 static int HcRhDescriptorA_w(POHCI pThis, uint32_t iReg, uint32_t val) 4378 { 4379 uint32_t chg = val ^ pThis->RootHub.desc_a; NOREF(chg); 4380 4380 Log2(("HcRhDescriptorA_w(%#010x) => %sNDP=%d %sPSM=%d %sNPS=%d %sDT=%d %sOCPM=%d %sNOCP=%d %sPOTGT=%#x - %sPowerSwitching Set%sPower\n", 4381 4381 val, … … 4396 4396 { 4397 4397 Log(("ohci: %s: invalid write to NDP or DT in roothub descriptor A!!! val=0x%.8x\n", 4398 p Ohci->PciDev.name, val));4398 pThis->PciDev.name, val)); 4399 4399 val &= ~(OHCI_RHA_NDP | OHCI_RHA_DT); 4400 4400 val |= OHCI_NDP; 4401 4401 } 4402 4402 4403 p Ohci->RootHub.desc_a = val;4403 pThis->RootHub.desc_a = val; 4404 4404 return VINF_SUCCESS; 4405 4405 } … … 4408 4408 * Read the HcRhDescriptorB register. 4409 4409 */ 4410 static int HcRhDescriptorB_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4411 { 4412 uint32_t val = p Ohci->RootHub.desc_b;4410 static int HcRhDescriptorB_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4411 { 4412 uint32_t val = pThis->RootHub.desc_b; 4413 4413 Log2(("HcRhDescriptorB_r() -> %#010x - DR=0x%04x PPCM=0x%04x\n", 4414 4414 val, val & 0xffff, val >> 16)); … … 4420 4420 * Write to the HcRhDescriptorB register. 4421 4421 */ 4422 static int HcRhDescriptorB_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4423 { 4424 uint32_t chg = p Ohci->RootHub.desc_b ^ val; NOREF(chg);4422 static int HcRhDescriptorB_w(POHCI pThis, uint32_t iReg, uint32_t val) 4423 { 4424 uint32_t chg = pThis->RootHub.desc_b ^ val; NOREF(chg); 4425 4425 Log2(("HcRhDescriptorB_w(%#010x) => %sDR=0x%04x %sPPCM=0x%04x\n", 4426 4426 val, … … 4428 4428 chg >> 16 ? "!!!" : "", val >> 16)); 4429 4429 4430 if ( p Ohci->RootHub.desc_b != val )4430 if ( pThis->RootHub.desc_b != val ) 4431 4431 Log(("ohci: %s: unsupported write to root descriptor B!!! 0x%.8x -> 0x%.8x\n", 4432 p Ohci->PciDev.name,4433 p Ohci->RootHub.desc_b, val));4434 p Ohci->RootHub.desc_b = val;4432 pThis->PciDev.name, 4433 pThis->RootHub.desc_b, val)); 4434 pThis->RootHub.desc_b = val; 4435 4435 return VINF_SUCCESS; 4436 4436 } … … 4439 4439 * Read the HcRhStatus (Rh = Root Hub) register. 4440 4440 */ 4441 static int HcRhStatus_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4442 { 4443 uint32_t val = p Ohci->RootHub.status;4441 static int HcRhStatus_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4442 { 4443 uint32_t val = pThis->RootHub.status; 4444 4444 if (val & (OHCI_RHS_LPSC | OHCI_RHS_OCIC)) 4445 4445 Log2(("HcRhStatus_r() -> %#010x - LPS=%d OCI=%d DRWE=%d LPSC=%d OCIC=%d CRWE=%d\n", … … 4452 4452 * Write to the HcRhStatus (Rh = Root Hub) register. 4453 4453 */ 4454 static int HcRhStatus_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4454 static int HcRhStatus_w(POHCI pThis, uint32_t iReg, uint32_t val) 4455 4455 { 4456 4456 #ifdef IN_RING3 4457 4457 /* log */ 4458 uint32_t old = p Ohci->RootHub.status;4458 uint32_t old = pThis->RootHub.status; 4459 4459 uint32_t chg; 4460 4460 if (val & ~0x80038003) … … 4468 4468 /* write 1 to clear OCIC */ 4469 4469 if ( val & OHCI_RHS_OCIC ) 4470 p Ohci->RootHub.status &= ~OHCI_RHS_OCIC;4470 pThis->RootHub.status &= ~OHCI_RHS_OCIC; 4471 4471 4472 4472 /* SetGlobalPower */ … … 4474 4474 { 4475 4475 int i; 4476 Log2(("ohci: %s: global power up\n", p Ohci->PciDev.name));4476 Log2(("ohci: %s: global power up\n", pThis->PciDev.name)); 4477 4477 for (i = 0; i < OHCI_NDP; i++) 4478 rhport_power(&p Ohci->RootHub, i, true /* power up */);4478 rhport_power(&pThis->RootHub, i, true /* power up */); 4479 4479 } 4480 4480 … … 4483 4483 { 4484 4484 int i; 4485 Log2(("ohci: %s: global power down\n", p Ohci->PciDev.name));4485 Log2(("ohci: %s: global power down\n", pThis->PciDev.name)); 4486 4486 for (i = 0; i < OHCI_NDP; i++) 4487 rhport_power(&p Ohci->RootHub, i, false /* power down */);4487 rhport_power(&pThis->RootHub, i, false /* power down */); 4488 4488 } 4489 4489 4490 4490 if ( val & OHCI_RHS_DRWE ) 4491 p Ohci->RootHub.status |= OHCI_RHS_DRWE;4491 pThis->RootHub.status |= OHCI_RHS_DRWE; 4492 4492 4493 4493 if ( val & OHCI_RHS_CRWE ) 4494 p Ohci->RootHub.status &= ~OHCI_RHS_DRWE;4495 4496 chg = p Ohci->RootHub.status ^ old;4494 pThis->RootHub.status &= ~OHCI_RHS_DRWE; 4495 4496 chg = pThis->RootHub.status ^ old; 4497 4497 Log2(("HcRhStatus_w(%#010x) => %sCGP=%d %sOCI=%d %sSRWE=%d %sSGP=%d %sOCIC=%d %sCRWE=%d\n", 4498 4498 val, … … 4512 4512 * Read the HcRhPortStatus register of a port. 4513 4513 */ 4514 static int HcRhPortStatus_r(PCOHCI p Ohci, uint32_t iReg, uint32_t *pu32Value)4514 static int HcRhPortStatus_r(PCOHCI pThis, uint32_t iReg, uint32_t *pu32Value) 4515 4515 { 4516 4516 const unsigned i = iReg - 21; 4517 uint32_t val = p Ohci->RootHub.aPorts[i].fReg | OHCI_PORT_R_POWER_STATUS; /* PortPowerStatus: see todo on power in _w function. */4517 uint32_t val = pThis->RootHub.aPorts[i].fReg | OHCI_PORT_R_POWER_STATUS; /* PortPowerStatus: see todo on power in _w function. */ 4518 4518 if (val & OHCI_PORT_R_RESET_STATUS) 4519 4519 { … … 4540 4540 static DECLCALLBACK(void) uchi_port_reset_done(PVUSBIDEVICE pDev, int rc, void *pvUser) 4541 4541 { 4542 POHCI p Ohci= (POHCI)pvUser;4542 POHCI pThis = (POHCI)pvUser; 4543 4543 4544 4544 /* … … 4547 4547 POHCIHUBPORT pPort = NULL; 4548 4548 unsigned iPort; 4549 for (iPort = 0; iPort < RT_ELEMENTS(p Ohci->RootHub.aPorts); iPort++) /* lazy bird */4550 if (p Ohci->RootHub.aPorts[iPort].pDev == pDev)4549 for (iPort = 0; iPort < RT_ELEMENTS(pThis->RootHub.aPorts); iPort++) /* lazy bird */ 4550 if (pThis->RootHub.aPorts[iPort].pDev == pDev) 4551 4551 { 4552 pPort = &p Ohci->RootHub.aPorts[iPort];4552 pPort = &pThis->RootHub.aPorts[iPort]; 4553 4553 break; 4554 4554 } … … 4593 4593 4594 4594 /* Raise roothub status change interrupt. */ 4595 ohciSetInterrupt(p Ohci, OHCI_INTR_ROOT_HUB_STATUS_CHANGE);4595 ohciSetInterrupt(pThis, OHCI_INTR_ROOT_HUB_STATUS_CHANGE); 4596 4596 } 4597 4597 … … 4633 4633 * Write to the HcRhPortStatus register of a port. 4634 4634 */ 4635 static int HcRhPortStatus_w(POHCI p Ohci, uint32_t iReg, uint32_t val)4635 static int HcRhPortStatus_w(POHCI pThis, uint32_t iReg, uint32_t val) 4636 4636 { 4637 4637 #ifdef IN_RING3 4638 4638 const unsigned i = iReg - 21; 4639 POHCIHUBPORT p = &p Ohci->RootHub.aPorts[i];4639 POHCIHUBPORT p = &pThis->RootHub.aPorts[i]; 4640 4640 uint32_t old_state = p->fReg; 4641 4641 … … 4672 4672 } 4673 4673 4674 if (rhport_set_if_connected(&p Ohci->RootHub, i, val & OHCI_PORT_W_SET_ENABLE))4674 if (rhport_set_if_connected(&pThis->RootHub, i, val & OHCI_PORT_W_SET_ENABLE)) 4675 4675 Log2(("HcRhPortStatus_w(): port %u: ENABLE\n", i)); 4676 4676 4677 if (rhport_set_if_connected(&p Ohci->RootHub, i, val & OHCI_PORT_W_SET_SUSPEND))4677 if (rhport_set_if_connected(&pThis->RootHub, i, val & OHCI_PORT_W_SET_SUSPEND)) 4678 4678 Log2(("HcRhPortStatus_w(): port %u: SUSPEND - not implemented correctly!!!\n", i)); 4679 4679 4680 4680 if (val & OHCI_PORT_W_SET_RESET) 4681 4681 { 4682 if (rhport_set_if_connected(&p Ohci->RootHub, i, val & OHCI_PORT_W_SET_RESET))4682 if (rhport_set_if_connected(&pThis->RootHub, i, val & OHCI_PORT_W_SET_RESET)) 4683 4683 { 4684 PVM pVM = PDMDevHlpGetVM(p Ohci->CTX_SUFF(pDevIns));4684 PVM pVM = PDMDevHlpGetVM(pThis->CTX_SUFF(pDevIns)); 4685 4685 p->fReg &= ~OHCI_PORT_R_RESET_STATUS_CHANGE; 4686 VUSBIDevReset(p->pDev, false /* don't reset on linux */, uchi_port_reset_done, p Ohci, pVM);4686 VUSBIDevReset(p->pDev, false /* don't reset on linux */, uchi_port_reset_done, pThis, pVM); 4687 4687 } 4688 4688 else if (p->fReg & OHCI_PORT_R_RESET_STATUS) … … 4694 4694 } 4695 4695 4696 if (!(p Ohci->RootHub.desc_a & OHCI_RHA_NPS))4696 if (!(pThis->RootHub.desc_a & OHCI_RHA_NPS)) 4697 4697 { 4698 4698 /** @todo To implement per-device power-switching … … 4701 4701 */ 4702 4702 if (val & OHCI_PORT_W_CLEAR_POWER) 4703 rhport_power(&p Ohci->RootHub, i, false /* power down */);4703 rhport_power(&pThis->RootHub, i, false /* power down */); 4704 4704 if (val & OHCI_PORT_W_SET_POWER) 4705 rhport_power(&p Ohci->RootHub, i, true /* power up */);4705 rhport_power(&pThis->RootHub, i, true /* power up */); 4706 4706 } 4707 4707 … … 4709 4709 if (val & OHCI_PORT_W_CLEAR_SUSPEND_STATUS) 4710 4710 { 4711 rhport_power(&p Ohci->RootHub, i, true /* power up */);4712 p Ohci->RootHub.aPorts[i].fReg &= ~OHCI_PORT_R_SUSPEND_STATUS;4713 p Ohci->RootHub.aPorts[i].fReg |= OHCI_PORT_R_SUSPEND_STATUS_CHANGE;4714 ohciSetInterrupt(p Ohci, OHCI_INTR_ROOT_HUB_STATUS_CHANGE);4711 rhport_power(&pThis->RootHub, i, true /* power up */); 4712 pThis->RootHub.aPorts[i].fReg &= ~OHCI_PORT_R_SUSPEND_STATUS; 4713 pThis->RootHub.aPorts[i].fReg |= OHCI_PORT_R_SUSPEND_STATUS_CHANGE; 4714 ohciSetInterrupt(pThis, OHCI_INTR_ROOT_HUB_STATUS_CHANGE); 4715 4715 } 4716 4716 … … 4786 4786 PDMBOTHCBDECL(int) ohciMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 4787 4787 { 4788 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);4788 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 4789 4789 4790 4790 /* Paranoia: Assert that IOMMMIO_FLAGS_READ_DWORD works. */ … … 4796 4796 */ 4797 4797 int rc; 4798 const uint32_t iReg = (GCPhysAddr - p Ohci->MMIOBase) >> 2;4798 const uint32_t iReg = (GCPhysAddr - pThis->MMIOBase) >> 2; 4799 4799 if (iReg < RT_ELEMENTS(g_aOpRegs)) 4800 4800 { 4801 4801 const OHCIOPREG *pReg = &g_aOpRegs[iReg]; 4802 rc = pReg->pfnRead(p Ohci, iReg, (uint32_t *)pv);4802 rc = pReg->pfnRead(pThis, iReg, (uint32_t *)pv); 4803 4803 } 4804 4804 else … … 4816 4816 PDMBOTHCBDECL(int) ohciMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 4817 4817 { 4818 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);4818 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 4819 4819 4820 4820 /* Paranoia: Assert that IOMMMIO_FLAGS_WRITE_DWORD_ZEROED works. */ … … 4826 4826 */ 4827 4827 int rc; 4828 const uint32_t iReg = (GCPhysAddr - p Ohci->MMIOBase) >> 2;4828 const uint32_t iReg = (GCPhysAddr - pThis->MMIOBase) >> 2; 4829 4829 if (iReg < RT_ELEMENTS(g_aOpRegs)) 4830 4830 { 4831 4831 const OHCIOPREG *pReg = &g_aOpRegs[iReg]; 4832 rc = pReg->pfnWrite(p Ohci, iReg, *(uint32_t const *)pv);4832 rc = pReg->pfnWrite(pThis, iReg, *(uint32_t const *)pv); 4833 4833 } 4834 4834 else … … 4847 4847 static DECLCALLBACK(int) ohciR3Map(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType) 4848 4848 { 4849 POHCI p Ohci= (POHCI)pPciDev;4850 int rc = PDMDevHlpMMIORegister(p Ohci->CTX_SUFF(pDevIns), GCPhysAddress, cb, NULL /*pvUser*/,4849 POHCI pThis = (POHCI)pPciDev; 4850 int rc = PDMDevHlpMMIORegister(pThis->CTX_SUFF(pDevIns), GCPhysAddress, cb, NULL /*pvUser*/, 4851 4851 IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_DWORD_ZEROED 4852 4852 | IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_WRITE, … … 4855 4855 return rc; 4856 4856 4857 if (p Ohci->fRZEnabled)4858 { 4859 rc = PDMDevHlpMMIORegisterRC(p Ohci->CTX_SUFF(pDevIns), GCPhysAddress, cb,4857 if (pThis->fRZEnabled) 4858 { 4859 rc = PDMDevHlpMMIORegisterRC(pThis->CTX_SUFF(pDevIns), GCPhysAddress, cb, 4860 4860 NIL_RTRCPTR /*pvUser*/, "ohciMmioWrite", "ohciMmioRead"); 4861 4861 if (RT_FAILURE(rc)) 4862 4862 return rc; 4863 4863 4864 rc = PDMDevHlpMMIORegisterR0(p Ohci->CTX_SUFF(pDevIns), GCPhysAddress, cb,4864 rc = PDMDevHlpMMIORegisterR0(pThis->CTX_SUFF(pDevIns), GCPhysAddress, cb, 4865 4865 NIL_RTR0PTR /*pvUser*/, "ohciMmioWrite", "ohciMmioRead"); 4866 4866 if (RT_FAILURE(rc)) … … 4868 4868 } 4869 4869 4870 p Ohci->MMIOBase = GCPhysAddress;4870 pThis->MMIOBase = GCPhysAddress; 4871 4871 return VINF_SUCCESS; 4872 4872 } … … 4883 4883 static DECLCALLBACK(int) ohciR3SavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4884 4884 { 4885 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);4886 POHCIROOTHUB pRh = &p Ohci->RootHub;4885 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 4886 POHCIROOTHUB pRh = &pThis->RootHub; 4887 4887 LogFlow(("ohciR3SavePrep: \n")); 4888 4888 … … 4890 4890 * Detach all proxied devices. 4891 4891 */ 4892 PDMCritSectEnter(p Ohci->pDevInsR3->pCritSectRoR3, VERR_IGNORED);4892 PDMCritSectEnter(pThis->pDevInsR3->pCritSectRoR3, VERR_IGNORED); 4893 4893 /** @todo we a) can't tell which are proxied, and b) this won't work well when continuing after saving! */ 4894 4894 for (unsigned i = 0; i < RT_ELEMENTS(pRh->aPorts); i++) … … 4906 4906 } 4907 4907 } 4908 PDMCritSectLeave(p Ohci->pDevInsR3->pCritSectRoR3);4908 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); 4909 4909 4910 4910 /* 4911 4911 * Kill old load data which might be hanging around. 4912 4912 */ 4913 if (p Ohci->pLoad)4914 { 4915 TMR3TimerDestroy(p Ohci->pLoad->pTimer);4916 MMR3HeapFree(p Ohci->pLoad);4917 p Ohci->pLoad = NULL;4913 if (pThis->pLoad) 4914 { 4915 TMR3TimerDestroy(pThis->pLoad->pTimer); 4916 MMR3HeapFree(pThis->pLoad); 4917 pThis->pLoad = NULL; 4918 4918 } 4919 4919 return VINF_SUCCESS; … … 4930 4930 static DECLCALLBACK(int) ohciR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4931 4931 { 4932 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);4932 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 4933 4933 LogFlow(("ohciR3SaveExec: \n")); 4934 4934 4935 int rc = SSMR3PutStructEx(pSSM, p Ohci, sizeof(*pOhci), 0 /*fFlags*/, &g_aOhciFields[0], NULL);4935 int rc = SSMR3PutStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aOhciFields[0], NULL); 4936 4936 if (RT_SUCCESS(rc)) 4937 rc = TMR3TimerSave(p Ohci->CTX_SUFF(pEndOfFrameTimer), pSSM);4937 rc = TMR3TimerSave(pThis->CTX_SUFF(pEndOfFrameTimer), pSSM); 4938 4938 return rc; 4939 4939 } … … 4949 4949 static DECLCALLBACK(int) ohciR3SaveDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4950 4950 { 4951 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);4952 POHCIROOTHUB pRh = &p Ohci->RootHub;4951 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 4952 POHCIROOTHUB pRh = &pThis->RootHub; 4953 4953 OHCIROOTHUB Rh; 4954 4954 unsigned i; … … 4989 4989 { 4990 4990 int rc = VINF_SUCCESS; 4991 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);4991 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 4992 4992 LogFlow(("ohciR3LoadPrep:\n")); 4993 if (!p Ohci->pLoad)4994 { 4995 POHCIROOTHUB pRh = &p Ohci->RootHub;4993 if (!pThis->pLoad) 4994 { 4995 POHCIROOTHUB pRh = &pThis->RootHub; 4996 4996 OHCILOAD Load; 4997 4997 unsigned i; … … 5019 5019 if (Load.cDevs) 5020 5020 { 5021 p Ohci->pLoad = (POHCILOAD)PDMDevHlpMMHeapAlloc(pDevIns, sizeof(Load));5022 if (!p Ohci->pLoad)5021 pThis->pLoad = (POHCILOAD)PDMDevHlpMMHeapAlloc(pDevIns, sizeof(Load)); 5022 if (!pThis->pLoad) 5023 5023 return VERR_NO_MEMORY; 5024 *p Ohci->pLoad = Load;5024 *pThis->pLoad = Load; 5025 5025 } 5026 5026 } … … 5042 5042 static DECLCALLBACK(int) ohciR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 5043 5043 { 5044 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);5044 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5045 5045 int rc; 5046 5046 LogFlow(("ohciR3LoadExec:\n")); … … 5049 5049 if (uVersion == OHCI_SAVED_STATE_VERSION) 5050 5050 { 5051 rc = SSMR3GetStructEx(pSSM, p Ohci, sizeof(*pOhci), 0 /*fFlags*/, &g_aOhciFields[0], NULL);5051 rc = SSMR3GetStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aOhciFields[0], NULL); 5052 5052 if (RT_FAILURE(rc)) 5053 5053 return rc; … … 5115 5115 SSMFIELD_ENTRY_OLD_PAD_HC64( RootHub.aPorts[7].Alignment0, 4), 5116 5116 SSMFIELD_ENTRY_OLD_HCPTR( RootHub.aPorts[7].pDev), 5117 SSMFIELD_ENTRY_OLD_HCPTR( RootHub.p Ohci),5117 SSMFIELD_ENTRY_OLD_HCPTR( RootHub.pThis), 5118 5118 SSMFIELD_ENTRY( OHCI, ctl), 5119 5119 SSMFIELD_ENTRY( OHCI, status), … … 5149 5149 5150 5150 /* deserialize the struct */ 5151 rc = SSMR3GetStructEx(pSSM, p Ohci, sizeof(*pOhci), SSMSTRUCT_FLAGS_NO_MARKERS /*fFlags*/, &s_aOhciFields22[0], NULL);5151 rc = SSMR3GetStructEx(pSSM, pThis, sizeof(*pThis), SSMSTRUCT_FLAGS_NO_MARKERS /*fFlags*/, &s_aOhciFields22[0], NULL); 5152 5152 if (RT_FAILURE(rc)) 5153 5153 return rc; … … 5166 5166 * Finally restore the timer. 5167 5167 */ 5168 return TMR3TimerLoad(p Ohci->pEndOfFrameTimerR3, pSSM);5168 return TMR3TimerLoad(pThis->pEndOfFrameTimerR3, pSSM); 5169 5169 } 5170 5170 … … 5179 5179 static DECLCALLBACK(int) ohciR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 5180 5180 { 5181 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);5181 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5182 5182 LogFlow(("ohciR3LoadDone:\n")); 5183 5183 … … 5185 5185 * Start a timer if we've got devices to reattach 5186 5186 */ 5187 if (p Ohci->pLoad)5188 { 5189 int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ohciR3LoadReattachDevices, p Ohci,5187 if (pThis->pLoad) 5188 { 5189 int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ohciR3LoadReattachDevices, pThis, 5190 5190 TMTIMER_FLAGS_NO_CRIT_SECT, "OHCI reattach devices on load", 5191 &p Ohci->pLoad->pTimer);5191 &pThis->pLoad->pTimer); 5192 5192 if (RT_SUCCESS(rc)) 5193 rc = TMTimerSetMillies(p Ohci->pLoad->pTimer, 250);5193 rc = TMTimerSetMillies(pThis->pLoad->pTimer, 250); 5194 5194 return rc; 5195 5195 } … … 5204 5204 static DECLCALLBACK(void) ohciR3LoadReattachDevices(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 5205 5205 { 5206 POHCI p Ohci= (POHCI)pvUser;5207 POHCILOAD pLoad = p Ohci->pLoad;5208 POHCIROOTHUB pRh = &p Ohci->RootHub;5206 POHCI pThis = (POHCI)pvUser; 5207 POHCILOAD pLoad = pThis->pLoad; 5208 POHCIROOTHUB pRh = &pThis->RootHub; 5209 5209 LogFlow(("ohciR3LoadReattachDevices:\n")); 5210 5210 … … 5220 5220 TMR3TimerDestroy(pTimer); 5221 5221 MMR3HeapFree(pLoad); 5222 p Ohci->pLoad = NULL;5222 pThis->pLoad = NULL; 5223 5223 } 5224 5224 … … 5232 5232 static DECLCALLBACK(void) ohciR3Reset(PPDMDEVINS pDevIns) 5233 5233 { 5234 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);5234 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5235 5235 LogFlow(("ohciR3Reset:\n")); 5236 5236 … … 5243 5243 * just one way of getting into the UsbReset state. 5244 5244 */ 5245 ohciBusStop(p Ohci);5246 ohciDoReset(p Ohci, OHCI_USB_RESET, true /* reset devices */);5245 ohciBusStop(pThis); 5246 ohciDoReset(pThis, OHCI_USB_RESET, true /* reset devices */); 5247 5247 } 5248 5248 … … 5257 5257 static DECLCALLBACK(void) ohciR3InfoRegs(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 5258 5258 { 5259 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);5259 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5260 5260 uint32_t val, ctl, status; 5261 5261 5262 5262 /* Control register */ 5263 ctl = p Ohci->ctl;5263 ctl = pThis->ctl; 5264 5264 pHlp->pfnPrintf(pHlp, "HcControl: %08x - CBSR=%d PLE=%d IE=%d CLE=%d BLE=%d HCFS=%#x IR=%d RWC=%d RWE=%d\n", 5265 5265 ctl, ctl & 3, (ctl >> 2) & 1, (ctl >> 3) & 1, (ctl >> 4) & 1, (ctl >> 5) & 1, (ctl >> 6) & 3, (ctl >> 8) & 1, … … 5267 5267 5268 5268 /* Command status register */ 5269 status = p Ohci->status;5269 status = pThis->status; 5270 5270 pHlp->pfnPrintf(pHlp, "HcCommandStatus: %08x - HCR=%d CLF=%d BLF=%d OCR=%d SOC=%d\n", 5271 5271 status, status & 1, (status >> 1) & 1, (status >> 2) & 1, (status >> 3) & 1, (status >> 16) & 3); 5272 5272 5273 5273 /* Interrupt status register */ 5274 val = p Ohci->intr_status;5274 val = pThis->intr_status; 5275 5275 pHlp->pfnPrintf(pHlp, "HcInterruptStatus: %08x - SO=%d WDH=%d SF=%d RD=%d UE=%d FNO=%d RHSC=%d OC=%d\n", 5276 5276 val, val & 1, (val >> 1) & 1, (val >> 2) & 1, (val >> 3) & 1, (val >> 4) & 1, (val >> 5) & 1, … … 5278 5278 5279 5279 /* Interrupt enable register */ 5280 val = p Ohci->intr;5280 val = pThis->intr; 5281 5281 pHlp->pfnPrintf(pHlp, "HcInterruptEnable: %08x - SO=%d WDH=%d SF=%d RD=%d UE=%d FNO=%d RHSC=%d OC=%d MIE=%d\n", 5282 5282 val, val & 1, (val >> 1) & 1, (val >> 2) & 1, (val >> 3) & 1, (val >> 4) & 1, (val >> 5) & 1, … … 5284 5284 5285 5285 /* HCCA address register */ 5286 pHlp->pfnPrintf(pHlp, "HcHCCA: %08x\n", p Ohci->hcca);5286 pHlp->pfnPrintf(pHlp, "HcHCCA: %08x\n", pThis->hcca); 5287 5287 5288 5288 /* Current periodic ED register */ 5289 pHlp->pfnPrintf(pHlp, "HcPeriodCurrentED: %08x\n", p Ohci->per_cur);5289 pHlp->pfnPrintf(pHlp, "HcPeriodCurrentED: %08x\n", pThis->per_cur); 5290 5290 5291 5291 /* Control ED registers */ 5292 pHlp->pfnPrintf(pHlp, "HcControlHeadED: %08x\n", p Ohci->ctrl_head);5293 pHlp->pfnPrintf(pHlp, "HcControlCurrentED: %08x\n", p Ohci->ctrl_cur);5292 pHlp->pfnPrintf(pHlp, "HcControlHeadED: %08x\n", pThis->ctrl_head); 5293 pHlp->pfnPrintf(pHlp, "HcControlCurrentED: %08x\n", pThis->ctrl_cur); 5294 5294 5295 5295 /* Bulk ED registers */ 5296 pHlp->pfnPrintf(pHlp, "HcBulkHeadED: %08x\n", p Ohci->bulk_head);5297 pHlp->pfnPrintf(pHlp, "HcBulkCurrentED: %08x\n", p Ohci->bulk_cur);5296 pHlp->pfnPrintf(pHlp, "HcBulkHeadED: %08x\n", pThis->bulk_head); 5297 pHlp->pfnPrintf(pHlp, "HcBulkCurrentED: %08x\n", pThis->bulk_cur); 5298 5298 5299 5299 /* Done head register */ 5300 pHlp->pfnPrintf(pHlp, "HcDoneHead: %08x\n", p Ohci->done);5300 pHlp->pfnPrintf(pHlp, "HcDoneHead: %08x\n", pThis->done); 5301 5301 5302 5302 pHlp->pfnPrintf(pHlp, "\n"); … … 5313 5313 static DECLCALLBACK(void) ohciR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 5314 5314 { 5315 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);5316 p Ohci->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);5317 p Ohci->pEndOfFrameTimerRC = TMTimerRCPtr(pOhci->pEndOfFrameTimerR3);5315 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5316 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 5317 pThis->pEndOfFrameTimerRC = TMTimerRCPtr(pThis->pEndOfFrameTimerR3); 5318 5318 } 5319 5319 … … 5345 5345 static DECLCALLBACK(int) ohciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 5346 5346 { 5347 POHCI p Ohci= PDMINS_2_DATA(pDevIns, POHCI);5347 POHCI pThis = PDMINS_2_DATA(pDevIns, POHCI); 5348 5348 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 5349 5349 … … 5351 5351 * Init instance data. 5352 5352 */ 5353 p Ohci->pDevInsR3 = pDevIns;5354 p Ohci->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);5355 p Ohci->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);5356 5357 PCIDevSetVendorId (&p Ohci->PciDev, 0x106b);5358 PCIDevSetDeviceId (&p Ohci->PciDev, 0x003f);5359 PCIDevSetClassProg (&p Ohci->PciDev, 0x10); /* OHCI */5360 PCIDevSetClassSub (&p Ohci->PciDev, 0x03);5361 PCIDevSetClassBase (&p Ohci->PciDev, 0x0c);5362 PCIDevSetInterruptPin (&p Ohci->PciDev, 0x01);5353 pThis->pDevInsR3 = pDevIns; 5354 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 5355 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 5356 5357 PCIDevSetVendorId (&pThis->PciDev, 0x106b); 5358 PCIDevSetDeviceId (&pThis->PciDev, 0x003f); 5359 PCIDevSetClassProg (&pThis->PciDev, 0x10); /* OHCI */ 5360 PCIDevSetClassSub (&pThis->PciDev, 0x03); 5361 PCIDevSetClassBase (&pThis->PciDev, 0x0c); 5362 PCIDevSetInterruptPin (&pThis->PciDev, 0x01); 5363 5363 #ifdef VBOX_WITH_MSI_DEVICES 5364 PCIDevSetStatus (&p Ohci->PciDev, VBOX_PCI_STATUS_CAP_LIST);5365 PCIDevSetCapabilityList(&p Ohci->PciDev, 0x80);5364 PCIDevSetStatus (&pThis->PciDev, VBOX_PCI_STATUS_CAP_LIST); 5365 PCIDevSetCapabilityList(&pThis->PciDev, 0x80); 5366 5366 #endif 5367 5367 5368 p Ohci->RootHub.pOhci = pOhci;5369 p Ohci->RootHub.IBase.pfnQueryInterface = ohciRhQueryInterface;5370 p Ohci->RootHub.IRhPort.pfnGetAvailablePorts = ohciRhGetAvailablePorts;5371 p Ohci->RootHub.IRhPort.pfnGetUSBVersions = ohciRhGetUSBVersions;5372 p Ohci->RootHub.IRhPort.pfnAttach = ohciRhAttach;5373 p Ohci->RootHub.IRhPort.pfnDetach = ohciRhDetach;5374 p Ohci->RootHub.IRhPort.pfnReset = ohciRhReset;5375 p Ohci->RootHub.IRhPort.pfnXferCompletion = ohciRhXferCompletion;5376 p Ohci->RootHub.IRhPort.pfnXferError = ohciRhXferError;5368 pThis->RootHub.pOhci = pThis; 5369 pThis->RootHub.IBase.pfnQueryInterface = ohciRhQueryInterface; 5370 pThis->RootHub.IRhPort.pfnGetAvailablePorts = ohciRhGetAvailablePorts; 5371 pThis->RootHub.IRhPort.pfnGetUSBVersions = ohciRhGetUSBVersions; 5372 pThis->RootHub.IRhPort.pfnAttach = ohciRhAttach; 5373 pThis->RootHub.IRhPort.pfnDetach = ohciRhDetach; 5374 pThis->RootHub.IRhPort.pfnReset = ohciRhReset; 5375 pThis->RootHub.IRhPort.pfnXferCompletion = ohciRhXferCompletion; 5376 pThis->RootHub.IRhPort.pfnXferError = ohciRhXferError; 5377 5377 5378 5378 /* USB LED */ 5379 p Ohci->RootHub.Led.u32Magic = PDMLED_MAGIC;5380 p Ohci->RootHub.ILeds.pfnQueryStatusLed = ohciRhQueryStatusLed;5379 pThis->RootHub.Led.u32Magic = PDMLED_MAGIC; 5380 pThis->RootHub.ILeds.pfnQueryStatusLed = ohciRhQueryStatusLed; 5381 5381 5382 5382 … … 5385 5385 */ 5386 5386 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "RZEnabled", ""); 5387 int rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &p Ohci->fRZEnabled, true);5387 int rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true); 5388 5388 AssertLogRelRCReturn(rc, rc); 5389 5389 … … 5392 5392 * Register PCI device and I/O region. 5393 5393 */ 5394 rc = PDMDevHlpPCIRegister(pDevIns, &p Ohci->PciDev);5394 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev); 5395 5395 if (RT_FAILURE(rc)) 5396 5396 return rc; … … 5405 5405 if (RT_FAILURE(rc)) 5406 5406 { 5407 PCIDevSetCapabilityList(&p Ohci->PciDev, 0x0);5407 PCIDevSetCapabilityList(&pThis->PciDev, 0x0); 5408 5408 /* That's OK, we can work without MSI */ 5409 5409 } … … 5417 5417 * Create the end-of-frame timer. 5418 5418 */ 5419 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ohciFrameBoundaryTimer, p Ohci,5419 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ohciFrameBoundaryTimer, pThis, 5420 5420 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "USB Frame Timer", 5421 &p Ohci->pEndOfFrameTimerR3);5421 &pThis->pEndOfFrameTimerR3); 5422 5422 if (RT_FAILURE(rc)) 5423 5423 return rc; 5424 p Ohci->pEndOfFrameTimerR0 = TMTimerR0Ptr(pOhci->pEndOfFrameTimerR3);5425 p Ohci->pEndOfFrameTimerRC = TMTimerRCPtr(pOhci->pEndOfFrameTimerR3);5424 pThis->pEndOfFrameTimerR0 = TMTimerR0Ptr(pThis->pEndOfFrameTimerR3); 5425 pThis->pEndOfFrameTimerRC = TMTimerRCPtr(pThis->pEndOfFrameTimerR3); 5426 5426 5427 5427 /* 5428 5428 * Register the saved state data unit. 5429 5429 */ 5430 rc = PDMDevHlpSSMRegisterEx(pDevIns, OHCI_SAVED_STATE_VERSION, sizeof(*p Ohci), NULL,5430 rc = PDMDevHlpSSMRegisterEx(pDevIns, OHCI_SAVED_STATE_VERSION, sizeof(*pThis), NULL, 5431 5431 NULL, NULL, NULL, 5432 5432 ohciR3SavePrep, ohciR3SaveExec, ohciR3SaveDone, … … 5438 5438 * Attach to the VBox USB RootHub Driver on LUN #0. 5439 5439 */ 5440 rc = PDMDevHlpDriverAttach(pDevIns, 0, &p Ohci->RootHub.IBase, &pOhci->RootHub.pIBase, "RootHub");5440 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->RootHub.IBase, &pThis->RootHub.pIBase, "RootHub"); 5441 5441 if (RT_FAILURE(rc)) 5442 5442 { … … 5444 5444 return rc; 5445 5445 } 5446 p Ohci->RootHub.pIRhConn = PDMIBASE_QUERY_INTERFACE(pOhci->RootHub.pIBase, VUSBIROOTHUBCONNECTOR);5447 AssertMsgReturn(p Ohci->RootHub.pIRhConn,5446 pThis->RootHub.pIRhConn = PDMIBASE_QUERY_INTERFACE(pThis->RootHub.pIBase, VUSBIROOTHUBCONNECTOR); 5447 AssertMsgReturn(pThis->RootHub.pIRhConn, 5448 5448 ("Configuration error: The driver doesn't provide the VUSBIROOTHUBCONNECTOR interface!\n"), 5449 5449 VERR_PDM_MISSING_INTERFACE); 5450 p Ohci->RootHub.pIDev = PDMIBASE_QUERY_INTERFACE(pOhci->RootHub.pIBase, VUSBIDEVICE);5451 AssertMsgReturn(p Ohci->RootHub.pIDev,5450 pThis->RootHub.pIDev = PDMIBASE_QUERY_INTERFACE(pThis->RootHub.pIBase, VUSBIDEVICE); 5451 AssertMsgReturn(pThis->RootHub.pIDev, 5452 5452 ("Configuration error: The driver doesn't provide the VUSBIDEVICE interface!\n"), 5453 5453 VERR_PDM_MISSING_INTERFACE); … … 5457 5457 */ 5458 5458 PPDMIBASE pBase; 5459 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &p Ohci->RootHub.IBase, &pBase, "Status Port");5459 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->RootHub.IBase, &pBase, "Status Port"); 5460 5460 if (RT_SUCCESS(rc)) 5461 p Ohci->RootHub.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);5461 pThis->RootHub.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS); 5462 5462 else if (rc != VERR_PDM_NO_ATTACHED_DRIVER) 5463 5463 { … … 5470 5470 * This assumes that the VM timer doesn't change frequency during the run. 5471 5471 */ 5472 p Ohci->u64TimerHz = TMTimerGetFreq(pOhci->CTX_SUFF(pEndOfFrameTimer));5473 ohciCalcTimerIntervals(p Ohci, OHCI_DEFAULT_TIMER_FREQ);5472 pThis->u64TimerHz = TMTimerGetFreq(pThis->CTX_SUFF(pEndOfFrameTimer)); 5473 ohciCalcTimerIntervals(pThis, OHCI_DEFAULT_TIMER_FREQ); 5474 5474 Log(("ohci: cTicksPerFrame=%RU64 cTicksPerUsbTick=%RU64\n", 5475 p Ohci->cTicksPerFrame, pOhci->cTicksPerUsbTick));5475 pThis->cTicksPerFrame, pThis->cTicksPerUsbTick)); 5476 5476 5477 5477 /* 5478 5478 * Do a hardware reset. 5479 5479 */ 5480 ohciDoReset(p Ohci, OHCI_USB_RESET, false /* don't reset devices */);5480 ohciDoReset(pThis, OHCI_USB_RESET, false /* don't reset devices */); 5481 5481 5482 5482 #ifdef VBOX_WITH_STATISTICS … … 5484 5484 * Register statistics. 5485 5485 */ 5486 PDMDevHlpSTAMRegister(pDevIns, &p Ohci->StatCanceledIsocUrbs, STAMTYPE_COUNTER, "/Devices/OHCI/CanceledIsocUrbs", STAMUNIT_OCCURENCES, "Detected canceled isochronous URBs.");5487 PDMDevHlpSTAMRegister(pDevIns, &p Ohci->StatCanceledGenUrbs, STAMTYPE_COUNTER, "/Devices/OHCI/CanceledGenUrbs", STAMUNIT_OCCURENCES, "Detected canceled general URBs.");5488 PDMDevHlpSTAMRegister(pDevIns, &p Ohci->StatDroppedUrbs, STAMTYPE_COUNTER, "/Devices/OHCI/DroppedUrbs", STAMUNIT_OCCURENCES, "Dropped URBs (endpoint halted, or URB canceled).");5489 PDMDevHlpSTAMRegister(pDevIns, &p Ohci->StatTimer, STAMTYPE_PROFILE, "/Devices/OHCI/Timer", STAMUNIT_TICKS_PER_CALL, "Profiling ohciFrameBoundaryTimer.");5486 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCanceledIsocUrbs, STAMTYPE_COUNTER, "/Devices/OHCI/CanceledIsocUrbs", STAMUNIT_OCCURENCES, "Detected canceled isochronous URBs."); 5487 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCanceledGenUrbs, STAMTYPE_COUNTER, "/Devices/OHCI/CanceledGenUrbs", STAMUNIT_OCCURENCES, "Detected canceled general URBs."); 5488 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatDroppedUrbs, STAMTYPE_COUNTER, "/Devices/OHCI/DroppedUrbs", STAMUNIT_OCCURENCES, "Dropped URBs (endpoint halted, or URB canceled)."); 5489 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatTimer, STAMTYPE_PROFILE, "/Devices/OHCI/Timer", STAMUNIT_TICKS_PER_CALL, "Profiling ohciFrameBoundaryTimer."); 5490 5490 #endif 5491 5491
Note:
See TracChangeset
for help on using the changeset viewer.