Save original PCI attributes in start() function and restore it in Stop().

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4324 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2007-11-23 06:19:16 +00:00
parent 54857d5a7c
commit 94b73c2482
2 changed files with 71 additions and 55 deletions

View File

@ -242,6 +242,20 @@ CirrusLogic5430ControllerDriverStart (
goto Error;
}
//
// Save original PCI attributes
//
Status = Private->PciIo->Attributes (
Private->PciIo,
EfiPciIoAttributeOperationGet,
0,
&Private->OriginalPciAttributes
);
if (EFI_ERROR (Status)) {
goto Error;
}
Status = Private->PciIo->Attributes (
Private->PciIo,
EfiPciIoAttributeOperationEnable,
@ -305,25 +319,27 @@ Error:
if (EFI_ERROR (Status)) {
if (Private) {
if (Private->PciIo) {
//
// Restore original PCI attributes
//
Private->PciIo->Attributes (
Private->PciIo,
EfiPciIoAttributeOperationDisable,
EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
NULL
);
}
}
Private->PciIo,
EfiPciIoAttributeOperationSet,
Private->OriginalPciAttributes,
NULL
);
//
// Close the PCI I/O Protocol
//
gBS->CloseProtocol (
Private->Handle,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
Private->Handle
);
}
//
// Close the PCI I/O Protocol
//
gBS->CloseProtocol (
Private->Handle,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
Private->Handle
);
if (Private) {
gBS->FreePool (Private);
}
}
@ -433,16 +449,15 @@ CirrusLogic5430ControllerDriverStop (
return Status;
}
//
// Shutdown the hardware
// Restore original PCI attributes
//
Private->PciIo->Attributes (
Private->PciIo,
EfiPciIoAttributeOperationDisable,
EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
NULL
);
Private->PciIo,
EfiPciIoAttributeOperationSet,
Private->OriginalPciAttributes,
NULL
);
//
// Close the PCI I/O Protocol

View File

@ -65,6 +65,7 @@ typedef struct {
UINT64 Signature;
EFI_HANDLE Handle;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 OriginalPciAttributes;
EFI_UGA_DRAW_PROTOCOL UgaDraw;
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
UINTN CurrentMode;