]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PvScsiDxe: Backup/Restore PCI attributes on Init/UnInit
authorLiran Alon <liran.alon@oracle.com>
Sat, 28 Mar 2020 20:00:52 +0000 (23:00 +0300)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 30 Mar 2020 16:45:07 +0000 (16:45 +0000)
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>
OvmfPkg/PvScsiDxe/PvScsi.c
OvmfPkg/PvScsiDxe/PvScsi.h

index e0380d729b3c5eed06a473ffde6e1c5795a08747..5566b4cce46725743ce2f2aa2981278a5ceac06c 100644 (file)
@@ -283,18 +283,70 @@ PvScsiGetNextTarget (
   return EFI_NOT_FOUND;\r
 }\r
 \r
+STATIC\r
+EFI_STATUS\r
+PvScsiSetPciAttributes (\r
+  IN OUT PVSCSI_DEV *Dev\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  //\r
+  // Backup original PCI Attributes\r
+  //\r
+  Status = Dev->PciIo->Attributes (\r
+                         Dev->PciIo,\r
+                         EfiPciIoAttributeOperationGet,\r
+                         0,\r
+                         &Dev->OriginalPciAttributes\r
+                         );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // TODO: Change PCI Attributes\r
+  //\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+PvScsiRestorePciAttributes (\r
+  IN PVSCSI_DEV *Dev\r
+  )\r
+{\r
+  Dev->PciIo->Attributes (\r
+                Dev->PciIo,\r
+                EfiPciIoAttributeOperationSet,\r
+                Dev->OriginalPciAttributes,\r
+                NULL\r
+                );\r
+}\r
+\r
 STATIC\r
 EFI_STATUS\r
 PvScsiInit (\r
   IN OUT PVSCSI_DEV *Dev\r
   )\r
 {\r
+  EFI_STATUS Status;\r
+\r
   //\r
   // Init configuration\r
   //\r
   Dev->MaxTarget = PcdGet8 (PcdPvScsiMaxTargetLimit);\r
   Dev->MaxLun = PcdGet8 (PcdPvScsiMaxLunLimit);\r
 \r
+  //\r
+  // Set PCI Attributes\r
+  //\r
+  Status = PvScsiSetPciAttributes (Dev);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Populate the exported interface's attributes\r
   //\r
@@ -333,7 +385,7 @@ PvScsiUninit (
   IN OUT PVSCSI_DEV *Dev\r
   )\r
 {\r
-  // Currently nothing to do here\r
+  PvScsiRestorePciAttributes (Dev);\r
 }\r
 \r
 //\r
index e1e5ae18ebf2f187b7555493747bb076d8b858a1..5f611dbbc98c5e2e41cb864769e4a6f9ae04f78a 100644 (file)
@@ -20,6 +20,7 @@
 typedef struct {\r
   UINT32                          Signature;\r
   EFI_PCI_IO_PROTOCOL             *PciIo;\r
+  UINT64                          OriginalPciAttributes;\r
   UINT8                           MaxTarget;\r
   UINT8                           MaxLun;\r
   EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;\r