]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/EmmcDxe: Implementation of Disk Information Protocol
authorHao Wu <hao.a.wu@intel.com>
Mon, 3 Jul 2017 00:41:16 +0000 (08:41 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 6 Jul 2017 04:55:43 +0000 (12:55 +0800)
Adds the implementation of Disk Information Protocol for EMMC devices per
PI 1.6 spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDiskInfo.c [new file with mode: 0644]
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDiskInfo.h [new file with mode: 0644]
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.h
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf

diff --git a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDiskInfo.c b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDiskInfo.c
new file mode 100644 (file)
index 0000000..85c7ac6
--- /dev/null
@@ -0,0 +1,140 @@
+/** @file\r
+  Implement the EFI_DISK_INFO_PROTOCOL interface on EMMC devices.\r
+\r
+  Copyright (c) 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
+\r
+**/\r
+\r
+#include "EmmcDxe.h"\r
+\r
+/**\r
+  Provides inquiry information for the controller type.\r
+\r
+  This function is used by the driver entity to get inquiry data. Data format of\r
+  Identify data is defined by the Interface GUID.\r
+\r
+  @param[in]     This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in,out] InquiryData       Pointer to a buffer for the inquiry data.\r
+  @param[in,out] InquiryDataSize   Pointer to the value for the inquiry data size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading InquiryData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   InquiryDataSize not big enough.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoInquiry (\r
+  IN     EFI_DISK_INFO_PROTOCOL  *This,\r
+  IN OUT VOID                    *InquiryData,\r
+  IN OUT UINT32                  *InquiryDataSize\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  EMMC_PARTITION    *Partition;\r
+  EMMC_DEVICE       *Device;\r
+\r
+  Partition = EMMC_PARTITION_DATA_FROM_DISKINFO (This);\r
+  Device    = Partition->Device;\r
+\r
+  if (*InquiryDataSize >= sizeof (Device->Cid)) {\r
+    Status = EFI_SUCCESS;\r
+    CopyMem (InquiryData, &Device->Cid, sizeof (Device->Cid));\r
+  } else {\r
+    Status = EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  *InquiryDataSize = sizeof (Device->Cid);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Provides identify information for the controller type.\r
+\r
+  This function is used by the driver entity to get identify data. Data format\r
+  of Identify data is defined by the Interface GUID.\r
+\r
+  @param[in]     This               Pointer to the EFI_DISK_INFO_PROTOCOL\r
+                                    instance.\r
+  @param[in,out] IdentifyData       Pointer to a buffer for the identify data.\r
+  @param[in,out] IdentifyDataSize   Pointer to the value for the identify data\r
+                                    size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading IdentifyData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   IdentifyDataSize not big enough.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoIdentify (\r
+  IN     EFI_DISK_INFO_PROTOCOL  *This,\r
+  IN OUT VOID                    *IdentifyData,\r
+  IN OUT UINT32                  *IdentifyDataSize\r
+  )\r
+{\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  Provides sense data information for the controller type.\r
+\r
+  This function is used by the driver entity to get sense data. Data format of\r
+  Sense data is defined by the Interface GUID.\r
+\r
+  @param[in]     This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in,out] SenseData         Pointer to the SenseData.\r
+  @param[in,out] SenseDataSize     Size of SenseData in bytes.\r
+  @param[out]    SenseDataNumber   Pointer to the value for the sense data size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading SenseData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   SenseDataSize not big enough.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoSenseData (\r
+  IN     EFI_DISK_INFO_PROTOCOL  *This,\r
+  IN OUT VOID                    *SenseData,\r
+  IN OUT UINT32                  *SenseDataSize,\r
+  OUT    UINT8                   *SenseDataNumber\r
+  )\r
+{\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  Provides IDE channel and device information for the interface.\r
+\r
+  This function is used by the driver entity to get controller information.\r
+\r
+  @param[in]  This         Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[out] IdeChannel   Pointer to the Ide Channel number.  Primary or secondary.\r
+  @param[out] IdeDevice    Pointer to the Ide Device number.  Master or slave.\r
+\r
+  @retval EFI_SUCCESS       IdeChannel and IdeDevice are valid.\r
+  @retval EFI_UNSUPPORTED   This is not an IDE device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoWhichIde (\r
+  IN  EFI_DISK_INFO_PROTOCOL  *This,\r
+  OUT UINT32                  *IdeChannel,\r
+  OUT UINT32                  *IdeDevice\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDiskInfo.h b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDiskInfo.h
new file mode 100644 (file)
index 0000000..4d3e691
--- /dev/null
@@ -0,0 +1,115 @@
+/** @file\r
+  Header file for EFI_DISK_INFO_PROTOCOL interface on EMMC devices.\r
+\r
+  Copyright (c) 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
+\r
+**/\r
+\r
+#ifndef _EMMC_DISKINFO_H_\r
+#define _EMMC_DISKINFO_H_\r
+\r
+/**\r
+  Provides inquiry information for the controller type.\r
+\r
+  This function is used by the driver entity to get inquiry data. Data format of\r
+  Identify data is defined by the Interface GUID.\r
+\r
+  @param[in]     This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in,out] InquiryData       Pointer to a buffer for the inquiry data.\r
+  @param[in,out] InquiryDataSize   Pointer to the value for the inquiry data size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading InquiryData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   InquiryDataSize not big enough.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoInquiry (\r
+  IN     EFI_DISK_INFO_PROTOCOL  *This,\r
+  IN OUT VOID                    *InquiryData,\r
+  IN OUT UINT32                  *InquiryDataSize\r
+  );\r
+\r
+/**\r
+  Provides identify information for the controller type.\r
+\r
+  This function is used by the driver entity to get identify data. Data format\r
+  of Identify data is defined by the Interface GUID.\r
+\r
+  @param[in]     This               Pointer to the EFI_DISK_INFO_PROTOCOL\r
+                                    instance.\r
+  @param[in,out] IdentifyData       Pointer to a buffer for the identify data.\r
+  @param[in,out] IdentifyDataSize   Pointer to the value for the identify data\r
+                                    size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading IdentifyData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   IdentifyDataSize not big enough.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoIdentify (\r
+  IN     EFI_DISK_INFO_PROTOCOL  *This,\r
+  IN OUT VOID                    *IdentifyData,\r
+  IN OUT UINT32                  *IdentifyDataSize\r
+  );\r
+\r
+/**\r
+  Provides sense data information for the controller type.\r
+\r
+  This function is used by the driver entity to get sense data. Data format of\r
+  Sense data is defined by the Interface GUID.\r
+\r
+  @param[in]     This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in,out] SenseData         Pointer to the SenseData.\r
+  @param[in,out] SenseDataSize     Size of SenseData in bytes.\r
+  @param[out]    SenseDataNumber   Pointer to the value for the sense data size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading SenseData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   SenseDataSize not big enough.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoSenseData (\r
+  IN     EFI_DISK_INFO_PROTOCOL  *This,\r
+  IN OUT VOID                    *SenseData,\r
+  IN OUT UINT32                  *SenseDataSize,\r
+  OUT    UINT8                   *SenseDataNumber\r
+  );\r
+\r
+/**\r
+  Provides IDE channel and device information for the interface.\r
+\r
+  This function is used by the driver entity to get controller information.\r
+\r
+  @param[in]  This         Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[out] IdeChannel   Pointer to the Ide Channel number.  Primary or secondary.\r
+  @param[out] IdeDevice    Pointer to the Ide Device number.  Master or slave.\r
+\r
+  @retval EFI_SUCCESS       IdeChannel and IdeDevice are valid.\r
+  @retval EFI_UNSUPPORTED   This is not an IDE device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcDiskInfoWhichIde (\r
+  IN  EFI_DISK_INFO_PROTOCOL  *This,\r
+  OUT UINT32                  *IdeChannel,\r
+  OUT UINT32                  *IdeDevice\r
+  );\r
+\r
+#endif\r
index 5040882d622fe3f31e547b867e915e046ce71320..4ebced0b949751c953bf91933a3107c4ae5f892e 100644 (file)
@@ -4,7 +4,7 @@
   It produces BlockIo, BlockIo2 and StorageSecurity protocols to allow upper layer\r
   access the EMMC device.\r
 \r
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 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
@@ -73,6 +73,13 @@ EMMC_PARTITION mEmmcPartitionTemplate = {
     1,\r
     EmmcEraseBlocks\r
   },\r
+  {                            // DiskInfo\r
+    EFI_DISK_INFO_SD_MMC_INTERFACE_GUID,\r
+    EmmcDiskInfoInquiry,\r
+    EmmcDiskInfoIdentify,\r
+    EmmcDiskInfoSenseData,\r
+    EmmcDiskInfoWhichIde\r
+  },\r
   {\r
     NULL,\r
     NULL\r
@@ -454,6 +461,8 @@ InstallProtocolOnPartition (
                       &Partition->BlockIo2,\r
                       &gEfiEraseBlockProtocolGuid,\r
                       &Partition->EraseBlock,\r
+                      &gEfiDiskInfoProtocolGuid,\r
+                      &Partition->DiskInfo,\r
                       NULL\r
                       );\r
       if (EFI_ERROR (Status)) {\r
@@ -481,6 +490,8 @@ InstallProtocolOnPartition (
                  &Partition->BlockIo2,\r
                  &gEfiEraseBlockProtocolGuid,\r
                  &Partition->EraseBlock,\r
+                 &gEfiDiskInfoProtocolGuid,\r
+                 &Partition->DiskInfo,\r
                  NULL\r
                  );\r
           goto Error;\r
@@ -1104,6 +1115,8 @@ EmmcDxeDriverBindingStop (
                     &Partition->BlockIo2,\r
                     &gEfiEraseBlockProtocolGuid,\r
                     &Partition->EraseBlock,\r
+                    &gEfiDiskInfoProtocolGuid,\r
+                    &Partition->DiskInfo,\r
                     NULL\r
                     );\r
     if (EFI_ERROR (Status)) {\r
index 0ae4eccac6ea0d991009b1c7affafaf7495c2af2..abdffbb50b360e3c79db7b236dc60cf6e4565b91 100644 (file)
@@ -4,7 +4,7 @@
   This file defines common data structures, macro definitions and some module\r
   internal function header files.\r
 \r
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 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
@@ -26,6 +26,7 @@
 #include <Protocol/BlockIo2.h>\r
 #include <Protocol/StorageSecurityCommand.h>\r
 #include <Protocol/EraseBlock.h>\r
+#include <Protocol/DiskInfo.h>\r
 \r
 #include <Protocol/DevicePath.h>\r
 \r
@@ -40,6 +41,8 @@
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 \r
 #include "EmmcBlockIo.h"\r
+#include "EmmcDiskInfo.h"\r
+\r
 //\r
 // Global Variables\r
 //\r
@@ -61,6 +64,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL     gEmmcDxeComponentName2;
 #define EMMC_PARTITION_DATA_FROM_ERASEBLK(a) \\r
     CR(a, EMMC_PARTITION, EraseBlock, EMMC_PARTITION_SIGNATURE)\r
 \r
+#define EMMC_PARTITION_DATA_FROM_DISKINFO(a) \\r
+    CR(a, EMMC_PARTITION, DiskInfo, EMMC_PARTITION_SIGNATURE)\r
+\r
 //\r
 // Take 2.5 seconds as generic time out value, 1 microsecond as unit.\r
 //\r
@@ -102,6 +108,7 @@ typedef struct {
   EFI_BLOCK_IO_MEDIA                    BlockMedia;\r
   EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;\r
   EFI_ERASE_BLOCK_PROTOCOL              EraseBlock;\r
+  EFI_DISK_INFO_PROTOCOL                DiskInfo;\r
 \r
   LIST_ENTRY                            Queue;\r
 \r
index 7b0504937a6d45098fea7dc571466efaf353296e..3f27bdbcaff5bc4aaf796be5ecd3aaf2a3ceaec5 100644 (file)
@@ -4,7 +4,7 @@
 #  It produces BlockIo, BlockIo2 and StorageSecurity protocols to allow upper layer\r
 #  access the EMMC device.\r
 #\r
-#  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -41,6 +41,8 @@
   EmmcDxe.h\r
   EmmcBlockIo.c\r
   EmmcBlockIo.h\r
+  EmmcDiskInfo.c\r
+  EmmcDiskInfo.h\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
@@ -61,6 +63,7 @@
   gEfiBlockIo2ProtocolGuid                     ## BY_START\r
   gEfiStorageSecurityCommandProtocolGuid       ## SOMETIMES_PRODUCES\r
   gEfiEraseBlockProtocolGuid                   ## BY_START\r
+  gEfiDiskInfoProtocolGuid                     ## BY_START\r
   ## TO_START\r
   ## BY_START\r
   gEfiDevicePathProtocolGuid\r