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