]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
4c2d6ae27f100da0a4b91ec0072c94a3be553456
[mirror_edk2.git] / MdeModulePkg / Bus / Ufs / UfsPassThruDxe / UfsPassThru.c
1 /** @file
2
3 Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
4 Copyright (c) Microsoft Corporation.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "UfsPassThru.h"
10
11 //
12 // Template for Ufs Pass Thru private data.
13 //
14 UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate = {
15 UFS_PASS_THRU_SIG, // Signature
16 NULL, // Handle
17 { // ExtScsiPassThruMode
18 0xFFFFFFFF,
19 EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO,
20 sizeof (UINTN)
21 },
22 { // ExtScsiPassThru
23 NULL,
24 UfsPassThruPassThru,
25 UfsPassThruGetNextTargetLun,
26 UfsPassThruBuildDevicePath,
27 UfsPassThruGetTargetLun,
28 UfsPassThruResetChannel,
29 UfsPassThruResetTargetLun,
30 UfsPassThruGetNextTarget
31 },
32 { // UfsDevConfig
33 UfsRwUfsDescriptor,
34 UfsRwUfsFlag,
35 UfsRwUfsAttribute
36 },
37 0, // UfsHostController
38 0, // UfsHcBase
39 { 0, 0 }, // UfsHcInfo
40 { NULL, NULL }, // UfsHcDriverInterface
41 0, // TaskTag
42 0, // UtpTrlBase
43 0, // Nutrs
44 0, // TrlMapping
45 0, // UtpTmrlBase
46 0, // Nutmrs
47 0, // TmrlMapping
48 { // Luns
49 {
50 UFS_LUN_0, // Ufs Common Lun 0
51 UFS_LUN_1, // Ufs Common Lun 1
52 UFS_LUN_2, // Ufs Common Lun 2
53 UFS_LUN_3, // Ufs Common Lun 3
54 UFS_LUN_4, // Ufs Common Lun 4
55 UFS_LUN_5, // Ufs Common Lun 5
56 UFS_LUN_6, // Ufs Common Lun 6
57 UFS_LUN_7, // Ufs Common Lun 7
58 UFS_WLUN_REPORT_LUNS, // Ufs Reports Luns Well Known Lun
59 UFS_WLUN_UFS_DEV, // Ufs Device Well Known Lun
60 UFS_WLUN_BOOT, // Ufs Boot Well Known Lun
61 UFS_WLUN_RPMB // RPMB Well Known Lun
62 },
63 0x0000, // By default don't expose any Luns.
64 0x0
65 },
66 NULL, // TimerEvent
67 { // Queue
68 NULL,
69 NULL
70 }
71 };
72
73 EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding = {
74 UfsPassThruDriverBindingSupported,
75 UfsPassThruDriverBindingStart,
76 UfsPassThruDriverBindingStop,
77 0x10,
78 NULL,
79 NULL
80 };
81
82 UFS_DEVICE_PATH mUfsDevicePathTemplate = {
83 {
84 MESSAGING_DEVICE_PATH,
85 MSG_UFS_DP,
86 {
87 (UINT8)(sizeof (UFS_DEVICE_PATH)),
88 (UINT8)((sizeof (UFS_DEVICE_PATH)) >> 8)
89 }
90 },
91 0,
92 0
93 };
94
95 UINT8 mUfsTargetId[TARGET_MAX_BYTES];
96
97 GLOBAL_REMOVE_IF_UNREFERENCED EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatform;
98
99 /**
100 Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
101 supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
102 nonblocking I/O functionality is optional.
103
104 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
105 @param Target The Target is an array of size TARGET_MAX_BYTES and it represents
106 the id of the SCSI device to send the SCSI Request Packet. Each
107 transport driver may choose to utilize a subset of this size to suit the needs
108 of transport target representation. For example, a Fibre Channel driver
109 may use only 8 bytes (WWN) to represent an FC target.
110 @param Lun The LUN of the SCSI device to send the SCSI Request Packet.
111 @param Packet A pointer to the SCSI Request Packet to send to the SCSI device
112 specified by Target and Lun.
113 @param Event If nonblocking I/O is not supported then Event is ignored, and blocking
114 I/O is performed. If Event is NULL, then blocking I/O is performed. If
115 Event is not NULL and non blocking I/O is supported, then
116 nonblocking I/O is performed, and Event will be signaled when the
117 SCSI Request Packet completes.
118
119 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional
120 commands, InTransferLength bytes were transferred from
121 InDataBuffer. For write and bi-directional commands,
122 OutTransferLength bytes were transferred by
123 OutDataBuffer.
124 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that
125 could be transferred is returned in InTransferLength. For write
126 and bi-directional commands, OutTransferLength bytes were
127 transferred by OutDataBuffer.
128 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many
129 SCSI Request Packets already queued. The caller may retry again later.
130 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request
131 Packet.
132 @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.
133 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported
134 by the host adapter. This includes the case of Bi-directional SCSI
135 commands not supported by the implementation. The SCSI Request
136 Packet was not sent, so no additional status information is available.
137 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
138
139 **/
140 EFI_STATUS
141 EFIAPI
142 UfsPassThruPassThru (
143 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
144 IN UINT8 *Target,
145 IN UINT64 Lun,
146 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
147 IN EFI_EVENT Event OPTIONAL
148 )
149 {
150 EFI_STATUS Status;
151 UFS_PASS_THRU_PRIVATE_DATA *Private;
152 UINT8 UfsLun;
153 UINT16 Index;
154
155 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
156
157 if ((Packet == NULL) || (Packet->Cdb == NULL)) {
158 return EFI_INVALID_PARAMETER;
159 }
160
161 //
162 // Don't support variable length CDB
163 //
164 if ((Packet->CdbLength != 6) && (Packet->CdbLength != 10) &&
165 (Packet->CdbLength != 12) && (Packet->CdbLength != 16))
166 {
167 return EFI_INVALID_PARAMETER;
168 }
169
170 if ((Packet->SenseDataLength != 0) && (Packet->SenseData == NULL)) {
171 return EFI_INVALID_PARAMETER;
172 }
173
174 if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
175 return EFI_INVALID_PARAMETER;
176 }
177
178 if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
179 return EFI_INVALID_PARAMETER;
180 }
181
182 if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
183 return EFI_INVALID_PARAMETER;
184 }
185
186 //
187 // For UFS 2.0 compatible device, 0 is always used to represent the location of the UFS device.
188 //
189 SetMem (mUfsTargetId, TARGET_MAX_BYTES, 0x00);
190 if ((Target == NULL) || (CompareMem (Target, mUfsTargetId, TARGET_MAX_BYTES) != 0)) {
191 return EFI_INVALID_PARAMETER;
192 }
193
194 //
195 // UFS 2.0 spec Section 10.6.7 - Translation of 8-bit UFS LUN to 64-bit SCSI LUN Address
196 // 0xC1 in the first 8 bits of the 64-bit address indicates a well known LUN address in the SAM SCSI format.
197 // The second 8 bits of the 64-bit address saves the corresponding 8-bit UFS LUN.
198 //
199 if ((UINT8)Lun == UFS_WLUN_PREFIX) {
200 UfsLun = BIT7 | (((UINT8 *)&Lun)[1] & 0xFF);
201 } else if ((UINT8)Lun == 0) {
202 UfsLun = ((UINT8 *)&Lun)[1] & 0xFF;
203 } else {
204 return EFI_INVALID_PARAMETER;
205 }
206
207 for (Index = 0; Index < UFS_MAX_LUNS; Index++) {
208 if ((Private->Luns.BitMask & (BIT0 << Index)) == 0) {
209 continue;
210 }
211
212 if (Private->Luns.Lun[Index] == UfsLun) {
213 break;
214 }
215 }
216
217 if (Index == UFS_MAX_LUNS) {
218 return EFI_INVALID_PARAMETER;
219 }
220
221 Status = UfsExecScsiCmds (Private, UfsLun, Packet, Event);
222
223 return Status;
224 }
225
226 /**
227 Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
228 can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
229 Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
230 Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
231 channel.
232
233 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
234 @param Target On input, a pointer to the Target ID (an array of size
235 TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
236 On output, a pointer to the Target ID (an array of
237 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
238 channel. An input value of 0xF(all bytes in the array are 0xF) in the
239 Target array retrieves the Target ID of the first SCSI device present on a
240 SCSI channel.
241 @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI
242 channel. On output, a pointer to the LUN of the next SCSI device present
243 on a SCSI channel.
244
245 @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI
246 channel was returned in Target and Lun.
247 @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were
248 not returned on a previous call to GetNextTargetLun().
249 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
250
251 **/
252 EFI_STATUS
253 EFIAPI
254 UfsPassThruGetNextTargetLun (
255 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
256 IN OUT UINT8 **Target,
257 IN OUT UINT64 *Lun
258 )
259 {
260 UFS_PASS_THRU_PRIVATE_DATA *Private;
261 UINT8 UfsLun;
262 UINT16 Index;
263 UINT16 Next;
264
265 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
266
267 if ((Target == NULL) || (Lun == NULL)) {
268 return EFI_INVALID_PARAMETER;
269 }
270
271 if (*Target == NULL) {
272 return EFI_INVALID_PARAMETER;
273 }
274
275 UfsLun = 0;
276 SetMem (mUfsTargetId, TARGET_MAX_BYTES, 0xFF);
277 if (CompareMem (*Target, mUfsTargetId, TARGET_MAX_BYTES) == 0) {
278 //
279 // If the array is all 0xFF's, return the first exposed Lun to caller.
280 //
281 SetMem (*Target, TARGET_MAX_BYTES, 0x00);
282 for (Index = 0; Index < UFS_MAX_LUNS; Index++) {
283 if ((Private->Luns.BitMask & (BIT0 << Index)) != 0) {
284 UfsLun = Private->Luns.Lun[Index];
285 break;
286 }
287 }
288
289 if (Index != UFS_MAX_LUNS) {
290 *Lun = 0;
291 if ((UfsLun & BIT7) == BIT7) {
292 ((UINT8 *)Lun)[0] = UFS_WLUN_PREFIX;
293 ((UINT8 *)Lun)[1] = UfsLun & ~BIT7;
294 } else {
295 ((UINT8 *)Lun)[1] = UfsLun;
296 }
297
298 return EFI_SUCCESS;
299 } else {
300 return EFI_NOT_FOUND;
301 }
302 }
303
304 SetMem (mUfsTargetId, TARGET_MAX_BYTES, 0x00);
305 if (CompareMem (*Target, mUfsTargetId, TARGET_MAX_BYTES) == 0) {
306 if (((UINT8 *)Lun)[0] == UFS_WLUN_PREFIX) {
307 UfsLun = BIT7 | (((UINT8 *)Lun)[1] & 0xFF);
308 } else if (((UINT8 *)Lun)[0] == 0) {
309 UfsLun = ((UINT8 *)Lun)[1] & 0xFF;
310 } else {
311 return EFI_NOT_FOUND;
312 }
313
314 for (Index = 0; Index < UFS_MAX_LUNS; Index++) {
315 if ((Private->Luns.BitMask & (BIT0 << Index)) == 0) {
316 continue;
317 }
318
319 if (Private->Luns.Lun[Index] != UfsLun) {
320 continue;
321 }
322
323 for (Next = Index + 1; Next < UFS_MAX_LUNS; Next++) {
324 if ((Private->Luns.BitMask & (BIT0 << Next)) != 0) {
325 UfsLun = Private->Luns.Lun[Next];
326 break;
327 }
328 }
329
330 if (Next == UFS_MAX_LUNS) {
331 return EFI_NOT_FOUND;
332 } else {
333 break;
334 }
335 }
336
337 if (Index != UFS_MAX_LUNS) {
338 *Lun = 0;
339 if ((UfsLun & BIT7) == BIT7) {
340 ((UINT8 *)Lun)[0] = UFS_WLUN_PREFIX;
341 ((UINT8 *)Lun)[1] = UfsLun & ~BIT7;
342 } else {
343 ((UINT8 *)Lun)[1] = UfsLun;
344 }
345
346 return EFI_SUCCESS;
347 } else {
348 return EFI_NOT_FOUND;
349 }
350 }
351
352 return EFI_NOT_FOUND;
353 }
354
355 /**
356 Used to allocate and build a device path node for a SCSI device on a SCSI channel.
357
358 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
359 @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the
360 Target ID of the SCSI device for which a device path node is to be
361 allocated and built. Transport drivers may chose to utilize a subset of
362 this size to suit the representation of targets. For example, a Fibre
363 Channel driver may use only 8 bytes (WWN) in the array to represent a
364 FC target.
365 @param Lun The LUN of the SCSI device for which a device path node is to be
366 allocated and built.
367 @param DevicePath A pointer to a single device path node that describes the SCSI device
368 specified by Target and Lun. This function is responsible for
369 allocating the buffer DevicePath with the boot service
370 AllocatePool(). It is the caller's responsibility to free
371 DevicePath when the caller is finished with DevicePath.
372
373 @retval EFI_SUCCESS The device path node that describes the SCSI device specified by
374 Target and Lun was allocated and returned in
375 DevicePath.
376 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
377 @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist
378 on the SCSI channel.
379 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
380
381 **/
382 EFI_STATUS
383 EFIAPI
384 UfsPassThruBuildDevicePath (
385 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
386 IN UINT8 *Target,
387 IN UINT64 Lun,
388 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
389 )
390 {
391 UFS_PASS_THRU_PRIVATE_DATA *Private;
392 EFI_DEV_PATH *DevicePathNode;
393 UINT8 UfsLun;
394 UINT16 Index;
395
396 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
397
398 //
399 // Validate parameters passed in.
400 //
401 SetMem (mUfsTargetId, TARGET_MAX_BYTES, 0x00);
402 if (CompareMem (Target, mUfsTargetId, TARGET_MAX_BYTES) != 0) {
403 return EFI_INVALID_PARAMETER;
404 }
405
406 if ((UINT8)Lun == UFS_WLUN_PREFIX) {
407 UfsLun = BIT7 | (((UINT8 *)&Lun)[1] & 0xFF);
408 } else if ((UINT8)Lun == 0) {
409 UfsLun = ((UINT8 *)&Lun)[1] & 0xFF;
410 } else {
411 return EFI_NOT_FOUND;
412 }
413
414 for (Index = 0; Index < UFS_MAX_LUNS; Index++) {
415 if ((Private->Luns.BitMask & (BIT0 << Index)) == 0) {
416 continue;
417 }
418
419 if (Private->Luns.Lun[Index] == UfsLun) {
420 break;
421 }
422 }
423
424 if (Index == UFS_MAX_LUNS) {
425 return EFI_NOT_FOUND;
426 }
427
428 DevicePathNode = AllocateCopyPool (sizeof (UFS_DEVICE_PATH), &mUfsDevicePathTemplate);
429 if (DevicePathNode == NULL) {
430 return EFI_OUT_OF_RESOURCES;
431 }
432
433 DevicePathNode->Ufs.Pun = 0;
434 DevicePathNode->Ufs.Lun = UfsLun;
435
436 *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode;
437
438 return EFI_SUCCESS;
439 }
440
441 /**
442 Used to translate a device path node to a Target ID and LUN.
443
444 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
445 @param DevicePath A pointer to a single device path node that describes the SCSI device
446 on the SCSI channel.
447 @param Target A pointer to the Target Array which represents the ID of a SCSI device
448 on the SCSI channel.
449 @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.
450
451 @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and
452 LUN, and they were returned in Target and Lun.
453 @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.
454 @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN
455 does not exist.
456 @retval EFI_UNSUPPORTED This driver does not support the device path node type in
457 DevicePath.
458
459 **/
460 EFI_STATUS
461 EFIAPI
462 UfsPassThruGetTargetLun (
463 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
464 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
465 OUT UINT8 **Target,
466 OUT UINT64 *Lun
467 )
468 {
469 UFS_PASS_THRU_PRIVATE_DATA *Private;
470 EFI_DEV_PATH *DevicePathNode;
471 UINT8 Pun;
472 UINT8 UfsLun;
473 UINT16 Index;
474
475 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
476
477 //
478 // Validate parameters passed in.
479 //
480 if ((DevicePath == NULL) || (Target == NULL) || (Lun == NULL)) {
481 return EFI_INVALID_PARAMETER;
482 }
483
484 if (*Target == NULL) {
485 return EFI_INVALID_PARAMETER;
486 }
487
488 //
489 // Check whether the DevicePath belongs to UFS_DEVICE_PATH
490 //
491 if ((DevicePath->Type != MESSAGING_DEVICE_PATH) || (DevicePath->SubType != MSG_UFS_DP) ||
492 (DevicePathNodeLength (DevicePath) != sizeof (UFS_DEVICE_PATH)))
493 {
494 return EFI_UNSUPPORTED;
495 }
496
497 DevicePathNode = (EFI_DEV_PATH *)DevicePath;
498
499 Pun = (UINT8)DevicePathNode->Ufs.Pun;
500 UfsLun = (UINT8)DevicePathNode->Ufs.Lun;
501
502 if (Pun != 0) {
503 return EFI_NOT_FOUND;
504 }
505
506 for (Index = 0; Index < UFS_MAX_LUNS; Index++) {
507 if ((Private->Luns.BitMask & (BIT0 << Index)) == 0) {
508 continue;
509 }
510
511 if (Private->Luns.Lun[Index] == UfsLun) {
512 break;
513 }
514 }
515
516 if (Index == UFS_MAX_LUNS) {
517 return EFI_NOT_FOUND;
518 }
519
520 SetMem (*Target, TARGET_MAX_BYTES, 0x00);
521 *Lun = 0;
522 if ((UfsLun & BIT7) == BIT7) {
523 ((UINT8 *)Lun)[0] = UFS_WLUN_PREFIX;
524 ((UINT8 *)Lun)[1] = UfsLun & ~BIT7;
525 } else {
526 ((UINT8 *)Lun)[1] = UfsLun;
527 }
528
529 return EFI_SUCCESS;
530 }
531
532 /**
533 Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.
534
535 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
536
537 @retval EFI_SUCCESS The SCSI channel was reset.
538 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.
539 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.
540 @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.
541
542 **/
543 EFI_STATUS
544 EFIAPI
545 UfsPassThruResetChannel (
546 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
547 )
548 {
549 //
550 // Return success directly then upper layer driver could think reset channel operation is done.
551 //
552 return EFI_SUCCESS;
553 }
554
555 /**
556 Resets a SCSI logical unit that is connected to a SCSI channel.
557
558 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
559 @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the
560 target port ID of the SCSI device containing the SCSI logical unit to
561 reset. Transport drivers may chose to utilize a subset of this array to suit
562 the representation of their targets.
563 @param Lun The LUN of the SCSI device to reset.
564
565 @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.
566 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
567 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device
568 specified by Target and Lun.
569 @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.
570 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device
571 specified by Target and Lun.
572
573 **/
574 EFI_STATUS
575 EFIAPI
576 UfsPassThruResetTargetLun (
577 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
578 IN UINT8 *Target,
579 IN UINT64 Lun
580 )
581 {
582 //
583 // Return success directly then upper layer driver could think reset target LUN operation is done.
584 //
585 return EFI_SUCCESS;
586 }
587
588 /**
589 Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either
590 be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs
591 for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to
592 see if a SCSI device is actually present at that location on the SCSI channel.
593
594 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
595 @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
596 On output, a pointer to the Target ID (an array of
597 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
598 channel. An input value of 0xF(all bytes in the array are 0xF) in the
599 Target array retrieves the Target ID of the first SCSI device present on a
600 SCSI channel.
601
602 @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI
603 channel was returned in Target.
604 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
605 @retval EFI_TIMEOUT Target array is not all 0xF, and Target was not
606 returned on a previous call to GetNextTarget().
607 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
608
609 **/
610 EFI_STATUS
611 EFIAPI
612 UfsPassThruGetNextTarget (
613 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
614 IN OUT UINT8 **Target
615 )
616 {
617 if ((Target == NULL) || (*Target == NULL)) {
618 return EFI_INVALID_PARAMETER;
619 }
620
621 SetMem (mUfsTargetId, TARGET_MAX_BYTES, 0xFF);
622 if (CompareMem (*Target, mUfsTargetId, TARGET_MAX_BYTES) == 0) {
623 SetMem (*Target, TARGET_MAX_BYTES, 0x00);
624 return EFI_SUCCESS;
625 }
626
627 return EFI_NOT_FOUND;
628 }
629
630 /**
631 Tests to see if this driver supports a given controller. If a child device is provided,
632 it further tests to see if this driver supports creating a handle for the specified child device.
633
634 This function checks to see if the driver specified by This supports the device specified by
635 ControllerHandle. Drivers will typically use the device path attached to
636 ControllerHandle and/or the services from the bus I/O abstraction attached to
637 ControllerHandle to determine if the driver supports ControllerHandle. This function
638 may be called many times during platform initialization. In order to reduce boot times, the tests
639 performed by this function must be very small, and take as little time as possible to execute. This
640 function must not change the state of any hardware devices, and this function must be aware that the
641 device specified by ControllerHandle may already be managed by the same driver or a
642 different driver. This function must match its calls to AllocatePages() with FreePages(),
643 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
644 Since ControllerHandle may have been previously started by the same driver, if a protocol is
645 already in the opened state, then it must not be closed with CloseProtocol(). This is required
646 to guarantee the state of ControllerHandle is not modified by this function.
647
648 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
649 @param[in] ControllerHandle The handle of the controller to test. This handle
650 must support a protocol interface that supplies
651 an I/O abstraction to the driver.
652 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
653 parameter is ignored by device drivers, and is optional for bus
654 drivers. For bus drivers, if this parameter is not NULL, then
655 the bus driver must determine if the bus controller specified
656 by ControllerHandle and the child controller specified
657 by RemainingDevicePath are both supported by this
658 bus driver.
659
660 @retval EFI_SUCCESS The device specified by ControllerHandle and
661 RemainingDevicePath is supported by the driver specified by This.
662 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
663 RemainingDevicePath is already being managed by the driver
664 specified by This.
665 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
666 RemainingDevicePath is already being managed by a different
667 driver or an application that requires exclusive access.
668 Currently not implemented.
669 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
670 RemainingDevicePath is not supported by the driver specified by This.
671 **/
672 EFI_STATUS
673 EFIAPI
674 UfsPassThruDriverBindingSupported (
675 IN EFI_DRIVER_BINDING_PROTOCOL *This,
676 IN EFI_HANDLE Controller,
677 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
678 )
679 {
680 EFI_STATUS Status;
681 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
682 EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController;
683
684 //
685 // Ufs Pass Thru driver is a device driver, and should ingore the
686 // "RemainingDevicePath" according to UEFI spec
687 //
688 Status = gBS->OpenProtocol (
689 Controller,
690 &gEfiDevicePathProtocolGuid,
691 (VOID *)&ParentDevicePath,
692 This->DriverBindingHandle,
693 Controller,
694 EFI_OPEN_PROTOCOL_BY_DRIVER
695 );
696 if (EFI_ERROR (Status)) {
697 //
698 // EFI_ALREADY_STARTED is also an error
699 //
700 return Status;
701 }
702
703 //
704 // Close the protocol because we don't use it here
705 //
706 gBS->CloseProtocol (
707 Controller,
708 &gEfiDevicePathProtocolGuid,
709 This->DriverBindingHandle,
710 Controller
711 );
712
713 Status = gBS->OpenProtocol (
714 Controller,
715 &gEdkiiUfsHostControllerProtocolGuid,
716 (VOID **)&UfsHostController,
717 This->DriverBindingHandle,
718 Controller,
719 EFI_OPEN_PROTOCOL_BY_DRIVER
720 );
721
722 if (EFI_ERROR (Status)) {
723 //
724 // EFI_ALREADY_STARTED is also an error
725 //
726 return Status;
727 }
728
729 //
730 // Close the I/O Abstraction(s) used to perform the supported test
731 //
732 gBS->CloseProtocol (
733 Controller,
734 &gEdkiiUfsHostControllerProtocolGuid,
735 This->DriverBindingHandle,
736 Controller
737 );
738
739 return EFI_SUCCESS;
740 }
741
742 /**
743 Finishes device initialization by setting fDeviceInit flag and waiting untill device responds by
744 clearing it.
745
746 @param[in] Private Pointer to the UFS_PASS_THRU_PRIVATE_DATA.
747
748 @retval EFI_SUCCESS The operation succeeds.
749 @retval Others The operation fails.
750
751 **/
752 EFI_STATUS
753 UfsFinishDeviceInitialization (
754 IN UFS_PASS_THRU_PRIVATE_DATA *Private
755 )
756 {
757 EFI_STATUS Status;
758 UINT8 DeviceInitStatus;
759 UINT32 Timeout;
760
761 DeviceInitStatus = 0xFF;
762
763 //
764 // The host enables the device initialization completion by setting fDeviceInit flag.
765 //
766 Status = UfsSetFlag (Private, UfsFlagDevInit);
767 if (EFI_ERROR (Status)) {
768 return Status;
769 }
770
771 //
772 // There are cards that can take upto 600ms to clear fDeviceInit flag.
773 //
774 Timeout = UFS_INIT_COMPLETION_TIMEOUT;
775 do {
776 Status = UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus);
777 if (EFI_ERROR (Status)) {
778 return Status;
779 }
780
781 MicroSecondDelay (1);
782 Timeout--;
783 } while (DeviceInitStatus != 0 && Timeout != 0);
784
785 if (Timeout == 0) {
786 DEBUG ((DEBUG_ERROR, "UfsFinishDeviceInitialization DeviceInitStatus=%x EFI_TIMEOUT \n", DeviceInitStatus));
787 return EFI_TIMEOUT;
788 } else {
789 DEBUG ((DEBUG_INFO, "UfsFinishDeviceInitialization Timeout left=%x EFI_SUCCESS \n", Timeout));
790 return EFI_SUCCESS;
791 }
792 }
793
794 /**
795 Starts a device controller or a bus controller.
796
797 The Start() function is designed to be invoked from the EFI boot service ConnectController().
798 As a result, much of the error checking on the parameters to Start() has been moved into this
799 common boot service. It is legal to call Start() from other locations,
800 but the following calling restrictions must be followed or the system behavior will not be deterministic.
801 1. ControllerHandle must be a valid EFI_HANDLE.
802 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
803 EFI_DEVICE_PATH_PROTOCOL.
804 3. Prior to calling Start(), the Supported() function for the driver specified by This must
805 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
806
807 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
808 @param[in] ControllerHandle The handle of the controller to start. This handle
809 must support a protocol interface that supplies
810 an I/O abstraction to the driver.
811 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
812 parameter is ignored by device drivers, and is optional for bus
813 drivers. For a bus driver, if this parameter is NULL, then handles
814 for all the children of Controller are created by this driver.
815 If this parameter is not NULL and the first Device Path Node is
816 not the End of Device Path Node, then only the handle for the
817 child device specified by the first Device Path Node of
818 RemainingDevicePath is created by this driver.
819 If the first Device Path Node of RemainingDevicePath is
820 the End of Device Path Node, no child handle is created by this
821 driver.
822
823 @retval EFI_SUCCESS The device was started.
824 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
825 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
826 @retval Others The driver failded to start the device.
827
828 **/
829 EFI_STATUS
830 EFIAPI
831 UfsPassThruDriverBindingStart (
832 IN EFI_DRIVER_BINDING_PROTOCOL *This,
833 IN EFI_HANDLE Controller,
834 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
835 )
836 {
837 EFI_STATUS Status;
838 EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc;
839 UFS_PASS_THRU_PRIVATE_DATA *Private;
840 UINTN UfsHcBase;
841 UINT32 Index;
842 UFS_UNIT_DESC UnitDescriptor;
843 UFS_DEV_DESC DeviceDescriptor;
844 UINT32 UnitDescriptorSize;
845 UINT32 DeviceDescriptorSize;
846
847 Status = EFI_SUCCESS;
848 UfsHc = NULL;
849 Private = NULL;
850 UfsHcBase = 0;
851
852 DEBUG ((DEBUG_INFO, "==UfsPassThru Start== Controller = %x\n", Controller));
853
854 Status = gBS->OpenProtocol (
855 Controller,
856 &gEdkiiUfsHostControllerProtocolGuid,
857 (VOID **)&UfsHc,
858 This->DriverBindingHandle,
859 Controller,
860 EFI_OPEN_PROTOCOL_BY_DRIVER
861 );
862
863 if (EFI_ERROR (Status)) {
864 DEBUG ((DEBUG_ERROR, "Open Ufs Host Controller Protocol Error, Status = %r\n", Status));
865 goto Error;
866 }
867
868 //
869 // Get the UFS Host Controller MMIO Bar Base Address.
870 //
871 Status = UfsHc->GetUfsHcMmioBar (UfsHc, &UfsHcBase);
872 if (EFI_ERROR (Status)) {
873 DEBUG ((DEBUG_ERROR, "Get Ufs Host Controller Mmio Bar Error, Status = %r\n", Status));
874 goto Error;
875 }
876
877 //
878 // Initialize Ufs Pass Thru private data for managed UFS Host Controller.
879 //
880 Private = AllocateCopyPool (sizeof (UFS_PASS_THRU_PRIVATE_DATA), &gUfsPassThruTemplate);
881 if (Private == NULL) {
882 DEBUG ((DEBUG_ERROR, "Unable to allocate Ufs Pass Thru private data\n"));
883 Status = EFI_OUT_OF_RESOURCES;
884 goto Error;
885 }
886
887 Private->ExtScsiPassThru.Mode = &Private->ExtScsiPassThruMode;
888 Private->UfsHostController = UfsHc;
889 Private->UfsHcBase = UfsHcBase;
890 Private->Handle = Controller;
891 Private->UfsHcDriverInterface.UfsHcProtocol = UfsHc;
892 Private->UfsHcDriverInterface.UfsExecUicCommand = UfsHcDriverInterfaceExecUicCommand;
893 InitializeListHead (&Private->Queue);
894
895 //
896 // This has to be done before initializing UfsHcInfo or calling the UfsControllerInit
897 //
898 if (mUfsHcPlatform == NULL) {
899 Status = gBS->LocateProtocol (&gEdkiiUfsHcPlatformProtocolGuid, NULL, (VOID **)&mUfsHcPlatform);
900 if (EFI_ERROR (Status)) {
901 DEBUG ((DEBUG_INFO, "No UfsHcPlatformProtocol present\n"));
902 }
903 }
904
905 Status = GetUfsHcInfo (Private);
906 if (EFI_ERROR (Status)) {
907 DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n"));
908 goto Error;
909 }
910
911 //
912 // Initialize UFS Host Controller H/W.
913 //
914 Status = UfsControllerInit (Private);
915 if (EFI_ERROR (Status)) {
916 DEBUG ((DEBUG_ERROR, "Ufs Host Controller Initialization Error, Status = %r\n", Status));
917 goto Error;
918 }
919
920 //
921 // UFS 2.0 spec Section 13.1.3.3:
922 // At the end of the UFS Interconnect Layer initialization on both host and device side,
923 // the host shall send a NOP OUT UPIU to verify that the device UTP Layer is ready.
924 //
925 Status = UfsExecNopCmds (Private);
926 if (EFI_ERROR (Status)) {
927 DEBUG ((DEBUG_ERROR, "Ufs Sending NOP IN command Error, Status = %r\n", Status));
928 goto Error;
929 }
930
931 Status = UfsFinishDeviceInitialization (Private);
932 if (EFI_ERROR (Status)) {
933 DEBUG ((DEBUG_ERROR, "Device failed to finish initialization, Status = %r\n", Status));
934 goto Error;
935 }
936
937 //
938 // Check if 8 common luns are active and set corresponding bit mask.
939 //
940 UnitDescriptorSize = sizeof (UFS_UNIT_DESC);
941 for (Index = 0; Index < 8; Index++) {
942 Status = UfsRwDeviceDesc (Private, TRUE, UfsUnitDesc, (UINT8)Index, 0, &UnitDescriptor, &UnitDescriptorSize);
943 if (EFI_ERROR (Status)) {
944 DEBUG ((DEBUG_ERROR, "Failed to read unit descriptor, index = %X, status = %r\n", Index, Status));
945 continue;
946 }
947
948 if (UnitDescriptor.LunEn == 0x1) {
949 DEBUG ((DEBUG_INFO, "UFS LUN %X is enabled\n", Index));
950 Private->Luns.BitMask |= (BIT0 << Index);
951 }
952 }
953
954 //
955 // Check if RPMB WLUN is supported and set corresponding bit mask.
956 //
957 DeviceDescriptorSize = sizeof (UFS_DEV_DESC);
958 Status = UfsRwDeviceDesc (Private, TRUE, UfsDeviceDesc, 0, 0, &DeviceDescriptor, &DeviceDescriptorSize);
959 if (EFI_ERROR (Status)) {
960 DEBUG ((DEBUG_ERROR, "Failed to read device descriptor, status = %r\n", Status));
961 } else {
962 if (DeviceDescriptor.SecurityLun == 0x1) {
963 DEBUG ((DEBUG_INFO, "UFS WLUN RPMB is supported\n"));
964 Private->Luns.BitMask |= BIT11;
965 }
966 }
967
968 //
969 // Start the asynchronous interrupt monitor
970 //
971 Status = gBS->CreateEvent (
972 EVT_TIMER | EVT_NOTIFY_SIGNAL,
973 TPL_NOTIFY,
974 ProcessAsyncTaskList,
975 Private,
976 &Private->TimerEvent
977 );
978 if (EFI_ERROR (Status)) {
979 DEBUG ((DEBUG_ERROR, "Ufs Create Async Tasks Event Error, Status = %r\n", Status));
980 goto Error;
981 }
982
983 Status = gBS->SetTimer (
984 Private->TimerEvent,
985 TimerPeriodic,
986 UFS_HC_ASYNC_TIMER
987 );
988 if (EFI_ERROR (Status)) {
989 DEBUG ((DEBUG_ERROR, "Ufs Set Periodic Timer Error, Status = %r\n", Status));
990 goto Error;
991 }
992
993 Status = gBS->InstallMultipleProtocolInterfaces (
994 &Controller,
995 &gEfiExtScsiPassThruProtocolGuid,
996 &(Private->ExtScsiPassThru),
997 &gEfiUfsDeviceConfigProtocolGuid,
998 &(Private->UfsDevConfig),
999 NULL
1000 );
1001 ASSERT_EFI_ERROR (Status);
1002
1003 return EFI_SUCCESS;
1004
1005 Error:
1006 if (Private != NULL) {
1007 if (Private->TmrlMapping != NULL) {
1008 UfsHc->Unmap (UfsHc, Private->TmrlMapping);
1009 }
1010
1011 if (Private->UtpTmrlBase != NULL) {
1012 UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (Private->Nutmrs * sizeof (UTP_TMRD)), Private->UtpTmrlBase);
1013 }
1014
1015 if (Private->TrlMapping != NULL) {
1016 UfsHc->Unmap (UfsHc, Private->TrlMapping);
1017 }
1018
1019 if (Private->UtpTrlBase != NULL) {
1020 UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (Private->Nutrs * sizeof (UTP_TMRD)), Private->UtpTrlBase);
1021 }
1022
1023 if (Private->TimerEvent != NULL) {
1024 gBS->CloseEvent (Private->TimerEvent);
1025 }
1026
1027 FreePool (Private);
1028 }
1029
1030 if (UfsHc != NULL) {
1031 gBS->CloseProtocol (
1032 Controller,
1033 &gEdkiiUfsHostControllerProtocolGuid,
1034 This->DriverBindingHandle,
1035 Controller
1036 );
1037 }
1038
1039 return Status;
1040 }
1041
1042 /**
1043 Stops a device controller or a bus controller.
1044
1045 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
1046 As a result, much of the error checking on the parameters to Stop() has been moved
1047 into this common boot service. It is legal to call Stop() from other locations,
1048 but the following calling restrictions must be followed or the system behavior will not be deterministic.
1049 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
1050 same driver's Start() function.
1051 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
1052 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
1053 Start() function, and the Start() function must have called OpenProtocol() on
1054 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
1055
1056 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
1057 @param[in] ControllerHandle A handle to the device being stopped. The handle must
1058 support a bus specific I/O protocol for the driver
1059 to use to stop the device.
1060 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
1061 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
1062 if NumberOfChildren is 0.
1063
1064 @retval EFI_SUCCESS The device was stopped.
1065 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
1066
1067 **/
1068 EFI_STATUS
1069 EFIAPI
1070 UfsPassThruDriverBindingStop (
1071 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1072 IN EFI_HANDLE Controller,
1073 IN UINTN NumberOfChildren,
1074 IN EFI_HANDLE *ChildHandleBuffer
1075 )
1076 {
1077 EFI_STATUS Status;
1078 UFS_PASS_THRU_PRIVATE_DATA *Private;
1079 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
1080 EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc;
1081 UFS_PASS_THRU_TRANS_REQ *TransReq;
1082 LIST_ENTRY *Entry;
1083 LIST_ENTRY *NextEntry;
1084
1085 DEBUG ((DEBUG_INFO, "==UfsPassThru Stop== Controller Controller = %x\n", Controller));
1086
1087 Status = gBS->OpenProtocol (
1088 Controller,
1089 &gEfiExtScsiPassThruProtocolGuid,
1090 (VOID **)&ExtScsiPassThru,
1091 This->DriverBindingHandle,
1092 Controller,
1093 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1094 );
1095
1096 if (EFI_ERROR (Status)) {
1097 return EFI_DEVICE_ERROR;
1098 }
1099
1100 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS (ExtScsiPassThru);
1101 UfsHc = Private->UfsHostController;
1102
1103 //
1104 // Cleanup the resources of I/O requests in the async I/O queue
1105 //
1106 if (!IsListEmpty (&Private->Queue)) {
1107 BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->Queue) {
1108 TransReq = UFS_PASS_THRU_TRANS_REQ_FROM_THIS (Entry);
1109
1110 //
1111 // TODO: Should find/add a proper host adapter return status for this
1112 // case.
1113 //
1114 TransReq->Packet->HostAdapterStatus =
1115 EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR;
1116
1117 SignalCallerEvent (Private, TransReq);
1118 }
1119 }
1120
1121 Status = gBS->UninstallMultipleProtocolInterfaces (
1122 Controller,
1123 &gEfiExtScsiPassThruProtocolGuid,
1124 &(Private->ExtScsiPassThru),
1125 &gEfiUfsDeviceConfigProtocolGuid,
1126 &(Private->UfsDevConfig),
1127 NULL
1128 );
1129
1130 if (EFI_ERROR (Status)) {
1131 return EFI_DEVICE_ERROR;
1132 }
1133
1134 //
1135 // Stop Ufs Host Controller
1136 //
1137 Status = UfsControllerStop (Private);
1138 ASSERT_EFI_ERROR (Status);
1139
1140 if (Private->TmrlMapping != NULL) {
1141 UfsHc->Unmap (UfsHc, Private->TmrlMapping);
1142 }
1143
1144 if (Private->UtpTmrlBase != NULL) {
1145 UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (Private->Nutmrs * sizeof (UTP_TMRD)), Private->UtpTmrlBase);
1146 }
1147
1148 if (Private->TrlMapping != NULL) {
1149 UfsHc->Unmap (UfsHc, Private->TrlMapping);
1150 }
1151
1152 if (Private->UtpTrlBase != NULL) {
1153 UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (Private->Nutrs * sizeof (UTP_TMRD)), Private->UtpTrlBase);
1154 }
1155
1156 if (Private->TimerEvent != NULL) {
1157 gBS->CloseEvent (Private->TimerEvent);
1158 }
1159
1160 FreePool (Private);
1161
1162 //
1163 // Close protocols opened by UfsPassThru controller driver
1164 //
1165 gBS->CloseProtocol (
1166 Controller,
1167 &gEdkiiUfsHostControllerProtocolGuid,
1168 This->DriverBindingHandle,
1169 Controller
1170 );
1171
1172 return Status;
1173 }
1174
1175 /**
1176 The user Entry Point for module UfsPassThru. The user code starts with this function.
1177
1178 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1179 @param[in] SystemTable A pointer to the EFI System Table.
1180
1181 @retval EFI_SUCCESS The entry point is executed successfully.
1182 @retval other Some error occurs when executing this entry point.
1183
1184 **/
1185 EFI_STATUS
1186 EFIAPI
1187 InitializeUfsPassThru (
1188 IN EFI_HANDLE ImageHandle,
1189 IN EFI_SYSTEM_TABLE *SystemTable
1190 )
1191 {
1192 EFI_STATUS Status;
1193
1194 //
1195 // Install driver model protocol(s).
1196 //
1197 Status = EfiLibInstallDriverBindingComponentName2 (
1198 ImageHandle,
1199 SystemTable,
1200 &gUfsPassThruDriverBinding,
1201 ImageHandle,
1202 &gUfsPassThruComponentName,
1203 &gUfsPassThruComponentName2
1204 );
1205 ASSERT_EFI_ERROR (Status);
1206
1207 return Status;
1208 }