\r
The UHCI driver model and HC protocol routines.\r
\r
-Copyright (c) 2004 - 2009, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
return EFI_UNSUPPORTED;\r
}\r
\r
- Uhc = UHC_FROM_USB2_HC_PROTO (This);\r
+ Uhc = UHC_FROM_USB2_HC_PROTO (This);\r
+\r
+ if (Uhc->DevicePath != NULL) {\r
+ //\r
+ // Report Status Code to indicate reset happens\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ (EFI_IO_BUS_USB | EFI_IOB_PC_RESET),\r
+ Uhc->DevicePath\r
+ );\r
+ }\r
\r
OldTpl = gBS->RaiseTPL (UHCI_TPL);\r
\r
EFI_STATUS\r
EFIAPI\r
Uhci2GetState (\r
- IN CONST EFI_USB2_HC_PROTOCOL *This,\r
- OUT EFI_USB_HC_STATE *State\r
+ IN EFI_USB2_HC_PROTOCOL *This,\r
+ OUT EFI_USB_HC_STATE *State\r
)\r
{\r
USB_HC_DEV *Uhc;\r
EFI_STATUS\r
EFIAPI\r
Uhci2GetRootHubPortStatus (\r
- IN CONST EFI_USB2_HC_PROTOCOL *This,\r
- IN CONST UINT8 PortNumber,\r
- OUT EFI_USB_PORT_STATUS *PortStatus\r
+ IN EFI_USB2_HC_PROTOCOL *This,\r
+ IN UINT8 PortNumber,\r
+ OUT EFI_USB_PORT_STATUS *PortStatus\r
)\r
{\r
USB_HC_DEV *Uhc;\r
\r
\r
/**\r
- Submits control transfer to a target USB device accroding to UEFI 2.0 spec.\r
+ Submits control transfer to a target USB device according to UEFI 2.0 spec.\r
\r
@param This A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
@param DeviceAddress Target device address.\r
EFI_STATUS Status;\r
UINT8 *DataPtr;\r
UINT8 *DataPhy;\r
- VOID *DataMap;\r
UINT8 PktId;\r
\r
Uhc = UHC_FROM_USB2_HC_PROTO (This);\r
IntTds = NULL;\r
DataPtr = NULL;\r
DataPhy = NULL;\r
- DataMap = NULL;\r
\r
IsSlowDevice = (BOOLEAN) ((EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE);\r
\r
return EFI_DEVICE_ERROR;\r
}\r
\r
+ if ((EndPointAddress & 0x80) == 0) {\r
+ PktId = OUTPUT_PACKET_ID;\r
+ } else {\r
+ PktId = INPUT_PACKET_ID;\r
+ }\r
+\r
//\r
// Allocate and map source data buffer for bus master access.\r
//\r
- DataPtr = UsbHcAllocateMem (Uhc->MemPool, DataLength);\r
+ DataPtr = UsbHcAllocateMem (Uhc->MemPool, DataLength);\r
\r
if (DataPtr == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- OldTpl = gBS->RaiseTPL (UHCI_TPL);\r
-\r
- //\r
- // Map the user data then create a queue head and\r
- // list of TD for it.\r
- //\r
- Status = UhciMapUserData (\r
- Uhc,\r
- EfiUsbDataIn,\r
- DataPtr,\r
- &DataLength,\r
- &PktId,\r
- &DataPhy,\r
- &DataMap\r
- );\r
+ DataPhy = (UINT8 *) (UINTN) UsbHcGetPciAddressForHostMem (Uhc->MemPool, DataPtr, DataLength);\r
\r
- if (EFI_ERROR (Status)) {\r
- goto FREE_DATA;\r
- }\r
+ OldTpl = gBS->RaiseTPL (UHCI_TPL);\r
\r
Qh = UhciCreateQh (Uhc, PollingInterval);\r
\r
if (Qh == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
- goto UNMAP_DATA;\r
+ goto FREE_DATA;\r
}\r
\r
IntTds = UhciCreateBulkOrIntTds (\r
EndPointAddress,\r
DataLength,\r
PollingInterval,\r
- DataMap,\r
DataPtr,\r
CallBackFunction,\r
Context,\r
DESTORY_QH:\r
UsbHcFreeMem (Uhc->MemPool, Qh, sizeof (UHCI_QH_SW));\r
\r
-UNMAP_DATA:\r
- Uhc->PciIo->Unmap (Uhc->PciIo, DataMap);\r
-\r
FREE_DATA:\r
- gBS->FreePool (DataPtr);\r
+ UsbHcFreeMem (Uhc->MemPool, DataPtr, DataLength);\r
Uhc->PciIo->Flush (Uhc->PciIo);\r
\r
gBS->RestoreTPL (OldTpl);\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- if ((EndPointAddress & 0x80) == 0) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
if ((*DataToggle != 1) && (*DataToggle != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
//\r
if ((UsbClassCReg.BaseCode != PCI_CLASS_SERIAL) ||\r
(UsbClassCReg.SubClassCode != PCI_CLASS_SERIAL_USB) ||\r
- (UsbClassCReg.PI != PCI_IF_UHCI)\r
+ (UsbClassCReg.ProgInterface != PCI_IF_UHCI)\r
) {\r
\r
Status = EFI_UNSUPPORTED;\r
Allocate and initialize the empty UHCI device.\r
\r
@param PciIo The PCIIO to use.\r
+ @param DevicePath The device path of host controller.\r
@param OriginalPciAttributes The original PCI attributes.\r
\r
@return Allocated UHCI device. If err, return NULL.\r
**/\r
USB_HC_DEV *\r
UhciAllocateDev (\r
- IN EFI_PCI_IO_PROTOCOL *PciIo,\r
- IN UINT64 OriginalPciAttributes\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN UINT64 OriginalPciAttributes\r
)\r
{\r
USB_HC_DEV *Uhc;\r
Uhc->Usb2Hc.MinorRevision = 0x1;\r
\r
Uhc->PciIo = PciIo;\r
+ Uhc->DevicePath = DevicePath;\r
Uhc->OriginalPciAttributes = OriginalPciAttributes;\r
Uhc->MemPool = UsbHcInitMemPool (PciIo, TRUE, 0);\r
\r
\r
Status = gBS->CreateEvent (\r
EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
- TPL_CALLBACK,\r
+ TPL_NOTIFY,\r
UhciMonitorAsyncReqList,\r
Uhc,\r
&Uhc->AsyncIntMonitor\r
)\r
{\r
USB_HC_DEV *Uhc;\r
+ EFI_STATUS Status;\r
\r
//\r
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller\r
//\r
Uhc = UHC_FROM_USB2_HC_PROTO (This);\r
- UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);\r
\r
- gBS->UninstallProtocolInterface (\r
- Controller,\r
- &gEfiUsb2HcProtocolGuid,\r
- &Uhc->Usb2Hc\r
- );\r
\r
+ Status = gBS->UninstallProtocolInterface (\r
+ Controller,\r
+ &gEfiUsb2HcProtocolGuid,\r
+ &Uhc->Usb2Hc\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return ;\r
+ }\r
+\r
+ UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);\r
UhciFreeAllAsyncReq (Uhc);\r
UhciDestoryFrameList (Uhc);\r
\r
One notified function to stop the Host Controller when gBS->ExitBootServices() called.\r
\r
@param Event Pointer to this event\r
- @param Context Event hanlder private data\r
+ @param Context Event handler private data\r
\r
**/\r
VOID\r
//\r
UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);\r
\r
- return;\r
+ //\r
+ // Reset the Host Controller\r
+ //\r
+ UhciSetRegBit (Uhc->PciIo, USBCMD_OFFSET, USBCMD_HCRESET);\r
+ gBS->Stall (UHC_ROOT_PORT_RECOVERY_STALL);\r
}\r
\r
/**\r
UINT64 Supports;\r
UINT64 OriginalPciAttributes;\r
BOOLEAN PciAttributesSaved;\r
+ EFI_DEVICE_PATH_PROTOCOL *HcDevicePath;\r
\r
//\r
// Open PCIIO, then enable the EHC device and turn off emulation\r
return Status;\r
}\r
\r
+ //\r
+ // Open Device Path Protocol for on USB host controller\r
+ //\r
+ HcDevicePath = NULL;\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &HcDevicePath,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
PciAttributesSaved = FALSE;\r
//\r
// Save original PCI attributes\r
&Supports\r
);\r
if (!EFI_ERROR (Status)) {\r
- Supports &= EFI_PCI_DEVICE_ENABLE;\r
+ Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
Status = PciIo->Attributes (\r
PciIo,\r
EfiPciIoAttributeOperationEnable,\r
goto CLOSE_PCIIO;\r
}\r
\r
- Uhc = UhciAllocateDev (PciIo, OriginalPciAttributes);\r
+ Uhc = UhciAllocateDev (PciIo, HcDevicePath, OriginalPciAttributes);\r
\r
if (Uhc == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
\r
\r
/**\r
- Stop this driver on ControllerHandle. Support stoping any child handles\r
+ Stop this driver on ControllerHandle. Support stopping any child handles\r
created by this driver.\r
\r
@param This Protocol instance pointer.\r