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; 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 ( Status = Private->PciIo->Attributes (
Private->PciIo, Private->PciIo,
EfiPciIoAttributeOperationEnable, EfiPciIoAttributeOperationEnable,
@ -305,14 +319,15 @@ Error:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Private) { if (Private) {
if (Private->PciIo) { if (Private->PciIo) {
//
// Restore original PCI attributes
//
Private->PciIo->Attributes ( Private->PciIo->Attributes (
Private->PciIo, Private->PciIo,
EfiPciIoAttributeOperationDisable, EfiPciIoAttributeOperationSet,
EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO, Private->OriginalPciAttributes,
NULL NULL
); );
}
}
// //
// Close the PCI I/O Protocol // Close the PCI I/O Protocol
@ -323,7 +338,8 @@ Error:
This->DriverBindingHandle, This->DriverBindingHandle,
Private->Handle Private->Handle
); );
if (Private) { }
gBS->FreePool (Private); gBS->FreePool (Private);
} }
} }
@ -433,14 +449,13 @@ CirrusLogic5430ControllerDriverStop (
return Status; return Status;
} }
// //
// Shutdown the hardware // Restore original PCI attributes
// //
Private->PciIo->Attributes ( Private->PciIo->Attributes (
Private->PciIo, Private->PciIo,
EfiPciIoAttributeOperationDisable, EfiPciIoAttributeOperationSet,
EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO, Private->OriginalPciAttributes,
NULL NULL
); );

View File

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