]>
Commit | Line | Data |
---|---|---|
0591696e FT |
1 | /** @file\r |
2 | \r | |
095f0779 | 3 | Copyright (c) 2014 - 2015, 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 HW |
53 | //\r |
54 | // Iterate through the doule linked list. This is delete-safe.\r | |
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 | |
125 | VOID *InDataBuffer;\r | |
126 | VOID *OutDataBuffer;\r | |
127 | UINT8 Opcode;\r | |
128 | UINT8 DescId;\r | |
129 | UINT8 Index;\r | |
130 | UINT8 Selector;\r | |
131 | UINT32 InTransferLength;\r | |
132 | UINT32 OutTransferLength;\r | |
133 | UINT8 DataDirection;\r | |
134 | UINT8 Ocs;\r | |
135 | } UFS_DEVICE_MANAGEMENT_REQUEST_PACKET;\r | |
136 | \r | |
137 | //\r | |
138 | // function prototype\r | |
139 | //\r | |
140 | /**\r | |
141 | Tests to see if this driver supports a given controller. If a child device is provided,\r | |
142 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
143 | \r | |
144 | This function checks to see if the driver specified by This supports the device specified by\r | |
145 | ControllerHandle. Drivers will typically use the device path attached to\r | |
146 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
147 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
148 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
149 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
150 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
151 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
152 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
153 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
154 | Since ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
155 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
156 | to guarantee the state of ControllerHandle is not modified by this function.\r | |
157 | \r | |
158 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
159 | @param[in] ControllerHandle The handle of the controller to test. This handle\r | |
160 | must support a protocol interface that supplies\r | |
161 | an I/O abstraction to the driver.\r | |
162 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
163 | parameter is ignored by device drivers, and is optional for bus\r | |
164 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
165 | the bus driver must determine if the bus controller specified\r | |
166 | by ControllerHandle and the child controller specified\r | |
167 | by RemainingDevicePath are both supported by this\r | |
168 | bus driver.\r | |
169 | \r | |
170 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
171 | RemainingDevicePath is supported by the driver specified by This.\r | |
172 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
173 | RemainingDevicePath is already being managed by the driver\r | |
174 | specified by This.\r | |
175 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
176 | RemainingDevicePath is already being managed by a different\r | |
177 | driver or an application that requires exclusive access.\r | |
178 | Currently not implemented.\r | |
179 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
180 | RemainingDevicePath is not supported by the driver specified by This.\r | |
181 | **/\r | |
182 | EFI_STATUS\r | |
183 | EFIAPI\r | |
184 | UfsPassThruDriverBindingSupported (\r | |
185 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
186 | IN EFI_HANDLE Controller,\r | |
187 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
188 | );\r | |
189 | \r | |
190 | /**\r | |
191 | Starts a device controller or a bus controller.\r | |
192 | \r | |
193 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
194 | As a result, much of the error checking on the parameters to Start() has been moved into this\r | |
195 | common boot service. It is legal to call Start() from other locations,\r | |
196 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
197 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
198 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
199 | EFI_DEVICE_PATH_PROTOCOL.\r | |
200 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
201 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r | |
202 | \r | |
203 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
204 | @param[in] ControllerHandle The handle of the controller to start. This handle\r | |
205 | must support a protocol interface that supplies\r | |
206 | an I/O abstraction to the driver.\r | |
207 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
208 | parameter is ignored by device drivers, and is optional for bus\r | |
209 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
210 | for all the children of Controller are created by this driver.\r | |
211 | If this parameter is not NULL and the first Device Path Node is\r | |
212 | not the End of Device Path Node, then only the handle for the\r | |
213 | child device specified by the first Device Path Node of\r | |
214 | RemainingDevicePath is created by this driver.\r | |
215 | If the first Device Path Node of RemainingDevicePath is\r | |
216 | the End of Device Path Node, no child handle is created by this\r | |
217 | driver.\r | |
218 | \r | |
219 | @retval EFI_SUCCESS The device was started.\r | |
220 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
221 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
222 | @retval Others The driver failded to start the device.\r | |
223 | \r | |
224 | **/\r | |
225 | EFI_STATUS\r | |
226 | EFIAPI\r | |
227 | UfsPassThruDriverBindingStart (\r | |
228 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
229 | IN EFI_HANDLE Controller,\r | |
230 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
231 | );\r | |
232 | \r | |
233 | /**\r | |
234 | Stops a device controller or a bus controller.\r | |
235 | \r | |
236 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
237 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
238 | into this common boot service. It is legal to call Stop() from other locations,\r | |
239 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
240 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
241 | same driver's Start() function.\r | |
242 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
243 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
244 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
245 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
246 | \r | |
247 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
248 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r | |
249 | support a bus specific I/O protocol for the driver\r | |
250 | to use to stop the device.\r | |
251 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
252 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r | |
253 | if NumberOfChildren is 0.\r | |
254 | \r | |
255 | @retval EFI_SUCCESS The device was stopped.\r | |
256 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
257 | \r | |
258 | **/\r | |
259 | EFI_STATUS\r | |
260 | EFIAPI\r | |
261 | UfsPassThruDriverBindingStop (\r | |
262 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
263 | IN EFI_HANDLE Controller,\r | |
264 | IN UINTN NumberOfChildren,\r | |
265 | IN EFI_HANDLE *ChildHandleBuffer\r | |
266 | );\r | |
267 | \r | |
268 | //\r | |
269 | // EFI Component Name Functions\r | |
270 | //\r | |
271 | /**\r | |
272 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
273 | \r | |
274 | This function retrieves the user readable name of a driver in the form of a\r | |
275 | Unicode string. If the driver specified by This has a user readable name in\r | |
276 | the language specified by Language, then a pointer to the driver name is\r | |
277 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
278 | by This does not support the language specified by Language,\r | |
279 | then EFI_UNSUPPORTED is returned.\r | |
280 | \r | |
281 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
282 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
283 | \r | |
284 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
285 | array indicating the language. This is the\r | |
286 | language of the driver name that the caller is\r | |
287 | requesting, and it must match one of the\r | |
288 | languages specified in SupportedLanguages. The\r | |
289 | number of languages supported by a driver is up\r | |
290 | to the driver writer. Language is specified\r | |
291 | in RFC 4646 or ISO 639-2 language code format.\r | |
292 | \r | |
293 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
294 | This Unicode string is the name of the\r | |
295 | driver specified by This in the language\r | |
296 | specified by Language.\r | |
297 | \r | |
298 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
299 | This and the language specified by Language was\r | |
300 | returned in DriverName.\r | |
301 | \r | |
302 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
303 | \r | |
304 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
305 | \r | |
306 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
307 | the language specified by Language.\r | |
308 | \r | |
309 | **/\r | |
310 | EFI_STATUS\r | |
311 | EFIAPI\r | |
312 | UfsPassThruComponentNameGetDriverName (\r | |
313 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
314 | IN CHAR8 *Language,\r | |
315 | OUT CHAR16 **DriverName\r | |
316 | );\r | |
317 | \r | |
318 | \r | |
319 | /**\r | |
320 | Retrieves a Unicode string that is the user readable name of the controller\r | |
321 | that is being managed by a driver.\r | |
322 | \r | |
323 | This function retrieves the user readable name of the controller specified by\r | |
324 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
325 | driver specified by This has a user readable name in the language specified by\r | |
326 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
327 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
328 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
329 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
330 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
331 | \r | |
332 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
333 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
334 | \r | |
335 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
336 | specified by This is managing. This handle\r | |
337 | specifies the controller whose name is to be\r | |
338 | returned.\r | |
339 | \r | |
340 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
341 | the name of. This is an optional parameter that\r | |
342 | may be NULL. It will be NULL for device\r | |
343 | drivers. It will also be NULL for a bus drivers\r | |
344 | that wish to retrieve the name of the bus\r | |
345 | controller. It will not be NULL for a bus\r | |
346 | driver that wishes to retrieve the name of a\r | |
347 | child controller.\r | |
348 | \r | |
349 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
350 | array indicating the language. This is the\r | |
351 | language of the driver name that the caller is\r | |
352 | requesting, and it must match one of the\r | |
353 | languages specified in SupportedLanguages. The\r | |
354 | number of languages supported by a driver is up\r | |
355 | to the driver writer. Language is specified in\r | |
356 | RFC 4646 or ISO 639-2 language code format.\r | |
357 | \r | |
358 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
359 | This Unicode string is the name of the\r | |
360 | controller specified by ControllerHandle and\r | |
361 | ChildHandle in the language specified by\r | |
362 | Language from the point of view of the driver\r | |
363 | specified by This.\r | |
364 | \r | |
365 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
366 | the language specified by Language for the\r | |
367 | driver specified by This was returned in\r | |
368 | DriverName.\r | |
369 | \r | |
370 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r | |
371 | \r | |
372 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
373 | EFI_HANDLE.\r | |
374 | \r | |
375 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
376 | \r | |
377 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
378 | \r | |
379 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
380 | managing the controller specified by\r | |
381 | ControllerHandle and ChildHandle.\r | |
382 | \r | |
383 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
384 | the language specified by Language.\r | |
385 | \r | |
386 | **/\r | |
387 | EFI_STATUS\r | |
388 | EFIAPI\r | |
389 | UfsPassThruComponentNameGetControllerName (\r | |
390 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
391 | IN EFI_HANDLE ControllerHandle,\r | |
392 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
393 | IN CHAR8 *Language,\r | |
394 | OUT CHAR16 **ControllerName\r | |
395 | );\r | |
396 | \r | |
397 | /**\r | |
398 | Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function\r | |
399 | supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the\r | |
400 | nonblocking I/O functionality is optional.\r | |
401 | \r | |
402 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
403 | @param Target The Target is an array of size TARGET_MAX_BYTES and it represents\r | |
404 | the id of the SCSI device to send the SCSI Request Packet. Each\r | |
405 | transport driver may choose to utilize a subset of this size to suit the needs\r | |
406 | of transport target representation. For example, a Fibre Channel driver\r | |
407 | may use only 8 bytes (WWN) to represent an FC target.\r | |
408 | @param Lun The LUN of the SCSI device to send the SCSI Request Packet.\r | |
409 | @param Packet A pointer to the SCSI Request Packet to send to the SCSI device\r | |
410 | specified by Target and Lun.\r | |
411 | @param Event If nonblocking I/O is not supported then Event is ignored, and blocking\r | |
412 | I/O is performed. If Event is NULL, then blocking I/O is performed. If\r | |
413 | Event is not NULL and non blocking I/O is supported, then\r | |
414 | nonblocking I/O is performed, and Event will be signaled when the\r | |
415 | SCSI Request Packet completes.\r | |
416 | \r | |
417 | @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional\r | |
418 | commands, InTransferLength bytes were transferred from\r | |
419 | InDataBuffer. For write and bi-directional commands,\r | |
420 | OutTransferLength bytes were transferred by\r | |
421 | OutDataBuffer.\r | |
422 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that\r | |
423 | could be transferred is returned in InTransferLength. For write\r | |
424 | and bi-directional commands, OutTransferLength bytes were\r | |
425 | transferred by OutDataBuffer.\r | |
426 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many\r | |
427 | SCSI Request Packets already queued. The caller may retry again later.\r | |
428 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request\r | |
429 | Packet.\r | |
430 | @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.\r | |
431 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported\r | |
432 | by the host adapter. This includes the case of Bi-directional SCSI\r | |
433 | commands not supported by the implementation. The SCSI Request\r | |
434 | Packet was not sent, so no additional status information is available.\r | |
435 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
436 | \r | |
437 | **/\r | |
438 | EFI_STATUS\r | |
439 | EFIAPI\r | |
440 | UfsPassThruPassThru (\r | |
441 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
442 | IN UINT8 *Target,\r | |
443 | IN UINT64 Lun,\r | |
444 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r | |
445 | IN EFI_EVENT Event OPTIONAL\r | |
446 | );\r | |
447 | \r | |
448 | /**\r | |
449 | Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These\r | |
450 | can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal\r | |
451 | Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the\r | |
452 | Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI\r | |
453 | channel.\r | |
454 | \r | |
455 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
456 | @param Target On input, a pointer to the Target ID (an array of size\r | |
457 | TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r | |
458 | On output, a pointer to the Target ID (an array of\r | |
459 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r | |
460 | channel. An input value of 0xF(all bytes in the array are 0xF) in the\r | |
461 | Target array retrieves the Target ID of the first SCSI device present on a\r | |
462 | SCSI channel.\r | |
463 | @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI\r | |
464 | channel. On output, a pointer to the LUN of the next SCSI device present\r | |
465 | on a SCSI channel.\r | |
466 | \r | |
467 | @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI\r | |
468 | channel was returned in Target and Lun.\r | |
469 | @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were\r | |
470 | not returned on a previous call to GetNextTargetLun().\r | |
471 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.\r | |
472 | \r | |
473 | **/\r | |
474 | EFI_STATUS\r | |
475 | EFIAPI\r | |
476 | UfsPassThruGetNextTargetLun (\r | |
477 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
478 | IN OUT UINT8 **Target,\r | |
479 | IN OUT UINT64 *Lun\r | |
480 | );\r | |
481 | \r | |
482 | /**\r | |
483 | Used to allocate and build a device path node for a SCSI device on a SCSI channel.\r | |
484 | \r | |
485 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
486 | @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the\r | |
487 | Target ID of the SCSI device for which a device path node is to be\r | |
488 | allocated and built. Transport drivers may chose to utilize a subset of\r | |
489 | this size to suit the representation of targets. For example, a Fibre\r | |
490 | Channel driver may use only 8 bytes (WWN) in the array to represent a\r | |
491 | FC target.\r | |
492 | @param Lun The LUN of the SCSI device for which a device path node is to be\r | |
493 | allocated and built.\r | |
494 | @param DevicePath A pointer to a single device path node that describes the SCSI device\r | |
495 | specified by Target and Lun. This function is responsible for\r | |
496 | allocating the buffer DevicePath with the boot service\r | |
497 | AllocatePool(). It is the caller's responsibility to free\r | |
498 | DevicePath when the caller is finished with DevicePath.\r | |
499 | \r | |
500 | @retval EFI_SUCCESS The device path node that describes the SCSI device specified by\r | |
501 | Target and Lun was allocated and returned in\r | |
502 | DevicePath.\r | |
503 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r | |
504 | @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist\r | |
505 | on the SCSI channel.\r | |
506 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r | |
507 | \r | |
508 | **/\r | |
509 | EFI_STATUS\r | |
510 | EFIAPI\r | |
511 | UfsPassThruBuildDevicePath (\r | |
512 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
513 | IN UINT8 *Target,\r | |
514 | IN UINT64 Lun,\r | |
515 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r | |
516 | );\r | |
517 | \r | |
518 | /**\r | |
519 | Used to translate a device path node to a Target ID and LUN.\r | |
520 | \r | |
521 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
522 | @param DevicePath A pointer to a single device path node that describes the SCSI device\r | |
523 | on the SCSI channel.\r | |
524 | @param Target A pointer to the Target Array which represents the ID of a SCSI device\r | |
525 | on the SCSI channel.\r | |
526 | @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.\r | |
527 | \r | |
528 | @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and\r | |
529 | LUN, and they were returned in Target and Lun.\r | |
530 | @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.\r | |
531 | @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN\r | |
532 | does not exist.\r | |
533 | @retval EFI_UNSUPPORTED This driver does not support the device path node type in\r | |
534 | DevicePath.\r | |
535 | \r | |
536 | **/\r | |
537 | EFI_STATUS\r | |
538 | EFIAPI\r | |
539 | UfsPassThruGetTargetLun (\r | |
540 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
541 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
542 | OUT UINT8 **Target,\r | |
543 | OUT UINT64 *Lun\r | |
544 | );\r | |
545 | \r | |
546 | /**\r | |
547 | Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.\r | |
548 | \r | |
549 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
550 | \r | |
551 | @retval EFI_SUCCESS The SCSI channel was reset.\r | |
552 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.\r | |
553 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.\r | |
554 | @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.\r | |
555 | \r | |
556 | **/\r | |
557 | EFI_STATUS\r | |
558 | EFIAPI\r | |
559 | UfsPassThruResetChannel (\r | |
560 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This\r | |
561 | );\r | |
562 | \r | |
563 | /**\r | |
564 | Resets a SCSI logical unit that is connected to a SCSI channel.\r | |
565 | \r | |
566 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
567 | @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the\r | |
568 | target port ID of the SCSI device containing the SCSI logical unit to\r | |
569 | reset. Transport drivers may chose to utilize a subset of this array to suit\r | |
570 | the representation of their targets.\r | |
571 | @param Lun The LUN of the SCSI device to reset.\r | |
572 | \r | |
573 | @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.\r | |
574 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r | |
575 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device\r | |
576 | specified by Target and Lun.\r | |
577 | @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.\r | |
578 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device\r | |
579 | specified by Target and Lun.\r | |
580 | \r | |
581 | **/\r | |
582 | EFI_STATUS\r | |
583 | EFIAPI\r | |
584 | UfsPassThruResetTargetLun (\r | |
585 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
586 | IN UINT8 *Target,\r | |
587 | IN UINT64 Lun\r | |
588 | );\r | |
589 | \r | |
590 | /**\r | |
591 | Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either\r | |
592 | be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs\r | |
593 | for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to\r | |
594 | see if a SCSI device is actually present at that location on the SCSI channel.\r | |
595 | \r | |
596 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
597 | @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r | |
598 | On output, a pointer to the Target ID (an array of\r | |
599 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r | |
600 | channel. An input value of 0xF(all bytes in the array are 0xF) in the\r | |
601 | Target array retrieves the Target ID of the first SCSI device present on a\r | |
602 | SCSI channel.\r | |
603 | \r | |
604 | @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI\r | |
605 | channel was returned in Target.\r | |
606 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r | |
607 | @retval EFI_TIMEOUT Target array is not all 0xF, and Target was not\r | |
608 | returned on a previous call to GetNextTarget().\r | |
609 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.\r | |
610 | \r | |
611 | **/\r | |
612 | EFI_STATUS\r | |
613 | EFIAPI\r | |
614 | UfsPassThruGetNextTarget (\r | |
615 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
616 | IN OUT UINT8 **Target\r | |
617 | );\r | |
618 | \r | |
619 | /**\r | |
620 | Sends a UFS-supported SCSI Request Packet to a UFS device that is attached to the UFS host controller.\r | |
621 | \r | |
622 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
623 | @param[in] Lun The LUN of the UFS device to send the SCSI Request Packet.\r | |
624 | @param[in, out] Packet A pointer to the SCSI Request Packet to send to a specified Lun of the\r | |
625 | UFS device.\r | |
0350b57c HW |
626 | @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking\r |
627 | I/O is performed. If Event is NULL, then blocking I/O is performed. If\r | |
628 | Event is not NULL and non blocking I/O is supported, then\r | |
629 | nonblocking I/O is performed, and Event will be signaled when the\r | |
630 | SCSI Request Packet completes.\r | |
0591696e FT |
631 | \r |
632 | @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional\r | |
633 | commands, InTransferLength bytes were transferred from\r | |
634 | InDataBuffer. For write and bi-directional commands,\r | |
635 | OutTransferLength bytes were transferred by\r | |
636 | OutDataBuffer.\r | |
637 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request\r | |
638 | Packet.\r | |
639 | @retval EFI_OUT_OF_RESOURCES The resource for transfer is not available.\r | |
640 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
641 | \r | |
642 | **/\r | |
643 | EFI_STATUS\r | |
644 | UfsExecScsiCmds (\r | |
645 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
646 | IN UINT8 Lun,\r | |
0350b57c HW |
647 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r |
648 | IN EFI_EVENT Event OPTIONAL\r | |
0591696e FT |
649 | );\r |
650 | \r | |
651 | /**\r | |
652 | Initialize the UFS host controller.\r | |
653 | \r | |
654 | @param[in] Private The pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.\r | |
655 | \r | |
656 | @retval EFI_SUCCESS The NVM Express Controller is initialized successfully.\r | |
657 | @retval Others A device error occurred while initializing the controller.\r | |
658 | \r | |
659 | **/\r | |
660 | EFI_STATUS\r | |
661 | UfsControllerInit (\r | |
662 | IN UFS_PASS_THRU_PRIVATE_DATA *Private\r | |
663 | );\r | |
664 | \r | |
665 | /**\r | |
666 | Stop the UFS host controller.\r | |
667 | \r | |
668 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
669 | \r | |
670 | @retval EFI_SUCCESS The Ufs Host Controller is stopped successfully.\r | |
671 | @retval Others A device error occurred while stopping the controller.\r | |
672 | \r | |
673 | **/\r | |
674 | EFI_STATUS\r | |
675 | UfsControllerStop (\r | |
676 | IN UFS_PASS_THRU_PRIVATE_DATA *Private\r | |
677 | );\r | |
678 | \r | |
679 | /**\r | |
680 | Allocate common buffer for host and UFS bus master access simultaneously.\r | |
681 | \r | |
682 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
683 | @param[in] Size The length of buffer to be allocated.\r | |
684 | @param[out] CmdDescHost A pointer to store the base system memory address of the allocated range.\r | |
685 | @param[out] CmdDescPhyAddr The resulting map address for the UFS bus master to use to access the hosts CmdDescHost.\r | |
686 | @param[out] CmdDescMapping A resulting value to pass to Unmap().\r | |
687 | \r | |
688 | @retval EFI_SUCCESS The common buffer was allocated successfully.\r | |
689 | @retval EFI_DEVICE_ERROR The allocation fails.\r | |
690 | @retval EFI_OUT_OF_RESOURCES The memory resource is insufficient.\r | |
691 | \r | |
692 | **/\r | |
693 | EFI_STATUS\r | |
694 | UfsAllocateAlignCommonBuffer (\r | |
695 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
696 | IN UINTN Size,\r | |
697 | OUT VOID **CmdDescHost,\r | |
698 | OUT EFI_PHYSICAL_ADDRESS *CmdDescPhyAddr,\r | |
699 | OUT VOID **CmdDescMapping\r | |
700 | );\r | |
701 | \r | |
702 | /**\r | |
703 | Set specified flag to 1 on a UFS device.\r | |
704 | \r | |
705 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
706 | @param[in] FlagId The ID of flag to be set.\r | |
707 | \r | |
708 | @retval EFI_SUCCESS The flag was set successfully.\r | |
709 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to set the flag.\r | |
710 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of setting the flag.\r | |
711 | \r | |
712 | **/\r | |
713 | EFI_STATUS\r | |
714 | UfsSetFlag (\r | |
715 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
716 | IN UINT8 FlagId\r | |
717 | );\r | |
718 | \r | |
719 | /**\r | |
720 | Read or write specified device descriptor of a UFS device.\r | |
721 | \r | |
722 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
723 | @param[in] Read The boolean variable to show r/w direction.\r | |
724 | @param[in] DescId The ID of device descriptor.\r | |
725 | @param[in] Index The Index of device descriptor.\r | |
726 | @param[in] Selector The Selector of device descriptor.\r | |
727 | @param[in, out] Descriptor The buffer of device descriptor to be read or written.\r | |
728 | @param[in] DescSize The size of device descriptor buffer.\r | |
729 | \r | |
730 | @retval EFI_SUCCESS The device descriptor was read/written successfully.\r | |
731 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the device descriptor.\r | |
732 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of r/w the device descriptor.\r | |
733 | \r | |
734 | **/\r | |
735 | EFI_STATUS\r | |
736 | UfsRwDeviceDesc (\r | |
737 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
738 | IN BOOLEAN Read,\r | |
739 | IN UINT8 DescId,\r | |
740 | IN UINT8 Index,\r | |
741 | IN UINT8 Selector,\r | |
742 | IN OUT VOID *Descriptor,\r | |
743 | IN UINT32 DescSize\r | |
744 | );\r | |
745 | \r | |
746 | /**\r | |
747 | Sends NOP IN cmd to a UFS device for initialization process request.\r | |
748 | For more details, please refer to UFS 2.0 spec Figure 13.3.\r | |
749 | \r | |
750 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r | |
751 | \r | |
752 | @retval EFI_SUCCESS The NOP IN command was sent by the host. The NOP OUT response was\r | |
753 | received successfully.\r | |
754 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to execute NOP IN command.\r | |
755 | @retval EFI_OUT_OF_RESOURCES The resource for transfer is not available.\r | |
756 | @retval EFI_TIMEOUT A timeout occurred while waiting for the NOP IN command to execute.\r | |
757 | \r | |
758 | **/\r | |
759 | EFI_STATUS\r | |
760 | UfsExecNopCmds (\r | |
761 | IN UFS_PASS_THRU_PRIVATE_DATA *Private\r | |
762 | );\r | |
763 | \r | |
0350b57c HW |
764 | /**\r |
765 | Call back function when the timer event is signaled.\r | |
766 | \r | |
767 | @param[in] Event The Event this notify function registered to.\r | |
768 | @param[in] Context Pointer to the context data registered to the Event.\r | |
769 | \r | |
770 | **/\r | |
771 | VOID\r | |
772 | EFIAPI\r | |
773 | ProcessAsyncTaskList (\r | |
774 | IN EFI_EVENT Event,\r | |
775 | IN VOID *Context\r | |
776 | );\r | |
777 | \r | |
778 | /**\r | |
779 | Internal helper function which will signal the caller event and clean up\r | |
780 | resources.\r | |
781 | \r | |
782 | @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data\r | |
783 | structure.\r | |
784 | @param[in] TransReq The pointer to the UFS_PASS_THRU_TRANS_REQ data\r | |
785 | structure.\r | |
786 | \r | |
787 | **/\r | |
788 | VOID\r | |
789 | EFIAPI\r | |
790 | SignalCallerEvent (\r | |
791 | IN UFS_PASS_THRU_PRIVATE_DATA *Private,\r | |
792 | IN UFS_PASS_THRU_TRANS_REQ *TransReq\r | |
793 | );\r | |
794 | \r | |
5966dd8f FT |
795 | extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName;\r |
796 | extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2;\r | |
797 | extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding;\r | |
0591696e FT |
798 | \r |
799 | #endif\r |