]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UfsPassThruDxe: Check for RPMB W-LUN (SecurityLun)
authorZurcher, Christopher J <christopher.j.zurcher@intel.com>
Fri, 27 Sep 2019 02:19:58 +0000 (10:19 +0800)
committerHao A Wu <hao.a.wu@intel.com>
Sun, 29 Sep 2019 08:43:45 +0000 (16:43 +0800)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1546

Currently UfsPassThru only checks for 8 common LUNs. This adds a check
for the RPMB Well-known LUN and sets the corresponding bit-mask. Further
handling of the WLUN is already present in the driver.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Christopher J Zurcher <christopher.j.zurcher@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c

index b12404aacb11fefe8a130b35932acf5caf842982..26c5a8b8555498d9fef8dab654e9058e45d41222 100644 (file)
@@ -822,7 +822,9 @@ UfsPassThruDriverBindingStart (
   UINTN                                 UfsHcBase;\r
   UINT32                                Index;\r
   UFS_UNIT_DESC                         UnitDescriptor;\r
   UINTN                                 UfsHcBase;\r
   UINT32                                Index;\r
   UFS_UNIT_DESC                         UnitDescriptor;\r
+  UFS_DEV_DESC                          DeviceDescriptor;\r
   UINT32                                UnitDescriptorSize;\r
   UINT32                                UnitDescriptorSize;\r
+  UINT32                                DeviceDescriptorSize;\r
 \r
   Status    = EFI_SUCCESS;\r
   UfsHc     = NULL;\r
 \r
   Status    = EFI_SUCCESS;\r
   UfsHc     = NULL;\r
@@ -916,7 +918,6 @@ UfsPassThruDriverBindingStart (
 \r
   //\r
   // Check if 8 common luns are active and set corresponding bit mask.\r
 \r
   //\r
   // Check if 8 common luns are active and set corresponding bit mask.\r
-  // TODO: Parse device descriptor to decide if exposing RPMB LUN to upper layer for authentication access.\r
   //\r
   UnitDescriptorSize = sizeof (UFS_UNIT_DESC);\r
   for (Index = 0; Index < 8; Index++) {\r
   //\r
   UnitDescriptorSize = sizeof (UFS_UNIT_DESC);\r
   for (Index = 0; Index < 8; Index++) {\r
@@ -931,6 +932,20 @@ UfsPassThruDriverBindingStart (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
+  //\r
+  // Check if RPMB WLUN is supported and set corresponding bit mask.\r
+  //\r
+  DeviceDescriptorSize = sizeof (UFS_DEV_DESC);\r
+  Status = UfsRwDeviceDesc (Private, TRUE, UfsDeviceDesc, 0, 0, &DeviceDescriptor, &DeviceDescriptorSize);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "Failed to read device descriptor, status = %r\n", Status));\r
+  } else {\r
+    if (DeviceDescriptor.SecurityLun == 0x1) {\r
+      DEBUG ((DEBUG_INFO, "UFS WLUN RPMB is supported\n"));\r
+      Private->Luns.BitMask |= BIT11;\r
+    }\r
+  }\r
+\r
   //\r
   // Start the asynchronous interrupt monitor\r
   //\r
   //\r
   // Start the asynchronous interrupt monitor\r
   //\r