Introduce tow non-blocking task lists to AtaBus. One maintains the sub-task which is related to running Ata Task and the other is for waiting Ata Task. And it will not pass any task to AtaAtapiPassThru until the previous Ata task has been finished or met error.

Signed-off-by: qianouyang
Reviewed-by: czhang46 erictian 

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13105 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qianouyang
2012-03-16 03:31:47 +00:00
parent be30ddf795
commit 58727f29ea
6 changed files with 580 additions and 468 deletions

View File

@@ -1,10 +1,10 @@
/** @file
This file implements protocol interfaces for ATA bus driver.
This file implements protocol interfaces: Driver Binding protocol,
Block IO protocol and DiskInfo protocol.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -58,7 +58,7 @@ ATA_DEVICE gAtaDeviceTemplate = {
FALSE, // LogicPartition
FALSE, // ReadOnly
FALSE, // WritingCache
0x200, // BlockSize
0x200, // BlockSize
0, // IoAlign
0, // LastBlock
0, // LowestAlignedLba
@@ -87,7 +87,8 @@ ATA_DEVICE gAtaDeviceTemplate = {
NULL, // IdentifyData
NULL, // ControllerNameTable
{L'\0', }, // ModelName
{NULL, NULL} // AtaTaskList
{NULL, NULL}, // AtaTaskList
{NULL, NULL} // AtaSubTaskList
};
/**
@@ -147,10 +148,11 @@ ReleaseAtaResources (
IN ATA_DEVICE *AtaDevice
)
{
ATA_BUS_ASYN_TASK *Task;
LIST_ENTRY *Entry;
LIST_ENTRY *DelEntry;
EFI_TPL OldTpl;
ATA_BUS_ASYN_SUB_TASK *SubTask;
ATA_BUS_ASYN_TASK *AtaTask;
LIST_ENTRY *Entry;
LIST_ENTRY *DelEntry;
EFI_TPL OldTpl;
FreeUnicodeStringTable (AtaDevice->ControllerNameTable);
FreeAlignedBuffer (AtaDevice->Asb, sizeof (EFI_ATA_STATUS_BLOCK));
@@ -159,19 +161,34 @@ ReleaseAtaResources (
FreePool (AtaDevice->DevicePath);
}
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {
//
// Free the Subtask list.
//
for(Entry = AtaDevice->AtaSubTaskList.ForwardLink;
Entry != (&AtaDevice->AtaSubTaskList);
) {
DelEntry = Entry;
Entry = Entry->ForwardLink;
SubTask = ATA_AYNS_SUB_TASK_FROM_ENTRY (DelEntry);
RemoveEntryList (DelEntry);
FreeAtaSubTask (SubTask);
}
}
if (!IsListEmpty (&AtaDevice->AtaTaskList)) {
//
// Free the Subtask list.
//
for(Entry = AtaDevice->AtaTaskList.ForwardLink;
for(Entry = AtaDevice->AtaTaskList.ForwardLink;
Entry != (&AtaDevice->AtaTaskList);
) {
DelEntry = Entry;
Entry = Entry->ForwardLink;
Task = ATA_AYNS_TASK_FROM_ENTRY (DelEntry);
AtaTask = ATA_AYNS_TASK_FROM_ENTRY (DelEntry);
RemoveEntryList (DelEntry);
FreeAtaSubTask (Task);
FreePool (AtaTask);
}
}
gBS->RestoreTPL (OldTpl);
@@ -183,7 +200,7 @@ ReleaseAtaResources (
Registers an ATA device.
This function allocates an ATA device structure for the ATA device specified by
Port and PortMultiplierPort if the ATA device is identified as a valid one.
Port and PortMultiplierPort if the ATA device is identified as a valid one.
Then it will create child handle and install Block IO and Disk Info protocol on
it.
@@ -217,7 +234,7 @@ RegisterAtaDevice (
RemainingDevicePath = NULL;
//
// Build device path
// Build device path
//
AtaPassThru = AtaBusDriverData->AtaPassThru;
Status = AtaPassThru->BuildDevicePath (AtaPassThru, Port, PortMultiplierPort, &NewDevicePathNode);
@@ -273,9 +290,10 @@ RegisterAtaDevice (
// Initial Ata Task List
//
InitializeListHead (&AtaDevice->AtaTaskList);
InitializeListHead (&AtaDevice->AtaSubTaskList);
//
// Try to identify the ATA device via the ATA pass through command.
// Try to identify the ATA device via the ATA pass through command.
//
Status = DiscoverAtaDevice (AtaDevice);
if (EFI_ERROR (Status)) {
@@ -363,7 +381,7 @@ Done:
}
if (EFI_ERROR (Status) && (AtaDevice != NULL)) {
ReleaseAtaResources (AtaDevice);
ReleaseAtaResources (AtaDevice);
DEBUG ((EFI_D_ERROR | EFI_D_INIT, "Failed to initialize Port %x PortMultiplierPort %x, status = %r\n", Port, PortMultiplierPort, Status));
}
return Status;
@@ -373,8 +391,8 @@ Done:
/**
Unregisters an ATA device.
This function removes the protocols installed on the controller handle and
frees the resources allocated for the ATA device.
This function removes the protocols installed on the controller handle and
frees the resources allocated for the ATA device.
@param This The pointer to EFI_DRIVER_BINDING_PROTOCOL instance.
@param Controller The controller handle of the ATA device.
@@ -433,7 +451,7 @@ UnregisterAtaDevice (
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
} else {
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (BlockIo2);
}
}
//
// Close the child handle
@@ -512,33 +530,33 @@ UnregisterAtaDevice (
/**
Tests to see if this driver supports a given controller. If a child device is provided,
Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device.
This function checks to see if the driver specified by This supports the device specified by
ControllerHandle. Drivers will typically use the device path attached to
ControllerHandle and/or the services from the bus I/O abstraction attached to
ControllerHandle to determine if the driver supports ControllerHandle. This function
may be called many times during platform initialization. In order to reduce boot times, the tests
performed by this function must be very small, and take as little time as possible to execute. This
function must not change the state of any hardware devices, and this function must be aware that the
device specified by ControllerHandle may already be managed by the same driver or a
different driver. This function must match its calls to AllocatePages() with FreePages(),
AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
Since ControllerHandle may have been previously started by the same driver, if a protocol is
already in the opened state, then it must not be closed with CloseProtocol(). This is required
This function checks to see if the driver specified by This supports the device specified by
ControllerHandle. Drivers will typically use the device path attached to
ControllerHandle and/or the services from the bus I/O abstraction attached to
ControllerHandle to determine if the driver supports ControllerHandle. This function
may be called many times during platform initialization. In order to reduce boot times, the tests
performed by this function must be very small, and take as little time as possible to execute. This
function must not change the state of any hardware devices, and this function must be aware that the
device specified by ControllerHandle may already be managed by the same driver or a
different driver. This function must match its calls to AllocatePages() with FreePages(),
AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
Since ControllerHandle may have been previously started by the same driver, if a protocol is
already in the opened state, then it must not be closed with CloseProtocol(). This is required
to guarantee the state of ControllerHandle is not modified by this function.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle The handle of the controller to test. This handle
must support a protocol interface that supplies
@param[in] ControllerHandle The handle of the controller to test. This handle
must support a protocol interface that supplies
an I/O abstraction to the driver.
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For bus drivers, if this parameter is not NULL, then
the bus driver must determine if the bus controller specified
by ControllerHandle and the child controller specified
by RemainingDevicePath are both supported by this
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For bus drivers, if this parameter is not NULL, then
the bus driver must determine if the bus controller specified
by ControllerHandle and the child controller specified
by RemainingDevicePath are both supported by this
bus driver.
@retval EFI_SUCCESS The device specified by ControllerHandle and
@@ -626,28 +644,28 @@ AtaBusDriverBindingSupported (
Starts a device controller or a bus controller.
The Start() function is designed to be invoked from the EFI boot service ConnectController().
As a result, much of the error checking on the parameters to Start() has been moved into this
common boot service. It is legal to call Start() from other locations,
As a result, much of the error checking on the parameters to Start() has been moved into this
common boot service. It is legal to call Start() from other locations,
but the following calling restrictions must be followed or the system behavior will not be deterministic.
1. ControllerHandle must be a valid EFI_HANDLE.
2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
EFI_DEVICE_PATH_PROTOCOL.
3. Prior to calling Start(), the Supported() function for the driver specified by This must
have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle The handle of the controller to start. This handle
must support a protocol interface that supplies
@param[in] ControllerHandle The handle of the controller to start. This handle
must support a protocol interface that supplies
an I/O abstraction to the driver.
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For a bus driver, if this parameter is NULL, then handles
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For a bus driver, if this parameter is NULL, then handles
for all the children of Controller are created by this driver.
If this parameter is not NULL and the first Device Path Node is
not the End of Device Path Node, then only the handle for the
child device specified by the first Device Path Node of
If this parameter is not NULL and the first Device Path Node is
not the End of Device Path Node, then only the handle for the
child device specified by the first Device Path Node of
RemainingDevicePath is created by this driver.
If the first Device Path Node of RemainingDevicePath is
If the first Device Path Node of RemainingDevicePath is
the End of Device Path Node, no child handle is created by this
driver.
@@ -798,10 +816,10 @@ ErrorExit:
/**
Stops a device controller or a bus controller.
The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
As a result, much of the error checking on the parameters to Stop() has been moved
into this common boot service. It is legal to call Stop() from other locations,
The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
As a result, much of the error checking on the parameters to Stop() has been moved
into this common boot service. It is legal to call Stop() from other locations,
but the following calling restrictions must be followed or the system behavior will not be deterministic.
1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
same driver's Start() function.
@@ -809,13 +827,13 @@ ErrorExit:
EFI_HANDLE. In addition, all of these handles must have been created in this driver's
Start() function, and the Start() function must have called OpenProtocol() on
ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle A handle to the device being stopped. The handle must
support a bus specific I/O protocol for the driver
@param[in] ControllerHandle A handle to the device being stopped. The handle must
support a bus specific I/O protocol for the driver
to use to stop the device.
@param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
@param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
@param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
if NumberOfChildren is 0.
@retval EFI_SUCCESS The device was stopped.
@@ -924,7 +942,7 @@ AtaBlockIoReset (
Read/Write BufferSize bytes from Lba from/into Buffer.
@param[in] This Indicates a pointer to the calling context. Either be
block I/O or block I/O2.
block I/O or block I/O2.
@param[in] MediaId The media ID that the read/write request is for.
@param[in] Lba The starting logical block address to be read/written.
The caller is responsible for reading/writing to only
@@ -942,7 +960,7 @@ AtaBlockIoReset (
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
@retval EFI_INVALID_PARAMETER The read/write request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The read/write request contains LBAs that are not valid,
or the buffer is not on proper alignment.
**/
@@ -987,13 +1005,13 @@ BlockIoReadWrite (
if (BufferSize == 0) {
return EFI_SUCCESS;
}
}
BlockSize = Media->BlockSize;
if ((BufferSize % BlockSize) != 0) {
return EFI_BAD_BUFFER_SIZE;
}
NumberOfBlocks = BufferSize / BlockSize;
if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {
return EFI_INVALID_PARAMETER;
@@ -1005,12 +1023,12 @@ BlockIoReadWrite (
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Invoke low level AtaDevice Access Routine.
//
Status = AccessAtaDevice (AtaDevice, Buffer, Lba, NumberOfBlocks, IsWrite, Token);
gBS->RestoreTPL (OldTpl);
return Status;
@@ -1032,7 +1050,7 @@ BlockIoReadWrite (
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
or the buffer is not on proper alignment.
**/
@@ -1066,7 +1084,7 @@ AtaBlockIoReadBlocks (
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
or the buffer is not on proper alignment.
**/
@@ -1162,7 +1180,7 @@ AtaBlockIoResetEx (
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
intrinsic block size of the device.
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
or the buffer is not on proper alignment.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
of resources.
@@ -1201,7 +1219,7 @@ AtaBlockIoReadBlocksEx (
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
or the buffer is not on proper alignment.
**/
@@ -1249,7 +1267,7 @@ AtaBlockIoFlushBlocksEx (
}
/**
Provides inquiry information for the controller type.
This function is used by the IDE bus driver to get inquiry data. Data format
of Identify data is defined by the Interface GUID.
@@ -1258,9 +1276,9 @@ AtaBlockIoFlushBlocksEx (
@param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.
@retval EFI_SUCCESS The command was accepted without any errors.
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading InquiryData from device
@retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading InquiryData from device
@retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
**/
EFI_STATUS
@@ -1281,16 +1299,16 @@ AtaDiskInfoInquiry (
This function is used by the IDE bus driver to get identify data. Data format
of Identify data is defined by the Interface GUID.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
instance.
@param[in, out] IdentifyData Pointer to a buffer for the identify data.
@param[in, out] IdentifyDataSize Pointer to the value for the identify data
size.
@retval EFI_SUCCESS The command was accepted without any errors.
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading IdentifyData from device
@retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading IdentifyData from device
@retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
**/
EFI_STATUS
@@ -1319,8 +1337,8 @@ AtaDiskInfoIdentify (
/**
Provides sense data information for the controller type.
This function is used by the IDE bus driver to get sense data.
This function is used by the IDE bus driver to get sense data.
Data format of Sense data is defined by the Interface GUID.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
@@ -1350,7 +1368,7 @@ AtaDiskInfoSenseData (
/**
This function is used by the IDE bus driver to get controller information.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
@param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.
@param[out] IdeDevice Pointer to the Ide Device number. Master or slave.

View File

@@ -4,7 +4,7 @@
This file defines common data structures, macro definitions and some module
internal function header files.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -35,6 +35,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/TimerLib.h>
#include <IndustryStandard/Atapi.h>
@@ -54,12 +55,12 @@
#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
//
// The maximum ATA transaction sector count in 28 bit addressing mode.
// The maximum ATA transaction sector count in 28 bit addressing mode.
//
#define MAX_28BIT_TRANSFER_BLOCK_NUM 0x100
//
// The maximum ATA transaction sector count in 48 bit addressing mode.
// The maximum ATA transaction sector count in 48 bit addressing mode.
//
//#define MAX_48BIT_TRANSFER_BLOCK_NUM 0x10000
@@ -72,27 +73,15 @@
#define MAX_48BIT_TRANSFER_BLOCK_NUM 0xFFFF
//
// The maximum model name in ATA identify data
// The maximum model name in ATA identify data
//
#define MAX_MODEL_NAME_LEN 40
#define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K')
#define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D')
#define ATA_SUB_TASK_SIGNATURE SIGNATURE_32 ('A', 'S', 'T', 'S')
#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
//
// Task for the non blocking I/O
//
typedef struct {
UINT32 Signature;
EFI_BLOCK_IO2_TOKEN *Token;
UINTN *UnsignalledEventCount;
EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
BOOLEAN *IsError;// Indicate whether meeting error during source allocation for new task.
LIST_ENTRY TaskEntry;
} ATA_BUS_ASYN_TASK;
//
// ATA bus data structure for ATA controller
//
@@ -140,12 +129,41 @@ typedef struct {
CHAR16 ModelName[MAX_MODEL_NAME_LEN + 1];
LIST_ENTRY AtaTaskList;
LIST_ENTRY AtaSubTaskList;
} ATA_DEVICE;
//
// Sub-Task for the non blocking I/O
//
typedef struct {
UINT32 Signature;
ATA_DEVICE *AtaDevice;
EFI_BLOCK_IO2_TOKEN *Token;
UINTN *UnsignalledEventCount;
EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
BOOLEAN *IsError;// Indicate whether meeting error during source allocation for new task.
LIST_ENTRY TaskEntry;
} ATA_BUS_ASYN_SUB_TASK;
//
// Task for the non blocking I/O
//
typedef struct {
UINT32 Signature;
EFI_BLOCK_IO2_TOKEN *Token;
ATA_DEVICE *AtaDevice;
UINT8 *Buffer;
EFI_LBA StartLba;
UINTN NumberOfBlocks;
BOOLEAN IsWrite;
LIST_ENTRY TaskEntry;
} ATA_BUS_ASYN_TASK;
#define ATA_DEVICE_FROM_BLOCK_IO(a) CR (a, ATA_DEVICE, BlockIo, ATA_DEVICE_SIGNATURE)
#define ATA_DEVICE_FROM_BLOCK_IO2(a) CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)
#define ATA_DEVICE_FROM_DISK_INFO(a) CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)
#define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)
#define ATA_AYNS_SUB_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_SUB_TASK, TaskEntry, ATA_SUB_TASK_SIGNATURE)
#define ATA_AYNS_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)
//
@@ -191,22 +209,22 @@ FreeAlignedBuffer (
);
/**
Free SubTask.
Free SubTask.
@param[in, out] Task Pointer to task to be freed.
**/
VOID
EFIAPI
EFIAPI
FreeAtaSubTask (
IN OUT ATA_BUS_ASYN_TASK *Task
IN OUT ATA_BUS_ASYN_SUB_TASK *Task
);
/**
Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().
This function wraps the ResetDevice() invocation for ATA pass through function
for an ATA device.
for an ATA device.
@param AtaDevice The ATA child device involved for the operation.
@@ -230,7 +248,7 @@ ResetAtaDevice (
@retval EFI_SUCCESS The device is successfully identified and Media information
is correctly initialized.
@return others Some error occurs when discovering the ATA device.
@return others Some error occurs when discovering the ATA device.
**/
EFI_STATUS
@@ -253,10 +271,10 @@ DiscoverAtaDevice (
@param[in, out] Token A pointer to the token associated with the transaction.
@retval EFI_SUCCESS The data transfer is complete successfully.
@return others Some error occurs when transferring data.
@return others Some error occurs when transferring data.
**/
EFI_STATUS
EFI_STATUS
AccessAtaDevice(
IN OUT ATA_DEVICE *AtaDevice,
IN OUT UINT8 *Buffer,
@@ -291,7 +309,7 @@ AccessAtaDevice(
written to the buffer. Ignore it when IsTrustSend is TRUE.
@retval EFI_SUCCESS The data transfer is complete successfully.
@return others Some error occurs when transferring data.
@return others Some error occurs when transferring data.
**/
EFI_STATUS
@@ -311,33 +329,33 @@ TrustTransferAtaDevice (
// Protocol interface prototypes
//
/**
Tests to see if this driver supports a given controller. If a child device is provided,
Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device.
This function checks to see if the driver specified by This supports the device specified by
ControllerHandle. Drivers will typically use the device path attached to
ControllerHandle and/or the services from the bus I/O abstraction attached to
ControllerHandle to determine if the driver supports ControllerHandle. This function
may be called many times during platform initialization. In order to reduce boot times, the tests
performed by this function must be very small, and take as little time as possible to execute. This
function must not change the state of any hardware devices, and this function must be aware that the
device specified by ControllerHandle may already be managed by the same driver or a
different driver. This function must match its calls to AllocatePages() with FreePages(),
AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
Since ControllerHandle may have been previously started by the same driver, if a protocol is
already in the opened state, then it must not be closed with CloseProtocol(). This is required
This function checks to see if the driver specified by This supports the device specified by
ControllerHandle. Drivers will typically use the device path attached to
ControllerHandle and/or the services from the bus I/O abstraction attached to
ControllerHandle to determine if the driver supports ControllerHandle. This function
may be called many times during platform initialization. In order to reduce boot times, the tests
performed by this function must be very small, and take as little time as possible to execute. This
function must not change the state of any hardware devices, and this function must be aware that the
device specified by ControllerHandle may already be managed by the same driver or a
different driver. This function must match its calls to AllocatePages() with FreePages(),
AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
Since ControllerHandle may have been previously started by the same driver, if a protocol is
already in the opened state, then it must not be closed with CloseProtocol(). This is required
to guarantee the state of ControllerHandle is not modified by this function.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle The handle of the controller to test. This handle
must support a protocol interface that supplies
@param[in] ControllerHandle The handle of the controller to test. This handle
must support a protocol interface that supplies
an I/O abstraction to the driver.
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For bus drivers, if this parameter is not NULL, then
the bus driver must determine if the bus controller specified
by ControllerHandle and the child controller specified
by RemainingDevicePath are both supported by this
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For bus drivers, if this parameter is not NULL, then
the bus driver must determine if the bus controller specified
by ControllerHandle and the child controller specified
by RemainingDevicePath are both supported by this
bus driver.
@retval EFI_SUCCESS The device specified by ControllerHandle and
@@ -364,28 +382,28 @@ AtaBusDriverBindingSupported (
Starts a device controller or a bus controller.
The Start() function is designed to be invoked from the EFI boot service ConnectController().
As a result, much of the error checking on the parameters to Start() has been moved into this
common boot service. It is legal to call Start() from other locations,
As a result, much of the error checking on the parameters to Start() has been moved into this
common boot service. It is legal to call Start() from other locations,
but the following calling restrictions must be followed or the system behavior will not be deterministic.
1. ControllerHandle must be a valid EFI_HANDLE.
2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
EFI_DEVICE_PATH_PROTOCOL.
3. Prior to calling Start(), the Supported() function for the driver specified by This must
have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle The handle of the controller to start. This handle
must support a protocol interface that supplies
@param[in] ControllerHandle The handle of the controller to start. This handle
must support a protocol interface that supplies
an I/O abstraction to the driver.
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For a bus driver, if this parameter is NULL, then handles
for all the children of Controller are created by this driver.
If this parameter is not NULL and the first Device Path Node is
not the End of Device Path Node, then only the handle for the
child device specified by the first Device Path Node of
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
drivers. For a bus driver, if this parameter is NULL, then handles
for all the children of Controller are created by this driver.
If this parameter is not NULL and the first Device Path Node is
not the End of Device Path Node, then only the handle for the
child device specified by the first Device Path Node of
RemainingDevicePath is created by this driver.
If the first Device Path Node of RemainingDevicePath is
If the first Device Path Node of RemainingDevicePath is
the End of Device Path Node, no child handle is created by this
driver.
@@ -405,10 +423,10 @@ AtaBusDriverBindingStart (
/**
Stops a device controller or a bus controller.
The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
As a result, much of the error checking on the parameters to Stop() has been moved
into this common boot service. It is legal to call Stop() from other locations,
The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
As a result, much of the error checking on the parameters to Stop() has been moved
into this common boot service. It is legal to call Stop() from other locations,
but the following calling restrictions must be followed or the system behavior will not be deterministic.
1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
same driver's Start() function.
@@ -416,13 +434,13 @@ AtaBusDriverBindingStart (
EFI_HANDLE. In addition, all of these handles must have been created in this driver's
Start() function, and the Start() function must have called OpenProtocol() on
ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle A handle to the device being stopped. The handle must
support a bus specific I/O protocol for the driver
@param[in] ControllerHandle A handle to the device being stopped. The handle must
support a bus specific I/O protocol for the driver
to use to stop the device.
@param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
@param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
@param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
if NumberOfChildren is 0.
@retval EFI_SUCCESS The device was stopped.
@@ -600,7 +618,7 @@ AtaBlockIoReset (
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
or the buffer is not on proper alignment.
**/
@@ -631,7 +649,7 @@ AtaBlockIoReadBlocks (
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
or the buffer is not on proper alignment.
**/
@@ -700,7 +718,7 @@ AtaBlockIoResetEx (
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
intrinsic block size of the device.
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
or the buffer is not on proper alignment.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
of resources.
@@ -735,7 +753,7 @@ AtaBlockIoReadBlocksEx (
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
or the buffer is not on proper alignment.
**/
@@ -770,7 +788,7 @@ AtaBlockIoFlushBlocksEx (
/**
Provides inquiry information for the controller type.
This function is used by the IDE bus driver to get inquiry data. Data format
of Identify data is defined by the Interface GUID.
@@ -779,9 +797,9 @@ AtaBlockIoFlushBlocksEx (
@param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.
@retval EFI_SUCCESS The command was accepted without any errors.
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading InquiryData from device
@retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading InquiryData from device
@retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
**/
EFI_STATUS
@@ -799,16 +817,16 @@ AtaDiskInfoInquiry (
This function is used by the IDE bus driver to get identify data. Data format
of Identify data is defined by the Interface GUID.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
instance.
@param[in, out] IdentifyData Pointer to a buffer for the identify data.
@param[in, out] IdentifyDataSize Pointer to the value for the identify data
size.
@retval EFI_SUCCESS The command was accepted without any errors.
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading IdentifyData from device
@retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
@retval EFI_NOT_FOUND Device does not support this data class
@retval EFI_DEVICE_ERROR Error reading IdentifyData from device
@retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
**/
EFI_STATUS
@@ -822,8 +840,8 @@ AtaDiskInfoIdentify (
/**
Provides sense data information for the controller type.
This function is used by the IDE bus driver to get sense data.
This function is used by the IDE bus driver to get sense data.
Data format of Sense data is defined by the Interface GUID.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
@@ -850,7 +868,7 @@ AtaDiskInfoSenseData (
/**
This function is used by the IDE bus driver to get controller information.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
@param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
@param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.
@param[out] IdeDevice Pointer to the Ide Device number. Master or slave.

View File

@@ -1,5 +1,5 @@
## @file
# ATA Bus driver to enumerate and identfy ATA devices.
# ATA Bus driver to enumerate and identfy ATA devices.
#
# This driver follows UEFI driver model and layers on ATA Pass Thru protocol defined
# in UEFI spec 2.2. It installs Block IO and Disk Info protocol for each ATA device
@@ -30,9 +30,9 @@
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
# DRIVER_BINDING = gAtaBusDriverBinding
# DRIVER_BINDING = gAtaBusDriverBinding
# COMPONENT_NAME = gAtaBusComponentName
# COMPONENT_NAME2 = gAtaBusComponentName2
# COMPONENT_NAME2 = gAtaBusComponentName2
#
#
@@ -41,7 +41,7 @@
AtaBus.c
AtaPassThruExecute.c
ComponentName.c
[Packages]
MdePkg/MdePkg.dec
@@ -54,7 +54,7 @@
BaseLib
UefiDriverEntryPoint
DebugLib
TimerLib
[Guids]
gEfiDiskInfoIdeInterfaceGuid # CONSUMES ## GUID

View File

@@ -6,11 +6,11 @@
through command and protocol.
NOTE: This file also implements the StorageSecurityCommandProtocol(SSP). For input
parameter SecurityProtocolSpecificData, ATA spec has no explicitly definition
for Security Protocol Specific layout. This implementation uses big endian for
parameter SecurityProtocolSpecificData, ATA spec has no explicitly definition
for Security Protocol Specific layout. This implementation uses big endian for
Cylinder register.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -73,7 +73,7 @@ UINT8 mAtaCommands[][2][2] = {
//
// Look up table (UdmaValid, IsTrustSend) for ATA_CMD
//
UINT8 mAtaTrustCommands[2][2] = {
UINT8 mAtaTrustCommands[2][2] = {
{
ATA_CMD_TRUST_RECEIVE, // PIO read
ATA_CMD_TRUST_SEND // PIO write
@@ -102,7 +102,7 @@ UINTN mMaxTransferBlockNumber[] = {
transaction.
@param[in, out] AtaDevice The ATA child device involved for the operation.
@param[in, out] TaskPacket Pointer to a Pass Thru Command Packet. Optional,
@param[in, out] TaskPacket Pointer to a Pass Thru Command Packet. Optional,
if it is NULL, blocking mode, and use the packet
in AtaDevice. If it is not NULL, non blocking mode,
and pass down this Packet.
@@ -127,7 +127,7 @@ AtaDevicePassThru (
EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
//
// Assemble packet. If it is non blocking mode, the Ata driver should keep each
// Assemble packet. If it is non blocking mode, the Ata driver should keep each
// subtask and clean them when the event is signaled.
//
if (TaskPacket != NULL) {
@@ -152,7 +152,7 @@ AtaDevicePassThru (
);
//
// Ensure ATA pass through caller and callee have the same
// interpretation of ATA pass through protocol.
// interpretation of ATA pass through protocol.
//
ASSERT (Status != EFI_INVALID_PARAMETER);
ASSERT (Status != EFI_BAD_BUFFER_SIZE);
@@ -165,7 +165,7 @@ AtaDevicePassThru (
Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().
This function wraps the ResetDevice() invocation for ATA pass through function
for an ATA device.
for an ATA device.
@param AtaDevice The ATA child device involved for the operation.
@@ -178,9 +178,9 @@ ResetAtaDevice (
)
{
EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
AtaPassThru = AtaDevice->AtaBusDriverData->AtaPassThru;
return AtaPassThru->ResetDevice (
AtaPassThru,
AtaDevice->Port,
@@ -192,7 +192,7 @@ ResetAtaDevice (
/**
Prints ATA model name to ATA device structure.
This function converts ATA device model name from ATA identify data
This function converts ATA device model name from ATA identify data
to a string in ATA device structure. It needs to change the character
order in the original model name string.
@@ -271,7 +271,7 @@ GetAtapi6Capacity (
/**
Identifies ATA device via the Identify data.
This function identifies the ATA device and initializes the Media information in
This function identifies the ATA device and initializes the Media information in
Block IO protocol interface.
@param AtaDevice The ATA child device involved for the operation.
@@ -363,7 +363,7 @@ IdentifyAtaDevice (
AtaDevice->BlockIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;
}
//
// Get ATA model name from identify data structure.
// Get ATA model name from identify data structure.
//
PrintAtaModelName (AtaDevice);
@@ -382,7 +382,7 @@ IdentifyAtaDevice (
@retval EFI_SUCCESS The device is successfully identified and Media information
is correctly initialized.
@return others Some error occurs when discovering the ATA device.
@return others Some error occurs when discovering the ATA device.
**/
EFI_STATUS
@@ -437,7 +437,7 @@ DiscoverAtaDevice (
interface of ATA pass through.
@param[in, out] AtaDevice The ATA child device involved for the operation.
@param[in, out] TaskPacket Pointer to a Pass Thru Command Packet. Optional,
@param[in, out] TaskPacket Pointer to a Pass Thru Command Packet. Optional,
if it is NULL, blocking mode, and use the packet
in AtaDevice. If it is not NULL, non blocking mode,
and pass down this Packet.
@@ -452,7 +452,7 @@ DiscoverAtaDevice (
request is completed.
@retval EFI_SUCCESS The data transfer is complete successfully.
@return others Some error occurs when transferring data.
@return others Some error occurs when transferring data.
**/
EFI_STATUS
@@ -462,7 +462,7 @@ TransferAtaDevice (
IN OUT VOID *Buffer,
IN EFI_LBA StartLba,
IN UINT32 TransferLength,
IN BOOLEAN IsWrite,
IN BOOLEAN IsWrite,
IN EFI_EVENT Event OPTIONAL
)
{
@@ -470,7 +470,7 @@ TransferAtaDevice (
EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
//
// Ensure AtaDevice->UdmaValid, AtaDevice->Lba48Bit and IsWrite are valid boolean values
// Ensure AtaDevice->UdmaValid, AtaDevice->Lba48Bit and IsWrite are valid boolean values
//
ASSERT ((UINTN) AtaDevice->UdmaValid < 2);
ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
@@ -519,15 +519,15 @@ TransferAtaDevice (
}
/**
Free SubTask.
Free SubTask.
@param[in, out] Task Pointer to task to be freed.
**/
VOID
EFIAPI
EFIAPI
FreeAtaSubTask (
IN OUT ATA_BUS_ASYN_TASK *Task
IN OUT ATA_BUS_ASYN_SUB_TASK *Task
)
{
if (Task->Packet.Asb != NULL) {
@@ -549,17 +549,23 @@ FreeAtaSubTask (
**/
VOID
EFIAPI
EFIAPI
AtaNonBlockingCallBack (
IN EFI_EVENT Event,
IN VOID *Context
)
{
ATA_BUS_ASYN_TASK *Task;
ATA_BUS_ASYN_SUB_TASK *Task;
ATA_BUS_ASYN_TASK *AtaTask;
ATA_DEVICE *AtaDevice;
LIST_ENTRY *Entry;
EFI_STATUS Status;
Task = (ATA_BUS_ASYN_TASK *) Context;
Task = (ATA_BUS_ASYN_SUB_TASK *) Context;
gBS->CloseEvent (Event);
AtaDevice = Task->AtaDevice;
//
// Check the command status.
// If there is error during the sub task source allocation, the error status
@@ -594,9 +600,34 @@ AtaNonBlockingCallBack (
gBS->SignalEvent (Task->Token->Event);
DEBUG ((EFI_D_BLKIO, "Signal the upper layer event!\n"));
}
FreePool (Task->UnsignalledEventCount);
FreePool (Task->IsError);
//
// Finish all subtasks and move to the next task in AtaTaskList.
//
if (!IsListEmpty (&AtaDevice->AtaTaskList)) {
Entry = GetFirstNode (&AtaDevice->AtaTaskList);
AtaTask = ATA_AYNS_TASK_FROM_ENTRY (Entry);
DEBUG ((EFI_D_BLKIO, "Start to embark a new Ata Task\n"));
DEBUG ((EFI_D_BLKIO, "AtaTask->NumberOfBlocks = %x; AtaTask->Token=%x\n", AtaTask->NumberOfBlocks, AtaTask->Token));
Status = AccessAtaDevice (
AtaTask->AtaDevice,
AtaTask->Buffer,
AtaTask->StartLba,
AtaTask->NumberOfBlocks,
AtaTask->IsWrite,
AtaTask->Token
);
if (EFI_ERROR (Status)) {
AtaTask->Token->TransactionStatus = Status;
gBS->SignalEvent (AtaTask->Token->Event);
}
RemoveEntryList (Entry);
FreePool (AtaTask);
}
}
DEBUG ((
@@ -630,10 +661,10 @@ AtaNonBlockingCallBack (
@param[in, out] Token A pointer to the token associated with the transaction.
@retval EFI_SUCCESS The data transfer is complete successfully.
@return others Some error occurs when transferring data.
@return others Some error occurs when transferring data.
**/
EFI_STATUS
EFI_STATUS
AccessAtaDevice(
IN OUT ATA_DEVICE *AtaDevice,
IN OUT UINT8 *Buffer,
@@ -647,9 +678,10 @@ AccessAtaDevice(
UINTN MaxTransferBlockNumber;
UINTN TransferBlockNumber;
UINTN BlockSize;
ATA_BUS_ASYN_SUB_TASK *SubTask;
UINTN *EventCount;
UINTN TempCount;
ATA_BUS_ASYN_TASK *Task;
ATA_BUS_ASYN_TASK *AtaTask;
EFI_EVENT SubEvent;
UINTN Index;
BOOLEAN *IsError;
@@ -660,11 +692,12 @@ AccessAtaDevice(
EventCount = NULL;
IsError = NULL;
Index = 0;
Task = NULL;
SubTask = NULL;
SubEvent = NULL;
AtaTask = NULL;
//
// Ensure AtaDevice->Lba48Bit is a valid boolean value
// Ensure AtaDevice->Lba48Bit is a valid boolean value
//
ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
MaxTransferBlockNumber = mMaxTransferBlockNumber[AtaDevice->Lba48Bit];
@@ -674,22 +707,52 @@ AccessAtaDevice(
// Initial the return status and shared account for Non Blocking.
//
if ((Token != NULL) && (Token->Event != NULL)) {
Token->TransactionStatus = EFI_SUCCESS;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {
AtaTask = AllocateZeroPool (sizeof (ATA_BUS_ASYN_TASK));
if (AtaTask == NULL) {
gBS->RestoreTPL (OldTpl);
return EFI_OUT_OF_RESOURCES;
}
AtaTask->AtaDevice = AtaDevice;
AtaTask->Buffer = Buffer;
AtaTask->IsWrite = IsWrite;
AtaTask->NumberOfBlocks = NumberOfBlocks;
AtaTask->Signature = ATA_TASK_SIGNATURE;
AtaTask->StartLba = StartLba;
AtaTask->Token = Token;
InsertTailList (&AtaDevice->AtaTaskList, &AtaTask->TaskEntry);
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
gBS->RestoreTPL (OldTpl);
Token->TransactionStatus = EFI_SUCCESS;
EventCount = AllocateZeroPool (sizeof (UINTN));
if (EventCount == NULL) {
return EFI_OUT_OF_RESOURCES;
}
IsError = AllocateZeroPool (sizeof (BOOLEAN));
if (IsError == NULL) {
FreePool (EventCount);
return EFI_OUT_OF_RESOURCES;
}
DEBUG ((EFI_D_BLKIO, "Allocation IsError Addr=%x\n", IsError));
*IsError = FALSE;
TempCount = (NumberOfBlocks + MaxTransferBlockNumber - 1) / MaxTransferBlockNumber;
*EventCount = TempCount;
DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, NumberOfBlocks=%x\n", NumberOfBlocks));
DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, MaxTransferBlockNumber=%x\n", MaxTransferBlockNumber));
DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, EventCount=%x\n", TempCount));
}else {
while (!IsListEmpty (&AtaDevice->AtaTaskList) || !IsListEmpty (&AtaDevice->AtaSubTaskList)) {
//
// Stall for 100us.
//
MicroSecondDelay (100);
}
}
do {
@@ -705,27 +768,29 @@ AccessAtaDevice(
// Create sub event for the sub ata task. Non-blocking mode.
//
if ((Token != NULL) && (Token->Event != NULL)) {
Task = NULL;
SubTask = NULL;
SubEvent = NULL;
Task = AllocateZeroPool (sizeof (ATA_BUS_ASYN_TASK));
if (Task == NULL) {
SubTask = AllocateZeroPool (sizeof (ATA_BUS_ASYN_SUB_TASK));
if (SubTask == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Task->UnsignalledEventCount = EventCount;
Task->Token = Token;
Task->IsError = IsError;
InsertTailList (&AtaDevice->AtaTaskList, &Task->TaskEntry);
gBS->RestoreTPL (OldTpl);
SubTask->UnsignalledEventCount = EventCount;
SubTask->Signature = ATA_SUB_TASK_SIGNATURE;
SubTask->AtaDevice = AtaDevice;
SubTask->Token = Token;
SubTask->IsError = IsError;
InsertTailList (&AtaDevice->AtaSubTaskList, &SubTask->TaskEntry);
gBS->RestoreTPL (OldTpl);
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
AtaNonBlockingCallBack,
Task,
SubTask,
&SubEvent
);
//
@@ -737,11 +802,12 @@ AccessAtaDevice(
goto EXIT;
}
Status = TransferAtaDevice (AtaDevice, &Task->Packet, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, SubEvent);
Status = TransferAtaDevice (AtaDevice, &SubTask->Packet, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, SubEvent);
} else {
//
// Blocking Mode.
//
DEBUG ((EFI_D_BLKIO, "Blocking AccessAtaDevice, TransferBlockNumber=%x; StartLba = %x\n", TransferBlockNumber, StartLba));
Status = TransferAtaDevice (AtaDevice, NULL, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, NULL);
}
@@ -764,24 +830,23 @@ EXIT:
Token->TransactionStatus = Status;
*EventCount = (*EventCount) - (TempCount - Index);
*IsError = TRUE;
if (*EventCount == 0) {
FreePool (EventCount);
FreePool (IsError);
}
if (Task != NULL) {
RemoveEntryList (&Task->TaskEntry);
FreeAtaSubTask (Task);
if (SubTask != NULL) {
RemoveEntryList (&SubTask->TaskEntry);
FreeAtaSubTask (SubTask);
}
if (SubEvent != NULL) {
gBS->CloseEvent (SubEvent);
gBS->CloseEvent (SubEvent);
}
gBS->RestoreTPL (OldTpl);
}
}
}
return Status;
}
@@ -812,7 +877,7 @@ EXIT:
written to the buffer. Ignore it when IsTrustSend is TRUE.
@retval EFI_SUCCESS The data transfer is complete successfully.
@return others Some error occurs when transferring data.
@return others Some error occurs when transferring data.
**/
EFI_STATUS
@@ -835,7 +900,7 @@ TrustTransferAtaDevice (
EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
//
// Ensure AtaDevice->UdmaValid and IsTrustSend are valid boolean values
// Ensure AtaDevice->UdmaValid and IsTrustSend are valid boolean values
//
ASSERT ((UINTN) AtaDevice->UdmaValid < 2);
ASSERT ((UINTN) IsTrustSend < 2);
@@ -852,12 +917,12 @@ TrustTransferAtaDevice (
Acb->AtaSectorCount = (UINT8) (TransferLength / 512);
Acb->AtaSectorNumber = (UINT8) ((TransferLength / 512) >> 8);
//
// NOTE: ATA Spec has no explicitly definition for Security Protocol Specific layout.
// Here use big endian for Cylinder register.
// NOTE: ATA Spec has no explicitly definition for Security Protocol Specific layout.
// Here use big endian for Cylinder register.
//
Acb->AtaCylinderHigh = (UINT8) SecurityProtocolSpecificData;
Acb->AtaCylinderLow = (UINT8) (SecurityProtocolSpecificData >> 8);
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort << 4));
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort << 4));
//
// Prepare for ATA pass through packet.
@@ -877,7 +942,7 @@ TrustTransferAtaDevice (
CopyMem (NewBuffer, Buffer, TransferLength);
FreePool (Buffer);
Buffer = NewBuffer;
}
}
Packet->OutDataBuffer = Buffer;
Packet->OutTransferLength = (UINT32) TransferLength;
Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];