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