]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
Clean up DEC files:
[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
202 IN ATA_BUS_ASYN_TASK *Task\r
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
290\r
291 @retval EFI_SUCCESS The data transfer is complete successfully.\r
292 @return others Some error occurs when transferring data. \r
293\r
294**/\r
295EFI_STATUS\r
296EFIAPI\r
297TrustTransferAtaDevice (\r
298 IN OUT ATA_DEVICE *AtaDevice,\r
299 IN OUT VOID *Buffer,\r
300 IN UINT8 SecurityProtocolId,\r
301 IN UINT16 SecurityProtocolSpecificData,\r
302 IN UINTN TransferLength,\r
303 IN BOOLEAN IsTrustSend,\r
304 IN UINT64 Timeout,\r
305 OUT UINTN *TransferLengthOut\r
306 );\r
ad86a50a 307\r
308//\r
309// Protocol interface prototypes\r
310//\r
311/**\r
312 Tests to see if this driver supports a given controller. If a child device is provided, \r
313 it further tests to see if this driver supports creating a handle for the specified child device.\r
314\r
315 This function checks to see if the driver specified by This supports the device specified by \r
316 ControllerHandle. Drivers will typically use the device path attached to \r
317 ControllerHandle and/or the services from the bus I/O abstraction attached to \r
318 ControllerHandle to determine if the driver supports ControllerHandle. This function \r
319 may be called many times during platform initialization. In order to reduce boot times, the tests \r
320 performed by this function must be very small, and take as little time as possible to execute. This \r
321 function must not change the state of any hardware devices, and this function must be aware that the \r
322 device specified by ControllerHandle may already be managed by the same driver or a \r
323 different driver. This function must match its calls to AllocatePages() with FreePages(), \r
324 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). \r
325 Since ControllerHandle may have been previously started by the same driver, if a protocol is \r
326 already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
327 to guarantee the state of ControllerHandle is not modified by this function.\r
328\r
329 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
330 @param[in] ControllerHandle The handle of the controller to test. This handle \r
331 must support a protocol interface that supplies \r
332 an I/O abstraction to the driver.\r
333 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
334 parameter is ignored by device drivers, and is optional for bus \r
335 drivers. For bus drivers, if this parameter is not NULL, then \r
336 the bus driver must determine if the bus controller specified \r
337 by ControllerHandle and the child controller specified \r
338 by RemainingDevicePath are both supported by this \r
339 bus driver.\r
340\r
341 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
342 RemainingDevicePath is supported by the driver specified by This.\r
343 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
344 RemainingDevicePath is already being managed by the driver\r
345 specified by This.\r
346 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
347 RemainingDevicePath is already being managed by a different\r
348 driver or an application that requires exclusive access.\r
349 Currently not implemented.\r
350 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
351 RemainingDevicePath is not supported by the driver specified by This.\r
352**/\r
353EFI_STATUS\r
354EFIAPI\r
355AtaBusDriverBindingSupported (\r
356 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
357 IN EFI_HANDLE Controller,\r
358 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
359 );\r
360\r
361/**\r
362 Starts a device controller or a bus controller.\r
363\r
364 The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
365 As a result, much of the error checking on the parameters to Start() has been moved into this \r
366 common boot service. It is legal to call Start() from other locations, \r
367 but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
368 1. ControllerHandle must be a valid EFI_HANDLE.\r
369 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
370 EFI_DEVICE_PATH_PROTOCOL.\r
371 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
372 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r
373\r
374 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
375 @param[in] ControllerHandle The handle of the controller to start. This handle \r
376 must support a protocol interface that supplies \r
377 an I/O abstraction to the driver.\r
378 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
379 parameter is ignored by device drivers, and is optional for bus \r
380 drivers. For a bus driver, if this parameter is NULL, then handles \r
381 for all the children of Controller are created by this driver. \r
382 If this parameter is not NULL and the first Device Path Node is \r
383 not the End of Device Path Node, then only the handle for the \r
384 child device specified by the first Device Path Node of \r
385 RemainingDevicePath is created by this driver.\r
386 If the first Device Path Node of RemainingDevicePath is \r
387 the End of Device Path Node, no child handle is created by this\r
388 driver.\r
389\r
390 @retval EFI_SUCCESS The device was started.\r
391 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
392 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
393 @retval Others The driver failded to start the device.\r
394\r
395**/\r
396EFI_STATUS\r
397EFIAPI\r
398AtaBusDriverBindingStart (\r
399 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
400 IN EFI_HANDLE Controller,\r
401 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
402 );\r
403\r
404/**\r
405 Stops a device controller or a bus controller.\r
406 \r
407 The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
408 As a result, much of the error checking on the parameters to Stop() has been moved \r
409 into this common boot service. It is legal to call Stop() from other locations, \r
410 but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
411 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
412 same driver's Start() function.\r
413 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
414 EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
415 Start() function, and the Start() function must have called OpenProtocol() on\r
416 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
417 \r
418 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
419 @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
420 support a bus specific I/O protocol for the driver \r
421 to use to stop the device.\r
422 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
423 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
424 if NumberOfChildren is 0.\r
425\r
426 @retval EFI_SUCCESS The device was stopped.\r
427 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
428\r
429**/\r
430EFI_STATUS\r
431EFIAPI\r
432AtaBusDriverBindingStop (\r
433 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
434 IN EFI_HANDLE Controller,\r
435 IN UINTN NumberOfChildren,\r
436 IN EFI_HANDLE *ChildHandleBuffer\r
437 );\r
438\r
439\r
440/**\r
441 Retrieves a Unicode string that is the user readable name of the driver.\r
442\r
443 This function retrieves the user readable name of a driver in the form of a\r
444 Unicode string. If the driver specified by This has a user readable name in\r
445 the language specified by Language, then a pointer to the driver name is\r
446 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
447 by This does not support the language specified by Language,\r
448 then EFI_UNSUPPORTED is returned.\r
449\r
450 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
451 EFI_COMPONENT_NAME_PROTOCOL instance.\r
452\r
453 @param Language[in] A pointer to a Null-terminated ASCII string\r
454 array indicating the language. This is the\r
455 language of the driver name that the caller is\r
456 requesting, and it must match one of the\r
457 languages specified in SupportedLanguages. The\r
458 number of languages supported by a driver is up\r
459 to the driver writer. Language is specified\r
460 in RFC 4646 or ISO 639-2 language code format.\r
461\r
462 @param DriverName[out] A pointer to the Unicode string to return.\r
463 This Unicode string is the name of the\r
464 driver specified by This in the language\r
465 specified by Language.\r
466\r
467 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
468 This and the language specified by Language was\r
469 returned in DriverName.\r
470\r
471 @retval EFI_INVALID_PARAMETER Language is NULL.\r
472\r
473 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
474\r
475 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
476 the language specified by Language.\r
477\r
478**/\r
479EFI_STATUS\r
480EFIAPI\r
481AtaBusComponentNameGetDriverName (\r
482 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
483 IN CHAR8 *Language,\r
484 OUT CHAR16 **DriverName\r
485 );\r
486\r
487\r
488/**\r
489 Retrieves a Unicode string that is the user readable name of the controller\r
490 that is being managed by a driver.\r
491\r
492 This function retrieves the user readable name of the controller specified by\r
493 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
494 driver specified by This has a user readable name in the language specified by\r
495 Language, then a pointer to the controller name is returned in ControllerName,\r
496 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
497 managing the controller specified by ControllerHandle and ChildHandle,\r
498 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
499 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
500\r
501 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
502 EFI_COMPONENT_NAME_PROTOCOL instance.\r
503\r
504 @param ControllerHandle[in] The handle of a controller that the driver\r
505 specified by This is managing. This handle\r
506 specifies the controller whose name is to be\r
507 returned.\r
508\r
509 @param ChildHandle[in] The handle of the child controller to retrieve\r
510 the name of. This is an optional parameter that\r
511 may be NULL. It will be NULL for device\r
512 drivers. It will also be NULL for a bus drivers\r
513 that wish to retrieve the name of the bus\r
514 controller. It will not be NULL for a bus\r
515 driver that wishes to retrieve the name of a\r
516 child controller.\r
517\r
518 @param Language[in] A pointer to a Null-terminated ASCII string\r
519 array indicating the language. This is the\r
520 language of the driver name that the caller is\r
521 requesting, and it must match one of the\r
522 languages specified in SupportedLanguages. The\r
523 number of languages supported by a driver is up\r
524 to the driver writer. Language is specified in\r
525 RFC 4646 or ISO 639-2 language code format.\r
526\r
527 @param ControllerName[out] A pointer to the Unicode string to return.\r
528 This Unicode string is the name of the\r
529 controller specified by ControllerHandle and\r
530 ChildHandle in the language specified by\r
531 Language from the point of view of the driver\r
532 specified by This.\r
533\r
534 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
535 the language specified by Language for the\r
536 driver specified by This was returned in\r
537 DriverName.\r
538\r
539 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
540\r
541 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
542 EFI_HANDLE.\r
543\r
544 @retval EFI_INVALID_PARAMETER Language is NULL.\r
545\r
546 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
547\r
548 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
549 managing the controller specified by\r
550 ControllerHandle and ChildHandle.\r
551\r
552 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
553 the language specified by Language.\r
554\r
555**/\r
556EFI_STATUS\r
557EFIAPI\r
558AtaBusComponentNameGetControllerName (\r
559 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
560 IN EFI_HANDLE ControllerHandle,\r
561 IN EFI_HANDLE ChildHandle OPTIONAL,\r
562 IN CHAR8 *Language,\r
563 OUT CHAR16 **ControllerName\r
564 );\r
565\r
566\r
567/**\r
568 Reset the Block Device.\r
569\r
570 @param This Indicates a pointer to the calling context.\r
571 @param ExtendedVerification Driver may perform diagnostics on reset.\r
572\r
573 @retval EFI_SUCCESS The device was reset.\r
574 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
575 not be reset.\r
576\r
577**/\r
578EFI_STATUS\r
579EFIAPI\r
580AtaBlockIoReset (\r
581 IN EFI_BLOCK_IO_PROTOCOL *This,\r
582 IN BOOLEAN ExtendedVerification\r
583 );\r
584\r
585\r
586/**\r
587 Read BufferSize bytes from Lba into Buffer.\r
588\r
589 @param This Indicates a pointer to the calling context.\r
590 @param MediaId Id of the media, changes every time the media is replaced.\r
591 @param Lba The starting Logical Block Address to read from\r
592 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
593 @param Buffer A pointer to the destination buffer for the data. The caller is\r
594 responsible for either having implicit or explicit ownership of the buffer.\r
595\r
596 @retval EFI_SUCCESS The data was read correctly from the device.\r
597 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
598 @retval EFI_NO_MEDIA There is no media in the device.\r
599 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
600 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
601 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
602 or the buffer is not on proper alignment.\r
603\r
604**/\r
605EFI_STATUS\r
606EFIAPI\r
607AtaBlockIoReadBlocks (\r
608 IN EFI_BLOCK_IO_PROTOCOL *This,\r
609 IN UINT32 MediaId,\r
610 IN EFI_LBA Lba,\r
611 IN UINTN BufferSize,\r
612 OUT VOID *Buffer\r
613 );\r
614\r
615\r
616/**\r
617 Write BufferSize bytes from Lba into Buffer.\r
618\r
619 @param This Indicates a pointer to the calling context.\r
620 @param MediaId The media ID that the write request is for.\r
621 @param Lba The starting logical block address to be written. The caller is\r
622 responsible for writing to only legitimate locations.\r
623 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
624 @param Buffer A pointer to the source buffer for the data.\r
625\r
626 @retval EFI_SUCCESS The data was written correctly to the device.\r
627 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
628 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
629 @retval EFI_NO_MEDIA There is no media in the device.\r
630 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
631 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
632 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
633 or the buffer is not on proper alignment.\r
634\r
635**/\r
636EFI_STATUS\r
637EFIAPI\r
638AtaBlockIoWriteBlocks (\r
639 IN EFI_BLOCK_IO_PROTOCOL *This,\r
640 IN UINT32 MediaId,\r
641 IN EFI_LBA Lba,\r
642 IN UINTN BufferSize,\r
643 IN VOID *Buffer\r
644 );\r
645\r
646\r
647/**\r
648 Flush the Block Device.\r
649\r
650 @param This Indicates a pointer to the calling context.\r
651\r
652 @retval EFI_SUCCESS All outstanding data was written to the device\r
653 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data\r
654 @retval EFI_NO_MEDIA There is no media in the device.\r
655\r
656**/\r
657EFI_STATUS\r
658EFIAPI\r
659AtaBlockIoFlushBlocks (\r
660 IN EFI_BLOCK_IO_PROTOCOL *This\r
661 );\r
662\r
490b5ea1 663/**\r
664 Reset the Block Device throught Block I/O2 protocol.\r
665\r
666 @param[in] This Indicates a pointer to the calling context.\r
667 @param[in] ExtendedVerification Driver may perform diagnostics on reset.\r
668\r
669 @retval EFI_SUCCESS The device was reset.\r
670 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
671 not be reset.\r
672\r
673**/\r
674EFI_STATUS\r
675EFIAPI\r
676AtaBlockIoResetEx (\r
677 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
678 IN BOOLEAN ExtendedVerification\r
679 );\r
680\r
681/**\r
682 Read BufferSize bytes from Lba into Buffer.\r
683\r
684 @param[in] This Indicates a pointer to the calling context.\r
685 @param[in] MediaId Id of the media, changes every time the media is replaced.\r
686 @param[in] Lba The starting Logical Block Address to read from.\r
687 @param[in, out] Token A pointer to the token associated with the transaction.\r
688 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
689 @param[out] Buffer A pointer to the destination buffer for the data. The caller is\r
690 responsible for either having implicit or explicit ownership of the buffer.\r
691\r
692 @retval EFI_SUCCESS The read request was queued if Event is not NULL.\r
693 The data was read correctly from the device if\r
694 the Event is NULL.\r
695 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
696 the read.\r
697 @retval EFI_NO_MEDIA There is no media in the device.\r
698 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
699 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
700 intrinsic block size of the device.\r
701 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
702 or the buffer is not on proper alignment.\r
703 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
704 of resources.\r
705\r
706**/\r
707EFI_STATUS\r
708EFIAPI\r
709AtaBlockIoReadBlocksEx (\r
710 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
711 IN UINT32 MediaId,\r
712 IN EFI_LBA Lba,\r
713 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
714 IN UINTN BufferSize,\r
715 OUT VOID *Buffer\r
716 );\r
717\r
718/**\r
719 Write BufferSize bytes from Lba into Buffer.\r
720\r
721 @param[in] This Indicates a pointer to the calling context.\r
722 @param[in] MediaId The media ID that the write request is for.\r
723 @param[in] Lba The starting logical block address to be written. The\r
724 caller is responsible for writing to only legitimate\r
725 locations.\r
726 @param[in, out] Token A pointer to the token associated with the transaction.\r
727 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
728 @param[in] Buffer A pointer to the source buffer for the data.\r
729\r
730 @retval EFI_SUCCESS The data was written correctly to the device.\r
731 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
732 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
733 @retval EFI_NO_MEDIA There is no media in the device.\r
734 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
735 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
736 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
737 or the buffer is not on proper alignment.\r
738\r
739**/\r
740EFI_STATUS\r
741EFIAPI\r
742AtaBlockIoWriteBlocksEx (\r
743 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
744 IN UINT32 MediaId,\r
745 IN EFI_LBA Lba,\r
746 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
747 IN UINTN BufferSize,\r
748 IN VOID *Buffer\r
749 );\r
750\r
751/**\r
752 Flush the Block Device.\r
753\r
754 @param[in] This Indicates a pointer to the calling context.\r
755 @param[in, out] Token A pointer to the token associated with the transaction.\r
756\r
757 @retval EFI_SUCCESS All outstanding data was written to the device\r
758 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data\r
759 @retval EFI_NO_MEDIA There is no media in the device.\r
760\r
761**/\r
762EFI_STATUS\r
763EFIAPI\r
764AtaBlockIoFlushBlocksEx (\r
765 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
766 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
767 );\r
ad86a50a 768\r
769/**\r
770 Provides inquiry information for the controller type.\r
771 \r
772 This function is used by the IDE bus driver to get inquiry data. Data format\r
773 of Identify data is defined by the Interface GUID.\r
774\r
05a44e91 775 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
776 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.\r
777 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.\r
ad86a50a 778\r
779 @retval EFI_SUCCESS The command was accepted without any errors.\r
780 @retval EFI_NOT_FOUND Device does not support this data class \r
781 @retval EFI_DEVICE_ERROR Error reading InquiryData from device \r
782 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough \r
783\r
784**/\r
785EFI_STATUS\r
786EFIAPI\r
787AtaDiskInfoInquiry (\r
788 IN EFI_DISK_INFO_PROTOCOL *This,\r
789 IN OUT VOID *InquiryData,\r
790 IN OUT UINT32 *InquiryDataSize\r
791 );\r
792\r
793\r
794/**\r
795 Provides identify information for the controller type.\r
796\r
797 This function is used by the IDE bus driver to get identify data. Data format\r
798 of Identify data is defined by the Interface GUID.\r
799\r
05a44e91 800 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL \r
ad86a50a 801 instance.\r
05a44e91 802 @param[in, out] IdentifyData Pointer to a buffer for the identify data.\r
803 @param[in, out] IdentifyDataSize Pointer to the value for the identify data\r
ad86a50a 804 size.\r
805\r
806 @retval EFI_SUCCESS The command was accepted without any errors.\r
807 @retval EFI_NOT_FOUND Device does not support this data class \r
808 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device \r
809 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough \r
810\r
811**/\r
812EFI_STATUS\r
813EFIAPI\r
814AtaDiskInfoIdentify (\r
815 IN EFI_DISK_INFO_PROTOCOL *This,\r
816 IN OUT VOID *IdentifyData,\r
817 IN OUT UINT32 *IdentifyDataSize\r
818 );\r
819\r
820\r
821/**\r
822 Provides sense data information for the controller type.\r
823 \r
824 This function is used by the IDE bus driver to get sense data. \r
825 Data format of Sense data is defined by the Interface GUID.\r
826\r
05a44e91 827 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
828 @param[in, out] SenseData Pointer to the SenseData.\r
829 @param[in, out] SenseDataSize Size of SenseData in bytes.\r
830 @param[out] SenseDataNumber Pointer to the value for the sense data size.\r
ad86a50a 831\r
832 @retval EFI_SUCCESS The command was accepted without any errors.\r
833 @retval EFI_NOT_FOUND Device does not support this data class.\r
834 @retval EFI_DEVICE_ERROR Error reading SenseData from device.\r
835 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.\r
836\r
837**/\r
838EFI_STATUS\r
839EFIAPI\r
840AtaDiskInfoSenseData (\r
841 IN EFI_DISK_INFO_PROTOCOL *This,\r
842 IN OUT VOID *SenseData,\r
843 IN OUT UINT32 *SenseDataSize,\r
844 OUT UINT8 *SenseDataNumber\r
845 );\r
846\r
847\r
848/**\r
849 This function is used by the IDE bus driver to get controller information.\r
850\r
851 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. \r
852 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.\r
853 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.\r
854\r
855 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.\r
856 @retval EFI_UNSUPPORTED This is not an IDE device.\r
857\r
858**/\r
859EFI_STATUS\r
860EFIAPI\r
861AtaDiskInfoWhichIde (\r
862 IN EFI_DISK_INFO_PROTOCOL *This,\r
863 OUT UINT32 *IdeChannel,\r
864 OUT UINT32 *IdeDevice\r
865 );\r
866\r
c24097a5 867/**\r
868 Send a security protocol command to a device that receives data and/or the result\r
869 of one or more commands sent by SendData.\r
870\r
871 The ReceiveData function sends a security protocol command to the given MediaId.\r
872 The security protocol command sent is defined by SecurityProtocolId and contains\r
873 the security protocol specific data SecurityProtocolSpecificData. The function\r
874 returns the data from the security protocol command in PayloadBuffer.\r
875\r
876 For devices supporting the SCSI command set, the security protocol command is sent\r
877 using the SECURITY PROTOCOL IN command defined in SPC-4.\r
878\r
879 For devices supporting the ATA command set, the security protocol command is sent\r
880 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize\r
881 is non-zero.\r
882\r
883 If the PayloadBufferSize is zero, the security protocol command is sent using the\r
884 Trusted Non-Data command defined in ATA8-ACS.\r
885\r
886 If PayloadBufferSize is too small to store the available data from the security\r
887 protocol command, the function shall copy PayloadBufferSize bytes into the\r
888 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.\r
889\r
890 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,\r
891 the function shall return EFI_INVALID_PARAMETER.\r
892\r
893 If the given MediaId does not support security protocol commands, the function shall\r
894 return EFI_UNSUPPORTED. If there is no media in the device, the function returns\r
895 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,\r
896 the function returns EFI_MEDIA_CHANGED.\r
897\r
898 If the security protocol fails to complete within the Timeout period, the function\r
899 shall return EFI_TIMEOUT.\r
900\r
901 If the security protocol command completes without an error, the function shall\r
902 return EFI_SUCCESS. If the security protocol command completes with an error, the\r
903 function shall return EFI_DEVICE_ERROR.\r
904\r
905 @param This Indicates a pointer to the calling context.\r
906 @param MediaId ID of the medium to receive data from.\r
907 @param Timeout The timeout, in 100ns units, to use for the execution\r
908 of the security protocol command. A Timeout value of 0\r
909 means that this function will wait indefinitely for the\r
910 security protocol command to execute. If Timeout is greater\r
911 than zero, then this function will return EFI_TIMEOUT\r
912 if the time required to execute the receive data command\r
913 is greater than Timeout.\r
914 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
915 the security protocol command to be sent.\r
916 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
917 of the security protocol command to be sent.\r
918 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
919 @param PayloadBuffer A pointer to a destination buffer to store the security\r
920 protocol command specific payload data for the security\r
921 protocol command. The caller is responsible for having\r
922 either implicit or explicit ownership of the buffer.\r
923 @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the\r
924 data written to the payload data buffer.\r
925\r
926 @retval EFI_SUCCESS The security protocol command completed successfully.\r
927 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available\r
928 data from the device. The PayloadBuffer contains the truncated data.\r
929 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
930 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
931 @retval EFI_NO_MEDIA There is no media in the device.\r
932 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
933 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and\r
934 PayloadBufferSize is non-zero.\r
935 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
936 protocol command to execute.\r
937\r
938**/\r
939EFI_STATUS\r
940EFIAPI\r
941AtaStorageSecurityReceiveData (\r
942 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
943 IN UINT32 MediaId,\r
944 IN UINT64 Timeout,\r
945 IN UINT8 SecurityProtocolId,\r
946 IN UINT16 SecurityProtocolSpecificData,\r
947 IN UINTN PayloadBufferSize,\r
948 OUT VOID *PayloadBuffer,\r
949 OUT UINTN *PayloadTransferSize\r
950);\r
951\r
952/**\r
953 Send a security protocol command to a device.\r
954\r
955 The SendData function sends a security protocol command containing the payload\r
956 PayloadBuffer to the given MediaId. The security protocol command sent is\r
957 defined by SecurityProtocolId and contains the security protocol specific data\r
958 SecurityProtocolSpecificData. If the underlying protocol command requires a\r
959 specific padding for the command payload, the SendData function shall add padding\r
960 bytes to the command payload to satisfy the padding requirements.\r
961\r
962 For devices supporting the SCSI command set, the security protocol command is sent\r
963 using the SECURITY PROTOCOL OUT command defined in SPC-4.\r
964\r
965 For devices supporting the ATA command set, the security protocol command is sent\r
966 using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize\r
967 is non-zero. If the PayloadBufferSize is zero, the security protocol command is\r
968 sent using the Trusted Non-Data command defined in ATA8-ACS.\r
969\r
970 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall\r
971 return EFI_INVALID_PARAMETER.\r
972\r
973 If the given MediaId does not support security protocol commands, the function\r
974 shall return EFI_UNSUPPORTED. If there is no media in the device, the function\r
975 returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the\r
976 device, the function returns EFI_MEDIA_CHANGED.\r
977\r
978 If the security protocol fails to complete within the Timeout period, the function\r
979 shall return EFI_TIMEOUT.\r
980\r
981 If the security protocol command completes without an error, the function shall return\r
982 EFI_SUCCESS. If the security protocol command completes with an error, the function\r
983 shall return EFI_DEVICE_ERROR.\r
984\r
985 @param This Indicates a pointer to the calling context.\r
986 @param MediaId ID of the medium to receive data from.\r
987 @param Timeout The timeout, in 100ns units, to use for the execution\r
988 of the security protocol command. A Timeout value of 0\r
989 means that this function will wait indefinitely for the\r
990 security protocol command to execute. If Timeout is greater\r
991 than zero, then this function will return EFI_TIMEOUT\r
992 if the time required to execute the receive data command\r
993 is greater than Timeout.\r
994 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
995 the security protocol command to be sent.\r
996 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
997 of the security protocol command to be sent.\r
998 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
999 @param PayloadBuffer A pointer to a destination buffer to store the security\r
1000 protocol command specific payload data for the security\r
1001 protocol command.\r
1002\r
1003 @retval EFI_SUCCESS The security protocol command completed successfully.\r
1004 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
1005 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
1006 @retval EFI_NO_MEDIA There is no media in the device.\r
1007 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
1008 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.\r
1009 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
1010 protocol command to execute.\r
1011\r
1012**/\r
1013EFI_STATUS\r
1014EFIAPI\r
1015AtaStorageSecuritySendData (\r
1016 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
1017 IN UINT32 MediaId,\r
1018 IN UINT64 Timeout,\r
1019 IN UINT8 SecurityProtocolId,\r
1020 IN UINT16 SecurityProtocolSpecificData,\r
1021 IN UINTN PayloadBufferSize,\r
1022 IN VOID *PayloadBuffer\r
1023);\r
1024\r
ad86a50a 1025#endif\r