OvmfPkg/PvScsiDxe: Backup/Restore PCI attributes on Init/UnInit

This commit doesn't change semantics.
It is done as a preparation for future commits which will modify
PCI attributes.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Message-Id: <20200328200100.60786-10-liran.alon@oracle.com>
Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
This commit is contained in:
Liran Alon 2020-03-28 23:00:52 +03:00 committed by mergify[bot]
parent c08eaaaf37
commit 45098e8a9a
2 changed files with 54 additions and 1 deletions

View File

@ -283,18 +283,70 @@ PvScsiGetNextTarget (
return EFI_NOT_FOUND;
}
STATIC
EFI_STATUS
PvScsiSetPciAttributes (
IN OUT PVSCSI_DEV *Dev
)
{
EFI_STATUS Status;
//
// Backup original PCI Attributes
//
Status = Dev->PciIo->Attributes (
Dev->PciIo,
EfiPciIoAttributeOperationGet,
0,
&Dev->OriginalPciAttributes
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// TODO: Change PCI Attributes
//
return EFI_SUCCESS;
}
STATIC
VOID
PvScsiRestorePciAttributes (
IN PVSCSI_DEV *Dev
)
{
Dev->PciIo->Attributes (
Dev->PciIo,
EfiPciIoAttributeOperationSet,
Dev->OriginalPciAttributes,
NULL
);
}
STATIC
EFI_STATUS
PvScsiInit (
IN OUT PVSCSI_DEV *Dev
)
{
EFI_STATUS Status;
//
// Init configuration
//
Dev->MaxTarget = PcdGet8 (PcdPvScsiMaxTargetLimit);
Dev->MaxLun = PcdGet8 (PcdPvScsiMaxLunLimit);
//
// Set PCI Attributes
//
Status = PvScsiSetPciAttributes (Dev);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Populate the exported interface's attributes
//
@ -333,7 +385,7 @@ PvScsiUninit (
IN OUT PVSCSI_DEV *Dev
)
{
// Currently nothing to do here
PvScsiRestorePciAttributes (Dev);
}
//

View File

@ -20,6 +20,7 @@
typedef struct {
UINT32 Signature;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 OriginalPciAttributes;
UINT8 MaxTarget;
UINT8 MaxLun;
EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;