]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/AtaPassThru.h
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Include / Protocol / AtaPassThru.h
1 /** @file
2 The EFI_ATA_PASS_THRU_PROTOCOL provides information about an ATA controller and the ability
3 to send ATA Command Blocks to any ATA device attached to that ATA controller. The information
4 includes the attributes of the ATA controller.
5
6 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 @par Revision Reference:
10 This Protocol was introduced in UEFI Specification 2.3.
11
12 **/
13
14 #ifndef __ATA_PASS_THROUGH_H__
15 #define __ATA_PASS_THROUGH_H__
16
17 #define EFI_ATA_PASS_THRU_PROTOCOL_GUID \
18 { \
19 0x1d3de7f0, 0x807, 0x424f, {0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } \
20 }
21
22 typedef struct _EFI_ATA_PASS_THRU_PROTOCOL EFI_ATA_PASS_THRU_PROTOCOL;
23
24 typedef struct {
25 UINT32 Attributes;
26 UINT32 IoAlign;
27 } EFI_ATA_PASS_THRU_MODE;
28
29 ///
30 /// If this bit is set, then the EFI_ATA_PASS_THRU_PROTOCOL interface is for physical
31 /// devices on the ATA controller.
32 ///
33 #define EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001
34 ///
35 /// If this bit is set, then the EFI_ATA_PASS_THRU_PROTOCOL interface is for logical
36 /// devices on the ATA controller.
37 ///
38 #define EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002
39 ///
40 /// If this bit is set, then the EFI_ATA_PASS_THRU_PROTOCOL interface supports non blocking
41 /// I/O. Every EFI_ATA_PASS_THRU_PROTOCOL must support blocking I/O. The support of non-blocking
42 /// I/O is optional.
43 ///
44 #define EFI_ATA_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004
45
46 typedef struct _EFI_ATA_COMMAND_BLOCK {
47 UINT8 Reserved1[2];
48 UINT8 AtaCommand;
49 UINT8 AtaFeatures;
50 UINT8 AtaSectorNumber;
51 UINT8 AtaCylinderLow;
52 UINT8 AtaCylinderHigh;
53 UINT8 AtaDeviceHead;
54 UINT8 AtaSectorNumberExp;
55 UINT8 AtaCylinderLowExp;
56 UINT8 AtaCylinderHighExp;
57 UINT8 AtaFeaturesExp;
58 UINT8 AtaSectorCount;
59 UINT8 AtaSectorCountExp;
60 UINT8 Reserved2[6];
61 } EFI_ATA_COMMAND_BLOCK;
62
63 typedef struct _EFI_ATA_STATUS_BLOCK {
64 UINT8 Reserved1[2];
65 UINT8 AtaStatus;
66 UINT8 AtaError;
67 UINT8 AtaSectorNumber;
68 UINT8 AtaCylinderLow;
69 UINT8 AtaCylinderHigh;
70 UINT8 AtaDeviceHead;
71 UINT8 AtaSectorNumberExp;
72 UINT8 AtaCylinderLowExp;
73 UINT8 AtaCylinderHighExp;
74 UINT8 Reserved2;
75 UINT8 AtaSectorCount;
76 UINT8 AtaSectorCountExp;
77 UINT8 Reserved3[6];
78 } EFI_ATA_STATUS_BLOCK;
79
80 typedef UINT8 EFI_ATA_PASS_THRU_CMD_PROTOCOL;
81
82 #define EFI_ATA_PASS_THRU_PROTOCOL_ATA_HARDWARE_RESET 0x00
83 #define EFI_ATA_PASS_THRU_PROTOCOL_ATA_SOFTWARE_RESET 0x01
84 #define EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA 0x02
85 #define EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN 0x04
86 #define EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT 0x05
87 #define EFI_ATA_PASS_THRU_PROTOCOL_DMA 0x06
88 #define EFI_ATA_PASS_THRU_PROTOCOL_DMA_QUEUED 0x07
89 #define EFI_ATA_PASS_THRU_PROTOCOL_DEVICE_DIAGNOSTIC 0x08
90 #define EFI_ATA_PASS_THRU_PROTOCOL_DEVICE_RESET 0x09
91 #define EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_IN 0x0A
92 #define EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_OUT 0x0B
93 #define EFI_ATA_PASS_THRU_PROTOCOL_FPDMA 0x0C
94 #define EFI_ATA_PASS_THRU_PROTOCOL_RETURN_RESPONSE 0xFF
95
96 typedef UINT8 EFI_ATA_PASS_THRU_LENGTH;
97
98 #define EFI_ATA_PASS_THRU_LENGTH_BYTES 0x80
99
100 #define EFI_ATA_PASS_THRU_LENGTH_MASK 0x70
101 #define EFI_ATA_PASS_THRU_LENGTH_NO_DATA_TRANSFER 0x00
102 #define EFI_ATA_PASS_THRU_LENGTH_FEATURES 0x10
103 #define EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT 0x20
104 #define EFI_ATA_PASS_THRU_LENGTH_TPSIU 0x30
105
106 #define EFI_ATA_PASS_THRU_LENGTH_COUNT 0x0F
107
108 typedef struct {
109 ///
110 /// A pointer to the sense data that was generated by the execution of the ATA
111 /// command. It must be aligned to the boundary specified in the IoAlign field
112 /// in the EFI_ATA_PASS_THRU_MODE structure.
113 ///
114 EFI_ATA_STATUS_BLOCK *Asb;
115 ///
116 /// A pointer to buffer that contains the Command Data Block to send to the ATA
117 /// device specified by Port and PortMultiplierPort.
118 ///
119 EFI_ATA_COMMAND_BLOCK *Acb;
120 ///
121 /// The timeout, in 100 ns units, to use for the execution of this ATA command.
122 /// A Timeout value of 0 means that this function will wait indefinitely for the
123 /// ATA command to execute. If Timeout is greater than zero, then this function
124 /// will return EFI_TIMEOUT if the time required to execute the ATA command is
125 /// greater than Timeout.
126 ///
127 UINT64 Timeout;
128 ///
129 /// A pointer to the data buffer to transfer between the ATA controller and the
130 /// ATA device for read and bidirectional commands. For all write and non data
131 /// commands where InTransferLength is 0 this field is optional and may be NULL.
132 /// If this field is not NULL, then it must be aligned on the boundary specified
133 /// by the IoAlign field in the EFI_ATA_PASS_THRU_MODE structure.
134 ///
135 VOID *InDataBuffer;
136 ///
137 /// A pointer to the data buffer to transfer between the ATA controller and the
138 /// ATA device for write or bidirectional commands. For all read and non data
139 /// commands where OutTransferLength is 0 this field is optional and may be NULL.
140 /// If this field is not NULL, then it must be aligned on the boundary specified
141 /// by the IoAlign field in the EFI_ATA_PASS_THRU_MODE structure.
142 ///
143 VOID *OutDataBuffer;
144 ///
145 /// On input, the size, in bytes, of InDataBuffer. On output, the number of bytes
146 /// transferred between the ATA controller and the ATA device. If InTransferLength
147 /// is larger than the ATA controller can handle, no data will be transferred,
148 /// InTransferLength will be updated to contain the number of bytes that the ATA
149 /// controller is able to transfer, and EFI_BAD_BUFFER_SIZE will be returned.
150 ///
151 UINT32 InTransferLength;
152 ///
153 /// On Input, the size, in bytes of OutDataBuffer. On Output, the Number of bytes
154 /// transferred between ATA Controller and the ATA device. If OutTransferLength is
155 /// larger than the ATA controller can handle, no data will be transferred,
156 /// OutTransferLength will be updated to contain the number of bytes that the ATA
157 /// controller is able to transfer, and EFI_BAD_BUFFER_SIZE will be returned.
158 ///
159 UINT32 OutTransferLength;
160 ///
161 /// Specifies the protocol used when the ATA device executes the command.
162 ///
163 EFI_ATA_PASS_THRU_CMD_PROTOCOL Protocol;
164 ///
165 /// Specifies the way in which the ATA command length is encoded.
166 ///
167 EFI_ATA_PASS_THRU_LENGTH Length;
168 } EFI_ATA_PASS_THRU_COMMAND_PACKET;
169
170 /**
171 Sends an ATA command to an ATA device that is attached to the ATA controller. This function
172 supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,
173 and the non-blocking I/O functionality is optional.
174
175 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
176 @param[in] Port The port number of the ATA device to send the command.
177 @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
178 If there is no port multiplier, then specify 0xFFFF.
179 @param[in,out] Packet A pointer to the ATA command to send to the ATA device specified by Port
180 and PortMultiplierPort.
181 @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking
182 I/O is performed. If Event is NULL, then blocking I/O is performed. If
183 Event is not NULL and non blocking I/O is supported, then non-blocking
184 I/O is performed, and Event will be signaled when the ATA command completes.
185
186 @retval EFI_SUCCESS The ATA command was sent by the host. For bi-directional commands,
187 InTransferLength bytes were transferred from InDataBuffer. For write and
188 bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer.
189 @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number of bytes that could be transferred
190 is returned in InTransferLength. For write and bi-directional commands,
191 OutTransferLength bytes were transferred by OutDataBuffer.
192 @retval EFI_NOT_READY The ATA command could not be sent because there are too many ATA commands
193 already queued. The caller may retry again later.
194 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the ATA command.
195 @retval EFI_INVALID_PARAMETER Port, PortMultiplierPort, or the contents of Acb are invalid. The ATA
196 command was not sent, so no additional status information is available.
197
198 **/
199 typedef
200 EFI_STATUS
201 (EFIAPI *EFI_ATA_PASS_THRU_PASSTHRU)(
202 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
203 IN UINT16 Port,
204 IN UINT16 PortMultiplierPort,
205 IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
206 IN EFI_EVENT Event OPTIONAL
207 );
208
209 /**
210 Used to retrieve the list of legal port numbers for ATA devices on an ATA controller.
211 These can either be the list of ports where ATA devices are actually present or the
212 list of legal port numbers for the ATA controller. Regardless, the caller of this
213 function must probe the port number returned to see if an ATA device is actually
214 present at that location on the ATA controller.
215
216 The GetNextPort() function retrieves the port number on an ATA controller. If on input
217 Port is 0xFFFF, then the port number of the first port on the ATA controller is returned
218 in Port and EFI_SUCCESS is returned.
219
220 If Port is a port number that was returned on a previous call to GetNextPort(), then the
221 port number of the next port on the ATA controller is returned in Port, and EFI_SUCCESS
222 is returned. If Port is not 0xFFFF and Port was not returned on a previous call to
223 GetNextPort(), then EFI_INVALID_PARAMETER is returned.
224
225 If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND is
226 returned.
227
228 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
229 @param[in,out] Port On input, a pointer to the port number on the ATA controller.
230 On output, a pointer to the next port number on the ATA
231 controller. An input value of 0xFFFF retrieves the first port
232 number on the ATA controller.
233
234 @retval EFI_SUCCESS The next port number on the ATA controller was returned in Port.
235 @retval EFI_NOT_FOUND There are no more ports on this ATA controller.
236 @retval EFI_INVALID_PARAMETER Port is not 0xFFFF and Port was not returned on a previous call
237 to GetNextPort().
238
239 **/
240 typedef
241 EFI_STATUS
242 (EFIAPI *EFI_ATA_PASS_THRU_GET_NEXT_PORT)(
243 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
244 IN OUT UINT16 *Port
245 );
246
247 /**
248 Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA
249 controller. These can either be the list of port multiplier ports where ATA devices are actually
250 present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this
251 function must probe the port number and port multiplier port number returned to see if an ATA
252 device is actually present.
253
254 The GetNextDevice() function retrieves the port multiplier port number of an ATA device
255 present on a port of an ATA controller.
256
257 If PortMultiplierPort points to a port multiplier port number value that was returned on a
258 previous call to GetNextDevice(), then the port multiplier port number of the next ATA device
259 on the port of the ATA controller is returned in PortMultiplierPort, and EFI_SUCCESS is
260 returned.
261
262 If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first
263 ATA device on port of the ATA controller is returned in PortMultiplierPort and
264 EFI_SUCCESS is returned.
265
266 If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort
267 was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER
268 is returned.
269
270 If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of
271 the ATA controller, then EFI_NOT_FOUND is returned.
272
273 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
274 @param[in] Port The port number present on the ATA controller.
275 @param[in,out] PortMultiplierPort On input, a pointer to the port multiplier port number of an
276 ATA device present on the ATA controller.
277 If on input a PortMultiplierPort of 0xFFFF is specified,
278 then the port multiplier port number of the first ATA device
279 is returned. On output, a pointer to the port multiplier port
280 number of the next ATA device present on an ATA controller.
281
282 @retval EFI_SUCCESS The port multiplier port number of the next ATA device on the port
283 of the ATA controller was returned in PortMultiplierPort.
284 @retval EFI_NOT_FOUND There are no more ATA devices on this port of the ATA controller.
285 @retval EFI_INVALID_PARAMETER PortMultiplierPort is not 0xFFFF, and PortMultiplierPort was not
286 returned on a previous call to GetNextDevice().
287
288 **/
289 typedef
290 EFI_STATUS
291 (EFIAPI *EFI_ATA_PASS_THRU_GET_NEXT_DEVICE)(
292 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
293 IN UINT16 Port,
294 IN OUT UINT16 *PortMultiplierPort
295 );
296
297 /**
298 Used to allocate and build a device path node for an ATA device on an ATA controller.
299
300 The BuildDevicePath() function allocates and builds a single device node for the ATA
301 device specified by Port and PortMultiplierPort. If the ATA device specified by Port and
302 PortMultiplierPort is not present on the ATA controller, then EFI_NOT_FOUND is returned.
303 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. If there are not enough
304 resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
305
306 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of
307 DevicePath are initialized to describe the ATA device specified by Port and PortMultiplierPort,
308 and EFI_SUCCESS is returned.
309
310 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
311 @param[in] Port Port specifies the port number of the ATA device for which a
312 device path node is to be allocated and built.
313 @param[in] PortMultiplierPort The port multiplier port number of the ATA device for which a
314 device path node is to be allocated and built. If there is no
315 port multiplier, then specify 0xFFFF.
316 @param[out] DevicePath A pointer to a single device path node that describes the ATA
317 device specified by Port and PortMultiplierPort. This function
318 is responsible for allocating the buffer DevicePath with the
319 boot service AllocatePool(). It is the caller's responsibility
320 to free DevicePath when the caller is finished with DevicePath.
321 @retval EFI_SUCCESS The device path node that describes the ATA device specified by
322 Port and PortMultiplierPort was allocated and returned in DevicePath.
323 @retval EFI_NOT_FOUND The ATA device specified by Port and PortMultiplierPort does not
324 exist on the ATA controller.
325 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
326 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
327
328 **/
329 typedef
330 EFI_STATUS
331 (EFIAPI *EFI_ATA_PASS_THRU_BUILD_DEVICE_PATH)(
332 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
333 IN UINT16 Port,
334 IN UINT16 PortMultiplierPort,
335 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
336 );
337
338 /**
339 Used to translate a device path node to a port number and port multiplier port number.
340
341 The GetDevice() function determines the port and port multiplier port number associated with
342 the ATA device described by DevicePath. If DevicePath is a device path node type that the
343 ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents
344 DevicePath into a port number and port multiplier port number.
345
346 If this translation is successful, then that port number and port multiplier port number are returned
347 in Port and PortMultiplierPort, and EFI_SUCCESS is returned.
348
349 If DevicePath, Port, or PortMultiplierPort are NULL, then EFI_INVALID_PARAMETER is returned.
350
351 If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then
352 EFI_UNSUPPORTED is returned.
353
354 If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not
355 a valid translation from DevicePath to a port number and port multiplier port number, then
356 EFI_NOT_FOUND is returned.
357
358 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
359 @param[in] DevicePath A pointer to the device path node that describes an ATA device on the
360 ATA controller.
361 @param[out] Port On return, points to the port number of an ATA device on the ATA controller.
362 @param[out] PortMultiplierPort On return, points to the port multiplier port number of an ATA device
363 on the ATA controller.
364
365 @retval EFI_SUCCESS DevicePath was successfully translated to a port number and port multiplier
366 port number, and they were returned in Port and PortMultiplierPort.
367 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
368 @retval EFI_INVALID_PARAMETER Port is NULL.
369 @retval EFI_INVALID_PARAMETER PortMultiplierPort is NULL.
370 @retval EFI_UNSUPPORTED This driver does not support the device path node type in DevicePath.
371 @retval EFI_NOT_FOUND A valid translation from DevicePath to a port number and port multiplier
372 port number does not exist.
373 **/
374 typedef
375 EFI_STATUS
376 (EFIAPI *EFI_ATA_PASS_THRU_GET_DEVICE)(
377 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
378 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
379 OUT UINT16 *Port,
380 OUT UINT16 *PortMultiplierPort
381 );
382
383 /**
384 Resets a specific port on the ATA controller. This operation also resets all the ATA devices
385 connected to the port.
386
387 The ResetChannel() function resets an a specific port on an ATA controller. This operation
388 resets all the ATA devices connected to that port. If this ATA controller does not support
389 a reset port operation, then EFI_UNSUPPORTED is returned.
390
391 If a device error occurs while executing that port reset operation, then EFI_DEVICE_ERROR is
392 returned.
393
394 If a timeout occurs during the execution of the port reset operation, then EFI_TIMEOUT is returned.
395
396 If the port reset operation is completed, then EFI_SUCCESS is returned.
397
398 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
399 @param[in] Port The port number on the ATA controller.
400
401 @retval EFI_SUCCESS The ATA controller port was reset.
402 @retval EFI_UNSUPPORTED The ATA controller does not support a port reset operation.
403 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA port.
404 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA port.
405
406 **/
407 typedef
408 EFI_STATUS
409 (EFIAPI *EFI_ATA_PASS_THRU_RESET_PORT)(
410 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
411 IN UINT16 Port
412 );
413
414 /**
415 Resets an ATA device that is connected to an ATA controller.
416
417 The ResetDevice() function resets the ATA device specified by Port and PortMultiplierPort.
418 If this ATA controller does not support a device reset operation, then EFI_UNSUPPORTED is
419 returned.
420
421 If Port or PortMultiplierPort are not in a valid range for this ATA controller, then
422 EFI_INVALID_PARAMETER is returned.
423
424 If a device error occurs while executing that device reset operation, then EFI_DEVICE_ERROR
425 is returned.
426
427 If a timeout occurs during the execution of the device reset operation, then EFI_TIMEOUT is
428 returned.
429
430 If the device reset operation is completed, then EFI_SUCCESS is returned.
431
432 @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
433 @param[in] Port Port represents the port number of the ATA device to be reset.
434 @param[in] PortMultiplierPort The port multiplier port number of the ATA device to reset.
435 If there is no port multiplier, then specify 0xFFFF.
436 @retval EFI_SUCCESS The ATA device specified by Port and PortMultiplierPort was reset.
437 @retval EFI_UNSUPPORTED The ATA controller does not support a device reset operation.
438 @retval EFI_INVALID_PARAMETER Port or PortMultiplierPort are invalid.
439 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA device
440 specified by Port and PortMultiplierPort.
441 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA device
442 specified by Port and PortMultiplierPort.
443
444 **/
445 typedef
446 EFI_STATUS
447 (EFIAPI *EFI_ATA_PASS_THRU_RESET_DEVICE)(
448 IN EFI_ATA_PASS_THRU_PROTOCOL *This,
449 IN UINT16 Port,
450 IN UINT16 PortMultiplierPort
451 );
452
453 struct _EFI_ATA_PASS_THRU_PROTOCOL {
454 EFI_ATA_PASS_THRU_MODE *Mode;
455 EFI_ATA_PASS_THRU_PASSTHRU PassThru;
456 EFI_ATA_PASS_THRU_GET_NEXT_PORT GetNextPort;
457 EFI_ATA_PASS_THRU_GET_NEXT_DEVICE GetNextDevice;
458 EFI_ATA_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;
459 EFI_ATA_PASS_THRU_GET_DEVICE GetDevice;
460 EFI_ATA_PASS_THRU_RESET_PORT ResetPort;
461 EFI_ATA_PASS_THRU_RESET_DEVICE ResetDevice;
462 };
463
464 extern EFI_GUID gEfiAtaPassThruProtocolGuid;
465
466 #endif