Changeset 69947 in vbox
- Timestamp:
- Dec 6, 2017 9:49:46 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DevOHCI.cpp
r69944 r69947 683 683 /** CCS - CurrentConnectionStatus - 0 = no device, 1 = device. */ 684 684 #define OHCI_PORT_CCS RT_BIT(0) 685 /** ClearPortEnable (when writing CCS). */ 686 #define OHCI_PORT_CLRPE OHCI_PORT_CCS 685 687 /** PES - PortEnableStatus. */ 686 688 #define OHCI_PORT_PES RT_BIT(1) … … 689 691 /** POCI- PortOverCurrentIndicator. */ 690 692 #define OHCI_PORT_POCI RT_BIT(3) 693 /** ClearSuspendStatus (when writing POCI). */ 694 #define OHCI_PORT_CLRSS OHCI_PORT_POCI 691 695 /** PRS - PortResetStatus */ 692 696 #define OHCI_PORT_PRS RT_BIT(4) … … 695 699 /** LSDA - LowSpeedDeviceAttached */ 696 700 #define OHCI_PORT_LSDA RT_BIT(9) 701 /** ClearPortPower (when writing LSDA). */ 702 #define OHCI_PORT_CLRPP OHCI_PORT_LSDA 697 703 /** CSC - ConnectStatusChange */ 698 704 #define OHCI_PORT_CSC RT_BIT(16) … … 705 711 /** PRSC - PortResetStatusChange */ 706 712 #define OHCI_PORT_PRSC RT_BIT(20) 707 /** @} */ 708 709 710 /** @name HcRhPortStatus[n] - Root Hub Port Status Registers - read. 711 * @{ */ 712 /** CCS - CurrentConnectStatus - 0 = no device, 1 = device. */ 713 #define OHCI_PORT_R_CURRENT_CONNECT_STATUS RT_BIT(0) 714 /** PES - PortEnableStatus. */ 715 #define OHCI_PORT_R_ENABLE_STATUS RT_BIT(1) 716 /** PSS - PortSuspendStatus */ 717 #define OHCI_PORT_R_SUSPEND_STATUS RT_BIT(2) 718 /** POCI- PortOverCurrentIndicator. */ 719 #define OHCI_PORT_R_OVER_CURRENT_INDICATOR RT_BIT(3) 720 /** PRS - PortResetStatus */ 721 #define OHCI_PORT_R_RESET_STATUS RT_BIT(4) 722 /** PPS - PortPowerStatus */ 723 #define OHCI_PORT_R_POWER_STATUS RT_BIT(8) 724 /** LSDA - LowSpeedDeviceAttached */ 725 #define OHCI_PORT_R_LOW_SPEED_DEVICE_ATTACHED RT_BIT(9) 726 /** CSC - ConnectStatusChange */ 727 #define OHCI_PORT_R_CONNECT_STATUS_CHANGE RT_BIT(16) 728 /** PESC - PortEnableStatusChange */ 729 #define OHCI_PORT_R_ENABLE_STATUS_CHANGE RT_BIT(17) 730 /** PSSC - PortSuspendStatusChange */ 731 #define OHCI_PORT_R_SUSPEND_STATUS_CHANGE RT_BIT(18) 732 /** OCIC - OverCurrentIndicatorChange */ 733 #define OHCI_PORT_R_OVER_CURRENT_INDICATOR_CHANGE RT_BIT(19) 734 /** PRSC - PortResetStatusChange */ 735 #define OHCI_PORT_R_RESET_STATUS_CHANGE RT_BIT(20) 736 /** @} */ 737 738 /** @name HcRhPortStatus[n] - Root Hub Port Status Registers - write. 739 * @{ */ 740 /** CCS - ClearPortEnable. */ 741 #define OHCI_PORT_W_CLEAR_ENABLE RT_BIT(0) 742 /** PES - SetPortEnable. */ 743 #define OHCI_PORT_W_SET_ENABLE RT_BIT(1) 744 /** PSS - SetPortSuspend */ 745 #define OHCI_PORT_W_SET_SUSPEND RT_BIT(2) 746 /** POCI- ClearSuspendStatus. */ 747 #define OHCI_PORT_W_CLEAR_SUSPEND_STATUS RT_BIT(3) 748 /** PRS - SetPortReset */ 749 #define OHCI_PORT_W_SET_RESET RT_BIT(4) 750 /** PPS - SetPortPower */ 751 #define OHCI_PORT_W_SET_POWER RT_BIT(8) 752 /** LSDA - ClearPortPower */ 753 #define OHCI_PORT_W_CLEAR_POWER RT_BIT(9) 754 /** CSC - ClearConnectStatusChange */ 755 #define OHCI_PORT_W_CLEAR_CSC RT_BIT(16) 756 /** PESC - PortEnableStatusChange */ 757 #define OHCI_PORT_W_CLEAR_PESC RT_BIT(17) 758 /** PSSC - PortSuspendStatusChange */ 759 #define OHCI_PORT_W_CLEAR_PSSC RT_BIT(18) 760 /** OCIC - OverCurrentIndicatorChange */ 761 #define OHCI_PORT_W_CLEAR_OCIC RT_BIT(19) 762 /** PRSC - PortResetStatusChange */ 763 #define OHCI_PORT_W_CLEAR_PRSC RT_BIT(20) 764 /** The mask of bit which are used to clear themselves. */ 765 #define OHCI_PORT_W_CLEAR_CHANGE_MASK ( OHCI_PORT_W_CLEAR_CSC | OHCI_PORT_W_CLEAR_PESC | OHCI_PORT_W_CLEAR_PSSC \ 766 | OHCI_PORT_W_CLEAR_OCIC | OHCI_PORT_W_CLEAR_PRSC) 713 /** The mask of RW1C bits. */ 714 #define OHCI_PORT_CLEAR_CHANGE_MASK (OHCI_PORT_CSC | OHCI_PORT_PESC | OHCI_PORT_PSSC | OHCI_PORT_OCIC | OHCI_PORT_PRSC) 767 715 /** @} */ 768 716 … … 1046 994 * Attach it. 1047 995 */ 1048 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_ R_CURRENT_CONNECT_STATUS | OHCI_PORT_R_CONNECT_STATUS_CHANGE;996 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_CCS | OHCI_PORT_CSC; 1049 997 pThis->RootHub.aPorts[uPort].pDev = pDev; 1050 998 ohciR3RhPortPower(&pThis->RootHub, uPort, 1 /* power on */); … … 1084 1032 pThis->RootHub.aPorts[uPort].pDev = NULL; 1085 1033 if (pThis->RootHub.aPorts[uPort].fReg & OHCI_PORT_PES) 1086 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_ R_CONNECT_STATUS_CHANGE| OHCI_PORT_PESC;1034 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_CSC | OHCI_PORT_PESC; 1087 1035 else 1088 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_ R_CONNECT_STATUS_CHANGE;1036 pThis->RootHub.aPorts[uPort].fReg = OHCI_PORT_CSC; 1089 1037 1090 1038 ohciR3RemoteWakeup(pThis); … … 1151 1099 if (pThis->RootHub.aPorts[iPort].pDev) 1152 1100 { 1153 pThis->RootHub.aPorts[iPort].fReg = OHCI_PORT_ R_CURRENT_CONNECT_STATUS | OHCI_PORT_R_CONNECT_STATUS_CHANGE| OHCI_PORT_PPS;1101 pThis->RootHub.aPorts[iPort].fReg = OHCI_PORT_CCS | OHCI_PORT_CSC | OHCI_PORT_PPS; 1154 1102 if (fResetOnLinux) 1155 1103 { … … 4258 4206 /* power up */ 4259 4207 if (pPort->pDev) 4260 pPort->fReg |= OHCI_PORT_ R_CURRENT_CONNECT_STATUS;4261 if (pPort->fReg & OHCI_PORT_ R_CURRENT_CONNECT_STATUS)4262 pPort->fReg |= OHCI_PORT_ R_POWER_STATUS;4208 pPort->fReg |= OHCI_PORT_CCS; 4209 if (pPort->fReg & OHCI_PORT_CCS) 4210 pPort->fReg |= OHCI_PORT_PPS; 4263 4211 if (pPort->pDev && !fOldPPS) 4264 4212 VUSBIDevPowerOn(pPort->pDev); … … 4267 4215 { 4268 4216 /* power down */ 4269 pPort->fReg &= ~( OHCI_PORT_R_POWER_STATUS 4270 | OHCI_PORT_R_CURRENT_CONNECT_STATUS 4271 | OHCI_PORT_R_SUSPEND_STATUS 4272 | OHCI_PORT_R_RESET_STATUS); 4217 pPort->fReg &= ~(OHCI_PORT_PPS | OHCI_PORT_CCS | OHCI_PORT_PSS | OHCI_PORT_PRS); 4273 4218 if (pPort->pDev && fOldPPS) 4274 4219 VUSBIDevPowerOff(pPort->pDev); … … 5076 5021 { 5077 5022 const unsigned i = iReg - 21; 5078 uint32_t val = pThis->RootHub.aPorts[i].fReg | OHCI_PORT_ R_POWER_STATUS; /* PortPowerStatus: see todo on power in _w function. */5079 if (val & OHCI_PORT_ R_RESET_STATUS)5023 uint32_t val = pThis->RootHub.aPorts[i].fReg | OHCI_PORT_PPS; /* PortPowerStatus: see todo on power in _w function. */ 5024 if (val & OHCI_PORT_PRS) 5080 5025 { 5081 5026 #ifdef IN_RING3 … … 5086 5031 #endif 5087 5032 } 5088 if (val & (OHCI_PORT_ R_RESET_STATUS | OHCI_PORT_CSC | OHCI_PORT_PESC | OHCI_PORT_PSSC | OHCI_PORT_OCIC | OHCI_PORT_PRSC))5033 if (val & (OHCI_PORT_PRS | OHCI_PORT_CLEAR_CHANGE_MASK)) 5089 5034 Log2(("HcRhPortStatus_r(): port %u: -> %#010x - CCS=%d PES=%d PSS=%d POCI=%d RRS=%d PPS=%d LSDA=%d CSC=%d PESC=%d PSSC=%d OCIC=%d PRSC=%d\n", 5090 5035 i, val, val & 1, (val >> 1) & 1, (val >> 2) & 1, (val >> 3) & 1, (val >> 4) & 1, (val >> 8) & 1, (val >> 9) & 1, … … 5126 5071 */ 5127 5072 Log2(("ohciR3PortResetDone: Reset completed.\n")); 5128 pPort->fReg &= ~(OHCI_PORT_ R_RESET_STATUS | OHCI_PORT_R_SUSPEND_STATUS | OHCI_PORT_R_SUSPEND_STATUS_CHANGE);5129 pPort->fReg |= OHCI_PORT_ R_ENABLE_STATUS | OHCI_PORT_R_RESET_STATUS_CHANGE;5073 pPort->fReg &= ~(OHCI_PORT_PRS | OHCI_PORT_PSS | OHCI_PORT_PSSC); 5074 pPort->fReg |= OHCI_PORT_PES | OHCI_PORT_PRSC; 5130 5075 } 5131 5076 else … … 5140 5085 */ 5141 5086 Log2(("ohciR3PortResetDone: The reset failed (rc=%Rrc)!!! Pretending reconnect at the speed of light.\n", rc)); 5142 pPort->fReg = OHCI_PORT_ R_CURRENT_CONNECT_STATUS | OHCI_PORT_R_CONNECT_STATUS_CHANGE;5087 pPort->fReg = OHCI_PORT_CCS | OHCI_PORT_CSC; 5143 5088 } 5144 5089 else … … 5148 5093 */ 5149 5094 Log2(("ohciR3PortResetDone: Disconnected (rc=%Rrc)!!!\n", rc)); 5150 pPort->fReg &= ~(OHCI_PORT_ R_RESET_STATUS | OHCI_PORT_R_SUSPEND_STATUS | OHCI_PORT_R_SUSPEND_STATUS_CHANGE | OHCI_PORT_R_RESET_STATUS_CHANGE);5151 pPort->fReg |= OHCI_PORT_ R_CONNECT_STATUS_CHANGE;5095 pPort->fReg &= ~(OHCI_PORT_PRS | OHCI_PORT_PSS | OHCI_PORT_PSSC | OHCI_PORT_PRSC); 5096 pPort->fReg |= OHCI_PORT_CSC; 5152 5097 } 5153 5098 } … … 5175 5120 * If CurrentConnectStatus is cleared we set ConnectStatusChange. 5176 5121 */ 5177 if (!(pRh->aPorts[iPort].fReg & OHCI_PORT_ R_CURRENT_CONNECT_STATUS))5178 { 5179 pRh->aPorts[iPort].fReg |= OHCI_PORT_ R_CONNECT_STATUS_CHANGE;5122 if (!(pRh->aPorts[iPort].fReg & OHCI_PORT_CCS)) 5123 { 5124 pRh->aPorts[iPort].fReg |= OHCI_PORT_CSC; 5180 5125 ohciR3SetInterrupt(pRh->pOhci, OHCI_INTR_ROOT_HUB_STATUS_CHANGE); 5181 5126 return false; … … 5224 5169 5225 5170 /* Write to clear any of the change bits: CSC, PESC, PSSC, OCIC and PRSC */ 5226 if (val & OHCI_PORT_ W_CLEAR_CHANGE_MASK)5227 p->fReg &= ~(val & OHCI_PORT_ W_CLEAR_CHANGE_MASK);5228 5229 if (val & OHCI_PORT_ W_CLEAR_ENABLE)5230 { 5231 p->fReg &= ~OHCI_PORT_ R_ENABLE_STATUS;5171 if (val & OHCI_PORT_CLEAR_CHANGE_MASK) 5172 p->fReg &= ~(val & OHCI_PORT_CLEAR_CHANGE_MASK); 5173 5174 if (val & OHCI_PORT_CLRPE) 5175 { 5176 p->fReg &= ~OHCI_PORT_PES; 5232 5177 Log2(("HcRhPortStatus_w(): port %u: DISABLE\n", i)); 5233 5178 } 5234 5179 5235 if (ohciR3RhPortSetIfConnected(&pThis->RootHub, i, val & OHCI_PORT_ W_SET_ENABLE))5180 if (ohciR3RhPortSetIfConnected(&pThis->RootHub, i, val & OHCI_PORT_PES)) 5236 5181 Log2(("HcRhPortStatus_w(): port %u: ENABLE\n", i)); 5237 5182 5238 if (ohciR3RhPortSetIfConnected(&pThis->RootHub, i, val & OHCI_PORT_ W_SET_SUSPEND))5183 if (ohciR3RhPortSetIfConnected(&pThis->RootHub, i, val & OHCI_PORT_PSS)) 5239 5184 Log2(("HcRhPortStatus_w(): port %u: SUSPEND - not implemented correctly!!!\n", i)); 5240 5185 5241 if (val & OHCI_PORT_ W_SET_RESET)5242 { 5243 if (ohciR3RhPortSetIfConnected(&pThis->RootHub, i, val & OHCI_PORT_ W_SET_RESET))5186 if (val & OHCI_PORT_PRS) 5187 { 5188 if (ohciR3RhPortSetIfConnected(&pThis->RootHub, i, val & OHCI_PORT_PRS)) 5244 5189 { 5245 5190 PVM pVM = PDMDevHlpGetVM(pThis->CTX_SUFF(pDevIns)); 5246 p->fReg &= ~OHCI_PORT_ R_RESET_STATUS_CHANGE;5191 p->fReg &= ~OHCI_PORT_PRSC; 5247 5192 VUSBIDevReset(p->pDev, false /* don't reset on linux */, ohciR3PortResetDone, pThis, pVM); 5248 5193 } 5249 else if (p->fReg & OHCI_PORT_ R_RESET_STATUS)5194 else if (p->fReg & OHCI_PORT_PRS) 5250 5195 { 5251 5196 /* the guest is getting impatient. */ … … 5261 5206 * sure it isn't gang powered 5262 5207 */ 5263 if (val & OHCI_PORT_ W_CLEAR_POWER)5208 if (val & OHCI_PORT_CLRPP) 5264 5209 ohciR3RhPortPower(&pThis->RootHub, i, false /* power down */); 5265 if (val & OHCI_PORT_ W_SET_POWER)5210 if (val & OHCI_PORT_PPS) 5266 5211 ohciR3RhPortPower(&pThis->RootHub, i, true /* power up */); 5267 5212 } 5268 5213 5269 5214 /** @todo r=frank: ClearSuspendStatus. Timing? */ 5270 if (val & OHCI_PORT_ W_CLEAR_SUSPEND_STATUS)5215 if (val & OHCI_PORT_CLRSS) 5271 5216 { 5272 5217 ohciR3RhPortPower(&pThis->RootHub, i, true /* power up */); 5273 pThis->RootHub.aPorts[i].fReg &= ~OHCI_PORT_ R_SUSPEND_STATUS;5274 pThis->RootHub.aPorts[i].fReg |= OHCI_PORT_ R_SUSPEND_STATUS_CHANGE;5218 pThis->RootHub.aPorts[i].fReg &= ~OHCI_PORT_PSS; 5219 pThis->RootHub.aPorts[i].fReg |= OHCI_PORT_PSSC; 5275 5220 ohciR3SetInterrupt(pThis, OHCI_INTR_ROOT_HUB_STATUS_CHANGE); 5276 5221 }
Note:
See TracChangeset
for help on using the changeset viewer.