]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
Fix the comments to follow UEFI Spec regarding how to check an EFI_HANDLE is valid...
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaBusDxe / AtaBus.h
1 /** @file
2 Master header file for ATA Bus Driver.
3
4 This file defines common data structures, macro definitions and some module
5 internal function header files.
6
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
12
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.
15
16 **/
17
18 #ifndef _ATA_BUS_H_
19 #define _ATA_BUS_H_
20
21 #include <Uefi.h>
22
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>
29
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>
38
39 #include <IndustryStandard/Atapi.h>
40
41 //
42 // Time out value for ATA pass through protocol
43 //
44 #define ATA_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)
45
46 //
47 // Maximum number of times to retry ATA command
48 //
49 #define MAX_RETRY_TIMES 3
50
51 //
52 // The maximum total sectors count in 28 bit addressing mode
53 //
54 #define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
55
56 //
57 // The maximum ATA transaction sector count in 28 bit addressing mode.
58 //
59 #define MAX_28BIT_TRANSFER_BLOCK_NUM 0x100
60
61 //
62 // The maximum ATA transaction sector count in 48 bit addressing mode.
63 //
64 //#define MAX_48BIT_TRANSFER_BLOCK_NUM 0x10000
65
66 //
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
70 // this issue.
71 //
72 #define MAX_48BIT_TRANSFER_BLOCK_NUM 0xFFFF
73
74 //
75 // The maximum model name in ATA identify data
76 //
77 #define MAX_MODEL_NAME_LEN 40
78
79 #define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K')
80 #define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D')
81
82 #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
83
84 //
85 // Task for the non blocking I/O
86 //
87 typedef struct {
88 UINT32 Signature;
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.
93 LIST_ENTRY TaskEntry;
94 } ATA_BUS_ASYN_TASK;
95
96 //
97 // ATA bus data structure for ATA controller
98 //
99 typedef struct {
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;
105
106 //
107 // ATA device data structure for each child device
108 //
109 typedef struct {
110 UINT32 Signature;
111
112 EFI_HANDLE Handle;
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;
119
120 ATA_BUS_DRIVER_DATA *AtaBusDriverData;
121 UINT16 Port;
122 UINT16 PortMultiplierPort;
123
124 //
125 // Buffer for the execution of ATA pass through protocol
126 //
127 EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
128 EFI_ATA_COMMAND_BLOCK Acb;
129 EFI_ATA_STATUS_BLOCK *Asb;
130
131 BOOLEAN UdmaValid;
132 BOOLEAN Lba48Bit;
133
134 //
135 // Cached data for ATA identify data
136 //
137 ATA_IDENTIFY_DATA *IdentifyData;
138
139 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
140 CHAR16 ModelName[MAX_MODEL_NAME_LEN + 1];
141
142 LIST_ENTRY AtaTaskList;
143 } ATA_DEVICE;
144
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)
150
151 //
152 // Global Variables
153 //
154 extern EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding;
155 extern EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName;
156 extern EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2;
157
158 /**
159 Allocates an aligned buffer for ATA device.
160
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
163 through interface.
164
165 @param AtaDevice The ATA child device involved for the operation.
166 @param BufferSize The request buffer size.
167
168 @return A pointer to the aligned buffer or NULL if the allocation fails.
169
170 **/
171 VOID *
172 AllocateAlignedBuffer (
173 IN ATA_DEVICE *AtaDevice,
174 IN UINTN BufferSize
175 );
176
177 /**
178 Frees an aligned buffer for ATA device.
179
180 This function frees an aligned buffer for the ATA device to perform
181 ATA pass through operations.
182
183 @param Buffer The aligned buffer to be freed.
184 @param BufferSize The request buffer size.
185
186 **/
187 VOID
188 FreeAlignedBuffer (
189 IN VOID *Buffer,
190 IN UINTN BufferSize
191 );
192
193 /**
194 Free SubTask.
195
196 @param[in, out] Task Pointer to task to be freed.
197
198 **/
199 VOID
200 EFIAPI
201 FreeAtaSubTask (
202 IN OUT ATA_BUS_ASYN_TASK *Task
203 );
204
205 /**
206 Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().
207
208 This function wraps the ResetDevice() invocation for ATA pass through function
209 for an ATA device.
210
211 @param AtaDevice The ATA child device involved for the operation.
212
213 @return The return status from EFI_ATA_PASS_THRU_PROTOCOL.PassThru().
214
215 **/
216 EFI_STATUS
217 ResetAtaDevice (
218 IN ATA_DEVICE *AtaDevice
219 );
220
221
222 /**
223 Discovers whether it is a valid ATA device.
224
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.
228
229 @param AtaDevice The ATA child device involved for the operation.
230
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.
234
235 **/
236 EFI_STATUS
237 DiscoverAtaDevice (
238 IN OUT ATA_DEVICE *AtaDevice
239 );
240
241 /**
242 Read or write a number of blocks from ATA device.
243
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
246 transactions.
247
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.
254
255 @retval EFI_SUCCESS The data transfer is complete successfully.
256 @return others Some error occurs when transferring data.
257
258 **/
259 EFI_STATUS
260 AccessAtaDevice(
261 IN OUT ATA_DEVICE *AtaDevice,
262 IN OUT UINT8 *Buffer,
263 IN EFI_LBA StartLba,
264 IN UINTN NumberOfBlocks,
265 IN BOOLEAN IsWrite,
266 IN OUT EFI_BLOCK_IO2_TOKEN *Token
267 );
268 /**
269 Trust transfer data from/to ATA device.
270
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.
274
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.
290 @param TransferLengthOut A pointer to a buffer to store the size in bytes of the data
291 written to the buffer. Ignore it when IsTrustSend is TRUE.
292
293 @retval EFI_SUCCESS The data transfer is complete successfully.
294 @return others Some error occurs when transferring data.
295
296 **/
297 EFI_STATUS
298 EFIAPI
299 TrustTransferAtaDevice (
300 IN OUT ATA_DEVICE *AtaDevice,
301 IN OUT VOID *Buffer,
302 IN UINT8 SecurityProtocolId,
303 IN UINT16 SecurityProtocolSpecificData,
304 IN UINTN TransferLength,
305 IN BOOLEAN IsTrustSend,
306 IN UINT64 Timeout,
307 OUT UINTN *TransferLengthOut
308 );
309
310 //
311 // Protocol interface prototypes
312 //
313 /**
314 Tests to see if this driver supports a given controller. If a child device is provided,
315 it further tests to see if this driver supports creating a handle for the specified child device.
316
317 This function checks to see if the driver specified by This supports the device specified by
318 ControllerHandle. Drivers will typically use the device path attached to
319 ControllerHandle and/or the services from the bus I/O abstraction attached to
320 ControllerHandle to determine if the driver supports ControllerHandle. This function
321 may be called many times during platform initialization. In order to reduce boot times, the tests
322 performed by this function must be very small, and take as little time as possible to execute. This
323 function must not change the state of any hardware devices, and this function must be aware that the
324 device specified by ControllerHandle may already be managed by the same driver or a
325 different driver. This function must match its calls to AllocatePages() with FreePages(),
326 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
327 Since ControllerHandle may have been previously started by the same driver, if a protocol is
328 already in the opened state, then it must not be closed with CloseProtocol(). This is required
329 to guarantee the state of ControllerHandle is not modified by this function.
330
331 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
332 @param[in] ControllerHandle The handle of the controller to test. This handle
333 must support a protocol interface that supplies
334 an I/O abstraction to the driver.
335 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
336 parameter is ignored by device drivers, and is optional for bus
337 drivers. For bus drivers, if this parameter is not NULL, then
338 the bus driver must determine if the bus controller specified
339 by ControllerHandle and the child controller specified
340 by RemainingDevicePath are both supported by this
341 bus driver.
342
343 @retval EFI_SUCCESS The device specified by ControllerHandle and
344 RemainingDevicePath is supported by the driver specified by This.
345 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
346 RemainingDevicePath is already being managed by the driver
347 specified by This.
348 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
349 RemainingDevicePath is already being managed by a different
350 driver or an application that requires exclusive access.
351 Currently not implemented.
352 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
353 RemainingDevicePath is not supported by the driver specified by This.
354 **/
355 EFI_STATUS
356 EFIAPI
357 AtaBusDriverBindingSupported (
358 IN EFI_DRIVER_BINDING_PROTOCOL *This,
359 IN EFI_HANDLE Controller,
360 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
361 );
362
363 /**
364 Starts a device controller or a bus controller.
365
366 The Start() function is designed to be invoked from the EFI boot service ConnectController().
367 As a result, much of the error checking on the parameters to Start() has been moved into this
368 common boot service. It is legal to call Start() from other locations,
369 but the following calling restrictions must be followed or the system behavior will not be deterministic.
370 1. ControllerHandle must be a valid EFI_HANDLE.
371 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
372 EFI_DEVICE_PATH_PROTOCOL.
373 3. Prior to calling Start(), the Supported() function for the driver specified by This must
374 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
375
376 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
377 @param[in] ControllerHandle The handle of the controller to start. This handle
378 must support a protocol interface that supplies
379 an I/O abstraction to the driver.
380 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
381 parameter is ignored by device drivers, and is optional for bus
382 drivers. For a bus driver, if this parameter is NULL, then handles
383 for all the children of Controller are created by this driver.
384 If this parameter is not NULL and the first Device Path Node is
385 not the End of Device Path Node, then only the handle for the
386 child device specified by the first Device Path Node of
387 RemainingDevicePath is created by this driver.
388 If the first Device Path Node of RemainingDevicePath is
389 the End of Device Path Node, no child handle is created by this
390 driver.
391
392 @retval EFI_SUCCESS The device was started.
393 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
394 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
395 @retval Others The driver failded to start the device.
396
397 **/
398 EFI_STATUS
399 EFIAPI
400 AtaBusDriverBindingStart (
401 IN EFI_DRIVER_BINDING_PROTOCOL *This,
402 IN EFI_HANDLE Controller,
403 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
404 );
405
406 /**
407 Stops a device controller or a bus controller.
408
409 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
410 As a result, much of the error checking on the parameters to Stop() has been moved
411 into this common boot service. It is legal to call Stop() from other locations,
412 but the following calling restrictions must be followed or the system behavior will not be deterministic.
413 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
414 same driver's Start() function.
415 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
416 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
417 Start() function, and the Start() function must have called OpenProtocol() on
418 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
419
420 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
421 @param[in] ControllerHandle A handle to the device being stopped. The handle must
422 support a bus specific I/O protocol for the driver
423 to use to stop the device.
424 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
425 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
426 if NumberOfChildren is 0.
427
428 @retval EFI_SUCCESS The device was stopped.
429 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
430
431 **/
432 EFI_STATUS
433 EFIAPI
434 AtaBusDriverBindingStop (
435 IN EFI_DRIVER_BINDING_PROTOCOL *This,
436 IN EFI_HANDLE Controller,
437 IN UINTN NumberOfChildren,
438 IN EFI_HANDLE *ChildHandleBuffer
439 );
440
441
442 /**
443 Retrieves a Unicode string that is the user readable name of the driver.
444
445 This function retrieves the user readable name of a driver in the form of a
446 Unicode string. If the driver specified by This has a user readable name in
447 the language specified by Language, then a pointer to the driver name is
448 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
449 by This does not support the language specified by Language,
450 then EFI_UNSUPPORTED is returned.
451
452 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
453 EFI_COMPONENT_NAME_PROTOCOL instance.
454
455 @param Language[in] A pointer to a Null-terminated ASCII string
456 array indicating the language. This is the
457 language of the driver name that the caller is
458 requesting, and it must match one of the
459 languages specified in SupportedLanguages. The
460 number of languages supported by a driver is up
461 to the driver writer. Language is specified
462 in RFC 4646 or ISO 639-2 language code format.
463
464 @param DriverName[out] A pointer to the Unicode string to return.
465 This Unicode string is the name of the
466 driver specified by This in the language
467 specified by Language.
468
469 @retval EFI_SUCCESS The Unicode string for the Driver specified by
470 This and the language specified by Language was
471 returned in DriverName.
472
473 @retval EFI_INVALID_PARAMETER Language is NULL.
474
475 @retval EFI_INVALID_PARAMETER DriverName is NULL.
476
477 @retval EFI_UNSUPPORTED The driver specified by This does not support
478 the language specified by Language.
479
480 **/
481 EFI_STATUS
482 EFIAPI
483 AtaBusComponentNameGetDriverName (
484 IN EFI_COMPONENT_NAME_PROTOCOL *This,
485 IN CHAR8 *Language,
486 OUT CHAR16 **DriverName
487 );
488
489
490 /**
491 Retrieves a Unicode string that is the user readable name of the controller
492 that is being managed by a driver.
493
494 This function retrieves the user readable name of the controller specified by
495 ControllerHandle and ChildHandle in the form of a Unicode string. If the
496 driver specified by This has a user readable name in the language specified by
497 Language, then a pointer to the controller name is returned in ControllerName,
498 and EFI_SUCCESS is returned. If the driver specified by This is not currently
499 managing the controller specified by ControllerHandle and ChildHandle,
500 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
501 support the language specified by Language, then EFI_UNSUPPORTED is returned.
502
503 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
504 EFI_COMPONENT_NAME_PROTOCOL instance.
505
506 @param ControllerHandle[in] The handle of a controller that the driver
507 specified by This is managing. This handle
508 specifies the controller whose name is to be
509 returned.
510
511 @param ChildHandle[in] The handle of the child controller to retrieve
512 the name of. This is an optional parameter that
513 may be NULL. It will be NULL for device
514 drivers. It will also be NULL for a bus drivers
515 that wish to retrieve the name of the bus
516 controller. It will not be NULL for a bus
517 driver that wishes to retrieve the name of a
518 child controller.
519
520 @param Language[in] A pointer to a Null-terminated ASCII string
521 array indicating the language. This is the
522 language of the driver name that the caller is
523 requesting, and it must match one of the
524 languages specified in SupportedLanguages. The
525 number of languages supported by a driver is up
526 to the driver writer. Language is specified in
527 RFC 4646 or ISO 639-2 language code format.
528
529 @param ControllerName[out] A pointer to the Unicode string to return.
530 This Unicode string is the name of the
531 controller specified by ControllerHandle and
532 ChildHandle in the language specified by
533 Language from the point of view of the driver
534 specified by This.
535
536 @retval EFI_SUCCESS The Unicode string for the user readable name in
537 the language specified by Language for the
538 driver specified by This was returned in
539 DriverName.
540
541 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
542
543 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
544 EFI_HANDLE.
545
546 @retval EFI_INVALID_PARAMETER Language is NULL.
547
548 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
549
550 @retval EFI_UNSUPPORTED The driver specified by This is not currently
551 managing the controller specified by
552 ControllerHandle and ChildHandle.
553
554 @retval EFI_UNSUPPORTED The driver specified by This does not support
555 the language specified by Language.
556
557 **/
558 EFI_STATUS
559 EFIAPI
560 AtaBusComponentNameGetControllerName (
561 IN EFI_COMPONENT_NAME_PROTOCOL *This,
562 IN EFI_HANDLE ControllerHandle,
563 IN EFI_HANDLE ChildHandle OPTIONAL,
564 IN CHAR8 *Language,
565 OUT CHAR16 **ControllerName
566 );
567
568
569 /**
570 Reset the Block Device.
571
572 @param This Indicates a pointer to the calling context.
573 @param ExtendedVerification Driver may perform diagnostics on reset.
574
575 @retval EFI_SUCCESS The device was reset.
576 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
577 not be reset.
578
579 **/
580 EFI_STATUS
581 EFIAPI
582 AtaBlockIoReset (
583 IN EFI_BLOCK_IO_PROTOCOL *This,
584 IN BOOLEAN ExtendedVerification
585 );
586
587
588 /**
589 Read BufferSize bytes from Lba into Buffer.
590
591 @param This Indicates a pointer to the calling context.
592 @param MediaId Id of the media, changes every time the media is replaced.
593 @param Lba The starting Logical Block Address to read from
594 @param BufferSize Size of Buffer, must be a multiple of device block size.
595 @param Buffer A pointer to the destination buffer for the data. The caller is
596 responsible for either having implicit or explicit ownership of the buffer.
597
598 @retval EFI_SUCCESS The data was read correctly from the device.
599 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
600 @retval EFI_NO_MEDIA There is no media in the device.
601 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
602 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
603 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
604 or the buffer is not on proper alignment.
605
606 **/
607 EFI_STATUS
608 EFIAPI
609 AtaBlockIoReadBlocks (
610 IN EFI_BLOCK_IO_PROTOCOL *This,
611 IN UINT32 MediaId,
612 IN EFI_LBA Lba,
613 IN UINTN BufferSize,
614 OUT VOID *Buffer
615 );
616
617
618 /**
619 Write BufferSize bytes from Lba into Buffer.
620
621 @param This Indicates a pointer to the calling context.
622 @param MediaId The media ID that the write request is for.
623 @param Lba The starting logical block address to be written. The caller is
624 responsible for writing to only legitimate locations.
625 @param BufferSize Size of Buffer, must be a multiple of device block size.
626 @param Buffer A pointer to the source buffer for the data.
627
628 @retval EFI_SUCCESS The data was written correctly to the device.
629 @retval EFI_WRITE_PROTECTED The device can not be written to.
630 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
631 @retval EFI_NO_MEDIA There is no media in the device.
632 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
633 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
634 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
635 or the buffer is not on proper alignment.
636
637 **/
638 EFI_STATUS
639 EFIAPI
640 AtaBlockIoWriteBlocks (
641 IN EFI_BLOCK_IO_PROTOCOL *This,
642 IN UINT32 MediaId,
643 IN EFI_LBA Lba,
644 IN UINTN BufferSize,
645 IN VOID *Buffer
646 );
647
648
649 /**
650 Flush the Block Device.
651
652 @param This Indicates a pointer to the calling context.
653
654 @retval EFI_SUCCESS All outstanding data was written to the device
655 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data
656 @retval EFI_NO_MEDIA There is no media in the device.
657
658 **/
659 EFI_STATUS
660 EFIAPI
661 AtaBlockIoFlushBlocks (
662 IN EFI_BLOCK_IO_PROTOCOL *This
663 );
664
665 /**
666 Reset the Block Device throught Block I/O2 protocol.
667
668 @param[in] This Indicates a pointer to the calling context.
669 @param[in] ExtendedVerification Driver may perform diagnostics on reset.
670
671 @retval EFI_SUCCESS The device was reset.
672 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
673 not be reset.
674
675 **/
676 EFI_STATUS
677 EFIAPI
678 AtaBlockIoResetEx (
679 IN EFI_BLOCK_IO2_PROTOCOL *This,
680 IN BOOLEAN ExtendedVerification
681 );
682
683 /**
684 Read BufferSize bytes from Lba into Buffer.
685
686 @param[in] This Indicates a pointer to the calling context.
687 @param[in] MediaId Id of the media, changes every time the media is replaced.
688 @param[in] Lba The starting Logical Block Address to read from.
689 @param[in, out] Token A pointer to the token associated with the transaction.
690 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
691 @param[out] Buffer A pointer to the destination buffer for the data. The caller is
692 responsible for either having implicit or explicit ownership of the buffer.
693
694 @retval EFI_SUCCESS The read request was queued if Event is not NULL.
695 The data was read correctly from the device if
696 the Event is NULL.
697 @retval EFI_DEVICE_ERROR The device reported an error while performing
698 the read.
699 @retval EFI_NO_MEDIA There is no media in the device.
700 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
701 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
702 intrinsic block size of the device.
703 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
704 or the buffer is not on proper alignment.
705 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
706 of resources.
707
708 **/
709 EFI_STATUS
710 EFIAPI
711 AtaBlockIoReadBlocksEx (
712 IN EFI_BLOCK_IO2_PROTOCOL *This,
713 IN UINT32 MediaId,
714 IN EFI_LBA Lba,
715 IN OUT EFI_BLOCK_IO2_TOKEN *Token,
716 IN UINTN BufferSize,
717 OUT VOID *Buffer
718 );
719
720 /**
721 Write BufferSize bytes from Lba into Buffer.
722
723 @param[in] This Indicates a pointer to the calling context.
724 @param[in] MediaId The media ID that the write request is for.
725 @param[in] Lba The starting logical block address to be written. The
726 caller is responsible for writing to only legitimate
727 locations.
728 @param[in, out] Token A pointer to the token associated with the transaction.
729 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
730 @param[in] Buffer A pointer to the source buffer for the data.
731
732 @retval EFI_SUCCESS The data was written correctly to the device.
733 @retval EFI_WRITE_PROTECTED The device can not be written to.
734 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
735 @retval EFI_NO_MEDIA There is no media in the device.
736 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
737 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
738 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
739 or the buffer is not on proper alignment.
740
741 **/
742 EFI_STATUS
743 EFIAPI
744 AtaBlockIoWriteBlocksEx (
745 IN EFI_BLOCK_IO2_PROTOCOL *This,
746 IN UINT32 MediaId,
747 IN EFI_LBA Lba,
748 IN OUT EFI_BLOCK_IO2_TOKEN *Token,
749 IN UINTN BufferSize,
750 IN VOID *Buffer
751 );
752
753 /**
754 Flush the Block Device.
755
756 @param[in] This Indicates a pointer to the calling context.
757 @param[in, out] Token A pointer to the token associated with the transaction.
758
759 @retval EFI_SUCCESS All outstanding data was written to the device
760 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data
761 @retval EFI_NO_MEDIA There is no media in the device.
762
763 **/
764 EFI_STATUS
765 EFIAPI
766 AtaBlockIoFlushBlocksEx (
767 IN EFI_BLOCK_IO2_PROTOCOL *This,
768 IN OUT EFI_BLOCK_IO2_TOKEN *Token
769 );
770
771 /**
772 Provides inquiry information for the controller type.
773
774 This function is used by the IDE bus driver to get inquiry data. Data format
775 of Identify data is defined by the Interface GUID.
776
777 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
778 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.
779 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.
780
781 @retval EFI_SUCCESS The command was accepted without any errors.
782 @retval EFI_NOT_FOUND Device does not support this data class
783 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
784 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
785
786 **/
787 EFI_STATUS
788 EFIAPI
789 AtaDiskInfoInquiry (
790 IN EFI_DISK_INFO_PROTOCOL *This,
791 IN OUT VOID *InquiryData,
792 IN OUT UINT32 *InquiryDataSize
793 );
794
795
796 /**
797 Provides identify information for the controller type.
798
799 This function is used by the IDE bus driver to get identify data. Data format
800 of Identify data is defined by the Interface GUID.
801
802 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
803 instance.
804 @param[in, out] IdentifyData Pointer to a buffer for the identify data.
805 @param[in, out] IdentifyDataSize Pointer to the value for the identify data
806 size.
807
808 @retval EFI_SUCCESS The command was accepted without any errors.
809 @retval EFI_NOT_FOUND Device does not support this data class
810 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
811 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
812
813 **/
814 EFI_STATUS
815 EFIAPI
816 AtaDiskInfoIdentify (
817 IN EFI_DISK_INFO_PROTOCOL *This,
818 IN OUT VOID *IdentifyData,
819 IN OUT UINT32 *IdentifyDataSize
820 );
821
822
823 /**
824 Provides sense data information for the controller type.
825
826 This function is used by the IDE bus driver to get sense data.
827 Data format of Sense data is defined by the Interface GUID.
828
829 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
830 @param[in, out] SenseData Pointer to the SenseData.
831 @param[in, out] SenseDataSize Size of SenseData in bytes.
832 @param[out] SenseDataNumber Pointer to the value for the sense data size.
833
834 @retval EFI_SUCCESS The command was accepted without any errors.
835 @retval EFI_NOT_FOUND Device does not support this data class.
836 @retval EFI_DEVICE_ERROR Error reading SenseData from device.
837 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.
838
839 **/
840 EFI_STATUS
841 EFIAPI
842 AtaDiskInfoSenseData (
843 IN EFI_DISK_INFO_PROTOCOL *This,
844 IN OUT VOID *SenseData,
845 IN OUT UINT32 *SenseDataSize,
846 OUT UINT8 *SenseDataNumber
847 );
848
849
850 /**
851 This function is used by the IDE bus driver to get controller information.
852
853 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
854 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.
855 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.
856
857 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.
858 @retval EFI_UNSUPPORTED This is not an IDE device.
859
860 **/
861 EFI_STATUS
862 EFIAPI
863 AtaDiskInfoWhichIde (
864 IN EFI_DISK_INFO_PROTOCOL *This,
865 OUT UINT32 *IdeChannel,
866 OUT UINT32 *IdeDevice
867 );
868
869 /**
870 Send a security protocol command to a device that receives data and/or the result
871 of one or more commands sent by SendData.
872
873 The ReceiveData function sends a security protocol command to the given MediaId.
874 The security protocol command sent is defined by SecurityProtocolId and contains
875 the security protocol specific data SecurityProtocolSpecificData. The function
876 returns the data from the security protocol command in PayloadBuffer.
877
878 For devices supporting the SCSI command set, the security protocol command is sent
879 using the SECURITY PROTOCOL IN command defined in SPC-4.
880
881 For devices supporting the ATA command set, the security protocol command is sent
882 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
883 is non-zero.
884
885 If the PayloadBufferSize is zero, the security protocol command is sent using the
886 Trusted Non-Data command defined in ATA8-ACS.
887
888 If PayloadBufferSize is too small to store the available data from the security
889 protocol command, the function shall copy PayloadBufferSize bytes into the
890 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
891
892 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
893 the function shall return EFI_INVALID_PARAMETER.
894
895 If the given MediaId does not support security protocol commands, the function shall
896 return EFI_UNSUPPORTED. If there is no media in the device, the function returns
897 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
898 the function returns EFI_MEDIA_CHANGED.
899
900 If the security protocol fails to complete within the Timeout period, the function
901 shall return EFI_TIMEOUT.
902
903 If the security protocol command completes without an error, the function shall
904 return EFI_SUCCESS. If the security protocol command completes with an error, the
905 function shall return EFI_DEVICE_ERROR.
906
907 @param This Indicates a pointer to the calling context.
908 @param MediaId ID of the medium to receive data from.
909 @param Timeout The timeout, in 100ns units, to use for the execution
910 of the security protocol command. A Timeout value of 0
911 means that this function will wait indefinitely for the
912 security protocol command to execute. If Timeout is greater
913 than zero, then this function will return EFI_TIMEOUT
914 if the time required to execute the receive data command
915 is greater than Timeout.
916 @param SecurityProtocolId The value of the "Security Protocol" parameter of
917 the security protocol command to be sent.
918 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
919 of the security protocol command to be sent.
920 @param PayloadBufferSize Size in bytes of the payload data buffer.
921 @param PayloadBuffer A pointer to a destination buffer to store the security
922 protocol command specific payload data for the security
923 protocol command. The caller is responsible for having
924 either implicit or explicit ownership of the buffer.
925 @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the
926 data written to the payload data buffer.
927
928 @retval EFI_SUCCESS The security protocol command completed successfully.
929 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available
930 data from the device. The PayloadBuffer contains the truncated data.
931 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
932 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
933 @retval EFI_NO_MEDIA There is no media in the device.
934 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
935 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and
936 PayloadBufferSize is non-zero.
937 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
938 protocol command to execute.
939
940 **/
941 EFI_STATUS
942 EFIAPI
943 AtaStorageSecurityReceiveData (
944 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
945 IN UINT32 MediaId,
946 IN UINT64 Timeout,
947 IN UINT8 SecurityProtocolId,
948 IN UINT16 SecurityProtocolSpecificData,
949 IN UINTN PayloadBufferSize,
950 OUT VOID *PayloadBuffer,
951 OUT UINTN *PayloadTransferSize
952 );
953
954 /**
955 Send a security protocol command to a device.
956
957 The SendData function sends a security protocol command containing the payload
958 PayloadBuffer to the given MediaId. The security protocol command sent is
959 defined by SecurityProtocolId and contains the security protocol specific data
960 SecurityProtocolSpecificData. If the underlying protocol command requires a
961 specific padding for the command payload, the SendData function shall add padding
962 bytes to the command payload to satisfy the padding requirements.
963
964 For devices supporting the SCSI command set, the security protocol command is sent
965 using the SECURITY PROTOCOL OUT command defined in SPC-4.
966
967 For devices supporting the ATA command set, the security protocol command is sent
968 using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize
969 is non-zero. If the PayloadBufferSize is zero, the security protocol command is
970 sent using the Trusted Non-Data command defined in ATA8-ACS.
971
972 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall
973 return EFI_INVALID_PARAMETER.
974
975 If the given MediaId does not support security protocol commands, the function
976 shall return EFI_UNSUPPORTED. If there is no media in the device, the function
977 returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the
978 device, the function returns EFI_MEDIA_CHANGED.
979
980 If the security protocol fails to complete within the Timeout period, the function
981 shall return EFI_TIMEOUT.
982
983 If the security protocol command completes without an error, the function shall return
984 EFI_SUCCESS. If the security protocol command completes with an error, the function
985 shall return EFI_DEVICE_ERROR.
986
987 @param This Indicates a pointer to the calling context.
988 @param MediaId ID of the medium to receive data from.
989 @param Timeout The timeout, in 100ns units, to use for the execution
990 of the security protocol command. A Timeout value of 0
991 means that this function will wait indefinitely for the
992 security protocol command to execute. If Timeout is greater
993 than zero, then this function will return EFI_TIMEOUT
994 if the time required to execute the receive data command
995 is greater than Timeout.
996 @param SecurityProtocolId The value of the "Security Protocol" parameter of
997 the security protocol command to be sent.
998 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
999 of the security protocol command to be sent.
1000 @param PayloadBufferSize Size in bytes of the payload data buffer.
1001 @param PayloadBuffer A pointer to a destination buffer to store the security
1002 protocol command specific payload data for the security
1003 protocol command.
1004
1005 @retval EFI_SUCCESS The security protocol command completed successfully.
1006 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
1007 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
1008 @retval EFI_NO_MEDIA There is no media in the device.
1009 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
1010 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.
1011 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
1012 protocol command to execute.
1013
1014 **/
1015 EFI_STATUS
1016 EFIAPI
1017 AtaStorageSecuritySendData (
1018 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
1019 IN UINT32 MediaId,
1020 IN UINT64 Timeout,
1021 IN UINT8 SecurityProtocolId,
1022 IN UINT16 SecurityProtocolSpecificData,
1023 IN UINTN PayloadBufferSize,
1024 IN VOID *PayloadBuffer
1025 );
1026
1027 #endif