2 Master header file for ATA Bus Driver.
4 This file defines common data structures, macro definitions and some module
5 internal function header files.
7 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include <Protocol/AtaPassThru.h>
24 #include <Protocol/BlockIo.h>
25 #include <Protocol/BlockIo2.h>
26 #include <Protocol/DiskInfo.h>
27 #include <Protocol/DevicePath.h>
28 #include <Protocol/StorageSecurityCommand.h>
30 #include <Library/DebugLib.h>
31 #include <Library/UefiDriverEntryPoint.h>
32 #include <Library/BaseLib.h>
33 #include <Library/UefiLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/DevicePathLib.h>
39 #include <IndustryStandard/Atapi.h>
42 // Time out value for ATA pass through protocol
44 #define ATA_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)
47 // Maximum number of times to retry ATA command
49 #define MAX_RETRY_TIMES 3
52 // The maximum total sectors count in 28 bit addressing mode
54 #define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
57 // The maximum ATA transaction sector count in 28 bit addressing mode.
59 #define MAX_28BIT_TRANSFER_BLOCK_NUM 0x100
62 // The maximum ATA transaction sector count in 48 bit addressing mode.
64 //#define MAX_48BIT_TRANSFER_BLOCK_NUM 0x10000
67 // BugBug: if the TransferLength is equal with 0x10000 (the 48bit max length),
68 // there is a bug that even the register interrupt bit has been sit, the buffer
69 // seems not ready. Change the Maximum Sector Numbers to 0xFFFF to work round
72 #define MAX_48BIT_TRANSFER_BLOCK_NUM 0xFFFF
75 // The maximum model name in ATA identify data
77 #define MAX_MODEL_NAME_LEN 40
79 #define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K')
80 #define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D')
82 #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
85 // Task for the non blocking I/O
89 EFI_BLOCK_IO2_TOKEN
*Token
;
90 UINTN
*UnsignalledEventCount
;
91 EFI_ATA_PASS_THRU_COMMAND_PACKET Packet
;
92 BOOLEAN
*IsError
;// Indicate whether meeting error during source allocation for new task.
97 // ATA bus data structure for ATA controller
100 EFI_ATA_PASS_THRU_PROTOCOL
*AtaPassThru
;
101 EFI_HANDLE Controller
;
102 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
103 EFI_HANDLE DriverBindingHandle
;
104 } ATA_BUS_DRIVER_DATA
;
107 // ATA device data structure for each child device
113 EFI_BLOCK_IO_PROTOCOL BlockIo
;
114 EFI_BLOCK_IO2_PROTOCOL BlockIo2
;
115 EFI_BLOCK_IO_MEDIA BlockMedia
;
116 EFI_DISK_INFO_PROTOCOL DiskInfo
;
117 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
118 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity
;
120 ATA_BUS_DRIVER_DATA
*AtaBusDriverData
;
122 UINT16 PortMultiplierPort
;
125 // Buffer for the execution of ATA pass through protocol
127 EFI_ATA_PASS_THRU_COMMAND_PACKET Packet
;
128 EFI_ATA_COMMAND_BLOCK Acb
;
129 EFI_ATA_STATUS_BLOCK
*Asb
;
135 // Cached data for ATA identify data
137 ATA_IDENTIFY_DATA
*IdentifyData
;
139 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
140 CHAR16 ModelName
[MAX_MODEL_NAME_LEN
+ 1];
142 LIST_ENTRY AtaTaskList
;
145 #define ATA_DEVICE_FROM_BLOCK_IO(a) CR (a, ATA_DEVICE, BlockIo, ATA_DEVICE_SIGNATURE)
146 #define ATA_DEVICE_FROM_BLOCK_IO2(a) CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)
147 #define ATA_DEVICE_FROM_DISK_INFO(a) CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)
148 #define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)
149 #define ATA_AYNS_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)
154 extern EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding
;
155 extern EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName
;
156 extern EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2
;
159 Allocates an aligned buffer for ATA device.
161 This function allocates an aligned buffer for the ATA device to perform
162 ATA pass through operations. The alignment requirement is from ATA pass
165 @param AtaDevice The ATA child device involved for the operation.
166 @param BufferSize The request buffer size.
168 @return A pointer to the aligned buffer or NULL if the allocation fails.
172 AllocateAlignedBuffer (
173 IN ATA_DEVICE
*AtaDevice
,
178 Frees an aligned buffer for ATA device.
180 This function frees an aligned buffer for the ATA device to perform
181 ATA pass through operations.
183 @param Buffer The aligned buffer to be freed.
184 @param BufferSize The request buffer size.
196 @param[in, out] Task Pointer to task to be freed.
202 IN ATA_BUS_ASYN_TASK
*Task
206 Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().
208 This function wraps the ResetDevice() invocation for ATA pass through function
211 @param AtaDevice The ATA child device involved for the operation.
213 @return The return status from EFI_ATA_PASS_THRU_PROTOCOL.PassThru().
218 IN ATA_DEVICE
*AtaDevice
223 Discovers whether it is a valid ATA device.
225 This function issues ATA_CMD_IDENTIFY_DRIVE command to the ATA device to identify it.
226 If the command is executed successfully, it then identifies it and initializes
227 the Media information in Block IO protocol interface.
229 @param AtaDevice The ATA child device involved for the operation.
231 @retval EFI_SUCCESS The device is successfully identified and Media information
232 is correctly initialized.
233 @return others Some error occurs when discovering the ATA device.
238 IN OUT ATA_DEVICE
*AtaDevice
242 Read or write a number of blocks from ATA device.
244 This function performs ATA pass through transactions to read/write data from/to
245 ATA device. It may separate the read/write request into several ATA pass through
248 @param[in, out] AtaDevice The ATA child device involved for the operation.
249 @param[in, out] Buffer The pointer to the current transaction buffer.
250 @param[in] StartLba The starting logical block address to be accessed.
251 @param[in] NumberOfBlocks The block number or sector count of the transfer.
252 @param[in] IsWrite Indicates whether it is a write operation.
253 @param[in, out] Token A pointer to the token associated with the transaction.
255 @retval EFI_SUCCESS The data transfer is complete successfully.
256 @return others Some error occurs when transferring data.
261 IN OUT ATA_DEVICE
*AtaDevice
,
262 IN OUT UINT8
*Buffer
,
264 IN UINTN NumberOfBlocks
,
266 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
269 Trust transfer data from/to ATA device.
271 This function performs one ATA pass through transaction to do a trust transfer from/to
272 ATA device. It chooses the appropriate ATA command and protocol to invoke PassThru
273 interface of ATA pass through.
275 @param AtaDevice The ATA child device involved for the operation.
276 @param Buffer The pointer to the current transaction buffer.
277 @param SecurityProtocolId The value of the "Security Protocol" parameter of
278 the security protocol command to be sent.
279 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
280 of the security protocol command to be sent.
281 @param TransferLength The block number or sector count of the transfer.
282 @param IsTrustSend Indicates whether it is a trust send operation or not.
283 @param Timeout The timeout, in 100ns units, to use for the execution
284 of the security protocol command. A Timeout value of 0
285 means that this function will wait indefinitely for the
286 security protocol command to execute. If Timeout is greater
287 than zero, then this function will return EFI_TIMEOUT
288 if the time required to execute the receive data command
289 is greater than Timeout.
291 @retval EFI_SUCCESS The data transfer is complete successfully.
292 @return others Some error occurs when transferring data.
297 TrustTransferAtaDevice (
298 IN OUT ATA_DEVICE
*AtaDevice
,
300 IN UINT8 SecurityProtocolId
,
301 IN UINT16 SecurityProtocolSpecificData
,
302 IN UINTN TransferLength
,
303 IN BOOLEAN IsTrustSend
,
305 OUT UINTN
*TransferLengthOut
309 // Protocol interface prototypes
312 Tests to see if this driver supports a given controller. If a child device is provided,
313 it further tests to see if this driver supports creating a handle for the specified child device.
315 This function checks to see if the driver specified by This supports the device specified by
316 ControllerHandle. Drivers will typically use the device path attached to
317 ControllerHandle and/or the services from the bus I/O abstraction attached to
318 ControllerHandle to determine if the driver supports ControllerHandle. This function
319 may be called many times during platform initialization. In order to reduce boot times, the tests
320 performed by this function must be very small, and take as little time as possible to execute. This
321 function must not change the state of any hardware devices, and this function must be aware that the
322 device specified by ControllerHandle may already be managed by the same driver or a
323 different driver. This function must match its calls to AllocatePages() with FreePages(),
324 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
325 Since ControllerHandle may have been previously started by the same driver, if a protocol is
326 already in the opened state, then it must not be closed with CloseProtocol(). This is required
327 to guarantee the state of ControllerHandle is not modified by this function.
329 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
330 @param[in] ControllerHandle The handle of the controller to test. This handle
331 must support a protocol interface that supplies
332 an I/O abstraction to the driver.
333 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
334 parameter is ignored by device drivers, and is optional for bus
335 drivers. For bus drivers, if this parameter is not NULL, then
336 the bus driver must determine if the bus controller specified
337 by ControllerHandle and the child controller specified
338 by RemainingDevicePath are both supported by this
341 @retval EFI_SUCCESS The device specified by ControllerHandle and
342 RemainingDevicePath is supported by the driver specified by This.
343 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
344 RemainingDevicePath is already being managed by the driver
346 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
347 RemainingDevicePath is already being managed by a different
348 driver or an application that requires exclusive access.
349 Currently not implemented.
350 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
351 RemainingDevicePath is not supported by the driver specified by This.
355 AtaBusDriverBindingSupported (
356 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
357 IN EFI_HANDLE Controller
,
358 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
362 Starts a device controller or a bus controller.
364 The Start() function is designed to be invoked from the EFI boot service ConnectController().
365 As a result, much of the error checking on the parameters to Start() has been moved into this
366 common boot service. It is legal to call Start() from other locations,
367 but the following calling restrictions must be followed or the system behavior will not be deterministic.
368 1. ControllerHandle must be a valid EFI_HANDLE.
369 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
370 EFI_DEVICE_PATH_PROTOCOL.
371 3. Prior to calling Start(), the Supported() function for the driver specified by This must
372 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
374 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
375 @param[in] ControllerHandle The handle of the controller to start. This handle
376 must support a protocol interface that supplies
377 an I/O abstraction to the driver.
378 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
379 parameter is ignored by device drivers, and is optional for bus
380 drivers. For a bus driver, if this parameter is NULL, then handles
381 for all the children of Controller are created by this driver.
382 If this parameter is not NULL and the first Device Path Node is
383 not the End of Device Path Node, then only the handle for the
384 child device specified by the first Device Path Node of
385 RemainingDevicePath is created by this driver.
386 If the first Device Path Node of RemainingDevicePath is
387 the End of Device Path Node, no child handle is created by this
390 @retval EFI_SUCCESS The device was started.
391 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
392 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
393 @retval Others The driver failded to start the device.
398 AtaBusDriverBindingStart (
399 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
400 IN EFI_HANDLE Controller
,
401 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
405 Stops a device controller or a bus controller.
407 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
408 As a result, much of the error checking on the parameters to Stop() has been moved
409 into this common boot service. It is legal to call Stop() from other locations,
410 but the following calling restrictions must be followed or the system behavior will not be deterministic.
411 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
412 same driver's Start() function.
413 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
414 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
415 Start() function, and the Start() function must have called OpenProtocol() on
416 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
418 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
419 @param[in] ControllerHandle A handle to the device being stopped. The handle must
420 support a bus specific I/O protocol for the driver
421 to use to stop the device.
422 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
423 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
424 if NumberOfChildren is 0.
426 @retval EFI_SUCCESS The device was stopped.
427 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
432 AtaBusDriverBindingStop (
433 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
434 IN EFI_HANDLE Controller
,
435 IN UINTN NumberOfChildren
,
436 IN EFI_HANDLE
*ChildHandleBuffer
441 Retrieves a Unicode string that is the user readable name of the driver.
443 This function retrieves the user readable name of a driver in the form of a
444 Unicode string. If the driver specified by This has a user readable name in
445 the language specified by Language, then a pointer to the driver name is
446 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
447 by This does not support the language specified by Language,
448 then EFI_UNSUPPORTED is returned.
450 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
451 EFI_COMPONENT_NAME_PROTOCOL instance.
453 @param Language[in] A pointer to a Null-terminated ASCII string
454 array indicating the language. This is the
455 language of the driver name that the caller is
456 requesting, and it must match one of the
457 languages specified in SupportedLanguages. The
458 number of languages supported by a driver is up
459 to the driver writer. Language is specified
460 in RFC 4646 or ISO 639-2 language code format.
462 @param DriverName[out] A pointer to the Unicode string to return.
463 This Unicode string is the name of the
464 driver specified by This in the language
465 specified by Language.
467 @retval EFI_SUCCESS The Unicode string for the Driver specified by
468 This and the language specified by Language was
469 returned in DriverName.
471 @retval EFI_INVALID_PARAMETER Language is NULL.
473 @retval EFI_INVALID_PARAMETER DriverName is NULL.
475 @retval EFI_UNSUPPORTED The driver specified by This does not support
476 the language specified by Language.
481 AtaBusComponentNameGetDriverName (
482 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
484 OUT CHAR16
**DriverName
489 Retrieves a Unicode string that is the user readable name of the controller
490 that is being managed by a driver.
492 This function retrieves the user readable name of the controller specified by
493 ControllerHandle and ChildHandle in the form of a Unicode string. If the
494 driver specified by This has a user readable name in the language specified by
495 Language, then a pointer to the controller name is returned in ControllerName,
496 and EFI_SUCCESS is returned. If the driver specified by This is not currently
497 managing the controller specified by ControllerHandle and ChildHandle,
498 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
499 support the language specified by Language, then EFI_UNSUPPORTED is returned.
501 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
502 EFI_COMPONENT_NAME_PROTOCOL instance.
504 @param ControllerHandle[in] The handle of a controller that the driver
505 specified by This is managing. This handle
506 specifies the controller whose name is to be
509 @param ChildHandle[in] The handle of the child controller to retrieve
510 the name of. This is an optional parameter that
511 may be NULL. It will be NULL for device
512 drivers. It will also be NULL for a bus drivers
513 that wish to retrieve the name of the bus
514 controller. It will not be NULL for a bus
515 driver that wishes to retrieve the name of a
518 @param Language[in] A pointer to a Null-terminated ASCII string
519 array indicating the language. This is the
520 language of the driver name that the caller is
521 requesting, and it must match one of the
522 languages specified in SupportedLanguages. The
523 number of languages supported by a driver is up
524 to the driver writer. Language is specified in
525 RFC 4646 or ISO 639-2 language code format.
527 @param ControllerName[out] A pointer to the Unicode string to return.
528 This Unicode string is the name of the
529 controller specified by ControllerHandle and
530 ChildHandle in the language specified by
531 Language from the point of view of the driver
534 @retval EFI_SUCCESS The Unicode string for the user readable name in
535 the language specified by Language for the
536 driver specified by This was returned in
539 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
541 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
544 @retval EFI_INVALID_PARAMETER Language is NULL.
546 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
548 @retval EFI_UNSUPPORTED The driver specified by This is not currently
549 managing the controller specified by
550 ControllerHandle and ChildHandle.
552 @retval EFI_UNSUPPORTED The driver specified by This does not support
553 the language specified by Language.
558 AtaBusComponentNameGetControllerName (
559 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
560 IN EFI_HANDLE ControllerHandle
,
561 IN EFI_HANDLE ChildHandle OPTIONAL
,
563 OUT CHAR16
**ControllerName
568 Reset the Block Device.
570 @param This Indicates a pointer to the calling context.
571 @param ExtendedVerification Driver may perform diagnostics on reset.
573 @retval EFI_SUCCESS The device was reset.
574 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
581 IN EFI_BLOCK_IO_PROTOCOL
*This
,
582 IN BOOLEAN ExtendedVerification
587 Read BufferSize bytes from Lba into Buffer.
589 @param This Indicates a pointer to the calling context.
590 @param MediaId Id of the media, changes every time the media is replaced.
591 @param Lba The starting Logical Block Address to read from
592 @param BufferSize Size of Buffer, must be a multiple of device block size.
593 @param Buffer A pointer to the destination buffer for the data. The caller is
594 responsible for either having implicit or explicit ownership of the buffer.
596 @retval EFI_SUCCESS The data was read correctly from the device.
597 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
598 @retval EFI_NO_MEDIA There is no media in the device.
599 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
600 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
601 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
602 or the buffer is not on proper alignment.
607 AtaBlockIoReadBlocks (
608 IN EFI_BLOCK_IO_PROTOCOL
*This
,
617 Write BufferSize bytes from Lba into Buffer.
619 @param This Indicates a pointer to the calling context.
620 @param MediaId The media ID that the write request is for.
621 @param Lba The starting logical block address to be written. The caller is
622 responsible for writing to only legitimate locations.
623 @param BufferSize Size of Buffer, must be a multiple of device block size.
624 @param Buffer A pointer to the source buffer for the data.
626 @retval EFI_SUCCESS The data was written correctly to the device.
627 @retval EFI_WRITE_PROTECTED The device can not be written to.
628 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
629 @retval EFI_NO_MEDIA There is no media in the device.
630 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
631 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
632 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
633 or the buffer is not on proper alignment.
638 AtaBlockIoWriteBlocks (
639 IN EFI_BLOCK_IO_PROTOCOL
*This
,
648 Flush the Block Device.
650 @param This Indicates a pointer to the calling context.
652 @retval EFI_SUCCESS All outstanding data was written to the device
653 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data
654 @retval EFI_NO_MEDIA There is no media in the device.
659 AtaBlockIoFlushBlocks (
660 IN EFI_BLOCK_IO_PROTOCOL
*This
664 Reset the Block Device throught Block I/O2 protocol.
666 @param[in] This Indicates a pointer to the calling context.
667 @param[in] ExtendedVerification Driver may perform diagnostics on reset.
669 @retval EFI_SUCCESS The device was reset.
670 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
677 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
678 IN BOOLEAN ExtendedVerification
682 Read BufferSize bytes from Lba into Buffer.
684 @param[in] This Indicates a pointer to the calling context.
685 @param[in] MediaId Id of the media, changes every time the media is replaced.
686 @param[in] Lba The starting Logical Block Address to read from.
687 @param[in, out] Token A pointer to the token associated with the transaction.
688 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
689 @param[out] Buffer A pointer to the destination buffer for the data. The caller is
690 responsible for either having implicit or explicit ownership of the buffer.
692 @retval EFI_SUCCESS The read request was queued if Event is not NULL.
693 The data was read correctly from the device if
695 @retval EFI_DEVICE_ERROR The device reported an error while performing
697 @retval EFI_NO_MEDIA There is no media in the device.
698 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
699 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
700 intrinsic block size of the device.
701 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
702 or the buffer is not on proper alignment.
703 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
709 AtaBlockIoReadBlocksEx (
710 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
713 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
719 Write BufferSize bytes from Lba into Buffer.
721 @param[in] This Indicates a pointer to the calling context.
722 @param[in] MediaId The media ID that the write request is for.
723 @param[in] Lba The starting logical block address to be written. The
724 caller is responsible for writing to only legitimate
726 @param[in, out] Token A pointer to the token associated with the transaction.
727 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
728 @param[in] Buffer A pointer to the source buffer for the data.
730 @retval EFI_SUCCESS The data was written correctly to the device.
731 @retval EFI_WRITE_PROTECTED The device can not be written to.
732 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
733 @retval EFI_NO_MEDIA There is no media in the device.
734 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
735 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
736 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
737 or the buffer is not on proper alignment.
742 AtaBlockIoWriteBlocksEx (
743 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
746 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
752 Flush the Block Device.
754 @param[in] This Indicates a pointer to the calling context.
755 @param[in, out] Token A pointer to the token associated with the transaction.
757 @retval EFI_SUCCESS All outstanding data was written to the device
758 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data
759 @retval EFI_NO_MEDIA There is no media in the device.
764 AtaBlockIoFlushBlocksEx (
765 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
766 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
770 Provides inquiry information for the controller type.
772 This function is used by the IDE bus driver to get inquiry data. Data format
773 of Identify data is defined by the Interface GUID.
775 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
776 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.
777 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.
779 @retval EFI_SUCCESS The command was accepted without any errors.
780 @retval EFI_NOT_FOUND Device does not support this data class
781 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
782 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
788 IN EFI_DISK_INFO_PROTOCOL
*This
,
789 IN OUT VOID
*InquiryData
,
790 IN OUT UINT32
*InquiryDataSize
795 Provides identify information for the controller type.
797 This function is used by the IDE bus driver to get identify data. Data format
798 of Identify data is defined by the Interface GUID.
800 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
802 @param[in, out] IdentifyData Pointer to a buffer for the identify data.
803 @param[in, out] IdentifyDataSize Pointer to the value for the identify data
806 @retval EFI_SUCCESS The command was accepted without any errors.
807 @retval EFI_NOT_FOUND Device does not support this data class
808 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
809 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
814 AtaDiskInfoIdentify (
815 IN EFI_DISK_INFO_PROTOCOL
*This
,
816 IN OUT VOID
*IdentifyData
,
817 IN OUT UINT32
*IdentifyDataSize
822 Provides sense data information for the controller type.
824 This function is used by the IDE bus driver to get sense data.
825 Data format of Sense data is defined by the Interface GUID.
827 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
828 @param[in, out] SenseData Pointer to the SenseData.
829 @param[in, out] SenseDataSize Size of SenseData in bytes.
830 @param[out] SenseDataNumber Pointer to the value for the sense data size.
832 @retval EFI_SUCCESS The command was accepted without any errors.
833 @retval EFI_NOT_FOUND Device does not support this data class.
834 @retval EFI_DEVICE_ERROR Error reading SenseData from device.
835 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.
840 AtaDiskInfoSenseData (
841 IN EFI_DISK_INFO_PROTOCOL
*This
,
842 IN OUT VOID
*SenseData
,
843 IN OUT UINT32
*SenseDataSize
,
844 OUT UINT8
*SenseDataNumber
849 This function is used by the IDE bus driver to get controller information.
851 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
852 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.
853 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.
855 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.
856 @retval EFI_UNSUPPORTED This is not an IDE device.
861 AtaDiskInfoWhichIde (
862 IN EFI_DISK_INFO_PROTOCOL
*This
,
863 OUT UINT32
*IdeChannel
,
864 OUT UINT32
*IdeDevice
868 Send a security protocol command to a device that receives data and/or the result
869 of one or more commands sent by SendData.
871 The ReceiveData function sends a security protocol command to the given MediaId.
872 The security protocol command sent is defined by SecurityProtocolId and contains
873 the security protocol specific data SecurityProtocolSpecificData. The function
874 returns the data from the security protocol command in PayloadBuffer.
876 For devices supporting the SCSI command set, the security protocol command is sent
877 using the SECURITY PROTOCOL IN command defined in SPC-4.
879 For devices supporting the ATA command set, the security protocol command is sent
880 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
883 If the PayloadBufferSize is zero, the security protocol command is sent using the
884 Trusted Non-Data command defined in ATA8-ACS.
886 If PayloadBufferSize is too small to store the available data from the security
887 protocol command, the function shall copy PayloadBufferSize bytes into the
888 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
890 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
891 the function shall return EFI_INVALID_PARAMETER.
893 If the given MediaId does not support security protocol commands, the function shall
894 return EFI_UNSUPPORTED. If there is no media in the device, the function returns
895 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
896 the function returns EFI_MEDIA_CHANGED.
898 If the security protocol fails to complete within the Timeout period, the function
899 shall return EFI_TIMEOUT.
901 If the security protocol command completes without an error, the function shall
902 return EFI_SUCCESS. If the security protocol command completes with an error, the
903 function shall return EFI_DEVICE_ERROR.
905 @param This Indicates a pointer to the calling context.
906 @param MediaId ID of the medium to receive data from.
907 @param Timeout The timeout, in 100ns units, to use for the execution
908 of the security protocol command. A Timeout value of 0
909 means that this function will wait indefinitely for the
910 security protocol command to execute. If Timeout is greater
911 than zero, then this function will return EFI_TIMEOUT
912 if the time required to execute the receive data command
913 is greater than Timeout.
914 @param SecurityProtocolId The value of the "Security Protocol" parameter of
915 the security protocol command to be sent.
916 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
917 of the security protocol command to be sent.
918 @param PayloadBufferSize Size in bytes of the payload data buffer.
919 @param PayloadBuffer A pointer to a destination buffer to store the security
920 protocol command specific payload data for the security
921 protocol command. The caller is responsible for having
922 either implicit or explicit ownership of the buffer.
923 @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the
924 data written to the payload data buffer.
926 @retval EFI_SUCCESS The security protocol command completed successfully.
927 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available
928 data from the device. The PayloadBuffer contains the truncated data.
929 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
930 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
931 @retval EFI_NO_MEDIA There is no media in the device.
932 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
933 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and
934 PayloadBufferSize is non-zero.
935 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
936 protocol command to execute.
941 AtaStorageSecurityReceiveData (
942 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
*This
,
945 IN UINT8 SecurityProtocolId
,
946 IN UINT16 SecurityProtocolSpecificData
,
947 IN UINTN PayloadBufferSize
,
948 OUT VOID
*PayloadBuffer
,
949 OUT UINTN
*PayloadTransferSize
953 Send a security protocol command to a device.
955 The SendData function sends a security protocol command containing the payload
956 PayloadBuffer to the given MediaId. The security protocol command sent is
957 defined by SecurityProtocolId and contains the security protocol specific data
958 SecurityProtocolSpecificData. If the underlying protocol command requires a
959 specific padding for the command payload, the SendData function shall add padding
960 bytes to the command payload to satisfy the padding requirements.
962 For devices supporting the SCSI command set, the security protocol command is sent
963 using the SECURITY PROTOCOL OUT command defined in SPC-4.
965 For devices supporting the ATA command set, the security protocol command is sent
966 using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize
967 is non-zero. If the PayloadBufferSize is zero, the security protocol command is
968 sent using the Trusted Non-Data command defined in ATA8-ACS.
970 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall
971 return EFI_INVALID_PARAMETER.
973 If the given MediaId does not support security protocol commands, the function
974 shall return EFI_UNSUPPORTED. If there is no media in the device, the function
975 returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the
976 device, the function returns EFI_MEDIA_CHANGED.
978 If the security protocol fails to complete within the Timeout period, the function
979 shall return EFI_TIMEOUT.
981 If the security protocol command completes without an error, the function shall return
982 EFI_SUCCESS. If the security protocol command completes with an error, the function
983 shall return EFI_DEVICE_ERROR.
985 @param This Indicates a pointer to the calling context.
986 @param MediaId ID of the medium to receive data from.
987 @param Timeout The timeout, in 100ns units, to use for the execution
988 of the security protocol command. A Timeout value of 0
989 means that this function will wait indefinitely for the
990 security protocol command to execute. If Timeout is greater
991 than zero, then this function will return EFI_TIMEOUT
992 if the time required to execute the receive data command
993 is greater than Timeout.
994 @param SecurityProtocolId The value of the "Security Protocol" parameter of
995 the security protocol command to be sent.
996 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
997 of the security protocol command to be sent.
998 @param PayloadBufferSize Size in bytes of the payload data buffer.
999 @param PayloadBuffer A pointer to a destination buffer to store the security
1000 protocol command specific payload data for the security
1003 @retval EFI_SUCCESS The security protocol command completed successfully.
1004 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
1005 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
1006 @retval EFI_NO_MEDIA There is no media in the device.
1007 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
1008 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.
1009 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
1010 protocol command to execute.
1015 AtaStorageSecuritySendData (
1016 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
*This
,
1019 IN UINT8 SecurityProtocolId
,
1020 IN UINT16 SecurityProtocolSpecificData
,
1021 IN UINTN PayloadBufferSize
,
1022 IN VOID
*PayloadBuffer