]>
Commit | Line | Data |
---|---|---|
0591696e FT |
1 | /** @file\r |
2 | \r | |
95ad8f7f | 3 | Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r |
0591696e FT |
4 | This program and the accompanying materials\r |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | **/\r | |
13 | \r | |
14 | #ifndef _UFS_PASS_THRU_H_\r | |
15 | #define _UFS_PASS_THRU_H_\r | |
16 | \r | |
17 | #include <Uefi.h>\r | |
18 | \r | |
19 | #include <Protocol/ScsiPassThruExt.h>\r | |
20 | #include <Protocol/UfsHostController.h>\r | |
21 | \r | |
22 | #include <Library/DebugLib.h>\r | |
23 | #include <Library/UefiDriverEntryPoint.h>\r | |
24 | #include <Library/BaseLib.h>\r | |
25 | #include <Library/UefiLib.h>\r | |
26 | #include <Library/BaseMemoryLib.h>\r | |
27 | #include <Library/MemoryAllocationLib.h>\r | |
28 | #include <Library/UefiBootServicesTableLib.h>\r | |
29 | #include <Library/DevicePathLib.h>\r | |
0591696e FT |
30 | #include <Library/TimerLib.h>\r |
31 | \r | |
32 | #include "UfsPassThruHci.h"\r | |
33 | \r | |
34 | #define UFS_PASS_THRU_SIG SIGNATURE_32 ('U', 'F', 'S', 'P')\r | |
35 | \r | |
36 | //\r | |
37 | // Lun 0~7 is for 8 common luns. \r | |
38 | // Lun 8~11 is for those 4 well known luns (Refer to UFS 2.0 spec Table 10.58 for details):\r | |
39 | // Lun 8: REPORT LUNS\r | |
40 | // Lun 9: UFS DEVICE\r | |
41 | // Lun 10: BOOT\r | |
42 | // Lun 11: RPMB\r | |
43 | //\r | |
44 | #define UFS_MAX_LUNS 12\r | |
45 | #define UFS_WLUN_PREFIX 0xC1\r | |
46 | \r | |
47 | typedef struct {\r | |
48 | UINT8 Lun[UFS_MAX_LUNS];\r | |
49 | UINT16 BitMask:12; // Bit 0~7 is 1/1 mapping to common luns. Bit 8~11 is 1/1 mapping to well-known luns.\r | |
50 | UINT16 Rsvd:4;\r | |
51 | } UFS_EXPOSED_LUNS;\r | |
52 | \r | |
0350b57c | 53 | //\r |
ed356b9e | 54 | // Iterate through the double linked list. This is delete-safe.\r |
0350b57c HW |
55 | // Do not touch NextEntry\r |
56 | //\r | |
57 | #define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \\r | |
58 | for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r | |
59 | Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r | |
60 | \r | |
0591696e FT |
61 | typedef struct _UFS_PASS_THRU_PRIVATE_DATA { \r |
62 | UINT32 Signature;\r | |
63 | EFI_HANDLE Handle;\r | |
64 | EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;\r | |
65 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;\r | |
66 | EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController;\r | |
67 | UINTN UfsHcBase;\r | |
68 | UINT32 Capabilities;\r | |
69 | \r | |
70 | UINT8 TaskTag;\r | |
71 | \r | |
72 | VOID *UtpTrlBase;\r | |
73 | UINT8 Nutrs;\r | |
74 | VOID *TrlMapping;\r | |
75 | VOID *UtpTmrlBase;\r | |
76 | UINT8 Nutmrs;\r | |
77 | VOID *TmrlMapping;\r | |
78 | \r | |
79 | UFS_EXPOSED_LUNS Luns;\r | |
0350b57c HW |
80 | \r |
81 | //\r | |
82 | // For Non-blocking operation.\r | |
83 | //\r | |
84 | EFI_EVENT TimerEvent;\r | |
85 | LIST_ENTRY Queue;\r | |
0591696e FT |
86 | } UFS_PASS_THRU_PRIVATE_DATA;\r |
87 | \r | |
0350b57c HW |
88 | #define UFS_PASS_THRU_TRANS_REQ_SIG SIGNATURE_32 ('U', 'F', 'S', 'T')\r |
89 | \r | |
90 | typedef struct {\r | |
91 | UINT32 Signature;\r | |
92 | LIST_ENTRY TransferList;\r | |
93 | \r | |
94 | UINT8 Slot;\r | |
95 | UTP_TRD *Trd;\r | |
96 | UINT32 CmdDescSize;\r | |
97 | VOID *CmdDescHost;\r | |
98 | VOID *CmdDescMapping;\r | |
99 | VOID *DataBufMapping;\r | |
100 | \r | |
101 | EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet;\r | |
102 | UINT64 TimeoutRemain;\r | |
103 | EFI_EVENT CallerEvent;\r | |
104 | } UFS_PASS_THRU_TRANS_REQ;\r | |
105 | \r | |
106 | #define UFS_PASS_THRU_TRANS_REQ_FROM_THIS(a) \\r | |
107 | CR(a, UFS_PASS_THRU_TRANS_REQ, TransferList, UFS_PASS_THRU_TRANS_REQ_SIG)\r | |
108 | \r | |
0591696e | 109 | #define UFS_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)\r |
0350b57c | 110 | #define UFS_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS(1)\r |
0591696e FT |
111 | \r |
112 | #define ROUNDUP8(x) (((x) % 8 == 0) ? (x) : ((x) / 8 + 1) * 8)\r | |
113 | \r | |
114 | #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)\r | |
115 | \r | |
116 | #define UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \\r | |
117 | CR (a, \\r | |
118 | UFS_PASS_THRU_PRIVATE_DATA, \\r | |
119 | ExtScsiPassThru, \\r | |
120 | UFS_PASS_THRU_SIG \\r | |
121 | )\r | |
122 | \r | |
123 | typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET {\r | |
124 | UINT64 Timeout;\r | |
95ad8f7f | 125 | VOID *DataBuffer;\r |
0591696e FT |
126 | UINT8 Opcode;\r |
127 | UINT8 DescId;\r | |
128 | UINT8 Index;\r | |
129 | UINT8 Selector;\r | |
95ad8f7f | 130 | UINT32 TransferLength;\r |
0591696e | 131 | UINT8 DataDirection;\r |
0591696e FT |
132 | } UFS_DEVICE_MANAGEMENT_REQUEST_PACKET;\r |
133 | \r | |
134 | //\r | |
135 | // function prototype\r | |
136 | //\r | |
137 | /**\r | |
138 | Tests to see if this driver supports a given controller. If a child device is provided,\r | |
139 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
140 | \r | |
141 | This function checks to see if the driver specified by This supports the device specified by\r | |
142 | ControllerHandle. Drivers will typically use the device path attached to\r | |
143 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
144 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
145 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
146 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
147 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
148 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
149 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
150 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
151 | Since ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
152 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
153 | to guarantee the state of ControllerHandle is not modified by this function.\r | |
154 | \r | |
155 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
156 | @param[in] ControllerHandle The handle of the controller to test. This handle\r | |
157 | must support a protocol interface that supplies\r | |
158 | an I/O abstraction to the driver.\r | |
159 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
160 | parameter is ignored by device drivers, and is optional for bus\r | |
161 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
162 | the bus driver must determine if the bus controller specified\r | |
163 | by ControllerHandle and the child controller specified\r | |
164 | by RemainingDevicePath are both supported by this\r | |
165 | bus driver.\r | |
166 | \r | |
167 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
168 | RemainingDevicePath is supported by the driver specified by This.\r | |
169 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
170 | RemainingDevicePath is already being managed by the driver\r | |
171 | specified by This.\r | |
172 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
173 | RemainingDevicePath is already being managed by a different\r | |
174 | driver or an application that requires exclusive access.\r | |
175 | Currently not implemented.\r | |
176 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
177 | RemainingDevicePath is not supported by the driver specified by This.\r | |
178 | **/\r | |
179 | EFI_STATUS\r | |
180 | EFIAPI\r | |
181 | UfsPassThruDriverBindingSupported (\r | |
182 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
183 | IN EFI_HANDLE Controller,\r | |
184 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
185 | );\r | |
186 | \r | |
187 | /**\r | |
188 | Starts a device controller or a bus controller.\r | |
189 | \r | |
190 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
191 | As a result, much of the error checking on the parameters to Start() has been moved into this\r | |
192 | common boot service. It is legal to call Start() from other locations,\r | |
193 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
194 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
195 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
196 | EFI_DEVICE_PATH_PROTOCOL.\r | |
197 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
198 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r | |
199 | \r | |
200 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
201 | @param[in] ControllerHandle The handle of the controller to start. This handle\r | |
202 | must support a protocol interface that supplies\r | |
203 | an I/O abstraction to the driver.\r | |
204 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
205 | parameter is ignored by device drivers, and is optional for bus\r | |
206 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
207 | for all the children of Controller are created by this driver.\r | |
208 | If this parameter is not NULL and the first Device Path Node is\r | |
209 | not the End of Device Path Node, then only the handle for the\r | |
210 | child device specified by the first Device Path Node of\r | |
211 | RemainingDevicePath is created by this driver.\r | |
212 | If the first Device Path Node of RemainingDevicePath is\r | |
213 | the End of Device Path Node, no child handle is created by this\r | |
214 | driver.\r | |
215 | \r | |
216 | @retval EFI_SUCCESS The device was started.\r | |
217 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
218 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
219 | @retval Others The driver failded to start the device.\r | |
220 | \r | |
221 | **/\r | |
222 | EFI_STATUS\r | |
223 | EFIAPI\r | |
224 | UfsPassThruDriverBindingStart (\r | |
225 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
226 | IN EFI_HANDLE Controller,\r | |
227 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
228 | );\r | |
229 | \r | |
230 | /**\r | |
231 | Stops a device controller or a bus controller.\r | |
232 | \r | |
233 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
234 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
235 | into this common boot service. It is legal to call Stop() from other locations,\r | |
236 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
237 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
238 | same driver's Start() function.\r | |
239 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
240 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
241 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
242 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
243 | \r | |
244 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
245 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r | |
246 | support a bus specific I/O protocol for the driver\r | |
247 | to use to stop the device.\r | |
248 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
249 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r | |
250 | if NumberOfChildren is 0.\r | |
251 | \r | |
252 | @retval EFI_SUCCESS The device was stopped.\r | |
253 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
254 | \r | |
255 | **/\r | |
256 | EFI_STATUS\r | |
257 | EFIAPI\r | |
258 | UfsPassThruDriverBindingStop (\r | |
259 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
260 | IN EFI_HANDLE Controller,\r | |
261 | IN UINTN NumberOfChildren,\r | |
262 | IN EFI_HANDLE *ChildHandleBuffer\r | |
263 | );\r | |
264 | \r | |
265 | //\r | |
266 | // EFI Component Name Functions\r | |
267 | //\r | |
268 | /**\r | |
269 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
270 | \r | |
271 | This function retrieves the user readable name of a driver in the form of a\r | |
272 | Unicode string. If the driver specified by This has a user readable name in\r | |
273 | the language specified by Language, then a pointer to the driver name is\r | |
274 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
275 | by This does not support the language specified by Language,\r | |
276 | then EFI_UNSUPPORTED is returned.\r | |
277 | \r | |
278 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
279 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
280 | \r | |
281 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
282 | array indicating the language. This is the\r | |
283 | language of the driver name that the caller is\r | |
284 | requesting, and it must match one of the\r | |
285 | languages specified in SupportedLanguages. The\r | |
286 | number of languages supported by a driver is up\r | |
287 | to the driver writer. Language is specified\r | |
288 | in RFC 4646 or ISO 639-2 language code format.\r | |
289 | \r | |
290 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
291 | This Unicode string is the name of the\r | |
292 | driver specified by This in the language\r | |
293 | specified by Language.\r | |
294 | \r | |
295 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
296 | This and the language specified by Language was\r | |
297 | returned in DriverName.\r | |
298 | \r | |
299 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
300 | \r | |
301 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
302 | \r | |
303 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
304 | the language specified by Language.\r | |
305 | \r | |
306 | **/\r | |
307 | EFI_STATUS\r | |
308 | EFIAPI\r | |
309 | UfsPassThruComponentNameGetDriverName (\r | |
310 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
311 | IN CHAR8 *Language,\r | |
312 | OUT CHAR16 **DriverName\r | |
313 | );\r | |
314 | \r | |
315 | \r | |
316 | /**\r | |
317 | Retrieves a Unicode string that is the user readable name of the controller\r | |
318 | that is being managed by a driver.\r | |
319 | \r | |
320 | This function retrieves the user readable name of the controller specified by\r | |
321 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
322 | driver specified by This has a user readable name in the language specified by\r | |
323 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
324 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
325 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
326 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
327 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
328 | \r | |
329 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
330 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
331 | \r | |
332 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
333 | specified by This is managing. This handle\r | |
334 | specifies the controller whose name is to be\r | |
335 | returned.\r | |
336 | \r | |
337 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
338 | the name of. This is an optional parameter that\r | |
339 | may be NULL. It will be NULL for device\r | |
340 | drivers. It will also be NULL for a bus drivers\r | |
341 | that wish to retrieve the name of the bus\r | |
342 | controller. It will not be NULL for a bus\r | |
343 | driver that wishes to retrieve the name of a\r | |
344 | child controller.\r | |
345 | \r | |
346 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
347 | array indicating the language. This is the\r | |
348 | language of the driver name that the caller is\r | |
349 | requesting, and it must match one of the\r | |
350 | languages specified in SupportedLanguages. The\r | |
351 | number of languages supported by a driver is up\r | |
352 | to the driver writer. Language is specified in\r | |
353 | RFC 4646 or ISO 639-2 language code format.\r | |
354 | \r | |
355 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
356 | This Unicode string is the name of the\r | |
357 | controller specified by ControllerHandle and\r | |
358 | ChildHandle in the language specified by\r | |
359 | Language from the point of view of the driver\r | |
360 | specified by This.\r | |
361 | \r | |
362 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
363 | the language specified by Language for the\r | |
364 | driver specified by This was returned in\r | |
365 | DriverName.\r | |
366 | \r | |
367 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r | |
368 | \r | |
369 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
370 | EFI_HANDLE.\r | |
371 | \r | |
372 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
373 | \r | |
374 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
375 | \r | |
376 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
377 | managing the controller specified by\r | |
378 | ControllerHandle and ChildHandle.\r | |
379 | \r | |
380 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
381 | the language specified by Language.\r | |
382 | \r | |
383 | **/\r | |
384 | EFI_STATUS\r | |
385 | EFIAPI\r | |
386 | UfsPassThruComponentNameGetControllerName (\r | |
387 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
388 | IN EFI_HANDLE ControllerHandle,\r | |
389 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
390 | IN CHAR8 *Language,\r | |
391 | OUT CHAR16 **ControllerName\r | |
392 | );\r | |
393 | \r | |
394 | /**\r | |
395 | Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function\r | |
396 | supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the\r | |
397 | nonblocking I/O functionality is optional.\r | |
398 | \r | |
399 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
400 | @param Target The Target is an array of size TARGET_MAX_BYTES and it represents\r | |
401 | the id of the SCSI device to send the SCSI Request Packet. Each\r | |
402 | transport driver may choose to utilize a subset of this size to suit the needs\r | |
403 | of transport target representation. For example, a Fibre Channel driver\r | |
404 | may use only 8 bytes (WWN) to represent an FC target.\r | |
405 | @param Lun The LUN of the SCSI device to send the SCSI Request Packet.\r | |
406 | @param Packet A pointer to the SCSI Request Packet to send to the SCSI device\r | |
407 | specified by Target and Lun.\r | |
408 | @param Event If nonblocking I/O is not supported then Event is ignored, and blocking\r | |
409 | I/O is performed. If Event is NULL, then blocking I/O is performed. If\r | |
410 | Event is not NULL and non blocking I/O is supported, then\r | |
411 | nonblocking I/O is performed, and Event will be signaled when the\r | |
412 | SCSI Request Packet completes.\r | |
413 | \r | |
414 | @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional\r | |
415 | commands, InTransferLength bytes were transferred from\r | |
416 | InDataBuffer. For write and bi-directional commands,\r | |
417 | OutTransferLength bytes were transferred by\r | |
418 | OutDataBuffer.\r | |
419 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that\r | |
420 | could be transferred is returned in InTransferLength. For write\r | |
421 | and bi-directional commands, OutTransferLength bytes were\r | |
422 | transferred by OutDataBuffer.\r | |
423 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many\r | |
424 | SCSI Request Packets already queued. The caller may retry again later.\r | |
425 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request\r | |
426 | Packet.\r | |
427 | @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.\r | |
428 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported\r | |
429 | by the host adapter. This includes the case of Bi-directional SCSI\r | |
430 | commands not supported by the implementation. The SCSI Request\r | |
431 | Packet was not sent, so no additional status information is available.\r | |
432 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
433 | \r | |
434 | **/\r | |
435 | EFI_STATUS\r | |
436 | EFIAPI\r | |
437 | UfsPassThruPassThru (\r | |
438 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
439 | IN UINT8 *Target,\r | |
440 | IN UINT64 Lun,\r | |
441 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r | |
442 | IN EFI_EVENT Event OPTIONAL\r | |
443 | );\r | |
444 | \r | |
445 | /**\r | |
446 | Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These\r | |
447 | can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal\r | |
448 | Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the\r | |
449 | Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI\r | |
450 | channel.\r | |
451 | \r | |
452 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
453 | @param Target On input, a pointer to the Target ID (an array of size\r | |
454 | TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r | |
455 | On output, a pointer to the Target ID (an array of\r | |
456 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r | |
457 | channel. An input value of 0xF(all bytes in the array are 0xF) in the\r | |
458 | Target array retrieves the Target ID of the first SCSI device present on a\r | |
459 | SCSI channel.\r | |
460 | @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI\r | |
461 | channel. On output, a pointer to the LUN of the next SCSI device present\r | |
462 | on a SCSI channel.\r | |
463 | \r | |
464 | @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI\r | |
465 | channel was returned in Target and Lun.\r | |
466 | @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were\r | |
467 | not returned on a previous call to GetNextTargetLun().\r | |
468 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.\r | |
469 | \r | |
470 | **/\r | |
471 | EFI_STATUS\r | |
472 | EFIAPI\r | |
473 | UfsPassThruGetNextTargetLun (\r | |
474 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
475 | IN OUT UINT8 **Target,\r | |
476 | IN OUT UINT64 *Lun\r | |
477 | );\r | |
478 | \r | |
479 | /**\r | |
480 | Used to allocate and build a device path node for a SCSI device on a SCSI channel.\r | |
481 | \r | |
482 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
483 | @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the\r | |
484 | Target ID of the SCSI device for which a device path node is to be\r | |
485 | allocated and built. Transport drivers may chose to utilize a subset of\r | |
486 | this size to suit the representation of targets. For example, a Fibre\r | |
487 | Channel driver may use only 8 bytes (WWN) in the array to represent a\r | |
488 | FC target.\r | |
489 | @param Lun The LUN of the SCSI device for which a device path node is to be\r | |
490 | allocated and built.\r | |
491 | @param DevicePath A pointer to a single device path node that describes the SCSI device\r | |
492 | specified by Target and Lun. This function is responsible for\r | |
493 | allocating the buffer DevicePath with the boot service\r | |
494 | AllocatePool(). It is the caller's responsibility to free\r | |
495 | DevicePath when the caller is finished with DevicePath.\r | |
496 | \r | |
497 | @retval EFI_SUCCESS The device path node that describes the SCSI device specified by\r | |
498 | Target and Lun was allocated and returned in\r | |
499 | DevicePath.\r | |
500 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r | |
501 | @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist\r | |
502 | on the SCSI channel.\r | |
503 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r | |
504 | \r | |
505 | **/\r | |
506 | EFI_STATUS\r | |
507 | EFIAPI\r | |
508 | UfsPassThruBuildDevicePath (\r | |
509 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
510 | IN UINT8 *Target,\r | |
511 | IN UINT64 Lun,\r | |
512 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r | |
513 | );\r | |
514 | \r | |
515 | /**\r | |
516 | Used to translate a device path node to a Target ID and LUN.\r | |
517 | \r | |
518 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
519 | @param DevicePath A pointer to a single device path node that describes the SCSI device\r | |
520 | on the SCSI channel.\r | |
521 | @param Target A pointer to the Target Array which represents the ID of a SCSI device\r | |
522 | on the SCSI channel.\r | |
523 | @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.\r | |
524 | \r | |
525 | @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and\r | |
526 | LUN, and they were returned in Target and Lun.\r | |
527 | @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.\r | |
528 | @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN\r | |
529 | does not exist.\r | |
530 | @retval EFI_UNSUPPORTED This driver does not support the device path node type in\r | |
531 | DevicePath.\r | |
532 | \r | |
533 | **/\r | |
534 | EFI_STATUS\r | |
535 | EFIAPI\r | |
536 | UfsPassThruGetTargetLun (\r | |
537 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
538 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
539 | OUT UINT8 **Target,\r | |
540 | OUT UINT64 *Lun\r | |
541 | );\r | |
542 | \r | |
543 | /**\r | |
544 | Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.\r | |
545 | \r | |
546 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
547 | \r | |
548 | @retval EFI_SUCCESS The SCSI channel was reset.\r | |
549 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.\r | |
550 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.\r | |
551 | @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.\r | |
552 | \r | |
553 | **/\r | |
554 | EFI_STATUS\r | |
555 | EFIAPI\r | |
556 | UfsPassThruResetChannel (\r | |
557 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This\r | |
558 | );\r | |
559 | \r | |
560 | /**\r | |
561 | Resets a SCSI logical unit that is connected to a SCSI channel.\r | |
562 | \r | |
563 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
564 | @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the\r | |
565 | target port ID of the SCSI device containing the SCSI logical unit to\r | |
566 | reset. Transport drivers may chose to utilize a subset of this array to suit\r | |
567 | the representation of their targets.\r | |
568 | @param Lun The LUN of the SCSI device to reset.\r | |
569 | \r | |
570 | @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.\r | |
571 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r | |
572 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device\r | |
573 | specified by Target and Lun.\r | |
574 | @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.\r | |
575 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device\r | |
576 | specified by Target and Lun.\r | |
577 | \r | |
578 | **/\r | |
579 | EFI_STATUS\r | |
580 | EFIAPI\r | |
581 | UfsPassThruResetTargetLun (\r | |
582 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
583 | IN UINT8 *Target,\r | |
584 | IN UINT64 Lun\r | |
585 | );\r | |
586 | \r | |
587 | /**\r | |
588 | Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either\r | |
589 | be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs\r | |
590 | for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to\r | |
591 | see if a SCSI device is actually present at that location on the SCSI channel.\r | |
592 | \r | |
593 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
594 | @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r | |
595 | On output, a pointer to the Target ID (an array of\r | |
596 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r | |
597 | channel. An input value of 0xF(all bytes in the array are 0xF) in the\r | |
598 | Target array retrieves the Target ID of the first SCSI device present on a\r | |
599 | SCSI channel.\r | |
600 | \r | |
601 | @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI\r | |
602 | channel was returned in Target.\r | |
603 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r | |
604 | @retval EFI_TIMEOUT Target array is not all 0xF, and Target was not\r | |
605 | returned on a previous call to GetNextTarget().\r | |
606 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.\r | |
607 | \r | |
608 | **/\r | |
609 | EFI_STATUS\r | |
610 | EFIAPI\r | |
611 | UfsPassThruGetNextTarget (\r | |
612 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
613 | IN OUT UINT8 **Target\r | |
614 | );\r | |
615 | \r | |
616 | /**\r | |
617 | Sends a UFS-supported SCSI Request Packet to a UFS device that is attached to the UFS host controller.\r | |
618 | \r | |
619 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
620 | @param[in] Lun The LUN of the UFS device to send the SCSI Request Packet.\r | |
621 | @param[in, out] Packet A pointer to the SCSI Request Packet to send to a specified Lun of the\r | |
622 | UFS device.\r | |
0350b57c HW |
623 | @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking\r |
624 | I/O is performed. If Event is NULL, then blocking I/O is performed. If\r | |
625 | Event is not NULL and non blocking I/O is supported, then\r | |
626 | nonblocking I/O is performed, and Event will be signaled when the\r | |
627 | SCSI Request Packet completes.\r | |
0591696e FT |
628 | \r |
629 | @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional\r | |
630 | commands, InTransferLength bytes were transferred from\r | |
631 | InDataBuffer. For write and bi-directional commands,\r | |
632 | OutTransferLength bytes were transferred by\r | |
633 | OutDataBuffer.\r | |
634 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request\r | |
635 | Packet.\r | |
636 | @retval EFI_OUT_OF_RESOURCES The resource for transfer is not available.\r | |
637 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
638 | \r | |
639 | **/\r | |
640 | EFI_STATUS\r | |
641 | UfsExecScsiCmds (\r | |
642 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
643 | IN UINT8 Lun,\r | |
0350b57c HW |
644 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r |
645 | IN EFI_EVENT Event OPTIONAL\r | |
0591696e FT |
646 | );\r |
647 | \r | |
648 | /**\r | |
649 | Initialize the UFS host controller.\r | |
650 | \r | |
651 | @param[in] Private The pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.\r | |
652 | \r | |
653 | @retval EFI_SUCCESS The NVM Express Controller is initialized successfully.\r | |
654 | @retval Others A device error occurred while initializing the controller.\r | |
655 | \r | |
656 | **/\r | |
657 | EFI_STATUS\r | |
658 | UfsControllerInit (\r | |
659 | IN UFS_PASS_THRU_PRIVATE_DATA *Private\r | |
660 | );\r | |
661 | \r | |
662 | /**\r | |
663 | Stop the UFS host controller.\r | |
664 | \r | |
665 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
666 | \r | |
667 | @retval EFI_SUCCESS The Ufs Host Controller is stopped successfully.\r | |
668 | @retval Others A device error occurred while stopping the controller.\r | |
669 | \r | |
670 | **/\r | |
671 | EFI_STATUS\r | |
672 | UfsControllerStop (\r | |
673 | IN UFS_PASS_THRU_PRIVATE_DATA *Private\r | |
674 | );\r | |
675 | \r | |
676 | /**\r | |
677 | Allocate common buffer for host and UFS bus master access simultaneously.\r | |
678 | \r | |
679 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
680 | @param[in] Size The length of buffer to be allocated.\r | |
681 | @param[out] CmdDescHost A pointer to store the base system memory address of the allocated range.\r | |
682 | @param[out] CmdDescPhyAddr The resulting map address for the UFS bus master to use to access the hosts CmdDescHost.\r | |
683 | @param[out] CmdDescMapping A resulting value to pass to Unmap().\r | |
684 | \r | |
685 | @retval EFI_SUCCESS The common buffer was allocated successfully.\r | |
686 | @retval EFI_DEVICE_ERROR The allocation fails.\r | |
687 | @retval EFI_OUT_OF_RESOURCES The memory resource is insufficient.\r | |
688 | \r | |
689 | **/\r | |
690 | EFI_STATUS\r | |
691 | UfsAllocateAlignCommonBuffer (\r | |
692 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
693 | IN UINTN Size,\r | |
694 | OUT VOID **CmdDescHost,\r | |
695 | OUT EFI_PHYSICAL_ADDRESS *CmdDescPhyAddr,\r | |
696 | OUT VOID **CmdDescMapping\r | |
697 | );\r | |
698 | \r | |
699 | /**\r | |
700 | Set specified flag to 1 on a UFS device.\r | |
701 | \r | |
702 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
703 | @param[in] FlagId The ID of flag to be set.\r | |
704 | \r | |
705 | @retval EFI_SUCCESS The flag was set successfully.\r | |
706 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to set the flag.\r | |
707 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of setting the flag.\r | |
708 | \r | |
709 | **/\r | |
710 | EFI_STATUS\r | |
711 | UfsSetFlag (\r | |
712 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
713 | IN UINT8 FlagId\r | |
714 | );\r | |
715 | \r | |
95ad8f7f HW |
716 | /**\r |
717 | Read specified flag from a UFS device.\r | |
718 | \r | |
719 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
720 | @param[in] FlagId The ID of flag to be read.\r | |
721 | @param[out] Value The flag's value.\r | |
722 | \r | |
723 | @retval EFI_SUCCESS The flag was read successfully.\r | |
724 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to read the flag.\r | |
725 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of reading the flag.\r | |
726 | \r | |
727 | **/\r | |
728 | EFI_STATUS\r | |
729 | UfsReadFlag (\r | |
730 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
731 | IN UINT8 FlagId,\r | |
732 | OUT UINT8 *Value\r | |
733 | );\r | |
734 | \r | |
0591696e FT |
735 | /**\r |
736 | Read or write specified device descriptor of a UFS device.\r | |
737 | \r | |
738 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
739 | @param[in] Read The boolean variable to show r/w direction.\r | |
740 | @param[in] DescId The ID of device descriptor.\r | |
741 | @param[in] Index The Index of device descriptor.\r | |
742 | @param[in] Selector The Selector of device descriptor.\r | |
743 | @param[in, out] Descriptor The buffer of device descriptor to be read or written.\r | |
744 | @param[in] DescSize The size of device descriptor buffer.\r | |
745 | \r | |
746 | @retval EFI_SUCCESS The device descriptor was read/written successfully.\r | |
747 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the device descriptor.\r | |
748 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of r/w the device descriptor.\r | |
749 | \r | |
750 | **/\r | |
751 | EFI_STATUS\r | |
752 | UfsRwDeviceDesc (\r | |
753 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
754 | IN BOOLEAN Read,\r | |
755 | IN UINT8 DescId,\r | |
756 | IN UINT8 Index,\r | |
757 | IN UINT8 Selector,\r | |
758 | IN OUT VOID *Descriptor,\r | |
759 | IN UINT32 DescSize\r | |
760 | );\r | |
761 | \r | |
95ad8f7f HW |
762 | /**\r |
763 | Read or write specified attribute of a UFS device.\r | |
764 | \r | |
765 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
766 | @param[in] Read The boolean variable to show r/w direction.\r | |
767 | @param[in] AttrId The ID of Attribute.\r | |
768 | @param[in] Index The Index of Attribute.\r | |
769 | @param[in] Selector The Selector of Attribute.\r | |
770 | @param[in, out] Attributes The value of Attribute to be read or written.\r | |
771 | \r | |
772 | @retval EFI_SUCCESS The Attribute was read/written successfully.\r | |
773 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the Attribute.\r | |
774 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of r/w the Attribute.\r | |
775 | \r | |
776 | **/\r | |
777 | EFI_STATUS\r | |
778 | UfsRwAttributes (\r | |
779 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
780 | IN BOOLEAN Read,\r | |
781 | IN UINT8 AttrId,\r | |
782 | IN UINT8 Index,\r | |
783 | IN UINT8 Selector,\r | |
784 | IN OUT UINT32 *Attributes\r | |
785 | );\r | |
786 | \r | |
0591696e FT |
787 | /**\r |
788 | Sends NOP IN cmd to a UFS device for initialization process request.\r | |
789 | For more details, please refer to UFS 2.0 spec Figure 13.3.\r | |
790 | \r | |
791 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
792 | \r | |
793 | @retval EFI_SUCCESS The NOP IN command was sent by the host. The NOP OUT response was\r | |
794 | received successfully.\r | |
795 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to execute NOP IN command.\r | |
796 | @retval EFI_OUT_OF_RESOURCES The resource for transfer is not available.\r | |
797 | @retval EFI_TIMEOUT A timeout occurred while waiting for the NOP IN command to execute.\r | |
798 | \r | |
799 | **/\r | |
800 | EFI_STATUS\r | |
801 | UfsExecNopCmds (\r | |
802 | IN UFS_PASS_THRU_PRIVATE_DATA *Private\r | |
803 | );\r | |
804 | \r | |
0350b57c HW |
805 | /**\r |
806 | Call back function when the timer event is signaled.\r | |
807 | \r | |
808 | @param[in] Event The Event this notify function registered to.\r | |
809 | @param[in] Context Pointer to the context data registered to the Event.\r | |
810 | \r | |
811 | **/\r | |
812 | VOID\r | |
813 | EFIAPI\r | |
814 | ProcessAsyncTaskList (\r | |
815 | IN EFI_EVENT Event,\r | |
816 | IN VOID *Context\r | |
817 | );\r | |
818 | \r | |
819 | /**\r | |
820 | Internal helper function which will signal the caller event and clean up\r | |
821 | resources.\r | |
822 | \r | |
823 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data\r | |
824 | structure.\r | |
825 | @param[in] TransReq The pointer to the UFS_PASS_THRU_TRANS_REQ data\r | |
826 | structure.\r | |
827 | \r | |
828 | **/\r | |
829 | VOID\r | |
830 | EFIAPI\r | |
831 | SignalCallerEvent (\r | |
832 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
833 | IN UFS_PASS_THRU_TRANS_REQ *TransReq\r | |
834 | );\r | |
835 | \r | |
5966dd8f FT |
836 | extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName;\r |
837 | extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2;\r | |
838 | extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding;\r | |
0591696e FT |
839 | \r |
840 | #endif\r |