]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
add native ide/ahci driver
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaAtapiPassThru / AtaAtapiPassThru.h
1 /** @file
2 Header file for ATA/ATAPI PASS THRU driver.
3
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14 #ifndef __ATA_ATAPI_PASS_THRU_H__
15 #define __ATA_ATAPI_PASS_THRU_H__
16
17 #include <Uefi.h>
18
19 #include <IndustryStandard/Pci.h>
20 #include <IndustryStandard/Atapi.h>
21 #include <IndustryStandard/Scsi.h>
22
23 #include <Protocol/PciIo.h>
24 #include <Protocol/IdeControllerInit.h>
25 #include <Protocol/AtaPassThru.h>
26 #include <Protocol/ScsiPassThruExt.h>
27
28 #include <Library/DebugLib.h>
29 #include <Library/BaseLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/UefiDriverEntryPoint.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/UefiLib.h>
34 #include <Library/PciLib.h>
35 #include <Library/PcdLib.h>
36 #include <Library/TimerLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/ReportStatusCodeLib.h>
39 #include <Library/DevicePathLib.h>
40
41 #include "IdeMode.h"
42 #include "AhciMode.h"
43
44 extern EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding;
45 extern EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName;
46 extern EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2;
47
48 #define ATA_ATAPI_PASS_THRU_SIGNATURE SIGNATURE_32 ('a', 'a', 'p', 't')
49 #define ATA_ATAPI_DEVICE_SIGNATURE SIGNATURE_32 ('a', 'd', 'e', 'v')
50
51 typedef enum {
52 EfiAtaIdeMode,
53 EfiAtaAhciMode,
54 EfiAtaRaidMode,
55 EfiAtaUnknownMode
56 } EFI_ATA_HC_WORK_MODE;
57
58 typedef enum {
59 EfiIdeCdrom, /* ATAPI CDROM */
60 EfiIdeHarddisk, /* Hard Disk */
61 EfiPortMultiplier, /* Port Multiplier */
62 EfiIdeUnknown
63 } EFI_ATA_DEVICE_TYPE;
64
65 //
66 // Ahci mode device info
67 //
68 typedef struct {
69 UINT32 Signature;
70 LIST_ENTRY Link;
71
72 UINT16 Port;
73 UINT16 PortMultiplier;
74 EFI_ATA_DEVICE_TYPE Type;
75
76 EFI_IDENTIFY_DATA *IdentifyData;
77 } EFI_ATA_DEVICE_INFO;
78
79 typedef struct {
80 UINT32 Signature;
81
82 EFI_HANDLE ControllerHandle;
83 EFI_PCI_IO_PROTOCOL *PciIo;
84 EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;
85
86 EFI_ATA_PASS_THRU_MODE AtaPassThruMode;
87 EFI_ATA_PASS_THRU_PROTOCOL AtaPassThru;
88 EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
89 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
90
91 EFI_ATA_HC_WORK_MODE Mode;
92
93 EFI_IDE_REGISTERS IdeRegisters[EfiIdeMaxChannel];
94 EFI_AHCI_REGISTERS AhciRegisters;
95
96 //
97 // The attached device list
98 //
99 LIST_ENTRY DeviceList;
100 UINT64 OriginalPciAttributes;
101
102 //
103 // For AtaPassThru protocol, using the following bytes to record the previous call in
104 // GetNextPort()/GetNextDevice().
105 //
106 UINT16 PreviousPort;
107 UINT16 PreviousPortMultiplier;
108 //
109 // For ExtScsiPassThru protocol, using the following bytes to record the previous call in
110 // GetNextTarget()/GetNextTargetLun().
111 //
112 UINT16 PreviousTargetId;
113 UINT64 PreviousLun;
114
115 } ATA_ATAPI_PASS_THRU_INSTANCE;
116
117 //
118 // Timeout value which uses 100ns as a unit.
119 // It means 3 second span.
120 //
121 #define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
122
123 #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
124
125 #define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
126 CR (a, \
127 ATA_ATAPI_PASS_THRU_INSTANCE, \
128 AtaPassThru, \
129 ATA_ATAPI_PASS_THRU_SIGNATURE \
130 )
131
132 #define EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
133 CR (a, \
134 ATA_ATAPI_PASS_THRU_INSTANCE, \
135 ExtScsiPassThru, \
136 ATA_ATAPI_PASS_THRU_SIGNATURE \
137 )
138
139 #define ATA_ATAPI_DEVICE_INFO_FROM_THIS(a) \
140 CR (a, \
141 EFI_ATA_DEVICE_INFO, \
142 Link, \
143 ATA_ATAPI_DEVICE_SIGNATURE \
144 );
145 /**
146 Retrieves a Unicode string that is the user readable name of the driver.
147
148 This function retrieves the user readable name of a driver in the form of a
149 Unicode string. If the driver specified by This has a user readable name in
150 the language specified by Language, then a pointer to the driver name is
151 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
152 by This does not support the language specified by Language,
153 then EFI_UNSUPPORTED is returned.
154
155 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
156 EFI_COMPONENT_NAME_PROTOCOL instance.
157
158 @param Language[in] A pointer to a Null-terminated ASCII string
159 array indicating the language. This is the
160 language of the driver name that the caller is
161 requesting, and it must match one of the
162 languages specified in SupportedLanguages. The
163 number of languages supported by a driver is up
164 to the driver writer. Language is specified
165 in RFC 4646 or ISO 639-2 language code format.
166
167 @param DriverName[out] A pointer to the Unicode string to return.
168 This Unicode string is the name of the
169 driver specified by This in the language
170 specified by Language.
171
172 @retval EFI_SUCCESS The Unicode string for the Driver specified by
173 This and the language specified by Language was
174 returned in DriverName.
175
176 @retval EFI_INVALID_PARAMETER Language is NULL.
177
178 @retval EFI_INVALID_PARAMETER DriverName is NULL.
179
180 @retval EFI_UNSUPPORTED The driver specified by This does not support
181 the language specified by Language.
182
183 **/
184 EFI_STATUS
185 EFIAPI
186 AtaAtapiPassThruComponentNameGetDriverName (
187 IN EFI_COMPONENT_NAME_PROTOCOL *This,
188 IN CHAR8 *Language,
189 OUT CHAR16 **DriverName
190 );
191
192 /**
193 Retrieves a Unicode string that is the user readable name of the controller
194 that is being managed by a driver.
195
196 This function retrieves the user readable name of the controller specified by
197 ControllerHandle and ChildHandle in the form of a Unicode string. If the
198 driver specified by This has a user readable name in the language specified by
199 Language, then a pointer to the controller name is returned in ControllerName,
200 and EFI_SUCCESS is returned. If the driver specified by This is not currently
201 managing the controller specified by ControllerHandle and ChildHandle,
202 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
203 support the language specified by Language, then EFI_UNSUPPORTED is returned.
204
205 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
206 EFI_COMPONENT_NAME_PROTOCOL instance.
207
208 @param ControllerHandle[in] The handle of a controller that the driver
209 specified by This is managing. This handle
210 specifies the controller whose name is to be
211 returned.
212
213 @param ChildHandle[in] The handle of the child controller to retrieve
214 the name of. This is an optional parameter that
215 may be NULL. It will be NULL for device
216 drivers. It will also be NULL for a bus drivers
217 that wish to retrieve the name of the bus
218 controller. It will not be NULL for a bus
219 driver that wishes to retrieve the name of a
220 child controller.
221
222 @param Language[in] A pointer to a Null-terminated ASCII string
223 array indicating the language. This is the
224 language of the driver name that the caller is
225 requesting, and it must match one of the
226 languages specified in SupportedLanguages. The
227 number of languages supported by a driver is up
228 to the driver writer. Language is specified in
229 RFC 4646 or ISO 639-2 language code format.
230
231 @param ControllerName[out] A pointer to the Unicode string to return.
232 This Unicode string is the name of the
233 controller specified by ControllerHandle and
234 ChildHandle in the language specified by
235 Language from the point of view of the driver
236 specified by This.
237
238 @retval EFI_SUCCESS The Unicode string for the user readable name in
239 the language specified by Language for the
240 driver specified by This was returned in
241 DriverName.
242
243 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
244
245 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
246 EFI_HANDLE.
247
248 @retval EFI_INVALID_PARAMETER Language is NULL.
249
250 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
251
252 @retval EFI_UNSUPPORTED The driver specified by This is not currently
253 managing the controller specified by
254 ControllerHandle and ChildHandle.
255
256 @retval EFI_UNSUPPORTED The driver specified by This does not support
257 the language specified by Language.
258
259 **/
260 EFI_STATUS
261 EFIAPI
262 AtaAtapiPassThruComponentNameGetControllerName (
263 IN EFI_COMPONENT_NAME_PROTOCOL *This,
264 IN EFI_HANDLE ControllerHandle,
265 IN EFI_HANDLE ChildHandle OPTIONAL,
266 IN CHAR8 *Language,
267 OUT CHAR16 **ControllerName
268 );
269
270 /**
271 Tests to see if this driver supports a given controller. If a child device is provided,
272 it further tests to see if this driver supports creating a handle for the specified child device.
273
274 This function checks to see if the driver specified by This supports the device specified by
275 ControllerHandle. Drivers will typically use the device path attached to
276 ControllerHandle and/or the services from the bus I/O abstraction attached to
277 ControllerHandle to determine if the driver supports ControllerHandle. This function
278 may be called many times during platform initialization. In order to reduce boot times, the tests
279 performed by this function must be very small, and take as little time as possible to execute. This
280 function must not change the state of any hardware devices, and this function must be aware that the
281 device specified by ControllerHandle may already be managed by the same driver or a
282 different driver. This function must match its calls to AllocatePages() with FreePages(),
283 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
284 Because ControllerHandle may have been previously started by the same driver, if a protocol is
285 already in the opened state, then it must not be closed with CloseProtocol(). This is required
286 to guarantee the state of ControllerHandle is not modified by this function.
287
288 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
289 @param[in] ControllerHandle The handle of the controller to test. This handle
290 must support a protocol interface that supplies
291 an I/O abstraction to the driver.
292 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
293 parameter is ignored by device drivers, and is optional for bus
294 drivers. For bus drivers, if this parameter is not NULL, then
295 the bus driver must determine if the bus controller specified
296 by ControllerHandle and the child controller specified
297 by RemainingDevicePath are both supported by this
298 bus driver.
299
300 @retval EFI_SUCCESS The device specified by ControllerHandle and
301 RemainingDevicePath is supported by the driver specified by This.
302 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
303 RemainingDevicePath is already being managed by the driver
304 specified by This.
305 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
306 RemainingDevicePath is already being managed by a different
307 driver or an application that requires exclusive access.
308 Currently not implemented.
309 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
310 RemainingDevicePath is not supported by the driver specified by This.
311 **/
312 EFI_STATUS
313 EFIAPI
314 AtaAtapiPassThruSupported (
315 IN EFI_DRIVER_BINDING_PROTOCOL *This,
316 IN EFI_HANDLE Controller,
317 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
318 );
319
320 /**
321 Starts a device controller or a bus controller.
322
323 The Start() function is designed to be invoked from the EFI boot service ConnectController().
324 As a result, much of the error checking on the parameters to Start() has been moved into this
325 common boot service. It is legal to call Start() from other locations,
326 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
327 1. ControllerHandle must be a valid EFI_HANDLE.
328 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
329 EFI_DEVICE_PATH_PROTOCOL.
330 3. Prior to calling Start(), the Supported() function for the driver specified by This must
331 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
332
333 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
334 @param[in] ControllerHandle The handle of the controller to start. This handle
335 must support a protocol interface that supplies
336 an I/O abstraction to the driver.
337 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
338 parameter is ignored by device drivers, and is optional for bus
339 drivers. For a bus driver, if this parameter is NULL, then handles
340 for all the children of Controller are created by this driver.
341 If this parameter is not NULL and the first Device Path Node is
342 not the End of Device Path Node, then only the handle for the
343 child device specified by the first Device Path Node of
344 RemainingDevicePath is created by this driver.
345 If the first Device Path Node of RemainingDevicePath is
346 the End of Device Path Node, no child handle is created by this
347 driver.
348
349 @retval EFI_SUCCESS The device was started.
350 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
351 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
352 @retval Others The driver failded to start the device.
353
354 **/
355 EFI_STATUS
356 EFIAPI
357 AtaAtapiPassThruStart (
358 IN EFI_DRIVER_BINDING_PROTOCOL *This,
359 IN EFI_HANDLE Controller,
360 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
361 );
362
363 /**
364 Stops a device controller or a bus controller.
365
366 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
367 As a result, much of the error checking on the parameters to Stop() has been moved
368 into this common boot service. It is legal to call Stop() from other locations,
369 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
370 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
371 same driver's Start() function.
372 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
373 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
374 Start() function, and the Start() function must have called OpenProtocol() on
375 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
376
377 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
378 @param[in] ControllerHandle A handle to the device being stopped. The handle must
379 support a bus specific I/O protocol for the driver
380 to use to stop the device.
381 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
382 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
383 if NumberOfChildren is 0.
384
385 @retval EFI_SUCCESS The device was stopped.
386 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
387
388 **/
389 EFI_STATUS
390 EFIAPI
391 AtaAtapiPassThruStop (
392 IN EFI_DRIVER_BINDING_PROTOCOL *This,
393 IN EFI_HANDLE Controller,
394 IN UINTN NumberOfChildren,
395 IN EFI_HANDLE *ChildHandleBuffer
396 );
397
398 /**
399 Traverse the attached ATA devices list to find out the device to access.
400
401 @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
402 @param[in] Port The port number of the ATA device to send the command.
403 @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
404 If there is no port multiplier, then specify 0.
405 @param[in] DeviceType The device type of the ATA device.
406
407 @retval The pointer to the data structure of the device info to access.
408
409 **/
410 LIST_ENTRY *
411 EFIAPI
412 SearchDeviceInfoList (
413 IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
414 IN UINT16 Port,
415 IN UINT16 PortMultiplier,
416 IN EFI_ATA_DEVICE_TYPE DeviceType
417 );
418
419 /**
420 Allocate device info data structure to contain device info.
421 And insert the data structure to the tail of device list for tracing.
422
423 @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
424 @param[in] Port The port number of the ATA device to send the command.
425 @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
426 If there is no port multiplier, then specify 0.
427 @param[in] DeviceType The device type of the ATA device.
428 @param[in] IdentifyData The data buffer to store the output of the IDENTIFY cmd.
429
430 @retval EFI_SUCCESS Successfully insert the ata device to the tail of device list.
431 @retval EFI_OUT_OF_RESOURCES Can not allocate enough resource for use.
432
433 **/
434 EFI_STATUS
435 EFIAPI
436 CreateNewDeviceInfo (
437 IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
438 IN UINT16 Port,
439 IN UINT16 PortMultiplier,
440 IN EFI_ATA_DEVICE_TYPE DeviceType,
441 IN EFI_IDENTIFY_DATA *IdentifyData
442 );
443
444 /**
445 Destroy all attached ATA devices info.
446
447 @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
448
449 **/
450 VOID
451 EFIAPI
452 DestroyDeviceInfoList (
453 IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
454 );
455
456 /**
457 Enumerate all attached ATA devices at IDE mode or AHCI mode separately.
458
459 The function is designed to enumerate all attached ATA devices.
460
461 @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
462
463 @retval EFI_SUCCESS Successfully enumerate attached ATA devices.
464 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
465
466 **/
467 EFI_STATUS
468 EFIAPI
469 EnumerateAttachedDevice (
470 IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
471 );
472
473 /**
474 Sends an ATA command to an ATA device that is attached to the ATA controller. This function
475 supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,
476 and the non-blocking I/O functionality is optional.
477
478 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
479 @param[in] Port The port number of the ATA device to send the command.
480 @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
481 If there is no port multiplier, then specify 0.
482 @param[in, out] Packet A pointer to the ATA command to send to the ATA device specified by Port
483 and PortMultiplierPort.
484 @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking
485 I/O is performed. If Event is NULL, then blocking I/O is performed. If
486 Event is not NULL and non blocking I/O is supported, then non-blocking
487 I/O is performed, and Event will be signaled when the ATA command completes.
488
489 @retval EFI_SUCCESS The ATA command was sent by the host. For bi-directional commands,
490 InTransferLength bytes were transferred from InDataBuffer. For write and
491 bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer.
492 @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number of bytes that could be transferred
493 is returned in InTransferLength. For write and bi-directional commands,
494 OutTransferLength bytes were transferred by OutDataBuffer.
495 @retval EFI_NOT_READY The ATA command could not be sent because there are too many ATA commands
496 already queued. The caller may retry again later.
497 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the ATA command.
498 @retval EFI_INVALID_PARAMETER Port, PortMultiplierPort, or the contents of Acb are invalid. The ATA
499 command was not sent, so no additional status information is available.
500
501 **/
502 EFI_STATUS
503 AtaPassThruPassThru (
504 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
505 IN UINT16 Port,
506 IN UINT16 PortMultiplierPort,
507 IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
508 IN EFI_EVENT Event OPTIONAL
509 );
510
511 /**
512 Used to retrieve the list of legal port numbers for ATA devices on an ATA controller.
513 These can either be the list of ports where ATA devices are actually present or the
514 list of legal port numbers for the ATA controller. Regardless, the caller of this
515 function must probe the port number returned to see if an ATA device is actually
516 present at that location on the ATA controller.
517
518 The GetNextPort() function retrieves the port number on an ATA controller. If on input
519 Port is 0xFFFF, then the port number of the first port on the ATA controller is returned
520 in Port and EFI_SUCCESS is returned.
521
522 If Port is a port number that was returned on a previous call to GetNextPort(), then the
523 port number of the next port on the ATA controller is returned in Port, and EFI_SUCCESS
524 is returned. If Port is not 0xFFFF and Port was not returned on a previous call to
525 GetNextPort(), then EFI_INVALID_PARAMETER is returned.
526
527 If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND is
528 returned.
529
530 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
531 @param[in, out] Port On input, a pointer to the port number on the ATA controller.
532 On output, a pointer to the next port number on the ATA
533 controller. An input value of 0xFFFF retrieves the first port
534 number on the ATA controller.
535
536 @retval EFI_SUCCESS The next port number on the ATA controller was returned in Port.
537 @retval EFI_NOT_FOUND There are no more ports on this ATA controller.
538 @retval EFI_INVALID_PARAMETER Port is not 0xFFFF and Port was not returned on a previous call
539 to GetNextPort().
540
541 **/
542 EFI_STATUS
543 AtaPassThruGetNextPort (
544 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
545 IN OUT UINT16 *Port
546 );
547
548 /**
549 Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA
550 controller. These can either be the list of port multiplier ports where ATA devices are actually
551 present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this
552 function must probe the port number and port multiplier port number returned to see if an ATA
553 device is actually present.
554
555 The GetNextDevice() function retrieves the port multiplier port number of an ATA device
556 present on a port of an ATA controller.
557
558 If PortMultiplierPort points to a port multiplier port number value that was returned on a
559 previous call to GetNextDevice(), then the port multiplier port number of the next ATA device
560 on the port of the ATA controller is returned in PortMultiplierPort, and EFI_SUCCESS is
561 returned.
562
563 If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first
564 ATA device on port of the ATA controller is returned in PortMultiplierPort and
565 EFI_SUCCESS is returned.
566
567 If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort
568 was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER
569 is returned.
570
571 If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of
572 the ATA controller, then EFI_NOT_FOUND is returned.
573
574 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
575 @param[in] Port The port number present on the ATA controller.
576 @param[in, out] PortMultiplierPort On input, a pointer to the port multiplier port number of an
577 ATA device present on the ATA controller.
578 If on input a PortMultiplierPort of 0xFFFF is specified,
579 then the port multiplier port number of the first ATA device
580 is returned. On output, a pointer to the port multiplier port
581 number of the next ATA device present on an ATA controller.
582
583 @retval EFI_SUCCESS The port multiplier port number of the next ATA device on the port
584 of the ATA controller was returned in PortMultiplierPort.
585 @retval EFI_NOT_FOUND There are no more ATA devices on this port of the ATA controller.
586 @retval EFI_INVALID_PARAMETER PortMultiplierPort is not 0xFFFF, and PortMultiplierPort was not
587 returned on a previous call to GetNextDevice().
588
589 **/
590 EFI_STATUS
591 AtaPassThruGetNextDevice (
592 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
593 IN UINT16 Port,
594 IN OUT UINT16 *PortMultiplierPort
595 );
596
597 /**
598 Used to allocate and build a device path node for an ATA device on an ATA controller.
599
600 The BuildDevicePath() function allocates and builds a single device node for the ATA
601 device specified by Port and PortMultiplierPort. If the ATA device specified by Port and
602 PortMultiplierPort is not present on the ATA controller, then EFI_NOT_FOUND is returned.
603 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. If there are not enough
604 resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
605
606 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of
607 DevicePath are initialized to describe the ATA device specified by Port and PortMultiplierPort,
608 and EFI_SUCCESS is returned.
609
610 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
611 @param[in] Port Port specifies the port number of the ATA device for which a
612 device path node is to be allocated and built.
613 @param[in] PortMultiplierPort The port multiplier port number of the ATA device for which a
614 device path node is to be allocated and built. If there is no
615 port multiplier, then specify 0.
616 @param[in, out] DevicePath A pointer to a single device path node that describes the ATA
617 device specified by Port and PortMultiplierPort. This function
618 is responsible for allocating the buffer DevicePath with the
619 boot service AllocatePool(). It is the caller's responsibility
620 to free DevicePath when the caller is finished with DevicePath.
621 @retval EFI_SUCCESS The device path node that describes the ATA device specified by
622 Port and PortMultiplierPort was allocated and returned in DevicePath.
623 @retval EFI_NOT_FOUND The ATA device specified by Port and PortMultiplierPort does not
624 exist on the ATA controller.
625 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
626 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
627
628 **/
629 EFI_STATUS
630 AtaPassThruBuildDevicePath (
631 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
632 IN UINT16 Port,
633 IN UINT16 PortMultiplierPort,
634 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
635 );
636
637 /**
638 Used to translate a device path node to a port number and port multiplier port number.
639
640 The GetDevice() function determines the port and port multiplier port number associated with
641 the ATA device described by DevicePath. If DevicePath is a device path node type that the
642 ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents
643 DevicePath into a port number and port multiplier port number.
644
645 If this translation is successful, then that port number and port multiplier port number are returned
646 in Port and PortMultiplierPort, and EFI_SUCCESS is returned.
647
648 If DevicePath, Port, or PortMultiplierPort are NULL, then EFI_INVALID_PARAMETER is returned.
649
650 If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then
651 EFI_UNSUPPORTED is returned.
652
653 If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not
654 a valid translation from DevicePath to a port number and port multiplier port number, then
655 EFI_NOT_FOUND is returned.
656
657 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
658 @param[in] DevicePath A pointer to the device path node that describes an ATA device on the
659 ATA controller.
660 @param[out] Port On return, points to the port number of an ATA device on the ATA controller.
661 @param[out] PortMultiplierPort On return, points to the port multiplier port number of an ATA device
662 on the ATA controller.
663
664 @retval EFI_SUCCESS DevicePath was successfully translated to a port number and port multiplier
665 port number, and they were returned in Port and PortMultiplierPort.
666 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
667 @retval EFI_INVALID_PARAMETER Port is NULL.
668 @retval EFI_INVALID_PARAMETER PortMultiplierPort is NULL.
669 @retval EFI_UNSUPPORTED This driver does not support the device path node type in DevicePath.
670 @retval EFI_NOT_FOUND A valid translation from DevicePath to a port number and port multiplier
671 port number does not exist.
672 **/
673 EFI_STATUS
674 AtaPassThruGetDevice (
675 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
676 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
677 OUT UINT16 *Port,
678 OUT UINT16 *PortMultiplierPort
679 );
680
681 /**
682 Resets a specific port on the ATA controller. This operation also resets all the ATA devices
683 connected to the port.
684
685 The ResetChannel() function resets an a specific port on an ATA controller. This operation
686 resets all the ATA devices connected to that port. If this ATA controller does not support
687 a reset port operation, then EFI_UNSUPPORTED is returned.
688
689 If a device error occurs while executing that port reset operation, then EFI_DEVICE_ERROR is
690 returned.
691
692 If a timeout occurs during the execution of the port reset operation, then EFI_TIMEOUT is returned.
693
694 If the port reset operation is completed, then EFI_SUCCESS is returned.
695
696 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
697 @param[in] Port The port number on the ATA controller.
698
699 @retval EFI_SUCCESS The ATA controller port was reset.
700 @retval EFI_UNSUPPORTED The ATA controller does not support a port reset operation.
701 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA port.
702 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA port.
703
704 **/
705 EFI_STATUS
706 AtaPassThruResetPort (
707 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
708 IN UINT16 Port
709 );
710
711 /**
712 Resets an ATA device that is connected to an ATA controller.
713
714 The ResetDevice() function resets the ATA device specified by Port and PortMultiplierPort.
715 If this ATA controller does not support a device reset operation, then EFI_UNSUPPORTED is
716 returned.
717
718 If Port or PortMultiplierPort are not in a valid range for this ATA controller, then
719 EFI_INVALID_PARAMETER is returned.
720
721 If a device error occurs while executing that device reset operation, then EFI_DEVICE_ERROR
722 is returned.
723
724 If a timeout occurs during the execution of the device reset operation, then EFI_TIMEOUT is
725 returned.
726
727 If the device reset operation is completed, then EFI_SUCCESS is returned.
728
729 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
730 @param[in] Port Port represents the port number of the ATA device to be reset.
731 @param[in] PortMultiplierPort The port multiplier port number of the ATA device to reset.
732 If there is no port multiplier, then specify 0.
733 @retval EFI_SUCCESS The ATA device specified by Port and PortMultiplierPort was reset.
734 @retval EFI_UNSUPPORTED The ATA controller does not support a device reset operation.
735 @retval EFI_INVALID_PARAMETER Port or PortMultiplierPort are invalid.
736 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA device
737 specified by Port and PortMultiplierPort.
738 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA device
739 specified by Port and PortMultiplierPort.
740
741 **/
742 EFI_STATUS
743 AtaPassThruResetDevice (
744 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
745 IN UINT16 Port,
746 IN UINT16 PortMultiplierPort
747 );
748
749 /**
750 Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
751 supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
752 nonblocking I/O functionality is optional.
753
754 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
755 @param Target The Target is an array of size TARGET_MAX_BYTES and it represents
756 the id of the SCSI device to send the SCSI Request Packet. Each
757 transport driver may choose to utilize a subset of this size to suit the needs
758 of transport target representation. For example, a Fibre Channel driver
759 may use only 8 bytes (WWN) to represent an FC target.
760 @param Lun The LUN of the SCSI device to send the SCSI Request Packet.
761 @param Packet A pointer to the SCSI Request Packet to send to the SCSI device
762 specified by Target and Lun.
763 @param Event If nonblocking I/O is not supported then Event is ignored, and blocking
764 I/O is performed. If Event is NULL, then blocking I/O is performed. If
765 Event is not NULL and non blocking I/O is supported, then
766 nonblocking I/O is performed, and Event will be signaled when the
767 SCSI Request Packet completes.
768
769 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional
770 commands, InTransferLength bytes were transferred from
771 InDataBuffer. For write and bi-directional commands,
772 OutTransferLength bytes were transferred by
773 OutDataBuffer.
774 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that
775 could be transferred is returned in InTransferLength. For write
776 and bi-directional commands, OutTransferLength bytes were
777 transferred by OutDataBuffer.
778 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many
779 SCSI Request Packets already queued. The caller may retry again later.
780 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request
781 Packet.
782 @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.
783 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported
784 by the host adapter. This includes the case of Bi-directional SCSI
785 commands not supported by the implementation. The SCSI Request
786 Packet was not sent, so no additional status information is available.
787 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
788
789 **/
790 EFI_STATUS
791 EFIAPI
792 ExtScsiPassThruPassThru (
793 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
794 IN UINT8 *Target,
795 IN UINT64 Lun,
796 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
797 IN EFI_EVENT Event OPTIONAL
798 );
799
800 /**
801 Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
802 can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
803 Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
804 Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
805 channel.
806
807 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
808 @param Target On input, a pointer to the Target ID (an array of size
809 TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
810 On output, a pointer to the Target ID (an array of
811 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
812 channel. An input value of 0xF(all bytes in the array are 0xF) in the
813 Target array retrieves the Target ID of the first SCSI device present on a
814 SCSI channel.
815 @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI
816 channel. On output, a pointer to the LUN of the next SCSI device present
817 on a SCSI channel.
818
819 @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI
820 channel was returned in Target and Lun.
821 @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were
822 not returned on a previous call to GetNextTargetLun().
823 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
824
825 **/
826 EFI_STATUS
827 EFIAPI
828 ExtScsiPassThruGetNextTargetLun (
829 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
830 IN OUT UINT8 **Target,
831 IN OUT UINT64 *Lun
832 );
833
834 /**
835 Used to allocate and build a device path node for a SCSI device on a SCSI channel.
836
837 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
838 @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the
839 Target ID of the SCSI device for which a device path node is to be
840 allocated and built. Transport drivers may chose to utilize a subset of
841 this size to suit the representation of targets. For example, a Fibre
842 Channel driver may use only 8 bytes (WWN) in the array to represent a
843 FC target.
844 @param Lun The LUN of the SCSI device for which a device path node is to be
845 allocated and built.
846 @param DevicePath A pointer to a single device path node that describes the SCSI device
847 specified by Target and Lun. This function is responsible for
848 allocating the buffer DevicePath with the boot service
849 AllocatePool(). It is the caller's responsibility to free
850 DevicePath when the caller is finished with DevicePath.
851
852 @retval EFI_SUCCESS The device path node that describes the SCSI device specified by
853 Target and Lun was allocated and returned in
854 DevicePath.
855 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
856 @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist
857 on the SCSI channel.
858 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
859
860 **/
861 EFI_STATUS
862 EFIAPI
863 ExtScsiPassThruBuildDevicePath (
864 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
865 IN UINT8 *Target,
866 IN UINT64 Lun,
867 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
868 );
869
870 /**
871 Used to translate a device path node to a Target ID and LUN.
872
873 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
874 @param DevicePath A pointer to a single device path node that describes the SCSI device
875 on the SCSI channel.
876 @param Target A pointer to the Target Array which represents the ID of a SCSI device
877 on the SCSI channel.
878 @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.
879
880 @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and
881 LUN, and they were returned in Target and Lun.
882 @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.
883 @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN
884 does not exist.
885 @retval EFI_UNSUPPORTED This driver does not support the device path node type in
886 DevicePath.
887
888 **/
889 EFI_STATUS
890 EFIAPI
891 ExtScsiPassThruGetTargetLun (
892 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
893 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
894 OUT UINT8 **Target,
895 OUT UINT64 *Lun
896 );
897
898 /**
899 Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.
900
901 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
902
903 @retval EFI_SUCCESS The SCSI channel was reset.
904 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.
905 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.
906 @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.
907
908 **/
909 EFI_STATUS
910 EFIAPI
911 ExtScsiPassThruResetChannel (
912 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
913 );
914
915 /**
916 Resets a SCSI logical unit that is connected to a SCSI channel.
917
918 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
919 @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the
920 target port ID of the SCSI device containing the SCSI logical unit to
921 reset. Transport drivers may chose to utilize a subset of this array to suit
922 the representation of their targets.
923 @param Lun The LUN of the SCSI device to reset.
924
925 @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.
926 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
927 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device
928 specified by Target and Lun.
929 @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.
930 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device
931 specified by Target and Lun.
932
933 **/
934 EFI_STATUS
935 EFIAPI
936 ExtScsiPassThruResetTargetLun (
937 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
938 IN UINT8 *Target,
939 IN UINT64 Lun
940 );
941
942 /**
943 Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either
944 be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs
945 for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to
946 see if a SCSI device is actually present at that location on the SCSI channel.
947
948 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
949 @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
950 On output, a pointer to the Target ID (an array of
951 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
952 channel. An input value of 0xF(all bytes in the array are 0xF) in the
953 Target array retrieves the Target ID of the first SCSI device present on a
954 SCSI channel.
955
956 @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI
957 channel was returned in Target.
958 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
959 @retval EFI_TIMEOUT Target array is not all 0xF, and Target was not
960 returned on a previous call to GetNextTarget().
961 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
962
963 **/
964 EFI_STATUS
965 EFIAPI
966 ExtScsiPassThruGetNextTarget (
967 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
968 IN OUT UINT8 **Target
969 );
970
971 /**
972 Initialize ATA host controller at IDE mode.
973
974 The function is designed to initialize ATA host controller.
975
976 @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
977
978 **/
979 EFI_STATUS
980 EFIAPI
981 IdeModeInitialization (
982 IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
983 );
984
985 /**
986 Initialize ATA host controller at AHCI mode.
987
988 The function is designed to initialize ATA host controller.
989
990 @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
991
992 **/
993 EFI_STATUS
994 EFIAPI
995 AhciModeInitialization (
996 IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
997 );
998
999 #endif
1000