]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
SecurityPkg/OpalPassword: Add PCD to skip password prompt
[mirror_edk2.git] / SecurityPkg / Tcg / Opal / OpalPassword / OpalHii.c
index d0f3eda1e8437e3ec908aa0bd8d77a5f13ca1602..18b65da756d63e66b0dca38b6a236d9a14bae296 100644 (file)
@@ -1215,6 +1215,40 @@ OpalDiskInitialize (
   return OpalDiskUpdateStatus (&Dev->OpalDisk);\r
 }\r
 \r
+/**\r
+  Update the device ownship\r
+\r
+  @param OpalDisk                The Opal device.\r
+\r
+  @retval EFI_SUCESS             Get ownership success.\r
+  @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership.\r
+  @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info.\r
+\r
+**/\r
+EFI_STATUS\r
+OpalDiskUpdateOwnerShip (\r
+  OPAL_DISK        *OpalDisk\r
+  )\r
+{\r
+  OPAL_SESSION  Session;\r
+\r
+  if (OpalDisk->MsidLength == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (OpalDisk->SentBlockSID) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  ZeroMem(&Session, sizeof(Session));\r
+  Session.Sscp = OpalDisk->Sscp;\r
+  Session.MediaId = OpalDisk->MediaId;\r
+  Session.OpalBaseComId = OpalDisk->OpalBaseComId;\r
+\r
+  OpalDisk->Owner = OpalUtilDetermineOwnership(&Session, OpalDisk->Msid, OpalDisk->MsidLength);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Update the device info.\r
 \r
@@ -1223,6 +1257,7 @@ OpalDiskInitialize (
   @retval EFI_SUCESS             Initialize the device success.\r
   @retval EFI_DEVICE_ERROR       Get info from device failed.\r
   @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info.\r
+  @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1243,15 +1278,6 @@ OpalDiskUpdateStatus (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  if (OpalDisk->MsidLength == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  } else {\r
-    //\r
-    // Base on the Msid info to get the ownership, so Msid info must get first.\r
-    //\r
-    OpalDisk->Owner = OpalUtilDetermineOwnership(&Session, OpalDisk->Msid, OpalDisk->MsidLength);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
+  return OpalDiskUpdateOwnerShip (OpalDisk);\r
 }\r
 \r