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