Save original PCI attributes in start() function and restore it in Stop() for those PCI device drivers.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4212 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c9a0a0fcf1
commit
68246fa809
@ -163,9 +163,9 @@ AtapiScsiPassThruDriverBindingStart (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_STATUS DisableStatus;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
UINT64 Supports;
|
UINT64 Supports;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
|
|
||||||
PciIo = NULL;
|
PciIo = NULL;
|
||||||
Status = gBS->OpenProtocol (
|
Status = gBS->OpenProtocol (
|
||||||
@ -180,6 +180,20 @@ AtapiScsiPassThruDriverBindingStart (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save original PCI attributes
|
||||||
|
//
|
||||||
|
Status = PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationGet,
|
||||||
|
0,
|
||||||
|
&OriginalPciAttributes
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Status = PciIo->Attributes (
|
Status = PciIo->Attributes (
|
||||||
PciIo,
|
PciIo,
|
||||||
EfiPciIoAttributeOperationSupported,
|
EfiPciIoAttributeOperationSupported,
|
||||||
@ -204,29 +218,19 @@ AtapiScsiPassThruDriverBindingStart (
|
|||||||
//
|
//
|
||||||
// Create SCSI Pass Thru instance for the IDE channel.
|
// Create SCSI Pass Thru instance for the IDE channel.
|
||||||
//
|
//
|
||||||
Status = RegisterAtapiScsiPassThru (This, Controller, PciIo);
|
Status = RegisterAtapiScsiPassThru (This, Controller, PciIo, OriginalPciAttributes);
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
if (PciIo) {
|
//
|
||||||
DisableStatus = PciIo->Attributes (
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
|
PciIo->Attributes (
|
||||||
PciIo,
|
PciIo,
|
||||||
EfiPciIoAttributeOperationSupported,
|
EfiPciIoAttributeOperationSet,
|
||||||
0,
|
OriginalPciAttributes,
|
||||||
&Supports
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (DisableStatus)) {
|
|
||||||
Supports &= (EFI_PCI_DEVICE_ENABLE |
|
|
||||||
EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO |
|
|
||||||
EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO);
|
|
||||||
DisableStatus = PciIo->Attributes (
|
|
||||||
PciIo,
|
|
||||||
EfiPciIoAttributeOperationDisable,
|
|
||||||
Supports,
|
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
Controller,
|
Controller,
|
||||||
@ -264,7 +268,6 @@ AtapiScsiPassThruDriverBindingStop (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;
|
EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;
|
||||||
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
|
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
|
||||||
UINT64 Supports;
|
|
||||||
|
|
||||||
Status = gBS->OpenProtocol (
|
Status = gBS->OpenProtocol (
|
||||||
Controller,
|
Controller,
|
||||||
@ -288,26 +291,16 @@ AtapiScsiPassThruDriverBindingStop (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Release Pci Io protocol on the controller handle.
|
// Restore original PCI attributes
|
||||||
//
|
//
|
||||||
Status = AtapiScsiPrivate->PciIo->Attributes (
|
AtapiScsiPrivate->PciIo->Attributes (
|
||||||
AtapiScsiPrivate->PciIo,
|
AtapiScsiPrivate->PciIo,
|
||||||
EfiPciIoAttributeOperationSupported,
|
EfiPciIoAttributeOperationSet,
|
||||||
0,
|
AtapiScsiPrivate->OriginalPciAttributes,
|
||||||
&Supports
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
Supports &= (EFI_PCI_DEVICE_ENABLE |
|
|
||||||
EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO |
|
|
||||||
EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO);
|
|
||||||
Status = AtapiScsiPrivate->PciIo->Attributes (
|
|
||||||
AtapiScsiPrivate->PciIo,
|
|
||||||
EfiPciIoAttributeOperationDisable,
|
|
||||||
Supports,
|
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
Controller,
|
Controller,
|
||||||
@ -326,6 +319,8 @@ AtapiScsiPassThruDriverBindingStop (
|
|||||||
|
|
||||||
@param Controller: Parent device handle to the IDE channel.
|
@param Controller: Parent device handle to the IDE channel.
|
||||||
@param PciIo: PCI I/O protocol attached on the "Controller".
|
@param PciIo: PCI I/O protocol attached on the "Controller".
|
||||||
|
@param OriginalPciAttributes Original PCI attributes
|
||||||
|
|
||||||
|
|
||||||
@return EFI_SUCCESS Always returned unless installing SCSI Pass Thru Protocol failed.
|
@return EFI_SUCCESS Always returned unless installing SCSI Pass Thru Protocol failed.
|
||||||
|
|
||||||
@ -338,12 +333,12 @@ EFI_STATUS
|
|||||||
RegisterAtapiScsiPassThru (
|
RegisterAtapiScsiPassThru (
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
IN EFI_HANDLE Controller,
|
IN EFI_HANDLE Controller,
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo
|
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
||||||
|
IN UINT64 OriginalPciAttributes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
|
ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate;
|
||||||
UINT64 Supports;
|
|
||||||
IDE_REGISTERS_BASE_ADDR IdeRegsBaseAddr[ATAPI_MAX_CHANNEL];
|
IDE_REGISTERS_BASE_ADDR IdeRegsBaseAddr[ATAPI_MAX_CHANNEL];
|
||||||
|
|
||||||
AtapiScsiPrivate = AllocateZeroPool (sizeof (ATAPI_SCSI_PASS_THRU_DEV));
|
AtapiScsiPrivate = AllocateZeroPool (sizeof (ATAPI_SCSI_PASS_THRU_DEV));
|
||||||
@ -353,27 +348,6 @@ RegisterAtapiScsiPassThru (
|
|||||||
|
|
||||||
CopyMem (AtapiScsiPrivate->ChannelName, gAtapiChannelString, sizeof (gAtapiChannelString));
|
CopyMem (AtapiScsiPrivate->ChannelName, gAtapiChannelString, sizeof (gAtapiChannelString));
|
||||||
|
|
||||||
//
|
|
||||||
// Enable channel
|
|
||||||
//
|
|
||||||
Status = PciIo->Attributes (
|
|
||||||
PciIo,
|
|
||||||
EfiPciIoAttributeOperationSupported,
|
|
||||||
0,
|
|
||||||
&Supports
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
Supports &= (EFI_PCI_DEVICE_ENABLE |
|
|
||||||
EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO |
|
|
||||||
EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO);
|
|
||||||
Status = PciIo->Attributes (
|
|
||||||
PciIo,
|
|
||||||
EfiPciIoAttributeOperationEnable,
|
|
||||||
Supports,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
AtapiScsiPrivate->Signature = ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE;
|
AtapiScsiPrivate->Signature = ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE;
|
||||||
AtapiScsiPrivate->Handle = Controller;
|
AtapiScsiPrivate->Handle = Controller;
|
||||||
|
|
||||||
@ -382,6 +356,7 @@ RegisterAtapiScsiPassThru (
|
|||||||
//
|
//
|
||||||
AtapiScsiPrivate->IoPort = NULL;
|
AtapiScsiPrivate->IoPort = NULL;
|
||||||
AtapiScsiPrivate->PciIo = PciIo;
|
AtapiScsiPrivate->PciIo = PciIo;
|
||||||
|
AtapiScsiPrivate->OriginalPciAttributes = OriginalPciAttributes;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Obtain IDE IO port registers' base addresses
|
// Obtain IDE IO port registers' base addresses
|
||||||
|
@ -102,6 +102,7 @@ typedef struct {
|
|||||||
EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru;
|
EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru;
|
||||||
EFI_SCSI_PASS_THRU_MODE ScsiPassThruMode;
|
EFI_SCSI_PASS_THRU_MODE ScsiPassThruMode;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
//
|
//
|
||||||
// Local Data goes here
|
// Local Data goes here
|
||||||
//
|
//
|
||||||
@ -454,6 +455,7 @@ AtapiScsiPassThruDriverEntryPoint (
|
|||||||
@param This
|
@param This
|
||||||
@param Controller
|
@param Controller
|
||||||
@param PciIo
|
@param PciIo
|
||||||
|
@param OriginalPciAttributes
|
||||||
|
|
||||||
@todo Add function description
|
@todo Add function description
|
||||||
@todo This add argument description
|
@todo This add argument description
|
||||||
@ -465,7 +467,8 @@ EFI_STATUS
|
|||||||
RegisterAtapiScsiPassThru (
|
RegisterAtapiScsiPassThru (
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||||
IN EFI_HANDLE Controller,
|
IN EFI_HANDLE Controller,
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo
|
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
||||||
|
IN UINT64 OriginalPciAttributes
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1396,6 +1396,7 @@ ON_EXIT:
|
|||||||
Create and initialize a USB2_HC_DEV
|
Create and initialize a USB2_HC_DEV
|
||||||
|
|
||||||
@param PciIo The PciIo on this device
|
@param PciIo The PciIo on this device
|
||||||
|
@param OriginalPciAttributes Original PCI attributes
|
||||||
|
|
||||||
@return The allocated and initialized USB2_HC_DEV structure
|
@return The allocated and initialized USB2_HC_DEV structure
|
||||||
@return if created, otherwise NULL.
|
@return if created, otherwise NULL.
|
||||||
@ -1404,7 +1405,8 @@ ON_EXIT:
|
|||||||
STATIC
|
STATIC
|
||||||
USB2_HC_DEV *
|
USB2_HC_DEV *
|
||||||
EhcCreateUsb2Hc (
|
EhcCreateUsb2Hc (
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo
|
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
||||||
|
IN UINT64 OriginalPciAttributes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
USB2_HC_DEV *Ehc;
|
USB2_HC_DEV *Ehc;
|
||||||
@ -1438,6 +1440,7 @@ EhcCreateUsb2Hc (
|
|||||||
Ehc->Usb2Hc.MinorRevision = 0x1;
|
Ehc->Usb2Hc.MinorRevision = 0x1;
|
||||||
|
|
||||||
Ehc->PciIo = PciIo;
|
Ehc->PciIo = PciIo;
|
||||||
|
Ehc->OriginalPciAttributes = OriginalPciAttributes;
|
||||||
|
|
||||||
InitializeListHead (&Ehc->AsyncIntTransfers);
|
InitializeListHead (&Ehc->AsyncIntTransfers);
|
||||||
|
|
||||||
@ -1492,6 +1495,7 @@ EhcDriverBindingStart (
|
|||||||
USB2_HC_DEV *Ehc;
|
USB2_HC_DEV *Ehc;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
UINT64 Supports;
|
UINT64 Supports;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open the PciIo Protocol, then enable the USB host controller
|
// Open the PciIo Protocol, then enable the USB host controller
|
||||||
@ -1510,6 +1514,20 @@ EhcDriverBindingStart (
|
|||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save original PCI attributes
|
||||||
|
//
|
||||||
|
Status = PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationGet,
|
||||||
|
0,
|
||||||
|
&OriginalPciAttributes
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Status = PciIo->Attributes (
|
Status = PciIo->Attributes (
|
||||||
PciIo,
|
PciIo,
|
||||||
EfiPciIoAttributeOperationSupported,
|
EfiPciIoAttributeOperationSupported,
|
||||||
@ -1534,7 +1552,7 @@ EhcDriverBindingStart (
|
|||||||
//
|
//
|
||||||
// Create then install USB2_HC_PROTOCOL
|
// Create then install USB2_HC_PROTOCOL
|
||||||
//
|
//
|
||||||
Ehc = EhcCreateUsb2Hc (PciIo);
|
Ehc = EhcCreateUsb2Hc (PciIo, OriginalPciAttributes);
|
||||||
|
|
||||||
if (Ehc == NULL) {
|
if (Ehc == NULL) {
|
||||||
EHC_ERROR (("EhcDriverBindingStart: failed to create USB2_HC\n"));
|
EHC_ERROR (("EhcDriverBindingStart: failed to create USB2_HC\n"));
|
||||||
@ -1616,6 +1634,16 @@ FREE_POOL:
|
|||||||
gBS->FreePool (Ehc);
|
gBS->FreePool (Ehc);
|
||||||
|
|
||||||
CLOSE_PCIIO:
|
CLOSE_PCIIO:
|
||||||
|
//
|
||||||
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
|
PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
Controller,
|
Controller,
|
||||||
&gEfiPciIoProtocolGuid,
|
&gEfiPciIoProtocolGuid,
|
||||||
@ -1653,7 +1681,6 @@ EhcDriverBindingStop (
|
|||||||
EFI_USB2_HC_PROTOCOL *Usb2Hc;
|
EFI_USB2_HC_PROTOCOL *Usb2Hc;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
USB2_HC_DEV *Ehc;
|
USB2_HC_DEV *Ehc;
|
||||||
UINT64 Supports;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test whether the Controller handler passed in is a valid
|
// Test whether the Controller handler passed in is a valid
|
||||||
@ -1704,23 +1731,14 @@ EhcDriverBindingStop (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Disable the USB Host Controller
|
// Restore original PCI attributes
|
||||||
//
|
//
|
||||||
Status = PciIo->Attributes (
|
PciIo->Attributes (
|
||||||
PciIo,
|
PciIo,
|
||||||
EfiPciIoAttributeOperationSupported,
|
EfiPciIoAttributeOperationSet,
|
||||||
0,
|
Ehc->OriginalPciAttributes,
|
||||||
&Supports
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
Supports &= EFI_PCI_DEVICE_ENABLE;
|
|
||||||
Status = PciIo->Attributes (
|
|
||||||
PciIo,
|
|
||||||
EfiPciIoAttributeOperationDisable,
|
|
||||||
Supports,
|
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
Controller,
|
Controller,
|
||||||
@ -1729,7 +1747,8 @@ EhcDriverBindingStop (
|
|||||||
Controller
|
Controller
|
||||||
);
|
);
|
||||||
|
|
||||||
gBS->FreePool (Ehc);
|
FreePool (Ehc);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ struct _USB2_HC_DEV {
|
|||||||
EFI_USB2_HC_PROTOCOL Usb2Hc;
|
EFI_USB2_HC_PROTOCOL Usb2Hc;
|
||||||
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
USBHC_MEM_POOL *MemPool;
|
USBHC_MEM_POOL *MemPool;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1941,7 +1941,8 @@ ON_EXIT:
|
|||||||
STATIC
|
STATIC
|
||||||
USB_HC_DEV *
|
USB_HC_DEV *
|
||||||
UhciAllocateDev (
|
UhciAllocateDev (
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo
|
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
||||||
|
IN UINT64 OriginalPciAttributes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
USB_HC_DEV *Uhc;
|
USB_HC_DEV *Uhc;
|
||||||
@ -1991,6 +1992,7 @@ UhciAllocateDev (
|
|||||||
Uhc->Usb2Hc.MinorRevision = 0x1;
|
Uhc->Usb2Hc.MinorRevision = 0x1;
|
||||||
|
|
||||||
Uhc->PciIo = PciIo;
|
Uhc->PciIo = PciIo;
|
||||||
|
Uhc->OriginalPciAttributes = OriginalPciAttributes;
|
||||||
Uhc->MemPool = UsbHcInitMemPool (PciIo, TRUE, 0);
|
Uhc->MemPool = UsbHcInitMemPool (PciIo, TRUE, 0);
|
||||||
|
|
||||||
if (Uhc->MemPool == NULL) {
|
if (Uhc->MemPool == NULL) {
|
||||||
@ -2068,7 +2070,6 @@ UhciCleanDevUp (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
USB_HC_DEV *Uhc;
|
USB_HC_DEV *Uhc;
|
||||||
UINT64 Supports;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller
|
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller
|
||||||
@ -2091,17 +2092,13 @@ UhciCleanDevUp (
|
|||||||
UhciFreeAllAsyncReq (Uhc);
|
UhciFreeAllAsyncReq (Uhc);
|
||||||
UhciDestoryFrameList (Uhc);
|
UhciDestoryFrameList (Uhc);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
Uhc->PciIo->Attributes (
|
Uhc->PciIo->Attributes (
|
||||||
Uhc->PciIo,
|
Uhc->PciIo,
|
||||||
EfiPciIoAttributeOperationSupported,
|
EfiPciIoAttributeOperationSet,
|
||||||
0,
|
Uhc->OriginalPciAttributes,
|
||||||
&Supports
|
|
||||||
);
|
|
||||||
Supports &= EFI_PCI_DEVICE_ENABLE;
|
|
||||||
Uhc->PciIo->Attributes (
|
|
||||||
Uhc->PciIo,
|
|
||||||
EfiPciIoAttributeOperationDisable,
|
|
||||||
Supports,
|
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2135,6 +2132,7 @@ UhciDriverBindingStart (
|
|||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
USB_HC_DEV *Uhc;
|
USB_HC_DEV *Uhc;
|
||||||
UINT64 Supports;
|
UINT64 Supports;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open PCIIO, then enable the EHC device and turn off emulation
|
// Open PCIIO, then enable the EHC device and turn off emulation
|
||||||
@ -2153,6 +2151,20 @@ UhciDriverBindingStart (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save original PCI attributes
|
||||||
|
//
|
||||||
|
Status = PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationGet,
|
||||||
|
0,
|
||||||
|
&OriginalPciAttributes
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
UhciTurnOffUsbEmulation (PciIo);
|
UhciTurnOffUsbEmulation (PciIo);
|
||||||
|
|
||||||
Status = PciIo->Attributes (
|
Status = PciIo->Attributes (
|
||||||
@ -2175,7 +2187,7 @@ UhciDriverBindingStart (
|
|||||||
goto CLOSE_PCIIO;
|
goto CLOSE_PCIIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uhc = UhciAllocateDev (PciIo);
|
Uhc = UhciAllocateDev (PciIo, OriginalPciAttributes);
|
||||||
|
|
||||||
if (Uhc == NULL) {
|
if (Uhc == NULL) {
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
@ -2250,6 +2262,16 @@ FREE_UHC:
|
|||||||
UhciFreeDev (Uhc);
|
UhciFreeDev (Uhc);
|
||||||
|
|
||||||
CLOSE_PCIIO:
|
CLOSE_PCIIO:
|
||||||
|
//
|
||||||
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
|
PciIo->Attributes (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
Controller,
|
Controller,
|
||||||
&gEfiPciIoProtocolGuid,
|
&gEfiPciIoProtocolGuid,
|
||||||
|
@ -117,6 +117,7 @@ struct _USB_HC_DEV {
|
|||||||
EFI_USB_HC_PROTOCOL UsbHc;
|
EFI_USB_HC_PROTOCOL UsbHc;
|
||||||
EFI_USB2_HC_PROTOCOL Usb2Hc;
|
EFI_USB2_HC_PROTOCOL Usb2Hc;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Schedule data structures
|
// Schedule data structures
|
||||||
|
@ -640,6 +640,10 @@ typedef struct s_data_instance {
|
|||||||
UINT64 Unique_ID;
|
UINT64 Unique_ID;
|
||||||
|
|
||||||
EFI_PCI_IO_PROTOCOL *Io_Function;
|
EFI_PCI_IO_PROTOCOL *Io_Function;
|
||||||
|
//
|
||||||
|
// Original PCI attributes
|
||||||
|
//
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
|
|
||||||
VOID (*Delay_30)(UINTN); // call back routine
|
VOID (*Delay_30)(UINTN); // call back routine
|
||||||
VOID (*Virt2Phys_30)(UINT64 virtual_addr, UINT64 physical_ptr); // call back routine
|
VOID (*Virt2Phys_30)(UINT64 virtual_addr, UINT64 physical_ptr); // call back routine
|
||||||
|
@ -22,7 +22,7 @@ Revision History
|
|||||||
--*/
|
--*/
|
||||||
|
|
||||||
#include "Undi32.h"
|
#include "Undi32.h"
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
//
|
//
|
||||||
// Global Variables
|
// Global Variables
|
||||||
//
|
//
|
||||||
@ -30,7 +30,7 @@ PXE_SW_UNDI *pxe = 0; // 3.0 entry point
|
|||||||
PXE_SW_UNDI *pxe_31 = 0; // 3.1 entry
|
PXE_SW_UNDI *pxe_31 = 0; // 3.1 entry
|
||||||
UNDI32_DEV *UNDI32DeviceList[MAX_NIC_INTERFACES];
|
UNDI32_DEV *UNDI32DeviceList[MAX_NIC_INTERFACES];
|
||||||
|
|
||||||
NII_TABLE *UnidiDataPointer=NULL;
|
NII_TABLE *UndiDataPointer = NULL;
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -334,6 +334,20 @@ Returns:
|
|||||||
|
|
||||||
ZeroMem ((CHAR8 *) UNDI32Device, sizeof (UNDI32_DEV));
|
ZeroMem ((CHAR8 *) UNDI32Device, sizeof (UNDI32_DEV));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get original PCI attributes
|
||||||
|
//
|
||||||
|
Status = PciIoFncs->Attributes (
|
||||||
|
PciIoFncs,
|
||||||
|
EfiPciIoAttributeOperationGet,
|
||||||
|
0,
|
||||||
|
&UNDI32Device->NicInfo.OriginalPciAttributes
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// allocate and initialize both (old and new) the !pxe structures here,
|
// allocate and initialize both (old and new) the !pxe structures here,
|
||||||
// there should only be one copy of each of these structure for any number
|
// there should only be one copy of each of these structure for any number
|
||||||
@ -511,15 +525,15 @@ Returns:
|
|||||||
//
|
//
|
||||||
// if the table exists, free it and alloc again, or alloc it directly
|
// if the table exists, free it and alloc again, or alloc it directly
|
||||||
//
|
//
|
||||||
if (UnidiDataPointer != NULL) {
|
if (UndiDataPointer != NULL) {
|
||||||
Status = gBS->FreePool(UnidiDataPointer);
|
Status = gBS->FreePool(UndiDataPointer);
|
||||||
}
|
}
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto UndiErrorDeleteDevicePath;
|
goto UndiErrorDeleteDevicePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
Len = (pxe_31->IFcnt * sizeof (NII_ENTRY)) + sizeof (UnidiDataPointer);
|
Len = (pxe_31->IFcnt * sizeof (NII_ENTRY)) + sizeof (UndiDataPointer);
|
||||||
Status = gBS->AllocatePool (EfiRuntimeServicesData, Len, (VOID **) &UnidiDataPointer);
|
Status = gBS->AllocatePool (EfiRuntimeServicesData, Len, (VOID **) &UndiDataPointer);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto UndiErrorAllocDataPointer;
|
goto UndiErrorAllocDataPointer;
|
||||||
@ -563,6 +577,16 @@ UndiErrorDeletePxe:
|
|||||||
}
|
}
|
||||||
|
|
||||||
UndiErrorDeleteDevice:
|
UndiErrorDeleteDevice:
|
||||||
|
//
|
||||||
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
|
PciIoFncs->Attributes (
|
||||||
|
PciIoFncs,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
UNDI32Device->NicInfo.OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
gBS->FreePool (UNDI32Device);
|
gBS->FreePool (UNDI32Device);
|
||||||
|
|
||||||
UndiError:
|
UndiError:
|
||||||
@ -659,6 +683,17 @@ Returns:
|
|||||||
|
|
||||||
UNDI32Device = UNDI_DEV_FROM_THIS (NIIProtocol);
|
UNDI32Device = UNDI_DEV_FROM_THIS (NIIProtocol);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Restore original PCI attributes
|
||||||
|
//
|
||||||
|
Status = UNDI32Device->NicInfo.Io_Function->Attributes (
|
||||||
|
UNDI32Device->NicInfo.Io_Function,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
UNDI32Device->NicInfo.OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = gBS->CloseProtocol (
|
Status = gBS->CloseProtocol (
|
||||||
Controller,
|
Controller,
|
||||||
&gEfiPciIoProtocolGuid,
|
&gEfiPciIoProtocolGuid,
|
||||||
@ -1007,11 +1042,11 @@ Returns:
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(UnidiDataPointer == NULL) {
|
if(UndiDataPointer == NULL) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UndiData = (NII_TABLE *)UnidiDataPointer;
|
UndiData = (NII_TABLE *)UndiDataPointer;
|
||||||
|
|
||||||
UndiData->NumEntries = pxe_31->IFcnt;
|
UndiData->NumEntries = pxe_31->IFcnt;
|
||||||
UndiData->NextLink = NULL;
|
UndiData->NextLink = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user