--- /dev/null
+/** @file\r
+ The EFI_SD_MMC_PASS_THRU_PROTOCOL provides the ability to send SD/MMC Commands\r
+ to any SD/MMC device attached to the SD compatible pci host controller.\r
+\r
+ Copyright (c) 2015, 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_MMC_PASS_THRU_H__\r
+#define __SD_MMC_PASS_THRU_H__\r
+\r
+#define EFI_SD_MMC_PASS_THRU_PROTOCOL_GUID \\r
+ { \\r
+ 0x716ef0d9, 0xff83, 0x4f69, {0x81, 0xe9, 0x51, 0x8b, 0xd3, 0x9a, 0x8e, 0x70 } \\r
+ }\r
+\r
+typedef struct _EFI_SD_MMC_PASS_THRU_PROTOCOL EFI_SD_MMC_PASS_THRU_PROTOCOL;\r
+\r
+typedef enum {\r
+ SdMmcCommandTypeBc, // Broadcast commands, no response\r
+ SdMmcCommandTypeBcr, // Broadcast commands with response\r
+ SdMmcCommandTypeAc, // Addressed(point-to-point) commands\r
+ SdMmcCommandTypeAdtc // Addressed(point-to-point) data transfer commands\r
+} EFI_SD_MMC_COMMAND_TYPE;\r
+\r
+typedef enum {\r
+ SdMmcResponseTypeR1,\r
+ SdMmcResponseTypeR1b,\r
+ SdMmcResponseTypeR2,\r
+ SdMmcResponseTypeR3,\r
+ SdMmcResponseTypeR4,\r
+ SdMmcResponseTypeR5,\r
+ SdMmcResponseTypeR5b,\r
+ SdMmcResponseTypeR6,\r
+ SdMmcResponseTypeR7\r
+} EFI_SD_MMC_RESPONSE_TYPE;\r
+\r
+typedef struct _EFI_SD_MMC_COMMAND_BLOCK {\r
+ UINT16 CommandIndex;\r
+ UINT32 CommandArgument;\r
+ UINT32 CommandType; // One of the EFI_SD_MMC_COMMAND_TYPE values\r
+ UINT32 ResponseType; // One of the EFI_SD_MMC_RESPONSE_TYPE values\r
+} EFI_SD_MMC_COMMAND_BLOCK;\r
+\r
+typedef struct _EFI_SD_MMC_STATUS_BLOCK {\r
+ UINT32 Resp0;\r
+ UINT32 Resp1;\r
+ UINT32 Resp2;\r
+ UINT32 Resp3;\r
+} EFI_SD_MMC_STATUS_BLOCK;\r
+\r
+typedef struct _EFI_SD_MMC_PASS_THRU_COMMAND_PACKET {\r
+ UINT64 Timeout;\r
+ EFI_SD_MMC_COMMAND_BLOCK *SdMmcCmdBlk;\r
+ EFI_SD_MMC_STATUS_BLOCK *SdMmcStatusBlk;\r
+ VOID *InDataBuffer;\r
+ VOID *OutDataBuffer;\r
+ UINT32 InTransferLength;\r
+ UINT32 OutTransferLength;\r
+ EFI_STATUS TransactionStatus;\r
+} EFI_SD_MMC_PASS_THRU_COMMAND_PACKET;\r
+\r
+/**\r
+ Sends SD command to an SD card that is attached to the SD controller.\r
+\r
+ The PassThru() function sends the SD command specified by Packet to the SD card\r
+ specified by Slot.\r
+\r
+ If Packet is successfully sent to the SD card, then EFI_SUCCESS is returned.\r
+\r
+ If a device error occurs while sending the Packet, then EFI_DEVICE_ERROR is returned.\r
+\r
+ If Slot is not in a valid range for the SD controller, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If Packet defines a data command but both InDataBuffer and OutDataBuffer are NULL,\r
+ EFI_INVALID_PARAMETER is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] Slot The slot number of the SD card to send the command to.\r
+ @param[in,out] Packet A pointer to the SD command data structure.\r
+ @param[in] Event If Event is NULL, blocking I/O is performed. If Event is\r
+ not NULL, then nonblocking I/O is performed, and Event\r
+ will be signaled when the Packet completes.\r
+\r
+ @retval EFI_SUCCESS The SD Command Packet was sent by the host.\r
+ @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SD\r
+ command Packet.\r
+ @retval EFI_INVALID_PARAMETER Packet, Slot, or the contents of the Packet is invalid.\r
+ @retval EFI_INVALID_PARAMETER Packet defines a data command but both InDataBuffer and\r
+ OutDataBuffer are NULL.\r
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.\r
+ @retval EFI_UNSUPPORTED The command described by the SD Command Packet is not\r
+ supported by the host controller.\r
+ @retval EFI_BAD_BUFFER_SIZE The InTransferLength or OutTransferLength exceeds the\r
+ limit supported by SD card ( i.e. if the number of bytes\r
+ exceed the Last LBA).\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_MMC_PASS_THRU_PASSTHRU) (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN UINT8 Slot,\r
+ IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,\r
+ IN EFI_EVENT Event OPTIONAL\r
+);\r
+\r
+/**\r
+ Used to retrieve next slot numbers supported by the SD controller. The function\r
+ returns information about all available slots (populated or not-populated).\r
+\r
+ The GetNextSlot() function retrieves the next slot number on an SD controller.\r
+ If on input Slot is 0xFF, then the slot number of the first slot on the SD controller\r
+ is returned.\r
+\r
+ If Slot is a slot number that was returned on a previous call to GetNextSlot(), then\r
+ the slot number of the next slot on the SD controller is returned.\r
+\r
+ If Slot is not 0xFF and Slot was not returned on a previous call to GetNextSlot(),\r
+ EFI_INVALID_PARAMETER is returned.\r
+\r
+ If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND\r
+ is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in,out] Slot On input, a pointer to a slot number on the SD controller.\r
+ On output, a pointer to the next slot number on the SD controller.\r
+ An input value of 0xFF retrieves the first slot number on the SD\r
+ controller.\r
+\r
+ @retval EFI_SUCCESS The next slot number on the SD controller was returned in Slot.\r
+ @retval EFI_NOT_FOUND There are no more slots on this SD controller.\r
+ @retval EFI_INVALID_PARAMETER Slot is not 0xFF and Slot was not returned on a previous call\r
+ to GetNextSlot().\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_MMC_PASS_THRU_GET_NEXT_SLOT) (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN OUT UINT8 *Slot\r
+);\r
+\r
+/**\r
+ Used to allocate and build a device path node for an SD card on the SD controller.\r
+\r
+ The BuildDevicePath() function allocates and builds a single device node for the SD\r
+ card specified by Slot.\r
+\r
+ If the SD card specified by Slot is not present on the SD controller, then EFI_NOT_FOUND\r
+ is returned.\r
+\r
+ If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r
+\r
+ If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES\r
+ is returned.\r
+\r
+ Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of\r
+ DevicePath are initialized to describe the SD card specified by Slot, and EFI_SUCCESS is\r
+ returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] Slot Specifies the slot number of the SD card for which a device\r
+ path node is to be allocated and built.\r
+ @param[in,out] DevicePath A pointer to a single device path node that describes the SD\r
+ card specified by Slot. This function is responsible for\r
+ allocating the buffer DevicePath with the boot service\r
+ AllocatePool(). It is the caller's responsibility to free\r
+ DevicePath when the caller is finished with DevicePath.\r
+\r
+ @retval EFI_SUCCESS The device path node that describes the SD card specified by\r
+ Slot was allocated and returned in DevicePath.\r
+ @retval EFI_NOT_FOUND The SD card specified by Slot does not exist on the SD controller.\r
+ @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_MMC_PASS_THRU_BUILD_DEVICE_PATH) (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN UINT8 Slot,\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
+);\r
+\r
+/**\r
+ This function retrieves an SD card slot number based on the input device path.\r
+\r
+ The GetSlotNumber() function retrieves slot number for the SD card specified by\r
+ the DevicePath node. If DevicePath is NULL, EFI_INVALID_PARAMETER is returned.\r
+\r
+ If DevicePath is not a device path node type that the SD Pass Thru driver supports,\r
+ EFI_UNSUPPORTED is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] DevicePath A pointer to the device path node that describes a SD\r
+ card on the SD controller.\r
+ @param[out] Slot On return, points to the slot number of an SD card on\r
+ the SD controller.\r
+\r
+ @retval EFI_SUCCESS SD card slot number is returned in Slot.\r
+ @retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL.\r
+ @retval EFI_UNSUPPORTED DevicePath is not a device path node type that the SD\r
+ Pass Thru driver supports.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_MMC_PASS_THRU_GET_SLOT_NUMBER) (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ OUT UINT8 *Slot\r
+);\r
+\r
+/**\r
+ Resets an SD card that is connected to the SD controller.\r
+\r
+ The ResetDevice() function resets the SD card specified by Slot.\r
+\r
+ If this SD controller does not support a device reset operation, EFI_UNSUPPORTED is\r
+ returned.\r
+\r
+ If Slot is not in a valid slot number for this SD controller, EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the device reset operation is completed, EFI_SUCCESS is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.\r
+ @param[in] Slot Specifies the slot number of the SD card to be reset.\r
+\r
+ @retval EFI_SUCCESS The SD card specified by Slot was reset.\r
+ @retval EFI_UNSUPPORTED The SD controller does not support a device reset operation.\r
+ @retval EFI_INVALID_PARAMETER Slot number is invalid.\r
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.\r
+ @retval EFI_DEVICE_ERROR The reset command failed due to a device error\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SD_MMC_PASS_THRU_RESET_DEVICE) (\r
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,\r
+ IN UINT8 Slot\r
+);\r
+\r
+struct _EFI_SD_MMC_PASS_THRU_PROTOCOL {\r
+ UINT32 IoAlign;\r
+ EFI_SD_MMC_PASS_THRU_PASSTHRU PassThru;\r
+ EFI_SD_MMC_PASS_THRU_GET_NEXT_SLOT GetNextSlot;\r
+ EFI_SD_MMC_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;\r
+ EFI_SD_MMC_PASS_THRU_GET_SLOT_NUMBER GetSlotNumber;\r
+ EFI_SD_MMC_PASS_THRU_RESET_DEVICE ResetDevice;\r
+};\r
+\r
+extern EFI_GUID gEfiSdMmcPassThruProtocolGuid;\r
+\r
+#endif\r