]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SdDxe: Implementation of Disk Information Protocol
authorHao Wu <hao.a.wu@intel.com>
Mon, 26 Jun 2017 08:40:35 +0000 (16:40 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 6 Jul 2017 04:55:38 +0000 (12:55 +0800)
Adds the implementation of Disk Information Protocol for SD 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/SdDxe/SdDiskInfo.c [new file with mode: 0644]
MdeModulePkg/Bus/Sd/SdDxe/SdDiskInfo.h [new file with mode: 0644]
MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c
MdeModulePkg/Bus/Sd/SdDxe/SdDxe.h
MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf

diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdDiskInfo.c b/MdeModulePkg/Bus/Sd/SdDxe/SdDiskInfo.c
new file mode 100644 (file)
index 0000000..a98dc75
--- /dev/null
@@ -0,0 +1,138 @@
+/** @file\r
+  Implement the EFI_DISK_INFO_PROTOCOL interface on SD memory card 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 "SdDxe.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
+SdDiskInfoInquiry (\r
+  IN     EFI_DISK_INFO_PROTOCOL  *This,\r
+  IN OUT VOID                    *InquiryData,\r
+  IN OUT UINT32                  *InquiryDataSize\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  SD_DEVICE     *Device;\r
+\r
+  Device = SD_DEVICE_DATA_FROM_DISKINFO (This);\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
+SdDiskInfoIdentify (\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
+SdDiskInfoSenseData (\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
+SdDiskInfoWhichIde (\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/SdDxe/SdDiskInfo.h b/MdeModulePkg/Bus/Sd/SdDxe/SdDiskInfo.h
new file mode 100644 (file)
index 0000000..cc7a359
--- /dev/null
@@ -0,0 +1,115 @@
+/** @file\r
+  Header file for EFI_DISK_INFO_PROTOCOL interface on SD memory card 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 _SD_DISKINFO_H_\r
+#define _SD_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
+SdDiskInfoInquiry (\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
+SdDiskInfoIdentify (\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
+SdDiskInfoSenseData (\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
+SdDiskInfoWhichIde (\r
+  IN  EFI_DISK_INFO_PROTOCOL  *This,\r
+  OUT UINT32                  *IdeChannel,\r
+  OUT UINT32                  *IdeDevice\r
+  );\r
+\r
+#endif\r
index 0cf9067701da03a4cc94c136481f8caf94ce89e3..fc060fdb3465ad7a0f8c1f0aee69e055f56c77e1 100644 (file)
@@ -4,7 +4,7 @@
   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
+  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
@@ -69,6 +69,13 @@ SD_DEVICE mSdDeviceTemplate = {
     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
@@ -382,6 +389,8 @@ DiscoverSdDevice (
                   &Device->BlockIo2,\r
                   &gEfiEraseBlockProtocolGuid,\r
                   &Device->EraseBlock,\r
+                  &gEfiDiskInfoProtocolGuid,\r
+                  &Device->DiskInfo,\r
                   NULL\r
                   );\r
 \r
@@ -840,6 +849,8 @@ SdDxeDriverBindingStop (
                     &Device->BlockIo2,\r
                     &gEfiEraseBlockProtocolGuid,\r
                     &Device->EraseBlock,\r
+                    &gEfiDiskInfoProtocolGuid,\r
+                    &Device->DiskInfo,\r
                     NULL\r
                     );\r
     if (EFI_ERROR (Status)) {\r
index 0ba72b7f9ce1977e9112491b52d94a8df0dd4981..63df7b74e48ac923ce9d6152c24f3574048b7170 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
@@ -25,6 +25,7 @@
 #include <Protocol/BlockIo.h>\r
 #include <Protocol/BlockIo2.h>\r
 #include <Protocol/EraseBlock.h>\r
+#include <Protocol/DiskInfo.h>\r
 \r
 #include <Protocol/DevicePath.h>\r
 \r
@@ -39,6 +40,8 @@
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 \r
 #include "SdBlockIo.h"\r
+#include "SdDiskInfo.h"\r
+\r
 //\r
 // Global Variables\r
 //\r
@@ -57,6 +60,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL     gSdDxeComponentName2;
 #define SD_DEVICE_DATA_FROM_ERASEBLK(a) \\r
     CR(a, SD_DEVICE, EraseBlock, SD_DEVICE_SIGNATURE)\r
 \r
+#define SD_DEVICE_DATA_FROM_DISKINFO(a) \\r
+    CR(a, SD_DEVICE, DiskInfo, SD_DEVICE_SIGNATURE)\r
+\r
 //\r
 // Take 2.5 seconds as generic time out value, 1 microsecond as unit.\r
 //\r
@@ -100,6 +106,7 @@ struct _SD_DEVICE {
   EFI_BLOCK_IO2_PROTOCOL                BlockIo2;\r
   EFI_BLOCK_IO_MEDIA                    BlockMedia;\r
   EFI_ERASE_BLOCK_PROTOCOL              EraseBlock;\r
+  EFI_DISK_INFO_PROTOCOL                DiskInfo;\r
 \r
   LIST_ENTRY                            Queue;\r
 \r
index 6f5e6ca72eaa3031ed0394ab53a894afa4aec4ad..a76331427558ce199cbae0acb19c80339ed9b335 100644 (file)
@@ -4,7 +4,7 @@
 #  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
+#  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 @@
   SdDxe.h\r
   SdBlockIo.c\r
   SdBlockIo.h\r
+  SdDiskInfo.c\r
+  SdDiskInfo.h\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
@@ -60,6 +62,7 @@
   gEfiBlockIoProtocolGuid                      ## BY_START\r
   gEfiBlockIo2ProtocolGuid                     ## BY_START\r
   gEfiEraseBlockProtocolGuid                   ## BY_START\r
+  gEfiDiskInfoProtocolGuid                     ## BY_START\r
   ## TO_START\r
   ## BY_START\r
   gEfiDevicePathProtocolGuid\r