]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Ufs / UfsPassThruDxe / UfsPassThru.c
index e27f4fbab175a2d53e2e58017680bbfc3d9a5388..1518b251d88a903ded02bf4d7fad1cfb313b2c46 100644 (file)
@@ -1,13 +1,7 @@
 /** @file\r
 \r
-  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -18,7 +12,7 @@
 //\r
 UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate = {\r
   UFS_PASS_THRU_SIG,              // Signature\r
-  NULL,                           // Handle  \r
+  NULL,                           // Handle\r
   {                               // ExtScsiPassThruMode\r
     0xFFFFFFFF,\r
     EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO,\r
@@ -34,6 +28,11 @@ UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate = {
     UfsPassThruResetTargetLun,\r
     UfsPassThruGetNextTarget\r
   },\r
+  {                               // UfsDevConfig\r
+    UfsRwUfsDescriptor,\r
+    UfsRwUfsFlag,\r
+    UfsRwUfsAttribute\r
+  },\r
   0,                              // UfsHostController\r
   0,                              // UfsHcBase\r
   0,                              // Capabilities\r
@@ -204,7 +203,7 @@ UfsPassThruPassThru (
     if ((Private->Luns.BitMask & (BIT0 << Index)) == 0) {\r
       continue;\r
     }\r
-  \r
+\r
     if (Private->Luns.Lun[Index] == UfsLun) {\r
       break;\r
     }\r
@@ -408,7 +407,7 @@ UfsPassThruBuildDevicePath (
     if ((Private->Luns.BitMask & (BIT0 << Index)) == 0) {\r
       continue;\r
     }\r
-  \r
+\r
     if (Private->Luns.Lun[Index] == UfsLun) {\r
       break;\r
     }\r
@@ -499,7 +498,7 @@ UfsPassThruGetTargetLun (
     if ((Private->Luns.BitMask & (BIT0 << Index)) == 0) {\r
       continue;\r
     }\r
-  \r
+\r
     if (Private->Luns.Lun[Index] == UfsLun) {\r
       break;\r
     }\r
@@ -725,7 +724,7 @@ UfsPassThruDriverBindingSupported (
         This->DriverBindingHandle,\r
         Controller\r
         );\r
-        \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -820,6 +819,7 @@ UfsPassThruDriverBindingStart (
   UINTN                                 UfsHcBase;\r
   UINT32                                Index;\r
   UFS_UNIT_DESC                         UnitDescriptor;\r
+  UINT32                                UnitDescriptorSize;\r
 \r
   Status    = EFI_SUCCESS;\r
   UfsHc     = NULL;\r
@@ -877,8 +877,8 @@ UfsPassThruDriverBindingStart (
 \r
   //\r
   // UFS 2.0 spec Section 13.1.3.3:\r
-  // At the end of the UFS Interconnect Layer initialization on both host and device side, \r
-  // the host shall send a NOP OUT UPIU to verify that the device UTP Layer is ready. \r
+  // At the end of the UFS Interconnect Layer initialization on both host and device side,\r
+  // the host shall send a NOP OUT UPIU to verify that the device UTP Layer is ready.\r
   //\r
   Status = UfsExecNopCmds (Private);\r
   if (EFI_ERROR (Status)) {\r
@@ -896,8 +896,9 @@ UfsPassThruDriverBindingStart (
   // 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
-    Status = UfsRwDeviceDesc (Private, TRUE, UfsUnitDesc, (UINT8) Index, 0, &UnitDescriptor, sizeof (UFS_UNIT_DESC));\r
+    Status = UfsRwDeviceDesc (Private, TRUE, UfsUnitDesc, (UINT8) Index, 0, &UnitDescriptor, &UnitDescriptorSize);\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((DEBUG_ERROR, "Failed to read unit descriptor, index = %X, status = %r\n", Index, Status));\r
       continue;\r
@@ -933,11 +934,13 @@ UfsPassThruDriverBindingStart (
     goto Error;\r
   }\r
 \r
-  Status = gBS->InstallProtocolInterface (\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &Controller,\r
                   &gEfiExtScsiPassThruProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &(Private->ExtScsiPassThru)\r
+                  &(Private->ExtScsiPassThru),\r
+                  &gEfiUfsDeviceConfigProtocolGuid,\r
+                  &(Private->UfsDevConfig),\r
+                  NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
@@ -946,7 +949,7 @@ UfsPassThruDriverBindingStart (
 Error:\r
   if (Private != NULL) {\r
     if (Private->TmrlMapping != NULL) {\r
-      UfsHc->Unmap (UfsHc, Private->TmrlMapping);  \r
+      UfsHc->Unmap (UfsHc, Private->TmrlMapping);\r
     }\r
     if (Private->UtpTmrlBase != NULL) {\r
       UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (Private->Nutmrs * sizeof (UTP_TMRD)), Private->UtpTmrlBase);\r
@@ -1057,10 +1060,13 @@ UfsPassThruDriverBindingStop (
     }\r
   }\r
 \r
-  Status = gBS->UninstallProtocolInterface (\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
                   Controller,\r
                   &gEfiExtScsiPassThruProtocolGuid,\r
-                  &(Private->ExtScsiPassThru)\r
+                  &(Private->ExtScsiPassThru),\r
+                  &gEfiUfsDeviceConfigProtocolGuid,\r
+                  &(Private->UfsDevConfig),\r
+                  NULL\r
                   );\r
 \r
   if (EFI_ERROR (Status)) {\r