/** @file\r
This file implements protocol interfaces for ATA bus driver.\r
- \r
+\r
This file implements protocol interfaces: Driver Binding protocol,\r
Block IO protocol and DiskInfo protocol.\r
- \r
- Copyright (c) 2009 - 2011, 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
// ATA Bus Driver Binding Protocol Instance\r
//\r
-EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding = {\r
+EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding = {\r
AtaBusDriverBindingSupported,\r
AtaBusDriverBindingStart,\r
AtaBusDriverBindingStop,\r
//\r
// Template for ATA Child Device.\r
//\r
-ATA_DEVICE gAtaDeviceTemplate = {\r
- ATA_DEVICE_SIGNATURE, // Signature\r
- NULL, // Handle\r
+ATA_DEVICE gAtaDeviceTemplate = {\r
+ ATA_DEVICE_SIGNATURE, // Signature\r
+ NULL, // Handle\r
{ // BlockIo\r
EFI_BLOCK_IO_PROTOCOL_REVISION,\r
NULL,\r
FALSE, // LogicPartition\r
FALSE, // ReadOnly\r
FALSE, // WritingCache\r
- 0x200, // BlockSize \r
+ 0x200, // BlockSize\r
0, // IoAlign\r
0, // LastBlock\r
0, // LowestAlignedLba\r
AtaDiskInfoSenseData,\r
AtaDiskInfoWhichIde\r
},\r
- NULL, // DevicePath\r
+ NULL, // DevicePath\r
{\r
AtaStorageSecurityReceiveData,\r
AtaStorageSecuritySendData\r
},\r
- NULL, // AtaBusDriverData\r
- 0, // Port\r
- 0, // PortMultiplierPort\r
- { 0, }, // Packet\r
- {{ 0}, }, // Acb\r
- NULL, // Asb\r
- FALSE, // UdmaValid\r
- FALSE, // Lba48Bit\r
- NULL, // IdentifyData\r
- NULL, // ControllerNameTable\r
- {L'\0', }, // ModelName\r
- {NULL, NULL} // AtaTaskList\r
+ NULL, // AtaBusDriverData\r
+ 0, // Port\r
+ 0, // PortMultiplierPort\r
+ { 0, }, // Packet\r
+ {\r
+ { 0 },\r
+ }, // Acb\r
+ NULL, // Asb\r
+ FALSE, // UdmaValid\r
+ FALSE, // Lba48Bit\r
+ NULL, // IdentifyData\r
+ NULL, // ControllerNameTable\r
+ { L'\0', }, // ModelName\r
+ { NULL, NULL }, // AtaTaskList\r
+ { NULL, NULL }, // AtaSubTaskList\r
+ FALSE // Abort\r
};\r
\r
/**\r
**/\r
VOID *\r
AllocateAlignedBuffer (\r
- IN ATA_DEVICE *AtaDevice,\r
- IN UINTN BufferSize\r
+ IN ATA_DEVICE *AtaDevice,\r
+ IN UINTN BufferSize\r
)\r
{\r
return AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), AtaDevice->AtaBusDriverData->AtaPassThru->Mode->IoAlign);\r
**/\r
VOID\r
FreeAlignedBuffer (\r
- IN VOID *Buffer,\r
- IN UINTN BufferSize\r
+ IN VOID *Buffer,\r
+ IN UINTN BufferSize\r
)\r
{\r
if (Buffer != NULL) {\r
- FreePages (Buffer, EFI_SIZE_TO_PAGES (BufferSize));\r
+ FreeAlignedPages (Buffer, EFI_SIZE_TO_PAGES (BufferSize));\r
}\r
}\r
\r
-\r
/**\r
Release all the resources allocated for the ATA device.\r
\r
IN ATA_DEVICE *AtaDevice\r
)\r
{\r
- ATA_BUS_ASYN_TASK *Task;\r
- LIST_ENTRY *Entry;\r
- LIST_ENTRY *DelEntry;\r
- EFI_TPL OldTpl;\r
+ ATA_BUS_ASYN_SUB_TASK *SubTask;\r
+ ATA_BUS_ASYN_TASK *AtaTask;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *DelEntry;\r
+ EFI_TPL OldTpl;\r
\r
FreeUnicodeStringTable (AtaDevice->ControllerNameTable);\r
- FreeAlignedBuffer (AtaDevice->Asb, sizeof (*AtaDevice->Asb));\r
- FreeAlignedBuffer (AtaDevice->IdentifyData, sizeof (*AtaDevice->IdentifyData));\r
+ FreeAlignedBuffer (AtaDevice->Asb, sizeof (EFI_ATA_STATUS_BLOCK));\r
+ FreeAlignedBuffer (AtaDevice->IdentifyData, sizeof (ATA_IDENTIFY_DATA));\r
if (AtaDevice->DevicePath != NULL) {\r
FreePool (AtaDevice->DevicePath);\r
}\r
+\r
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+ if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {\r
+ //\r
+ // Free the Subtask list.\r
+ //\r
+ for (Entry = AtaDevice->AtaSubTaskList.ForwardLink;\r
+ Entry != (&AtaDevice->AtaSubTaskList);\r
+ )\r
+ {\r
+ DelEntry = Entry;\r
+ Entry = Entry->ForwardLink;\r
+ SubTask = ATA_ASYN_SUB_TASK_FROM_ENTRY (DelEntry);\r
+\r
+ RemoveEntryList (DelEntry);\r
+ FreeAtaSubTask (SubTask);\r
+ }\r
+ }\r
+\r
if (!IsListEmpty (&AtaDevice->AtaTaskList)) {\r
//\r
// Free the Subtask list.\r
//\r
- for(Entry = (&AtaDevice->AtaTaskList)->ForwardLink; \r
- Entry != (&AtaDevice->AtaTaskList);\r
- ) {\r
+ for (Entry = AtaDevice->AtaTaskList.ForwardLink;\r
+ Entry != (&AtaDevice->AtaTaskList);\r
+ )\r
+ {\r
DelEntry = Entry;\r
Entry = Entry->ForwardLink;\r
- Task = ATA_AYNS_TASK_FROM_ENTRY (DelEntry);\r
- \r
+ AtaTask = ATA_ASYN_TASK_FROM_ENTRY (DelEntry);\r
+\r
RemoveEntryList (DelEntry);\r
- FreeAtaSubTask (Task);\r
+ FreePool (AtaTask);\r
}\r
}\r
+\r
gBS->RestoreTPL (OldTpl);\r
FreePool (AtaDevice);\r
}\r
\r
-\r
/**\r
Registers an ATA device.\r
\r
This function allocates an ATA device structure for the ATA device specified by\r
- Port and PortMultiplierPort if the ATA device is identified as a valid one. \r
+ Port and PortMultiplierPort if the ATA device is identified as a valid one.\r
Then it will create child handle and install Block IO and Disk Info protocol on\r
it.\r
\r
**/\r
EFI_STATUS\r
RegisterAtaDevice (\r
- IN OUT ATA_BUS_DRIVER_DATA *AtaBusDriverData,\r
- IN UINT16 Port,\r
- IN UINT16 PortMultiplierPort\r
+ IN OUT ATA_BUS_DRIVER_DATA *AtaBusDriverData,\r
+ IN UINT16 Port,\r
+ IN UINT16 PortMultiplierPort\r
)\r
{\r
- EFI_STATUS Status;\r
- ATA_DEVICE *AtaDevice;\r
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;\r
- EFI_HANDLE DeviceHandle;\r
-\r
- AtaDevice = NULL;\r
- NewDevicePathNode = NULL;\r
- DevicePath = NULL;\r
+ EFI_STATUS Status;\r
+ ATA_DEVICE *AtaDevice;\r
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;\r
+ EFI_HANDLE DeviceHandle;\r
+\r
+ AtaDevice = NULL;\r
+ NewDevicePathNode = NULL;\r
+ DevicePath = NULL;\r
RemainingDevicePath = NULL;\r
\r
//\r
- // Build device path \r
+ // Build device path\r
//\r
AtaPassThru = AtaBusDriverData->AtaPassThru;\r
- Status = AtaPassThru->BuildDevicePath (AtaPassThru, Port, PortMultiplierPort, &NewDevicePathNode);\r
+ Status = AtaPassThru->BuildDevicePath (AtaPassThru, Port, PortMultiplierPort, &NewDevicePathNode);\r
if (EFI_ERROR (Status)) {\r
goto Done;\r
}\r
goto Done;\r
}\r
\r
- DeviceHandle = NULL;\r
+ DeviceHandle = NULL;\r
RemainingDevicePath = DevicePath;\r
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);\r
- if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd(RemainingDevicePath)) {\r
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);\r
+ if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd (RemainingDevicePath)) {\r
Status = EFI_ALREADY_STARTED;\r
FreePool (DevicePath);\r
goto Done;\r
//\r
// Allocate ATA device from the template.\r
//\r
- AtaDevice = AllocateCopyPool (sizeof (gAtaDeviceTemplate), &gAtaDeviceTemplate);\r
+ AtaDevice = AllocateCopyPool (sizeof (ATA_DEVICE), &gAtaDeviceTemplate);\r
if (AtaDevice == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
AtaDevice->DevicePath = DevicePath;\r
AtaDevice->Port = Port;\r
AtaDevice->PortMultiplierPort = PortMultiplierPort;\r
- AtaDevice->Asb = AllocateAlignedBuffer (AtaDevice, sizeof (*AtaDevice->Asb));\r
+ AtaDevice->Asb = AllocateAlignedBuffer (AtaDevice, sizeof (EFI_ATA_STATUS_BLOCK));\r
if (AtaDevice->Asb == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AtaDevice->IdentifyData = AllocateAlignedBuffer (AtaDevice, sizeof (*AtaDevice->IdentifyData));\r
+\r
+ AtaDevice->IdentifyData = AllocateAlignedBuffer (AtaDevice, sizeof (ATA_IDENTIFY_DATA));\r
if (AtaDevice->IdentifyData == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
// Initial Ata Task List\r
//\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
+ // Try to identify the ATA device via the ATA pass through command.\r
//\r
Status = DiscoverAtaDevice (AtaDevice);\r
if (EFI_ERROR (Status)) {\r
// If yes, then install Storage Security Protocol at the ata device handle.\r
//\r
if ((AtaDevice->IdentifyData->trusted_computing_support & BIT0) != 0) {\r
- DEBUG ((EFI_D_INFO, "Found TCG support in Port %x PortMultiplierPort %x\n", Port, PortMultiplierPort));\r
+ DEBUG ((DEBUG_INFO, "Found TCG support in Port %x PortMultiplierPort %x\n", Port, PortMultiplierPort));\r
Status = gBS->InstallProtocolInterface (\r
&AtaDevice->Handle,\r
&gEfiStorageSecurityCommandProtocolGuid,\r
if (EFI_ERROR (Status)) {\r
goto Done;\r
}\r
+\r
+ DEBUG ((DEBUG_INFO, "Successfully Install Storage Security Protocol on the ATA device\n"));\r
}\r
\r
gBS->OpenProtocol (\r
AtaBusDriverData->Controller,\r
&gEfiAtaPassThruProtocolGuid,\r
- (VOID **) &AtaPassThru,\r
+ (VOID **)&AtaPassThru,\r
AtaBusDriverData->DriverBindingHandle,\r
AtaDevice->Handle,\r
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
}\r
\r
if (EFI_ERROR (Status) && (AtaDevice != NULL)) {\r
- ReleaseAtaResources (AtaDevice); \r
+ ReleaseAtaResources (AtaDevice);\r
DEBUG ((DEBUG_ERROR | DEBUG_INIT, "Failed to initialize Port %x PortMultiplierPort %x, status = %r\n", Port, PortMultiplierPort, Status));\r
}\r
+\r
return Status;\r
}\r
\r
-\r
/**\r
Unregisters an ATA device.\r
\r
- This function removes the protocols installed on the controller handle and \r
- frees the resources allocated for the ATA device. \r
+ This function removes the protocols installed on the controller handle and\r
+ frees the resources allocated for the ATA device.\r
\r
@param This The pointer to EFI_DRIVER_BINDING_PROTOCOL instance.\r
@param Controller The controller handle of the ATA device.\r
**/\r
EFI_STATUS\r
UnregisterAtaDevice (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN EFI_HANDLE Handle\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;\r
- ATA_DEVICE *AtaDevice;\r
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *StorageSecurity;\r
+ EFI_STATUS Status;\r
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+ EFI_BLOCK_IO2_PROTOCOL *BlockIo2;\r
+ ATA_DEVICE *AtaDevice;\r
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
+ EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *StorageSecurity;\r
\r
- BlockIo2 = NULL;\r
- BlockIo = NULL;\r
+ BlockIo2 = NULL;\r
+ BlockIo = NULL;\r
\r
Status = gBS->OpenProtocol (\r
Handle,\r
&gEfiBlockIoProtocolGuid,\r
- (VOID **) &BlockIo,\r
+ (VOID **)&BlockIo,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
Status = gBS->OpenProtocol (\r
Handle,\r
&gEfiBlockIo2ProtocolGuid,\r
- (VOID **) &BlockIo2,\r
+ (VOID **)&BlockIo2,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\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
\r
//\r
// Close the child handle\r
\r
if (EFI_ERROR (Status)) {\r
gBS->OpenProtocol (\r
- Controller,\r
- &gEfiAtaPassThruProtocolGuid,\r
- (VOID **) &AtaPassThru,\r
- This->DriverBindingHandle,\r
- Handle,\r
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
- );\r
+ Controller,\r
+ &gEfiAtaPassThruProtocolGuid,\r
+ (VOID **)&AtaPassThru,\r
+ This->DriverBindingHandle,\r
+ Handle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
return Status;\r
}\r
\r
Status = gBS->OpenProtocol (\r
Handle,\r
&gEfiStorageSecurityCommandProtocolGuid,\r
- (VOID **) &StorageSecurity,\r
+ (VOID **)&StorageSecurity,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
);\r
if (EFI_ERROR (Status)) {\r
gBS->OpenProtocol (\r
- Controller,\r
- &gEfiAtaPassThruProtocolGuid,\r
- (VOID **) &AtaPassThru,\r
- This->DriverBindingHandle,\r
- Handle,\r
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
- );\r
- return Status;\r
+ Controller,\r
+ &gEfiAtaPassThruProtocolGuid,\r
+ (VOID **)&AtaPassThru,\r
+ This->DriverBindingHandle,\r
+ Handle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ return Status;\r
}\r
}\r
\r
ReleaseAtaResources (AtaDevice);\r
- return Status;\r
+ return EFI_SUCCESS;\r
}\r
\r
-\r
-\r
/**\r
- Tests to see if this driver supports a given controller. If a child device is provided, \r
+ Tests to see if this driver supports a given controller. If a child device is provided,\r
it further tests to see if this driver supports creating a handle for the specified child device.\r
\r
- This function checks to see if the driver specified by This supports the device specified by \r
- ControllerHandle. Drivers will typically use the device path attached to \r
- ControllerHandle and/or the services from the bus I/O abstraction attached to \r
- ControllerHandle to determine if the driver supports ControllerHandle. This function \r
- may be called many times during platform initialization. In order to reduce boot times, the tests \r
- performed by this function must be very small, and take as little time as possible to execute. This \r
- function must not change the state of any hardware devices, and this function must be aware that the \r
- device specified by ControllerHandle may already be managed by the same driver or a \r
- different driver. This function must match its calls to AllocatePages() with FreePages(), \r
- AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). \r
- Since ControllerHandle may have been previously started by the same driver, if a protocol is \r
- already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
+ This function checks to see if the driver specified by This supports the device specified by\r
+ ControllerHandle. Drivers will typically use the device path attached to\r
+ ControllerHandle and/or the services from the bus I/O abstraction attached to\r
+ ControllerHandle to determine if the driver supports ControllerHandle. This function\r
+ may be called many times during platform initialization. In order to reduce boot times, the tests\r
+ performed by this function must be very small, and take as little time as possible to execute. This\r
+ function must not change the state of any hardware devices, and this function must be aware that the\r
+ device specified by ControllerHandle may already be managed by the same driver or a\r
+ different driver. This function must match its calls to AllocatePages() with FreePages(),\r
+ AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
+ Since ControllerHandle may have been previously started by the same driver, if a protocol is\r
+ already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
to guarantee the state of ControllerHandle is not modified by this function.\r
\r
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
- @param[in] ControllerHandle The handle of the controller to test. This handle \r
- must support a protocol interface that supplies \r
+ @param[in] ControllerHandle The handle of the controller to test. This handle\r
+ must support a protocol interface that supplies\r
an I/O abstraction to the driver.\r
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
- parameter is ignored by device drivers, and is optional for bus \r
- drivers. For bus drivers, if this parameter is not NULL, then \r
- the bus driver must determine if the bus controller specified \r
- by ControllerHandle and the child controller specified \r
- by RemainingDevicePath are both supported by this \r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
+ parameter is ignored by device drivers, and is optional for bus\r
+ drivers. For bus drivers, if this parameter is not NULL, then\r
+ the bus driver must determine if the bus controller specified\r
+ by ControllerHandle and the child controller specified\r
+ by RemainingDevicePath are both supported by this\r
bus driver.\r
\r
@retval EFI_SUCCESS The device specified by ControllerHandle and\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
- UINT16 Port;\r
- UINT16 PortMultiplierPort;\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
+ UINT16 Port;\r
+ UINT16 PortMultiplierPort;\r
\r
//\r
// Test EFI_ATA_PASS_THRU_PROTOCOL on controller handle.\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiAtaPassThruProtocolGuid,\r
- (VOID **) &AtaPassThru,\r
+ (VOID **)&AtaPassThru,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_BY_DRIVER\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
// 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
+ Controller,\r
+ &gEfiAtaPassThruProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
\r
//\r
// Open the EFI Device Path protocol needed to perform the supported test\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiDevicePathProtocolGuid,\r
- (VOID **) &ParentDevicePath,\r
+ (VOID **)&ParentDevicePath,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
return Status;\r
}\r
\r
-\r
/**\r
Starts a device controller or a bus controller.\r
\r
The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
- As a result, much of the error checking on the parameters to Start() has been moved into this \r
- common boot service. It is legal to call Start() from other locations, \r
+ As a result, much of the error checking on the parameters to Start() has been moved into this\r
+ common boot service. It is legal to call Start() from other locations,\r
but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
1. ControllerHandle must be a valid EFI_HANDLE.\r
2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
EFI_DEVICE_PATH_PROTOCOL.\r
3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
- have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r
+ have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
\r
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
- @param[in] ControllerHandle The handle of the controller to start. This handle \r
- must support a protocol interface that supplies \r
+ @param[in] ControllerHandle The handle of the controller to start. This handle\r
+ must support a protocol interface that supplies\r
an I/O abstraction to the driver.\r
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
- parameter is ignored by device drivers, and is optional for bus \r
- drivers. For a bus driver, if this parameter is NULL, then handles \r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
+ parameter is ignored by device drivers, and is optional for bus\r
+ drivers. For a bus driver, if this parameter is NULL, then handles\r
for all the children of Controller are created by this driver.\r
- If this parameter is not NULL and the first Device Path Node is \r
- not the End of Device Path Node, then only the handle for the \r
- child device specified by the first Device Path Node of \r
+ If this parameter is not NULL and the first Device Path Node is\r
+ not the End of Device Path Node, then only the handle for the\r
+ child device specified by the first Device Path Node of\r
RemainingDevicePath is created by this driver.\r
- If the first Device Path Node of RemainingDevicePath is \r
+ If the first Device Path Node of RemainingDevicePath is\r
the End of Device Path Node, no child handle is created by this\r
driver.\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
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
- ATA_BUS_DRIVER_DATA *AtaBusDriverData;\r
- UINT16 Port;\r
- UINT16 PortMultiplierPort;\r
+ EFI_STATUS Status;\r
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ ATA_BUS_DRIVER_DATA *AtaBusDriverData;\r
+ UINT16 Port;\r
+ UINT16 PortMultiplierPort;\r
\r
AtaBusDriverData = NULL;\r
\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiDevicePathProtocolGuid,\r
- (VOID **) &ParentDevicePath,\r
+ (VOID **)&ParentDevicePath,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\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
- (VOID **) &AtaPassThru,\r
+ (VOID **)&AtaPassThru,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
goto ErrorExit;\r
}\r
\r
- AtaBusDriverData->AtaPassThru = AtaPassThru;\r
- AtaBusDriverData->Controller = Controller;\r
- AtaBusDriverData->ParentDevicePath = ParentDevicePath;\r
+ AtaBusDriverData->AtaPassThru = AtaPassThru;\r
+ AtaBusDriverData->Controller = Controller;\r
+ AtaBusDriverData->ParentDevicePath = ParentDevicePath;\r
AtaBusDriverData->DriverBindingHandle = This->DriverBindingHandle;\r
\r
Status = gBS->InstallMultipleProtocolInterfaces (\r
if (EFI_ERROR (Status)) {\r
goto ErrorExit;\r
}\r
-\r
} else {\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiCallerIdGuid,\r
- (VOID **) &AtaBusDriverData,\r
+ (VOID **)&AtaBusDriverData,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\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
//\r
break;\r
}\r
+\r
RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);\r
}\r
}\r
+\r
Status = EFI_SUCCESS;\r
} else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);\r
if (!EFI_ERROR (Status)) {\r
- Status = RegisterAtaDevice (AtaBusDriverData,Port, PortMultiplierPort);\r
+ Status = RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);\r
}\r
}\r
\r
}\r
\r
gBS->CloseProtocol (\r
- Controller,\r
- &gEfiAtaPassThruProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
+ Controller,\r
+ &gEfiAtaPassThruProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
\r
return Status;\r
-\r
}\r
\r
-\r
/**\r
Stops a device controller or a bus controller.\r
- \r
- The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
- As a result, much of the error checking on the parameters to Stop() has been moved \r
- into this common boot service. It is legal to call Stop() from other locations, \r
+\r
+ The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
+ As a result, much of the error checking on the parameters to Stop() has been moved\r
+ into this common boot service. It is legal to call Stop() from other locations,\r
but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
same driver's Start() function.\r
EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
Start() function, and the Start() function must have called OpenProtocol() on\r
ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
- \r
+\r
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
- @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
- support a bus specific I/O protocol for the driver \r
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must\r
+ support a bus specific I/O protocol for the driver\r
to use to stop the device.\r
@param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
- @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r
if NumberOfChildren is 0.\r
\r
@retval EFI_SUCCESS The device was stopped.\r
EFI_STATUS\r
EFIAPI\r
AtaBusDriverBindingStop (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
)\r
{\r
- EFI_STATUS Status;\r
- BOOLEAN AllChildrenStopped;\r
- UINTN Index;\r
- ATA_BUS_DRIVER_DATA *AtaBusDriverData;\r
+ EFI_STATUS Status;\r
+ BOOLEAN AllChildrenStopped;\r
+ UINTN Index;\r
+ ATA_BUS_DRIVER_DATA *AtaBusDriverData;\r
\r
if (NumberOfChildren == 0) {\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiCallerIdGuid,\r
- (VOID **) &AtaBusDriverData,\r
+ (VOID **)&AtaBusDriverData,\r
This->DriverBindingHandle,\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
);\r
if (!EFI_ERROR (Status)) {\r
gBS->UninstallMultipleProtocolInterfaces (\r
- Controller,\r
- &gEfiCallerIdGuid,\r
- AtaBusDriverData,\r
- NULL\r
- );\r
+ Controller,\r
+ &gEfiCallerIdGuid,\r
+ AtaBusDriverData,\r
+ NULL\r
+ );\r
FreePool (AtaBusDriverData);\r
}\r
\r
gBS->CloseProtocol (\r
- Controller,\r
- &gEfiAtaPassThruProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
+ Controller,\r
+ &gEfiAtaPassThruProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
\r
return EFI_SUCCESS;\r
}\r
AllChildrenStopped = TRUE;\r
\r
for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
Status = UnregisterAtaDevice (This, Controller, ChildHandleBuffer[Index]);\r
if (EFI_ERROR (Status)) {\r
AllChildrenStopped = FALSE;\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Reset the Block Device.\r
\r
EFI_STATUS\r
EFIAPI\r
AtaBlockIoReset (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN BOOLEAN ExtendedVerification\r
+ IN EFI_BLOCK_IO_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
)\r
{\r
- EFI_STATUS Status;\r
- ATA_DEVICE *AtaDevice;\r
- EFI_TPL OldTpl;\r
+ EFI_STATUS Status;\r
+ ATA_DEVICE *AtaDevice;\r
+ EFI_TPL OldTpl;\r
\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
Read/Write BufferSize bytes from Lba from/into Buffer.\r
\r
@param[in] This Indicates a pointer to the calling context. Either be\r
- block I/O or block I/O2. \r
+ block I/O or block I/O2.\r
@param[in] MediaId The media ID that the read/write request is for.\r
@param[in] Lba The starting logical block address to be read/written.\r
The caller is responsible for reading/writing to only\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
+ @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
EFI_STATUS\r
BlockIoReadWrite (\r
- IN VOID *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer,\r
- IN BOOLEAN IsBlockIo2,\r
- IN BOOLEAN IsWrite\r
+ IN VOID *This,\r
+ IN UINT32 MediaId,\r
+ IN EFI_LBA Lba,\r
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
+ IN UINTN BufferSize,\r
+ OUT VOID *Buffer,\r
+ IN BOOLEAN IsBlockIo2,\r
+ IN BOOLEAN IsWrite\r
)\r
{\r
- ATA_DEVICE *AtaDevice;\r
- EFI_STATUS Status;\r
- EFI_TPL OldTpl;\r
- EFI_BLOCK_IO_MEDIA *Media;\r
- UINTN BlockSize;\r
- UINTN NumberOfBlocks;\r
- UINTN IoAlign;\r
+ ATA_DEVICE *AtaDevice;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+ EFI_BLOCK_IO_MEDIA *Media;\r
+ UINTN BlockSize;\r
+ UINTN NumberOfBlocks;\r
+ UINTN IoAlign;\r
\r
if (IsBlockIo2) {\r
- Media = ((EFI_BLOCK_IO2_PROTOCOL *) This)->Media;\r
- AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
+ Media = ((EFI_BLOCK_IO2_PROTOCOL *)This)->Media;\r
+ AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
} else {\r
- Media = ((EFI_BLOCK_IO_PROTOCOL *) This)->Media;\r
- AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (This);\r
+ Media = ((EFI_BLOCK_IO_PROTOCOL *)This)->Media;\r
+ AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (This);\r
}\r
\r
if (MediaId != Media->MediaId) {\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
+\r
return EFI_SUCCESS;\r
- } \r
+ }\r
\r
BlockSize = Media->BlockSize;\r
if ((BufferSize % BlockSize) != 0) {\r
return EFI_BAD_BUFFER_SIZE;\r
}\r
- \r
- NumberOfBlocks = BufferSize / BlockSize;\r
+\r
+ NumberOfBlocks = BufferSize / BlockSize;\r
if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
IoAlign = Media->IoAlign;\r
- if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {\r
+ if ((IoAlign > 0) && (((UINTN)Buffer & (IoAlign - 1)) != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
- \r
+\r
//\r
// Invoke low level AtaDevice Access Routine.\r
//\r
Status = AccessAtaDevice (AtaDevice, Buffer, Lba, NumberOfBlocks, IsWrite, Token);\r
- \r
+\r
gBS->RestoreTPL (OldTpl);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
Read BufferSize bytes from Lba into Buffer.\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
+ @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
AtaBlockIoReadBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- OUT VOID *Buffer\r
+ IN EFI_BLOCK_IO_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN BufferSize,\r
+ OUT VOID *Buffer\r
)\r
{\r
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);\r
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);\r
}\r
\r
-\r
/**\r
Write BufferSize bytes from Lba into Buffer.\r
\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
+ @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
AtaBlockIoWriteBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN EFI_LBA Lba,\r
- IN UINTN BufferSize,\r
- IN VOID *Buffer\r
+ IN EFI_BLOCK_IO_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN BufferSize,\r
+ IN VOID *Buffer\r
)\r
{\r
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);\r
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);\r
}\r
\r
-\r
/**\r
Flush the Block Device.\r
\r
EFI_STATUS\r
EFIAPI\r
AtaBlockIoFlushBlocks (\r
- IN EFI_BLOCK_IO_PROTOCOL *This\r
+ IN EFI_BLOCK_IO_PROTOCOL *This\r
)\r
{\r
//\r
IN BOOLEAN ExtendedVerification\r
)\r
{\r
- EFI_STATUS Status;\r
- ATA_DEVICE *AtaDevice;\r
- EFI_TPL OldTpl;\r
+ EFI_STATUS Status;\r
+ ATA_DEVICE *AtaDevice;\r
+ EFI_TPL OldTpl;\r
\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\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_MEDIA_CHANGED The MediaId is not for the current media.\r
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
intrinsic block size of the device.\r
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \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_OUT_OF_RESOURCES The request could not be completed due to a lack\r
of resources.\r
OUT VOID *Buffer\r
)\r
{\r
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);\r
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);\r
}\r
\r
-\r
/**\r
Write BufferSize bytes from Lba into Buffer.\r
\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
+ @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
or the buffer is not on proper alignment.\r
\r
**/\r
IN VOID *Buffer\r
)\r
{\r
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, TRUE);\r
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, TRUE);\r
}\r
\r
-\r
/**\r
Flush the Block Device.\r
\r
)\r
{\r
//\r
- // Signla event and return directly.\r
+ // Signal event and return directly.\r
//\r
- if (Token != NULL && Token->Event != NULL) {\r
+ if ((Token != NULL) && (Token->Event != NULL)) {\r
Token->TransactionStatus = EFI_SUCCESS;\r
gBS->SignalEvent (Token->Event);\r
}\r
+\r
return EFI_SUCCESS;\r
}\r
+\r
/**\r
Provides inquiry information for the controller type.\r
- \r
+\r
This function is used by the IDE bus driver to get inquiry data. Data format\r
of Identify data is defined by the Interface GUID.\r
\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
+ @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
AtaDiskInfoInquiry (\r
- IN EFI_DISK_INFO_PROTOCOL *This,\r
- IN OUT VOID *InquiryData,\r
- IN OUT UINT32 *InquiryDataSize\r
+ IN EFI_DISK_INFO_PROTOCOL *This,\r
+ IN OUT VOID *InquiryData,\r
+ IN OUT UINT32 *InquiryDataSize\r
)\r
{\r
return EFI_NOT_FOUND;\r
}\r
\r
-\r
/**\r
Provides identify information for the controller type.\r
\r
This function is used by the IDE bus driver 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
+ @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
+ @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
AtaDiskInfoIdentify (\r
- IN EFI_DISK_INFO_PROTOCOL *This,\r
- IN OUT VOID *IdentifyData,\r
- IN OUT UINT32 *IdentifyDataSize\r
+ IN EFI_DISK_INFO_PROTOCOL *This,\r
+ IN OUT VOID *IdentifyData,\r
+ IN OUT UINT32 *IdentifyDataSize\r
)\r
{\r
- EFI_STATUS Status;\r
- ATA_DEVICE *AtaDevice;\r
+ EFI_STATUS Status;\r
+ ATA_DEVICE *AtaDevice;\r
\r
AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);\r
\r
Status = EFI_BUFFER_TOO_SMALL;\r
- if (*IdentifyDataSize >= sizeof (*AtaDevice->IdentifyData)) {\r
+ if (*IdentifyDataSize >= sizeof (ATA_IDENTIFY_DATA)) {\r
Status = EFI_SUCCESS;\r
- CopyMem (IdentifyData, AtaDevice->IdentifyData, sizeof (*AtaDevice->IdentifyData));\r
+ CopyMem (IdentifyData, AtaDevice->IdentifyData, sizeof (ATA_IDENTIFY_DATA));\r
}\r
- *IdentifyDataSize = sizeof (*AtaDevice->IdentifyData);\r
+\r
+ *IdentifyDataSize = sizeof (ATA_IDENTIFY_DATA);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
Provides sense data information for the controller type.\r
- \r
- This function is used by the IDE bus driver to get sense data. \r
+\r
+ This function is used by the IDE bus driver to get sense data.\r
Data format of Sense data is defined by the Interface GUID.\r
\r
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
EFI_STATUS\r
EFIAPI\r
AtaDiskInfoSenseData (\r
- IN EFI_DISK_INFO_PROTOCOL *This,\r
- IN OUT VOID *SenseData,\r
- IN OUT UINT32 *SenseDataSize,\r
- OUT UINT8 *SenseDataNumber\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
/**\r
This function is used by the IDE bus driver to get controller information.\r
\r
- @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. \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
EFI_STATUS\r
EFIAPI\r
AtaDiskInfoWhichIde (\r
- IN EFI_DISK_INFO_PROTOCOL *This,\r
- OUT UINT32 *IdeChannel,\r
- OUT UINT32 *IdeDevice\r
+ IN EFI_DISK_INFO_PROTOCOL *This,\r
+ OUT UINT32 *IdeChannel,\r
+ OUT UINT32 *IdeDevice\r
)\r
{\r
- ATA_DEVICE *AtaDevice;\r
+ ATA_DEVICE *AtaDevice;\r
\r
- AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);\r
- *IdeChannel = AtaDevice->Port;\r
- *IdeDevice = AtaDevice->PortMultiplierPort;\r
+ AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);\r
+ *IdeChannel = AtaDevice->Port;\r
+ *IdeDevice = AtaDevice->PortMultiplierPort;\r
\r
return EFI_SUCCESS;\r
}\r
EFI_STATUS\r
EFIAPI\r
AtaStorageSecurityReceiveData (\r
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN UINT64 Timeout,\r
- IN UINT8 SecurityProtocolId,\r
- IN UINT16 SecurityProtocolSpecificData,\r
- IN UINTN PayloadBufferSize,\r
- OUT VOID *PayloadBuffer,\r
- OUT UINTN *PayloadTransferSize\r
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN UINT64 Timeout,\r
+ IN UINT8 SecurityProtocolId,\r
+ IN UINT16 SecurityProtocolSpecificData,\r
+ IN UINTN PayloadBufferSize,\r
+ OUT VOID *PayloadBuffer,\r
+ OUT UINTN *PayloadTransferSize\r
)\r
{\r
- EFI_STATUS Status;\r
- ATA_DEVICE *Private;\r
+ EFI_STATUS Status;\r
+ ATA_DEVICE *Private;\r
+ EFI_TPL OldTpl;\r
\r
- DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Read"));\r
- if ((PayloadBuffer == NULL || PayloadTransferSize == NULL) && PayloadBufferSize != 0) {\r
+ DEBUG ((DEBUG_INFO, "EFI Storage Security Protocol - Read\n"));\r
+ if (((PayloadBuffer == NULL) || (PayloadTransferSize == NULL)) && (PayloadBufferSize != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
return EFI_NO_MEDIA;\r
}\r
\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
Status = TrustTransferAtaDevice (\r
Private,\r
PayloadBuffer,\r
PayloadTransferSize\r
);\r
\r
+ gBS->RestoreTPL (OldTpl);\r
return Status;\r
}\r
\r
EFI_STATUS\r
EFIAPI\r
AtaStorageSecuritySendData (\r
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
- IN UINT32 MediaId,\r
- IN UINT64 Timeout,\r
- IN UINT8 SecurityProtocolId,\r
- IN UINT16 SecurityProtocolSpecificData,\r
- IN UINTN PayloadBufferSize,\r
- IN VOID *PayloadBuffer\r
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN UINT64 Timeout,\r
+ IN UINT8 SecurityProtocolId,\r
+ IN UINT16 SecurityProtocolSpecificData,\r
+ IN UINTN PayloadBufferSize,\r
+ IN VOID *PayloadBuffer\r
)\r
{\r
- EFI_STATUS Status;\r
- ATA_DEVICE *Private;\r
+ EFI_STATUS Status;\r
+ ATA_DEVICE *Private;\r
+ EFI_TPL OldTpl;\r
\r
- DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Send"));\r
+ DEBUG ((DEBUG_INFO, "EFI Storage Security Protocol - Send\n"));\r
if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
return EFI_MEDIA_CHANGED;\r
}\r
\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
Status = TrustTransferAtaDevice (\r
Private,\r
PayloadBuffer,\r
NULL\r
);\r
\r
+ gBS->RestoreTPL (OldTpl);\r
return Status;\r
}\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
-InitializeAtaBus(\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
+InitializeAtaBus (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
//\r
// Install driver model protocol(s).\r