This file implements protocol interfaces: Driver Binding protocol,\r
Block IO protocol and DiskInfo protocol.\r
\r
- Copyright (c) 2009 - 2012, 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) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
\r
**/\r
\r
#include "AtaBus.h"\r
\r
-UINT8 mMorControl;\r
-\r
//\r
// ATA Bus Driver Binding Protocol Instance\r
//\r
NULL, // ControllerNameTable\r
{L'\0', }, // ModelName\r
{NULL, NULL}, // AtaTaskList\r
- {NULL, NULL} // AtaSubTaskList\r
+ {NULL, NULL}, // AtaSubTaskList\r
+ FALSE // Abort\r
};\r
\r
/**\r
) {\r
DelEntry = Entry;\r
Entry = Entry->ForwardLink;\r
- SubTask = ATA_AYNS_SUB_TASK_FROM_ENTRY (DelEntry);\r
+ SubTask = ATA_ASYN_SUB_TASK_FROM_ENTRY (DelEntry);\r
\r
RemoveEntryList (DelEntry);\r
FreeAtaSubTask (SubTask);\r
) {\r
DelEntry = Entry;\r
Entry = Entry->ForwardLink;\r
- AtaTask = ATA_AYNS_TASK_FROM_ENTRY (DelEntry);\r
+ AtaTask = ATA_ASYN_TASK_FROM_ENTRY (DelEntry);\r
\r
RemoveEntryList (DelEntry);\r
FreePool (AtaTask);\r
InitializeListHead (&AtaDevice->AtaTaskList);\r
InitializeListHead (&AtaDevice->AtaSubTaskList);\r
\r
+ //\r
+ // Report Status Code to indicate the ATA device will be enabled\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_ENABLE),\r
+ AtaBusDriverData->ParentDevicePath\r
+ );\r
+\r
//\r
// Try to identify the ATA device via the ATA pass through command.\r
//\r
DEBUG ((EFI_D_INFO, "Successfully Install Storage Security Protocol on the ATA device\n"));\r
}\r
\r
-\r
- if (((mMorControl & 0x01) == 0x01) && ((AtaDevice->IdentifyData->trusted_computing_support & BIT0) != 0)) {\r
- DEBUG ((EFI_D_INFO,\r
- "mMorControl = %x, AtaDevice->IdentifyData->trusted_computing_support & BIT0 = %x\n",\r
- mMorControl,\r
- (AtaDevice->IdentifyData->trusted_computing_support & BIT0)\r
- ));\r
- DEBUG ((EFI_D_INFO, "Try to lock device by sending TPer Reset command...\n"));\r
- InitiateTPerReset(AtaDevice);\r
- }\r
-\r
gBS->OpenProtocol (\r
AtaBusDriverData->Controller,\r
&gEfiAtaPassThruProtocolGuid,\r
if (BlockIo != NULL) {\r
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);\r
} else {\r
+ ASSERT (BlockIo2 != NULL);\r
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (BlockIo2);\r
}\r
\r
return Status;\r
}\r
\r
+ //\r
+ // Test to see if this ATA Pass Thru Protocol is for a LOGICAL channel\r
+ //\r
+ if ((AtaPassThru->Mode->Attributes & EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL) == 0) {\r
+ //\r
+ // Close the I/O Abstraction(s) used to perform the supported test\r
+ //\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiAtaPassThruProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
//\r
// Test RemainingDevicePath is valid or not.\r
//\r
if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {\r
Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // Close the I/O Abstraction(s) used to perform the supported test\r
+ //\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiAtaPassThruProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
return Status;\r
}\r
}\r
@retval EFI_SUCCESS The device was started.\r
@retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
- @retval Others The driver failded to start the device.\r
+ @retval Others The driver failed to start the device.\r
\r
**/\r
EFI_STATUS\r
return Status;\r
}\r
\r
+ //\r
+ // Report Status Code to indicate ATA bus starts\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_INIT),\r
+ ParentDevicePath\r
+ );\r
+\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiAtaPassThruProtocolGuid,\r
}\r
}\r
\r
+ //\r
+ // Report Status Code to indicate detecting devices on bus\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_DETECT),\r
+ ParentDevicePath\r
+ );\r
+\r
if (RemainingDevicePath == NULL) {\r
Port = 0xFFFF;\r
while (TRUE) {\r
@param[in, out] Token A pointer to the token associated with the transaction.\r
@param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
@param[out] Buffer A pointer to the destination/source buffer for the data.\r
- @param[in] IsBlockIo2 Indicate the calling is from BlockIO or BlockIO2. TURE is\r
+ @param[in] IsBlockIo2 Indicate the calling is from BlockIO or BlockIO2. TRUE is\r
from BlockIO2, FALSE is for BlockIO.\r
@param[in] IsWrite Indicates whether it is a write operation.\r
\r
@retval EFI_WRITE_PROTECTED The device can not be read/written to.\r
@retval EFI_DEVICE_ERROR The device reported an error while performing the read/write.\r
@retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
+ @retval EFI_MEDIA_CHANGED The MediaId does not match the current device.\r
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
@retval EFI_INVALID_PARAMETER The read/write request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
}\r
\r
if (BufferSize == 0) {\r
+ if ((Token != NULL) && (Token->Event != NULL)) {\r
+ Token->TransactionStatus = EFI_SUCCESS;\r
+ gBS->SignalEvent (Token->Event);\r
+ }\r
return EFI_SUCCESS;\r
}\r
\r
@retval EFI_SUCCESS The data was read correctly from the device.\r
@retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
@retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
+ @retval EFI_MEDIA_CHANGED The MediaId does not match the current device.\r
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
@retval EFI_WRITE_PROTECTED The device can not be written to.\r
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
@retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
+ @retval EFI_MEDIA_CHANGED The MediaId does not match the current device.\r
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
\r
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
\r
+ AtaTerminateNonBlockingTask (AtaDevice);\r
+\r
Status = ResetAtaDevice (AtaDevice);\r
\r
if (EFI_ERROR (Status)) {\r
@retval EFI_WRITE_PROTECTED The device can not be written to.\r
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
@retval EFI_NO_MEDIA There is no media in the device.\r
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
+ @retval EFI_MEDIA_CHANGED The MediaId does not match the current device.\r
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
ATA_DEVICE *Private;\r
EFI_TPL OldTpl;\r
\r
- DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Read"));\r
+ DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Read\n"));\r
if ((PayloadBuffer == NULL || PayloadTransferSize == NULL) && PayloadBufferSize != 0) {\r
return EFI_INVALID_PARAMETER;\r
}\r
ATA_DEVICE *Private;\r
EFI_TPL OldTpl;\r
\r
- DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Send"));\r
+ DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Send\n"));\r
if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
)\r
{\r
EFI_STATUS Status;\r
- UINTN DataSize;\r
\r
//\r
// Install driver model protocol(s).\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
- //\r
- // Get the MorControl bit.\r
- //\r
- DataSize = sizeof (mMorControl);\r
- Status = gRT->GetVariable (\r
- MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,\r
- &gEfiMemoryOverwriteControlDataGuid,\r
- NULL,\r
- &DataSize,\r
- &mMorControl\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_INFO, "AtaBus:gEfiMemoryOverwriteControlDataGuid doesn't exist!!***\n"));\r
- mMorControl = 0;\r
- Status = EFI_SUCCESS;\r
- } else {\r
- DEBUG ((EFI_D_INFO, "AtaBus:Get the gEfiMemoryOverwriteControlDataGuid = %x!!***\n", mMorControl));\r
- }\r
-\r
return Status;\r
}\r
\r
-/**\r
- Send TPer Reset command to reset eDrive to lock all protected bands.\r
- Typically, there are 2 mechanism for resetting eDrive. They are:\r
- 1. TPer Reset through IEEE 1667 protocol.\r
- 2. TPer Reset through native TCG protocol.\r
- This routine will detect what protocol the attached eDrive comform to, TCG or\r
- IEEE 1667 protocol. Then send out TPer Reset command separately.\r
-\r
- @param[in] AtaDevice ATA_DEVICE pointer.\r
-\r
-**/\r
-VOID\r
-InitiateTPerReset (\r
- IN ATA_DEVICE *AtaDevice\r
- )\r
-{\r
-\r
- EFI_STATUS Status;\r
- UINT8 *Buffer;\r
- UINTN XferSize;\r
- UINTN Len;\r
- UINTN Index;\r
- BOOLEAN TcgFlag;\r
- BOOLEAN IeeeFlag;\r
- EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Ssp;\r
- SUPPORTED_SECURITY_PROTOCOLS_PARAMETER_DATA *Data;\r
-\r
- Buffer = NULL;\r
- TcgFlag = FALSE;\r
- IeeeFlag = FALSE;\r
- Ssp = &AtaDevice->StorageSecurity;\r
- BlockIo = &AtaDevice->BlockIo;\r
-\r
- //\r
- // ATA8-ACS 7.57.6.1 indicates the Transfer Length field requirements a multiple of 512.\r
- // If the length of the TRUSTED RECEIVE parameter data is greater than the Transfer Length,\r
- // then the device shall return the TRUSTED RECEIVE parameter data truncated to the requested Transfer Length.\r
- //\r
- Len = ROUNDUP512(sizeof(SUPPORTED_SECURITY_PROTOCOLS_PARAMETER_DATA));\r
- Buffer = AllocateZeroPool(Len);\r
-\r
- if (Buffer == NULL) {\r
- return;\r
- }\r
-\r
- //\r
- // When the Security Protocol field is set to 00h, and SP Specific is set to 0000h in a TRUSTED RECEIVE\r
- // command, the device basic information data shall be returned.\r
- //\r
- Status = Ssp->ReceiveData (\r
- Ssp,\r
- BlockIo->Media->MediaId,\r
- 100000000, // Timeout 10-sec\r
- 0, // SecurityProtocol\r
- 0, // SecurityProtocolSpecifcData\r
- Len, // PayloadBufferSize,\r
- Buffer, // PayloadBuffer\r
- &XferSize\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto Exit;\r
- }\r
-\r
- //\r
- // In returned data, the ListLength field indicates the total length, in bytes,\r
- // of the supported security protocol list.\r
- //\r
- Data = (SUPPORTED_SECURITY_PROTOCOLS_PARAMETER_DATA*)Buffer;\r
- Len = ROUNDUP512(sizeof (SUPPORTED_SECURITY_PROTOCOLS_PARAMETER_DATA) +\r
- (Data->SupportedSecurityListLength[0] << 8) +\r
- (Data->SupportedSecurityListLength[1])\r
- );\r
-\r
- //\r
- // Free original buffer and allocate new buffer.\r
- //\r
- FreePool(Buffer);\r
- Buffer = AllocateZeroPool(Len);\r
- if (Buffer == NULL) {\r
- return;\r
- }\r
-\r
- //\r
- // Read full supported security protocol list from device.\r
- //\r
- Status = Ssp->ReceiveData (\r
- Ssp,\r
- BlockIo->Media->MediaId,\r
- 100000000, // Timeout 10-sec\r
- 0, // SecurityProtocol\r
- 0, // SecurityProtocolSpecifcData\r
- Len, // PayloadBufferSize,\r
- Buffer, // PayloadBuffer\r
- &XferSize\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- goto Exit;\r
- }\r
-\r
- Data = (SUPPORTED_SECURITY_PROTOCOLS_PARAMETER_DATA*)Buffer;\r
- Len = (Data->SupportedSecurityListLength[0] << 8) + Data->SupportedSecurityListLength[1];\r
-\r
- //\r
- // Iterate full supported security protocol list to check if TCG or IEEE 1667 protocol\r
- // is supported.\r
- //\r
- for (Index = 0; Index < Len; Index++) {\r
- if (Data->SupportedSecurityProtocol[Index] == SECURITY_PROTOCOL_TCG) {\r
- //\r
- // Found a TCG device.\r
- //\r
- TcgFlag = TRUE;\r
- DEBUG ((EFI_D_INFO, "This device is a TCG protocol device\n"));\r
- break;\r
- }\r
-\r
- if (Data->SupportedSecurityProtocol[Index] == SECURITY_PROTOCOL_IEEE1667) {\r
- //\r
- // Found a IEEE 1667 device.\r
- //\r
- IeeeFlag = TRUE;\r
- DEBUG ((EFI_D_INFO, "This device is a IEEE 1667 protocol device\n"));\r
- break;\r
- }\r
- }\r
-\r
- if (!TcgFlag && !IeeeFlag) {\r
- DEBUG ((EFI_D_INFO, "Neither a TCG nor IEEE 1667 protocol device is found\n"));\r
- goto Exit;\r
- }\r
-\r
- if (TcgFlag) {\r
- //\r
- // As long as TCG protocol is supported, send out a TPer Reset\r
- // TCG command to the device via the TrustedSend command with a non-zero Transfer Length.\r
- //\r
- Status = Ssp->SendData (\r
- Ssp,\r
- BlockIo->Media->MediaId,\r
- 100000000, // Timeout 10-sec\r
- SECURITY_PROTOCOL_TCG, // SecurityProtocol\r
- 0x0400, // SecurityProtocolSpecifcData\r
- 512, // PayloadBufferSize,\r
- Buffer // PayloadBuffer\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_INFO, "Send TPer Reset Command Successfully !\n"));\r
- } else {\r
- DEBUG ((EFI_D_INFO, "Send TPer Reset Command Fail !\n"));\r
- }\r
- }\r
-\r
- if (IeeeFlag) {\r
- //\r
- // TBD : Perform a TPer Reset via IEEE 1667 Protocol\r
- //\r
- DEBUG ((EFI_D_INFO, "IEEE 1667 Protocol didn't support yet!\n"));\r
- }\r
-\r
-Exit:\r
-\r
- if (Buffer != NULL) {\r
- FreePool(Buffer);\r
- }\r
-}\r