]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Ppi/AtaPassThru.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Include / Ppi / AtaPassThru.h
1 /** @file
2
3 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 **/
7
8 #ifndef _EDKII_ATA_PASS_THRU_PPI_H_
9 #define _EDKII_ATA_PASS_THRU_PPI_H_
10
11 #include <Protocol/DevicePath.h>
12 #include <Protocol/AtaPassThru.h>
13
14 ///
15 /// Global ID for the EDKII_PEI_ATA_PASS_THRU_PPI.
16 ///
17 #define EDKII_PEI_ATA_PASS_THRU_PPI_GUID \
18 { \
19 0xa16473fd, 0xd474, 0x4c89, { 0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9 } \
20 }
21
22 //
23 // Forward declaration for the EDKII_PEI_ATA_PASS_THRU_PPI.
24 //
25 typedef struct _EDKII_PEI_ATA_PASS_THRU_PPI EDKII_PEI_ATA_PASS_THRU_PPI;
26
27 //
28 // Revision The revision to which the ATA Pass Thru PPI interface adheres.
29 // All future revisions must be backwards compatible.
30 // If a future version is not back wards compatible it is not the same GUID.
31 //
32 #define EDKII_PEI_ATA_PASS_THRU_PPI_REVISION 0x00010000
33
34
35 /**
36 Sends an ATA command to an ATA device that is attached to the ATA controller.
37
38 @param[in] This The PPI instance pointer.
39 @param[in] Port The port number of the ATA device to send
40 the command.
41 @param[in] PortMultiplierPort The port multiplier port number of the ATA
42 device to send the command.
43 If there is no port multiplier, then specify
44 0xFFFF.
45 @param[in,out] Packet A pointer to the ATA command to send to
46 the ATA device specified by Port and
47 PortMultiplierPort.
48
49 @retval EFI_SUCCESS The ATA command was sent by the host. For
50 bi-directional commands, InTransferLength bytes
51 were transferred from InDataBuffer. For write
52 and bi-directional commands, OutTransferLength
53 bytes were transferred by OutDataBuffer.
54 @retval EFI_NOT_FOUND The specified ATA device is not found.
55 @retval EFI_INVALID_PARAMETER The contents of Acb are invalid. The ATA command
56 was not sent, so no additional status information
57 is available.
58 @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number
59 of bytes that could be transferred is returned
60 in InTransferLength. For write and bi-directional
61 commands, OutTransferLength bytes were transferred
62 by OutDataBuffer.
63 @retval EFI_NOT_READY The ATA command could not be sent because there
64 are too many ATA commands already queued. The
65 caller may retry again later.
66 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
67 send the ATA command.
68
69 **/
70 typedef
71 EFI_STATUS
72 (EFIAPI *EDKII_PEI_ATA_PASS_THRU_PASSTHRU) (
73 IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
74 IN UINT16 Port,
75 IN UINT16 PortMultiplierPort,
76 IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet
77 );
78
79 /**
80 Used to retrieve the list of legal port numbers for ATA devices on an ATA controller.
81 These can either be the list of ports where ATA devices are actually present or the
82 list of legal port numbers for the ATA controller. Regardless, the caller of this
83 function must probe the port number returned to see if an ATA device is actually
84 present at that location on the ATA controller.
85
86 The GetNextPort() function retrieves the port number on an ATA controller. If on
87 input Port is 0xFFFF, then the port number of the first port on the ATA controller
88 is returned in Port and EFI_SUCCESS is returned.
89
90 If Port is a port number that was returned on a previous call to GetNextPort(),
91 then the port number of the next port on the ATA controller is returned in Port,
92 and EFI_SUCCESS is returned. If Port is not 0xFFFF and Port was not returned on
93 a previous call to GetNextPort(), then EFI_INVALID_PARAMETER is returned.
94
95 If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND
96 is returned.
97
98 @param[in] This The PPI instance pointer.
99 @param[in,out] Port On input, a pointer to the port number on the ATA controller.
100 On output, a pointer to the next port number on the ATA
101 controller. An input value of 0xFFFF retrieves the first
102 port number on the ATA controller.
103
104 @retval EFI_SUCCESS The next port number on the ATA controller was
105 returned in Port.
106 @retval EFI_NOT_FOUND There are no more ports on this ATA controller.
107 @retval EFI_INVALID_PARAMETER Port is not 0xFFFF and Port was not returned
108 on a previous call to GetNextPort().
109
110 **/
111 typedef
112 EFI_STATUS
113 (EFIAPI *EDKII_PEI_ATA_PASS_THRU_THRU_GET_NEXT_PORT) (
114 IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
115 IN OUT UINT16 *Port
116 );
117
118 /**
119 Used to retrieve the list of legal port multiplier port numbers for ATA devices
120 on a port of an ATA controller. These can either be the list of port multiplier
121 ports where ATA devices are actually present on port or the list of legal port
122 multiplier ports on that port. Regardless, the caller of this function must probe
123 the port number and port multiplier port number returned to see if an ATA device
124 is actually present.
125
126 The GetNextDevice() function retrieves the port multiplier port number of an ATA
127 device present on a port of an ATA controller.
128
129 If PortMultiplierPort points to a port multiplier port number value that was
130 returned on a previous call to GetNextDevice(), then the port multiplier port
131 number of the next ATA device on the port of the ATA controller is returned in
132 PortMultiplierPort, and EFI_SUCCESS is returned.
133
134 If PortMultiplierPort points to 0xFFFF, then the port multiplier port number
135 of the first ATA device on port of the ATA controller is returned in PortMultiplierPort
136 and EFI_SUCCESS is returned.
137
138 If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort
139 was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER
140 is returned.
141
142 If PortMultiplierPort is the port multiplier port number of the last ATA device
143 on the port of the ATA controller, then EFI_NOT_FOUND is returned.
144
145 @param[in] This The PPI instance pointer.
146 @param[in] Port The port number present on the ATA controller.
147 @param[in,out] PortMultiplierPort On input, a pointer to the port multiplier
148 port number of an ATA device present on the
149 ATA controller. If on input a PortMultiplierPort
150 of 0xFFFF is specified, then the port multiplier
151 port number of the first ATA device is returned.
152 On output, a pointer to the port multiplier port
153 number of the next ATA device present on an ATA
154 controller.
155
156 @retval EFI_SUCCESS The port multiplier port number of the next ATA
157 device on the port of the ATA controller was
158 returned in PortMultiplierPort.
159 @retval EFI_NOT_FOUND There are no more ATA devices on this port of
160 the ATA controller.
161 @retval EFI_INVALID_PARAMETER PortMultiplierPort is not 0xFFFF, and PortMultiplierPort
162 was not returned on a previous call to GetNextDevice().
163
164 **/
165 typedef
166 EFI_STATUS
167 (EFIAPI *EDKII_PEI_ATA_PASS_THRU_GET_NEXT_DEVICE) (
168 IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
169 IN UINT16 Port,
170 IN OUT UINT16 *PortMultiplierPort
171 );
172
173 /**
174 Gets the device path information of the underlying ATA host controller.
175
176 @param[in] This The PPI instance pointer.
177 @param[out] DevicePathLength The length of the device path in bytes specified
178 by DevicePath.
179 @param[out] DevicePath The device path of the underlying ATA host controller.
180 This field re-uses EFI Device Path Protocol as
181 defined by Section 10.2 EFI Device Path Protocol
182 of UEFI 2.7 Specification.
183
184 @retval EFI_SUCCESS The device path of the ATA host controller has
185 been successfully returned.
186 @retval EFI_INVALID_PARAMETER DevicePathLength or DevicePath is NULL.
187 @retval EFI_OUT_OF_RESOURCES Not enough resource to return the device path.
188
189 **/
190 typedef
191 EFI_STATUS
192 (EFIAPI *EDKII_PEI_ATA_PASS_THRU_GET_DEVICE_PATH) (
193 IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
194 OUT UINTN *DevicePathLength,
195 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
196 );
197
198 //
199 // EDKII_PEI_ATA_PASS_THRU_PPI provides the services that are required to send
200 // ATA commands to an ATA device during PEI.
201 //
202 struct _EDKII_PEI_ATA_PASS_THRU_PPI {
203 UINT64 Revision;
204 EFI_ATA_PASS_THRU_MODE *Mode;
205 EDKII_PEI_ATA_PASS_THRU_PASSTHRU PassThru;
206 EDKII_PEI_ATA_PASS_THRU_THRU_GET_NEXT_PORT GetNextPort;
207 EDKII_PEI_ATA_PASS_THRU_GET_NEXT_DEVICE GetNextDevice;
208 EDKII_PEI_ATA_PASS_THRU_GET_DEVICE_PATH GetDevicePath;
209 };
210
211 extern EFI_GUID gEdkiiPeiAtaPassThruPpiGuid;
212
213 #endif