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