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