default:\r
goto ON_INVAILD_PARAMETER;\r
}\r
- \r
+\r
//\r
// Delete all old transactions on the USB bus, then\r
// reinitialize the frame list\r
UhciInitFrameList (Uhc);\r
\r
gBS->RestoreTPL (OldTpl);\r
- \r
+\r
return EFI_SUCCESS;\r
\r
ON_INVAILD_PARAMETER:\r
- \r
+\r
gBS->RestoreTPL (OldTpl);\r
- \r
+\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
UsbCmd |= USBCMD_FGR;\r
UhciWriteReg (Uhc->PciIo, USBCMD_OFFSET, UsbCmd);\r
}\r
- \r
+\r
//\r
// wait 20ms to let resume complete (20ms is specified by UHCI spec)\r
//\r
Status = EFI_DEVICE_ERROR;\r
goto ON_EXIT;\r
}\r
- \r
+\r
//\r
// Set Enter Global Suspend Mode bit to 1.\r
//\r
STATIC\r
USB_HC_DEV *\r
UhciAllocateDev (\r
- IN EFI_PCI_IO_PROTOCOL *PciIo\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN UINT64 OriginalPciAttributes\r
)\r
{\r
USB_HC_DEV *Uhc;\r
Uhc->Usb2Hc.MajorRevision = 0x1;\r
Uhc->Usb2Hc.MinorRevision = 0x1;\r
\r
- Uhc->PciIo = PciIo;\r
- Uhc->MemPool = UsbHcInitMemPool (PciIo, TRUE, 0);\r
+ Uhc->PciIo = PciIo;\r
+ Uhc->OriginalPciAttributes = OriginalPciAttributes;\r
+ Uhc->MemPool = UsbHcInitMemPool (PciIo, TRUE, 0);\r
\r
if (Uhc->MemPool == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
)\r
{\r
USB_HC_DEV *Uhc;\r
- UINT64 Supports;\r
\r
//\r
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller\r
\r
UhciFreeAllAsyncReq (Uhc);\r
UhciDestoryFrameList (Uhc);\r
- \r
- Uhc->PciIo->Attributes (\r
- Uhc->PciIo,\r
- EfiPciIoAttributeOperationSupported,\r
- 0,\r
- &Supports\r
- );\r
- Supports &= EFI_PCI_DEVICE_ENABLE;\r
+\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
Uhc->PciIo->Attributes (\r
- Uhc->PciIo,\r
- EfiPciIoAttributeOperationDisable,\r
- Supports,\r
- NULL\r
- );\r
+ Uhc->PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ Uhc->OriginalPciAttributes,\r
+ NULL\r
+ );\r
\r
UhciFreeDev (Uhc);\r
}\r
EFI_PCI_IO_PROTOCOL *PciIo;\r
USB_HC_DEV *Uhc;\r
UINT64 Supports;\r
+ UINT64 OriginalPciAttributes;\r
\r
//\r
// Open PCIIO, then enable the EHC device and turn off emulation\r
return Status;\r
}\r
\r
+ //\r
+ // Save original PCI attributes\r
+ //\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationGet,\r
+ 0,\r
+ &OriginalPciAttributes\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
UhciTurnOffUsbEmulation (PciIo);\r
\r
Status = PciIo->Attributes (\r
goto CLOSE_PCIIO;\r
}\r
\r
- Uhc = UhciAllocateDev (PciIo);\r
+ Uhc = UhciAllocateDev (PciIo, OriginalPciAttributes);\r
\r
if (Uhc == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
UhciFreeDev (Uhc);\r
\r
CLOSE_PCIIO:\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ OriginalPciAttributes,\r
+ NULL\r
+ );\r
+\r
gBS->CloseProtocol (\r
Controller,\r
&gEfiPciIoProtocolGuid,\r