]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Sd / SdDxe / SdDxe.c
index 7ed80b6bd05b81e9827dcec5193cc4b17a070ef5..e341b4cc1c8d376aceac69c68e5e63545a4edeed 100644 (file)
@@ -4,14 +4,8 @@
   It produces BlockIo and BlockIo2 protocols to allow upper layer\r
   access the SD memory card device.\r
 \r
-  Copyright (c) 2015 - 2016, 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) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -64,6 +58,18 @@ SD_DEVICE mSdDeviceTemplate = {
     0,                         // IoAlign\r
     0                          // LastBlock\r
   },\r
+  {                            // EraseBlock\r
+    EFI_ERASE_BLOCK_PROTOCOL_REVISION,\r
+    1,\r
+    SdEraseBlocks\r
+  },\r
+  {                            // DiskInfo\r
+    EFI_DISK_INFO_SD_MMC_INTERFACE_GUID,\r
+    SdDiskInfoInquiry,\r
+    SdDiskInfoIdentify,\r
+    SdDiskInfoSenseData,\r
+    SdDiskInfoWhichIde\r
+  },\r
   {                            // Queue\r
     NULL,\r
     NULL\r
@@ -156,7 +162,7 @@ GetSdModelName (
   String[sizeof (Cid->OemId) + sizeof (Cid->ProductName)] = ' ';\r
   CopyMem (String + sizeof (Cid->OemId) + sizeof (Cid->ProductName) + 1, Cid->ProductSerialNumber, sizeof (Cid->ProductSerialNumber));\r
 \r
-  AsciiStrToUnicodeStr (String, Device->ModelName);\r
+  AsciiStrToUnicodeStrS (String, Device->ModelName, sizeof (Device->ModelName) / sizeof (Device->ModelName[0]));\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -247,6 +253,12 @@ DiscoverUserArea (
   Device->BlockMedia.LogicalPartition = FALSE;\r
   Device->BlockMedia.LastBlock        = DivU64x32 (Capacity, Device->BlockMedia.BlockSize) - 1;\r
 \r
+  if (Csd->EraseBlkEn) {\r
+    Device->EraseBlock.EraseLengthGranularity = 1;\r
+  } else {\r
+    Device->EraseBlock.EraseLengthGranularity = (Csd->SectorSize + 1) * (1 << (Csd->WriteBlLen - 9));\r
+  }\r
+\r
   return Status;\r
 }\r
 \r
@@ -355,7 +367,7 @@ DiscoverSdDevice (
     );\r
   AddUnicodeString2 (\r
     "en",\r
-    gSdDxeComponentName.SupportedLanguages,\r
+    gSdDxeComponentName2.SupportedLanguages,\r
     &Device->ControllerNameTable,\r
     Device->ModelName,\r
     FALSE\r
@@ -369,6 +381,10 @@ DiscoverSdDevice (
                   &Device->BlockIo,\r
                   &gEfiBlockIo2ProtocolGuid,\r
                   &Device->BlockIo2,\r
+                  &gEfiEraseBlockProtocolGuid,\r
+                  &Device->EraseBlock,\r
+                  &gEfiDiskInfoProtocolGuid,\r
+                  &Device->DiskInfo,\r
                   NULL\r
                   );\r
 \r
@@ -787,7 +803,7 @@ SdDxeDriverBindingStop (
     //\r
     // Free all on-going async tasks.\r
     //\r
-    OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+    OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
     for (Link = GetFirstNode (&Device->Queue);\r
          !IsNull (&Device->Queue, Link);\r
          Link = NextLink) {\r
@@ -825,6 +841,10 @@ SdDxeDriverBindingStop (
                     &Device->BlockIo,\r
                     &gEfiBlockIo2ProtocolGuid,\r
                     &Device->BlockIo2,\r
+                    &gEfiEraseBlockProtocolGuid,\r
+                    &Device->EraseBlock,\r
+                    &gEfiDiskInfoProtocolGuid,\r
+                    &Device->DiskInfo,\r
                     NULL\r
                     );\r
     if (EFI_ERROR (Status)) {\r