]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
ShellPkg: Add NULL pointer check.
[mirror_edk2.git] / ShellPkg / Library / UefiHandleParsingLib / UefiHandleParsingLib.c
1 /** @file
2 Provides interface to advanced shell functionality for parsing both handle and protocol database.
3
4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include "UefiHandleParsingLib.h"
18 #include "IndustryStandard/Acpi10.h"
19
20 EFI_HANDLE mHandleParsingHiiHandle = NULL;
21 HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};
22 GUID_INFO_BLOCK *GuidList;
23 UINTN GuidListCount;
24 /**
25 Function to translate the EFI_MEMORY_TYPE into a string.
26
27 @param[in] Memory The memory type.
28
29 @retval A string representation of the type allocated from BS Pool.
30 **/
31 CHAR16*
32 EFIAPI
33 ConvertMemoryType (
34 IN CONST EFI_MEMORY_TYPE Memory
35 )
36 {
37 CHAR16 *RetVal;
38 RetVal = NULL;
39
40 switch (Memory) {
41 case EfiReservedMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiReservedMemoryType", 0); break;
42 case EfiLoaderCode: StrnCatGrow(&RetVal, NULL, L"EfiLoaderCode", 0); break;
43 case EfiLoaderData: StrnCatGrow(&RetVal, NULL, L"EfiLoaderData", 0); break;
44 case EfiBootServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesCode", 0); break;
45 case EfiBootServicesData: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesData", 0); break;
46 case EfiRuntimeServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesCode", 0); break;
47 case EfiRuntimeServicesData: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesData", 0); break;
48 case EfiConventionalMemory: StrnCatGrow(&RetVal, NULL, L"EfiConventionalMemory", 0); break;
49 case EfiUnusableMemory: StrnCatGrow(&RetVal, NULL, L"EfiUnusableMemory", 0); break;
50 case EfiACPIReclaimMemory: StrnCatGrow(&RetVal, NULL, L"EfiACPIReclaimMemory", 0); break;
51 case EfiACPIMemoryNVS: StrnCatGrow(&RetVal, NULL, L"EfiACPIMemoryNVS", 0); break;
52 case EfiMemoryMappedIO: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIO", 0); break;
53 case EfiMemoryMappedIOPortSpace: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIOPortSpace", 0); break;
54 case EfiPalCode: StrnCatGrow(&RetVal, NULL, L"EfiPalCode", 0); break;
55 case EfiMaxMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiMaxMemoryType", 0); break;
56 default: ASSERT(FALSE);
57 }
58 return (RetVal);
59 }
60
61 /**
62 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
63
64 @param[in] Fmt The format type.
65
66 @retval A string representation of the type allocated from BS Pool.
67 **/
68 CHAR16*
69 EFIAPI
70 ConvertPixelFormat (
71 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
72 )
73 {
74 CHAR16 *RetVal;
75 RetVal = NULL;
76
77 switch (Fmt) {
78 case PixelRedGreenBlueReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelRedGreenBlueReserved8BitPerColor", 0); break;
79 case PixelBlueGreenRedReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelBlueGreenRedReserved8BitPerColor", 0); break;
80 case PixelBitMask: StrnCatGrow(&RetVal, NULL, L"PixelBitMask", 0); break;
81 case PixelBltOnly: StrnCatGrow(&RetVal, NULL, L"PixelBltOnly", 0); break;
82 case PixelFormatMax: StrnCatGrow(&RetVal, NULL, L"PixelFormatMax", 0); break;
83 default: ASSERT(FALSE);
84 }
85 return (RetVal);
86 }
87
88 /**
89 Constructor for the library.
90
91 @param[in] ImageHandle Ignored.
92 @param[in] SystemTable Ignored.
93
94 @retval EFI_SUCCESS The operation was successful.
95 **/
96 EFI_STATUS
97 EFIAPI
98 HandleParsingLibConstructor (
99 IN EFI_HANDLE ImageHandle,
100 IN EFI_SYSTEM_TABLE *SystemTable
101 )
102 {
103 GuidListCount = 0;
104 GuidList = NULL;
105
106 //
107 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
108 //
109 return (EFI_SUCCESS);
110 }
111
112 /**
113 Initialization function for HII packages.
114
115 **/
116 VOID
117 HandleParsingHiiInit (VOID)
118 {
119 if (mHandleParsingHiiHandle == NULL) {
120 mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL);
121 ASSERT (mHandleParsingHiiHandle != NULL);
122 }
123 }
124
125 /**
126 Destructor for the library. free any resources.
127
128 @param[in] ImageHandle Ignored.
129 @param[in] SystemTable Ignored.
130
131 @retval EFI_SUCCESS The operation was successful.
132 **/
133 EFI_STATUS
134 EFIAPI
135 HandleParsingLibDestructor (
136 IN EFI_HANDLE ImageHandle,
137 IN EFI_SYSTEM_TABLE *SystemTable
138 )
139 {
140 UINTN LoopCount;
141
142 for (LoopCount = 0; GuidList != NULL && LoopCount < GuidListCount; LoopCount++) {
143 SHELL_FREE_NON_NULL(GuidList[LoopCount].GuidId);
144 }
145
146 SHELL_FREE_NON_NULL(GuidList);
147 if (mHandleParsingHiiHandle != NULL) {
148 HiiRemovePackages(mHandleParsingHiiHandle);
149 }
150 return (EFI_SUCCESS);
151 }
152
153 /**
154 Function to dump information about LoadedImage.
155
156 This will allocate the return buffer from boot services pool.
157
158 @param[in] TheHandle The handle that has LoadedImage installed.
159 @param[in] Verbose TRUE for additional information, FALSE otherwise.
160
161 @retval A poitner to a string containing the information.
162 **/
163 CHAR16*
164 EFIAPI
165 LoadedImageProtocolDumpInformation(
166 IN CONST EFI_HANDLE TheHandle,
167 IN CONST BOOLEAN Verbose
168 )
169 {
170 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
171 EFI_STATUS Status;
172 CHAR16 *RetVal;
173 CHAR16 *Temp;
174 CHAR16 *CodeType;
175 CHAR16 *DataType;
176
177 if (!Verbose) {
178 return (CatSPrint(NULL, L"LoadedImage"));
179 }
180
181 HandleParsingHiiInit();
182
183 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);
184 if (Temp == NULL) {
185 return NULL;
186 }
187
188 Status = gBS->OpenProtocol (
189 TheHandle,
190 &gEfiLoadedImageProtocolGuid,
191 (VOID**)&LoadedImage,
192 gImageHandle,
193 NULL,
194 EFI_OPEN_PROTOCOL_GET_PROTOCOL
195 );
196
197 if (EFI_ERROR (Status)) {
198 SHELL_FREE_NON_NULL (Temp);
199 return NULL;
200 }
201
202 DataType = ConvertMemoryType(LoadedImage->ImageDataType);
203 CodeType = ConvertMemoryType(LoadedImage->ImageCodeType);
204
205 RetVal = CatSPrint(
206 NULL,
207 Temp,
208 LoadedImage->Revision,
209 LoadedImage->ParentHandle,
210 LoadedImage->SystemTable,
211 LoadedImage->DeviceHandle,
212 LoadedImage->FilePath,
213 LoadedImage->LoadOptionsSize,
214 LoadedImage->LoadOptions,
215 LoadedImage->ImageBase,
216 LoadedImage->ImageSize,
217 CodeType,
218 DataType,
219 LoadedImage->Unload
220 );
221
222
223 SHELL_FREE_NON_NULL(Temp);
224 SHELL_FREE_NON_NULL(CodeType);
225 SHELL_FREE_NON_NULL(DataType);
226
227 return RetVal;
228 }
229
230 /**
231 Function to dump information about GOP.
232
233 This will allocate the return buffer from boot services pool.
234
235 @param[in] TheHandle The handle that has LoadedImage installed.
236 @param[in] Verbose TRUE for additional information, FALSE otherwise.
237
238 @retval A poitner to a string containing the information.
239 **/
240 CHAR16*
241 EFIAPI
242 GraphicsOutputProtocolDumpInformation(
243 IN CONST EFI_HANDLE TheHandle,
244 IN CONST BOOLEAN Verbose
245 )
246 {
247 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
248 EFI_STATUS Status;
249 CHAR16 *RetVal;
250 CHAR16 *Temp;
251 CHAR16 *Fmt;
252 CHAR16 *TempRetVal;
253 UINTN GopInfoSize;
254 UINT32 Mode;
255 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopInfo;
256
257 if (!Verbose) {
258 return (CatSPrint(NULL, L"GraphicsOutput"));
259 }
260
261 HandleParsingHiiInit();
262
263 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_GOP_DUMP_MAIN), NULL);
264 if (Temp == NULL) {
265 return NULL;
266 }
267
268 Status = gBS->OpenProtocol (
269 TheHandle,
270 &gEfiGraphicsOutputProtocolGuid,
271 (VOID**)&GraphicsOutput,
272 gImageHandle,
273 NULL,
274 EFI_OPEN_PROTOCOL_GET_PROTOCOL
275 );
276
277 if (EFI_ERROR (Status)) {
278 SHELL_FREE_NON_NULL (Temp);
279 return NULL;
280 }
281
282 Fmt = ConvertPixelFormat(GraphicsOutput->Mode->Info->PixelFormat);
283
284 RetVal = CatSPrint(
285 NULL,
286 Temp,
287 GraphicsOutput->Mode->MaxMode,
288 GraphicsOutput->Mode->Mode,
289 GraphicsOutput->Mode->FrameBufferBase,
290 (UINT64)GraphicsOutput->Mode->FrameBufferSize,
291 (UINT64)GraphicsOutput->Mode->SizeOfInfo,
292 GraphicsOutput->Mode->Info->Version,
293 GraphicsOutput->Mode->Info->HorizontalResolution,
294 GraphicsOutput->Mode->Info->VerticalResolution,
295 Fmt,
296 GraphicsOutput->Mode->Info->PixelsPerScanLine,
297 GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.RedMask,
298 GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.GreenMask,
299 GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.BlueMask
300 );
301
302 SHELL_FREE_NON_NULL (Temp);
303
304 Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_MAIN), NULL);
305 if (Temp == NULL) {
306 SHELL_FREE_NON_NULL (RetVal);
307 goto EXIT;
308 }
309
310 TempRetVal = CatSPrint (RetVal, Temp);
311 SHELL_FREE_NON_NULL (RetVal);
312 if (TempRetVal == NULL) {
313 goto EXIT;
314 }
315 RetVal = TempRetVal;
316 SHELL_FREE_NON_NULL (Temp);
317
318 Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY), NULL);
319 if (Temp == NULL) {
320 SHELL_FREE_NON_NULL (RetVal);
321 goto EXIT;
322 }
323
324
325 for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) {
326 Status = GraphicsOutput->QueryMode (
327 GraphicsOutput,
328 Mode,
329 &GopInfoSize,
330 &GopInfo
331 );
332 if (EFI_ERROR (Status)) {
333 continue;
334 }
335
336 TempRetVal = CatSPrint (
337 RetVal,
338 Temp,
339 Mode,
340 GopInfo->HorizontalResolution,
341 GopInfo->VerticalResolution
342 );
343
344 SHELL_FREE_NON_NULL (GopInfo);
345 SHELL_FREE_NON_NULL (RetVal);
346 RetVal = TempRetVal;
347 }
348
349
350 EXIT:
351 SHELL_FREE_NON_NULL(Temp);
352 SHELL_FREE_NON_NULL(Fmt);
353
354 return RetVal;
355 }
356
357 /**
358 Function to dump information about EDID Discovered Protocol.
359
360 This will allocate the return buffer from boot services pool.
361
362 @param[in] TheHandle The handle that has LoadedImage installed.
363 @param[in] Verbose TRUE for additional information, FALSE otherwise.
364
365 @retval A pointer to a string containing the information.
366 **/
367 CHAR16*
368 EFIAPI
369 EdidDiscoveredProtocolDumpInformation (
370 IN CONST EFI_HANDLE TheHandle,
371 IN CONST BOOLEAN Verbose
372 )
373 {
374 EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered;
375 EFI_STATUS Status;
376 CHAR16 *RetVal;
377 CHAR16 *Temp;
378 CHAR16 *TempRetVal;
379
380 if (!Verbose) {
381 return (CatSPrint (NULL, L"EDIDDiscovered"));
382 }
383
384 Status = gBS->OpenProtocol (
385 TheHandle,
386 &gEfiEdidDiscoveredProtocolGuid,
387 (VOID**)&EdidDiscovered,
388 NULL,
389 NULL,
390 EFI_OPEN_PROTOCOL_GET_PROTOCOL
391 );
392
393 if (EFI_ERROR (Status)) {
394 return NULL;
395 }
396
397 Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_DISCOVERED_MAIN), NULL);
398 if (Temp == NULL) {
399 return NULL;
400 }
401
402 RetVal = CatSPrint (NULL, Temp, EdidDiscovered->SizeOfEdid);
403 SHELL_FREE_NON_NULL (Temp);
404
405 if (EdidDiscovered->SizeOfEdid != 0) {
406 Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_DISCOVERED_DATA), NULL);
407 if (Temp == NULL) {
408 SHELL_FREE_NON_NULL (RetVal);
409 return NULL;
410 }
411 TempRetVal = CatSPrint (RetVal, Temp);
412 SHELL_FREE_NON_NULL (RetVal);
413 RetVal = TempRetVal;
414
415 TempRetVal = CatSDumpHex (RetVal, 7, 0, EdidDiscovered->SizeOfEdid, EdidDiscovered->Edid);
416 RetVal = TempRetVal;
417 }
418 return RetVal;
419 }
420
421 /**
422 Function to dump information about EDID Active Protocol.
423
424 This will allocate the return buffer from boot services pool.
425
426 @param[in] TheHandle The handle that has LoadedImage installed.
427 @param[in] Verbose TRUE for additional information, FALSE otherwise.
428
429 @retval A pointer to a string containing the information.
430 **/
431 CHAR16*
432 EFIAPI
433 EdidActiveProtocolDumpInformation (
434 IN CONST EFI_HANDLE TheHandle,
435 IN CONST BOOLEAN Verbose
436 )
437 {
438 EFI_EDID_ACTIVE_PROTOCOL *EdidActive;
439 EFI_STATUS Status;
440 CHAR16 *RetVal;
441 CHAR16 *Temp;
442 CHAR16 *TempRetVal;
443
444 if (!Verbose) {
445 return (CatSPrint (NULL, L"EDIDActive"));
446 }
447
448 Status = gBS->OpenProtocol (
449 TheHandle,
450 &gEfiEdidActiveProtocolGuid,
451 (VOID**)&EdidActive,
452 NULL,
453 NULL,
454 EFI_OPEN_PROTOCOL_GET_PROTOCOL
455 );
456
457 if (EFI_ERROR (Status)) {
458 return NULL;
459 }
460
461 Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_ACTIVE_MAIN), NULL);
462 if (Temp == NULL) {
463 return NULL;
464 }
465
466 RetVal = CatSPrint (NULL, Temp, EdidActive->SizeOfEdid);
467 SHELL_FREE_NON_NULL (Temp);
468
469 if (EdidActive->SizeOfEdid != 0) {
470 Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_ACTIVE_DATA), NULL);
471 if (Temp == NULL) {
472 SHELL_FREE_NON_NULL (RetVal);
473 return NULL;
474 }
475 TempRetVal = CatSPrint (RetVal, Temp);
476 SHELL_FREE_NON_NULL (RetVal);
477 RetVal = TempRetVal;
478
479 TempRetVal = CatSDumpHex (RetVal, 7, 0, EdidActive->SizeOfEdid, EdidActive->Edid);
480 RetVal = TempRetVal;
481 }
482 return RetVal;
483 }
484
485 /**
486 Function to dump information about PciRootBridgeIo.
487
488 This will allocate the return buffer from boot services pool.
489
490 @param[in] TheHandle The handle that has PciRootBridgeIo installed.
491 @param[in] Verbose TRUE for additional information, FALSE otherwise.
492
493 @retval A poitner to a string containing the information.
494 **/
495 CHAR16*
496 EFIAPI
497 PciRootBridgeIoDumpInformation(
498 IN CONST EFI_HANDLE TheHandle,
499 IN CONST BOOLEAN Verbose
500 )
501 {
502 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
503 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Configuration;
504 UINT64 Supports;
505 UINT64 Attributes;
506 CHAR16 *Temp;
507 CHAR16 *Temp2;
508 CHAR16 *RetVal;
509 EFI_STATUS Status;
510
511 RetVal = NULL;
512
513 if (!Verbose) {
514 return (CatSPrint(NULL, L"PciRootBridgeIo"));
515 }
516
517 HandleParsingHiiInit();
518
519 Status = gBS->HandleProtocol(
520 TheHandle,
521 &gEfiPciRootBridgeIoProtocolGuid,
522 (VOID**)&PciRootBridgeIo);
523
524 if (EFI_ERROR(Status)) {
525 return NULL;
526 }
527
528 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_PH), NULL);
529 if (Temp == NULL) {
530 return NULL;
531 }
532 Temp2 = CatSPrint(L"\r\n", Temp, PciRootBridgeIo->ParentHandle);
533 FreePool(Temp);
534 RetVal = Temp2;
535 Temp2 = NULL;
536
537 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SEG), NULL);
538 if (Temp == NULL) {
539 SHELL_FREE_NON_NULL(RetVal);
540 return NULL;
541 }
542 Temp2 = CatSPrint(RetVal, Temp, PciRootBridgeIo->SegmentNumber);
543 FreePool(Temp);
544 FreePool(RetVal);
545 RetVal = Temp2;
546 Temp2 = NULL;
547
548 Supports = 0;
549 Attributes = 0;
550 Status = PciRootBridgeIo->GetAttributes (PciRootBridgeIo, &Supports, &Attributes);
551 if (!EFI_ERROR(Status)) {
552 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_ATT), NULL);
553 if (Temp == NULL) {
554 SHELL_FREE_NON_NULL(RetVal);
555 return NULL;
556 }
557 Temp2 = CatSPrint(RetVal, Temp, Attributes);
558 FreePool(Temp);
559 FreePool(RetVal);
560 RetVal = Temp2;
561 Temp2 = NULL;
562
563 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS), NULL);
564 if (Temp == NULL) {
565 SHELL_FREE_NON_NULL(RetVal);
566 return NULL;
567 }
568 Temp2 = CatSPrint(RetVal, Temp, Supports);
569 FreePool(Temp);
570 FreePool(RetVal);
571 RetVal = Temp2;
572 Temp2 = NULL;
573 }
574
575 Configuration = NULL;
576 Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Configuration);
577 if (!EFI_ERROR(Status) && Configuration != NULL) {
578 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_TITLE), NULL);
579 if (Temp == NULL) {
580 SHELL_FREE_NON_NULL(RetVal);
581 return NULL;
582 }
583 Temp2 = CatSPrint(RetVal, Temp, Supports);
584 FreePool(Temp);
585 FreePool(RetVal);
586 RetVal = Temp2;
587 Temp2 = NULL;
588 while (Configuration->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
589 Temp = NULL;
590 switch (Configuration->ResType) {
591 case ACPI_ADDRESS_SPACE_TYPE_MEM:
592 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_MEM), NULL);
593 break;
594 case ACPI_ADDRESS_SPACE_TYPE_IO:
595 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_IO), NULL);
596 break;
597 case ACPI_ADDRESS_SPACE_TYPE_BUS:
598 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_BUS), NULL);
599 break;
600 }
601 if (Temp != NULL) {
602 Temp2 = CatSPrint(RetVal, L"%s", Temp);
603 FreePool(Temp);
604 FreePool(RetVal);
605 RetVal = Temp2;
606 Temp2 = NULL;
607 }
608
609 Temp2 = CatSPrint(RetVal,
610 L"%H%02x %016lx %016lx %02x%N\r\n",
611 Configuration->SpecificFlag,
612 Configuration->AddrRangeMin,
613 Configuration->AddrRangeMax,
614 Configuration->AddrSpaceGranularity
615 );
616 FreePool(RetVal);
617 RetVal = Temp2;
618 Temp2 = NULL;
619 Configuration++;
620 }
621 }
622 return (RetVal);
623 }
624
625 /**
626 Function to dump information about SimpleTextOut.
627
628 This will allocate the return buffer from boot services pool.
629
630 @param[in] TheHandle The handle that has SimpleTextOut installed.
631 @param[in] Verbose TRUE for additional information, FALSE otherwise.
632
633 @retval A poitner to a string containing the information.
634 **/
635 CHAR16*
636 EFIAPI
637 TxtOutProtocolDumpInformation(
638 IN CONST EFI_HANDLE TheHandle,
639 IN CONST BOOLEAN Verbose
640 )
641 {
642 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Dev;
643 INTN Index;
644 UINTN Col;
645 UINTN Row;
646 EFI_STATUS Status;
647 CHAR16 *RetVal;
648 UINTN Size;
649 CHAR16 *Temp;
650 UINTN NewSize;
651
652 if (!Verbose) {
653 return (NULL);
654 }
655
656 HandleParsingHiiInit();
657
658 RetVal = NULL;
659 Size = 0;
660
661 Status = gBS->HandleProtocol(
662 TheHandle,
663 &gEfiSimpleTextOutProtocolGuid,
664 (VOID**)&Dev);
665
666 ASSERT_EFI_ERROR(Status);
667 ASSERT (Dev != NULL && Dev->Mode != NULL);
668
669 Size = (Dev->Mode->MaxMode + 1) * 80;
670 RetVal = AllocateZeroPool(Size);
671
672 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER), NULL);
673 if (Temp != NULL) {
674 UnicodeSPrint(RetVal, Size, Temp, Dev, Dev->Mode->Attribute);
675 FreePool(Temp);
676 }
677
678 //
679 // Dump TextOut Info
680 //
681 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE), NULL);
682 for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {
683 Status = Dev->QueryMode (Dev, Index, &Col, &Row);
684 NewSize = Size - StrSize(RetVal);
685 UnicodeSPrint(
686 RetVal + StrLen(RetVal),
687 NewSize,
688 Temp == NULL?L"":Temp,
689 Index == Dev->Mode->Mode ? L'*' : L' ',
690 Index,
691 !EFI_ERROR(Status)?(INTN)Col:-1,
692 !EFI_ERROR(Status)?(INTN)Row:-1
693 );
694 }
695 FreePool(Temp);
696 return (RetVal);
697 }
698
699 STATIC CONST UINTN VersionStringSize = 60;
700
701 /**
702 Function to dump information about EfiDriverSupportedEfiVersion protocol.
703
704 This will allocate the return buffer from boot services pool.
705
706 @param[in] TheHandle The handle that has the protocol installed.
707 @param[in] Verbose TRUE for additional information, FALSE otherwise.
708
709 @retval A poitner to a string containing the information.
710 **/
711 CHAR16*
712 EFIAPI
713 DriverEfiVersionProtocolDumpInformation(
714 IN CONST EFI_HANDLE TheHandle,
715 IN CONST BOOLEAN Verbose
716 )
717 {
718 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;
719 EFI_STATUS Status;
720 CHAR16 *RetVal;
721
722 Status = gBS->HandleProtocol(
723 TheHandle,
724 &gEfiDriverSupportedEfiVersionProtocolGuid,
725 (VOID**)&DriverEfiVersion);
726
727 ASSERT_EFI_ERROR(Status);
728
729 RetVal = AllocateZeroPool(VersionStringSize);
730 ASSERT(RetVal != NULL);
731 UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);
732 return (RetVal);
733 }
734
735 /**
736 Function to dump information about DevicePath protocol.
737
738 This will allocate the return buffer from boot services pool.
739
740 @param[in] TheHandle The handle that has the protocol installed.
741 @param[in] Verbose TRUE for additional information, FALSE otherwise.
742
743 @retval A poitner to a string containing the information.
744 **/
745 CHAR16*
746 EFIAPI
747 DevicePathProtocolDumpInformation(
748 IN CONST EFI_HANDLE TheHandle,
749 IN CONST BOOLEAN Verbose
750 )
751 {
752 EFI_DEVICE_PATH_PROTOCOL *DevPath;
753 CHAR16 *Temp;
754 CHAR16 *Temp2;
755 EFI_STATUS Status;
756 Temp = NULL;
757
758 Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
759 if (!EFI_ERROR(Status)) {
760 //
761 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
762 //
763 Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);
764 gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);
765 }
766 if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {
767 Temp2 = NULL;
768 Temp2 = StrnCatGrow(&Temp2, NULL, Temp+(StrLen(Temp) - 30), 30);
769 FreePool(Temp);
770 Temp = Temp2;
771 }
772 return (Temp);
773 }
774
775 /**
776 Function to dump information about EfiAdapterInformation Protocol.
777
778 @param[in] TheHandle The handle that has the protocol installed.
779 @param[in] Verbose TRUE for additional information, FALSE otherwise.
780
781 @retval A pointer to a string containing the information.
782 **/
783 CHAR16*
784 EFIAPI
785 AdapterInformationDumpInformation (
786 IN CONST EFI_HANDLE TheHandle,
787 IN CONST BOOLEAN Verbose
788 )
789 {
790 EFI_STATUS Status;
791 EFI_ADAPTER_INFORMATION_PROTOCOL *EfiAdptrInfoProtocol;
792 UINTN InfoTypesBufferCount;
793 UINTN GuidIndex;
794 EFI_GUID *InfoTypesBuffer;
795 CHAR16 *GuidStr;
796 CHAR16 *TempStr;
797 CHAR16 *RetVal;
798 CHAR16 *TempRetVal;
799 VOID *InformationBlock;
800 UINTN InformationBlockSize;
801
802 if (!Verbose) {
803 return (CatSPrint(NULL, L"AdapterInfo"));
804 }
805
806 InfoTypesBuffer = NULL;
807 InformationBlock = NULL;
808
809
810 Status = gBS->OpenProtocol (
811 (EFI_HANDLE) (TheHandle),
812 &gEfiAdapterInformationProtocolGuid,
813 (VOID **) &EfiAdptrInfoProtocol,
814 NULL,
815 NULL,
816 EFI_OPEN_PROTOCOL_GET_PROTOCOL
817 );
818
819 if (EFI_ERROR (Status)) {
820 return NULL;
821 }
822
823 //
824 // Get a list of supported information types for this instance of the protocol.
825 //
826 Status = EfiAdptrInfoProtocol->GetSupportedTypes (
827 EfiAdptrInfoProtocol,
828 &InfoTypesBuffer,
829 &InfoTypesBufferCount
830 );
831 RetVal = NULL;
832 if (EFI_ERROR (Status)) {
833 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL);
834 if (TempStr != NULL) {
835 RetVal = CatSPrint (NULL, TempStr, Status);
836 } else {
837 goto ERROR_EXIT;
838 }
839 } else {
840 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL);
841 if (TempStr == NULL) {
842 goto ERROR_EXIT;
843 }
844 RetVal = CatSPrint (NULL, TempStr);
845 SHELL_FREE_NON_NULL (TempStr);
846
847 for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) {
848 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL);
849 if (TempStr == NULL) {
850 goto ERROR_EXIT;
851 }
852 TempRetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), &InfoTypesBuffer[GuidIndex]);
853 SHELL_FREE_NON_NULL (RetVal);
854 RetVal = TempRetVal;
855 SHELL_FREE_NON_NULL (TempStr);
856
857 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL);
858 if (TempStr == NULL) {
859 goto ERROR_EXIT;
860 }
861
862 if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {
863 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid");
864 SHELL_FREE_NON_NULL (RetVal);
865 RetVal = TempRetVal;
866 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {
867 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid");
868 SHELL_FREE_NON_NULL (RetVal);
869 RetVal = TempRetVal;
870 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) {
871 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid");
872 SHELL_FREE_NON_NULL (RetVal);
873 RetVal = TempRetVal;
874 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid)) {
875 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoUndiIpv6SupportGuid");
876 SHELL_FREE_NON_NULL (RetVal);
877 RetVal = TempRetVal;
878 } else {
879
880 GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);
881
882 if (GuidStr != NULL) {
883 if (StrCmp(GuidStr, L"UnknownDevice") == 0) {
884 TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");
885 SHELL_FREE_NON_NULL (RetVal);
886 RetVal = TempRetVal;
887
888 SHELL_FREE_NON_NULL (TempStr);
889 SHELL_FREE_NON_NULL(GuidStr);
890 //
891 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
892 //
893 continue;
894 } else {
895 TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);
896 SHELL_FREE_NON_NULL (RetVal);
897 RetVal = TempRetVal;
898 SHELL_FREE_NON_NULL(GuidStr);
899 }
900 }
901 }
902
903 SHELL_FREE_NON_NULL (TempStr);
904
905 Status = EfiAdptrInfoProtocol->GetInformation (
906 EfiAdptrInfoProtocol,
907 &InfoTypesBuffer[GuidIndex],
908 &InformationBlock,
909 &InformationBlockSize
910 );
911
912 if (EFI_ERROR (Status)) {
913 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL);
914 if (TempStr == NULL) {
915 goto ERROR_EXIT;
916 }
917 TempRetVal = CatSPrint (RetVal, TempStr, Status);
918 SHELL_FREE_NON_NULL (RetVal);
919 RetVal = TempRetVal;
920 } else {
921 if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {
922 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL);
923 if (TempStr == NULL) {
924 goto ERROR_EXIT;
925 }
926 TempRetVal = CatSPrint (
927 RetVal,
928 TempStr,
929 ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState,
930 ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState
931 );
932 SHELL_FREE_NON_NULL (RetVal);
933 RetVal = TempRetVal;
934 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {
935 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL);
936 if (TempStr == NULL) {
937 goto ERROR_EXIT;
938 }
939 TempRetVal = CatSPrint (
940 RetVal,
941 TempStr,
942 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity,
943 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity,
944 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity,
945 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability,
946 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability,
947 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot,
948 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot,
949 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot
950 );
951 SHELL_FREE_NON_NULL (RetVal);
952 RetVal = TempRetVal;
953 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) {
954 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL);
955 if (TempStr == NULL) {
956 goto ERROR_EXIT;
957 }
958 TempRetVal = CatSPrint (
959 RetVal,
960 TempStr,
961 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0],
962 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1],
963 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2],
964 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3],
965 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4],
966 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5]
967 );
968 SHELL_FREE_NON_NULL (RetVal);
969 RetVal = TempRetVal;
970 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid) == TRUE) {
971 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNDI_IPV6_INFO), NULL);
972 if (TempStr == NULL) {
973 goto ERROR_EXIT;
974 }
975
976 TempRetVal = CatSPrint (
977 RetVal,
978 TempStr,
979 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InformationBlock)->Ipv6Support
980 );
981 SHELL_FREE_NON_NULL (RetVal);
982 RetVal = TempRetVal;
983 } else {
984 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL);
985 if (TempStr == NULL) {
986 goto ERROR_EXIT;
987 }
988 TempRetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]);
989 SHELL_FREE_NON_NULL (RetVal);
990 RetVal = TempRetVal;
991 }
992 }
993 SHELL_FREE_NON_NULL (TempStr);
994 SHELL_FREE_NON_NULL (InformationBlock);
995 }
996 }
997
998 SHELL_FREE_NON_NULL (InfoTypesBuffer);
999 return RetVal;
1000
1001 ERROR_EXIT:
1002 SHELL_FREE_NON_NULL (RetVal);
1003 SHELL_FREE_NON_NULL (InfoTypesBuffer);
1004 SHELL_FREE_NON_NULL (InformationBlock);
1005 return NULL;
1006 }
1007
1008 /**
1009 Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.
1010
1011 @param[in] TheHandle The handle that has the protocol installed.
1012 @param[in] Verbose TRUE for additional information, FALSE otherwise.
1013
1014 @retval A pointer to a string containing the information.
1015 **/
1016 CHAR16*
1017 EFIAPI
1018 FirmwareManagementDumpInformation (
1019 IN CONST EFI_HANDLE TheHandle,
1020 IN CONST BOOLEAN Verbose
1021 )
1022 {
1023 EFI_STATUS Status;
1024 EFI_FIRMWARE_MANAGEMENT_PROTOCOL *EfiFwMgmtProtocol;
1025 EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
1026 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1 *ImageInfoV1;
1027 EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2 *ImageInfoV2;
1028 UINT64 AttributeSetting;
1029 UINTN ImageInfoSize;
1030 UINTN DescriptorSize;
1031 UINT32 DescriptorVersion;
1032 UINT32 PackageVersion;
1033 UINT8 DescriptorCount;
1034 UINT8 Index;
1035 UINT8 Index1;
1036 UINT8 ImageCount;
1037 CHAR16 *PackageVersionName;
1038 CHAR16 *TempStr;
1039 CHAR16 *RetVal;
1040 CHAR16 *TempRetVal;
1041 CHAR16 *AttributeSettingStr;
1042 BOOLEAN Found;
1043 BOOLEAN AttributeSupported;
1044
1045 //
1046 // Initialize local variables
1047 //
1048 ImageCount = 0;
1049 ImageInfoSize = 1;
1050 AttributeSetting = 0;
1051 Found = FALSE;
1052 AttributeSupported = FALSE;
1053 ImageInfo = NULL;
1054 ImageInfoV1 = NULL;
1055 ImageInfoV2 = NULL;
1056 PackageVersionName = NULL;
1057 RetVal = NULL;
1058 TempRetVal = NULL;
1059 TempStr = NULL;
1060 AttributeSettingStr = NULL;
1061
1062 if (!Verbose) {
1063 return (CatSPrint(NULL, L"FirmwareManagement"));
1064 }
1065
1066 Status = gBS->OpenProtocol (
1067 (EFI_HANDLE) (TheHandle),
1068 &gEfiFirmwareManagementProtocolGuid,
1069 (VOID **) &EfiFwMgmtProtocol,
1070 NULL,
1071 NULL,
1072 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1073 );
1074
1075 if (EFI_ERROR (Status)) {
1076 return NULL;
1077 }
1078
1079 Status = EfiFwMgmtProtocol->GetImageInfo (
1080 EfiFwMgmtProtocol,
1081 &ImageInfoSize,
1082 ImageInfo,
1083 &DescriptorVersion,
1084 &DescriptorCount,
1085 &DescriptorSize,
1086 &PackageVersion,
1087 &PackageVersionName
1088 );
1089
1090 if (Status == EFI_BUFFER_TOO_SMALL) {
1091 ImageInfo = AllocateZeroPool (ImageInfoSize);
1092
1093 if (ImageInfo == NULL) {
1094 Status = EFI_OUT_OF_RESOURCES;
1095 } else {
1096 Status = EfiFwMgmtProtocol->GetImageInfo (
1097 EfiFwMgmtProtocol,
1098 &ImageInfoSize,
1099 ImageInfo,
1100 &DescriptorVersion,
1101 &DescriptorCount,
1102 &DescriptorSize,
1103 &PackageVersion,
1104 &PackageVersionName
1105 );
1106 }
1107 }
1108
1109 if (EFI_ERROR (Status)) {
1110 goto ERROR_EXIT;
1111 }
1112
1113 //
1114 // Decode Image Descriptor data only if its version is supported
1115 //
1116 if (DescriptorVersion <= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION) {
1117
1118 if (ImageInfo == NULL) {
1119 goto ERROR_EXIT;
1120 }
1121
1122 ImageInfoV1 = (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1 *)ImageInfo;
1123 ImageInfoV2 = (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2 *)ImageInfo;
1124
1125 //
1126 // Set ImageInfoSize in return buffer
1127 //
1128 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE), NULL);
1129 if (TempStr == NULL) {
1130 goto ERROR_EXIT;
1131 }
1132 RetVal = CatSPrint (NULL, TempStr, ImageInfoSize);
1133 SHELL_FREE_NON_NULL (TempStr);
1134
1135 //
1136 // Set DescriptorVersion in return buffer
1137 //
1138 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION), NULL);
1139 if (TempStr == NULL) {
1140 goto ERROR_EXIT;
1141 }
1142 TempRetVal = CatSPrint (RetVal, TempStr, DescriptorVersion);
1143 SHELL_FREE_NON_NULL (RetVal);
1144 RetVal = TempRetVal;
1145 SHELL_FREE_NON_NULL (TempStr);
1146
1147 //
1148 // Set DescriptorCount in return buffer
1149 //
1150 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT), NULL);
1151 if (TempStr == NULL) {
1152 goto ERROR_EXIT;
1153 }
1154 TempRetVal = CatSPrint (RetVal, TempStr, DescriptorCount);
1155 SHELL_FREE_NON_NULL (RetVal);
1156 RetVal = TempRetVal;
1157 SHELL_FREE_NON_NULL (TempStr);
1158
1159
1160 //
1161 // Set DescriptorSize in return buffer
1162 //
1163 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE), NULL);
1164 if (TempStr == NULL) {
1165 goto ERROR_EXIT;
1166 }
1167 TempRetVal = CatSPrint (RetVal, TempStr, DescriptorSize);
1168 SHELL_FREE_NON_NULL (RetVal);
1169 RetVal = TempRetVal;
1170 SHELL_FREE_NON_NULL (TempStr);
1171
1172 //
1173 // Set PackageVersion in return buffer
1174 //
1175 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_PACKAGE_VERSION), NULL);
1176 if (TempStr == NULL) {
1177 goto ERROR_EXIT;
1178 }
1179 TempRetVal = CatSPrint (RetVal, TempStr, PackageVersion);
1180 SHELL_FREE_NON_NULL (RetVal);
1181 RetVal = TempRetVal;
1182 SHELL_FREE_NON_NULL (TempStr);
1183
1184 //
1185 // Set PackageVersionName in return buffer
1186 //
1187 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME), NULL);
1188 if (TempStr == NULL) {
1189 goto ERROR_EXIT;
1190 }
1191 TempRetVal = CatSPrint (RetVal, TempStr, PackageVersionName);
1192 SHELL_FREE_NON_NULL (RetVal);
1193 RetVal = TempRetVal;
1194 SHELL_FREE_NON_NULL (TempStr);
1195
1196 for (Index = 0; Index < DescriptorCount; Index++) {
1197 //
1198 // First check if Attribute is supported
1199 // and generate a string for AttributeSetting field
1200 //
1201 SHELL_FREE_NON_NULL (AttributeSettingStr);
1202 AttributeSupported = FALSE;
1203 AttributeSetting = 0;
1204 if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {
1205 if (ImageInfoV1[Index].AttributesSupported != 0x0) {
1206 AttributeSupported = TRUE;
1207 AttributeSetting = ImageInfoV1[Index].AttributesSetting;
1208 }
1209 } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {
1210 if (ImageInfoV2[Index].AttributesSupported != 0x0) {
1211 AttributeSupported = TRUE;
1212 AttributeSetting = ImageInfoV2[Index].AttributesSetting;
1213 }
1214 } else {
1215 if (ImageInfo[Index].AttributesSupported != 0x0) {
1216 AttributeSupported = TRUE;
1217 AttributeSetting = ImageInfo[Index].AttributesSetting;
1218 }
1219 }
1220
1221 if (!AttributeSupported) {
1222 AttributeSettingStr = CatSPrint (NULL, L"None");
1223 } else {
1224 AttributeSettingStr = CatSPrint (NULL, L"(");
1225
1226 if ((AttributeSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != 0x0) {
1227 TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
1228 SHELL_FREE_NON_NULL (AttributeSettingStr);
1229 AttributeSettingStr = TempRetVal;
1230 }
1231 if ((AttributeSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0x0) {
1232 TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_RESET_REQUIRED");
1233 SHELL_FREE_NON_NULL (AttributeSettingStr);
1234 AttributeSettingStr = TempRetVal;
1235 }
1236 if ((AttributeSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != 0x0) {
1237 TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
1238 SHELL_FREE_NON_NULL (AttributeSettingStr);
1239 AttributeSettingStr = TempRetVal;
1240 }
1241 if ((AttributeSetting & IMAGE_ATTRIBUTE_IN_USE) != 0x0) {
1242 TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IN_USE");
1243 SHELL_FREE_NON_NULL (AttributeSettingStr);
1244 AttributeSettingStr = TempRetVal;
1245 }
1246 if ((AttributeSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE) != 0x0) {
1247 TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_UEFI_IMAGE");
1248 SHELL_FREE_NON_NULL (AttributeSettingStr);
1249 AttributeSettingStr = TempRetVal;
1250 }
1251 TempRetVal = CatSPrint (AttributeSettingStr, L" )");
1252 SHELL_FREE_NON_NULL (AttributeSettingStr);
1253 AttributeSettingStr = TempRetVal;
1254 }
1255
1256 if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {
1257 if (ImageInfoV1[Index].ImageIndex != 0x0) {
1258 ImageCount++;
1259 }
1260
1261 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1), NULL);
1262 if (TempStr == NULL) {
1263 goto ERROR_EXIT;
1264 }
1265 TempRetVal = CatSPrint (
1266 RetVal,
1267 TempStr,
1268 Index,
1269 ImageInfoV1[Index].ImageIndex,
1270 ImageInfoV1[Index].ImageTypeId,
1271 ImageInfoV1[Index].ImageId,
1272 ImageInfoV1[Index].ImageIdName,
1273 ImageInfoV1[Index].Version,
1274 ImageInfoV1[Index].VersionName,
1275 ImageInfoV1[Index].Size,
1276 ImageInfoV1[Index].AttributesSupported,
1277 AttributeSettingStr,
1278 ImageInfoV1[Index].Compatibilities
1279 );
1280 SHELL_FREE_NON_NULL (RetVal);
1281 RetVal = TempRetVal;
1282 SHELL_FREE_NON_NULL (TempStr);
1283 } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {
1284 if (ImageInfoV2[Index].ImageIndex != 0x0) {
1285 ImageCount++;
1286 }
1287
1288 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2), NULL);
1289 if (TempStr == NULL) {
1290 goto ERROR_EXIT;
1291 }
1292 TempRetVal = CatSPrint (
1293 RetVal,
1294 TempStr,
1295 Index,
1296 ImageInfoV2[Index].ImageIndex,
1297 ImageInfoV2[Index].ImageTypeId,
1298 ImageInfoV2[Index].ImageId,
1299 ImageInfoV2[Index].ImageIdName,
1300 ImageInfoV2[Index].Version,
1301 ImageInfoV2[Index].VersionName,
1302 ImageInfoV2[Index].Size,
1303 ImageInfoV2[Index].AttributesSupported,
1304 AttributeSettingStr,
1305 ImageInfoV2[Index].Compatibilities,
1306 ImageInfoV2[Index].LowestSupportedImageVersion
1307 );
1308 SHELL_FREE_NON_NULL (RetVal);
1309 RetVal = TempRetVal;
1310 SHELL_FREE_NON_NULL (TempStr);
1311 } else {
1312 if (ImageInfo[Index].ImageIndex != 0x0) {
1313 ImageCount++;
1314 }
1315
1316 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO), NULL);
1317 if (TempStr == NULL) {
1318 goto ERROR_EXIT;
1319 }
1320 TempRetVal = CatSPrint (
1321 RetVal,
1322 TempStr,
1323 Index,
1324 ImageInfo[Index].ImageIndex,
1325 ImageInfo[Index].ImageTypeId,
1326 ImageInfo[Index].ImageId,
1327 ImageInfo[Index].ImageIdName,
1328 ImageInfo[Index].Version,
1329 ImageInfo[Index].VersionName,
1330 ImageInfo[Index].Size,
1331 ImageInfo[Index].AttributesSupported,
1332 AttributeSettingStr,
1333 ImageInfo[Index].Compatibilities,
1334 ImageInfo[Index].LowestSupportedImageVersion,
1335 ImageInfo[Index].LastAttemptVersion,
1336 ImageInfo[Index].LastAttemptStatus,
1337 ImageInfo[Index].HardwareInstance
1338 );
1339 SHELL_FREE_NON_NULL (RetVal);
1340 RetVal = TempRetVal;
1341 SHELL_FREE_NON_NULL (TempStr);
1342 }
1343 }
1344 }
1345
1346 if (ImageCount > 0) {
1347 for (Index=0; Index<DescriptorCount; Index++) {
1348 for (Index1=Index+1; Index1<DescriptorCount; Index1++) {
1349 if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {
1350 if (ImageInfoV1[Index].ImageId == ImageInfoV1[Index1].ImageId) {
1351 Found = TRUE;
1352 //
1353 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1354 //
1355 goto ENDLOOP;
1356 }
1357 } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {
1358 if (ImageInfoV2[Index].ImageId == ImageInfoV2[Index1].ImageId) {
1359 Found = TRUE;
1360 //
1361 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1362 //
1363 goto ENDLOOP;
1364 }
1365 } else {
1366 if (ImageInfo[Index].ImageId == ImageInfo[Index1].ImageId) {
1367 Found = TRUE;
1368 //
1369 // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
1370 //
1371 goto ENDLOOP;
1372 }
1373 }
1374 }
1375 }
1376 }
1377
1378 ENDLOOP:
1379 //
1380 // Check if ImageId with duplicate value was found
1381 //
1382 if (Found) {
1383 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE), NULL);
1384 if (TempStr == NULL) {
1385 goto ERROR_EXIT;
1386 }
1387 TempRetVal = CatSPrint (RetVal, TempStr);
1388 SHELL_FREE_NON_NULL (RetVal);
1389 RetVal = TempRetVal;
1390 SHELL_FREE_NON_NULL (TempStr);
1391 }
1392
1393 SHELL_FREE_NON_NULL (ImageInfo);
1394 SHELL_FREE_NON_NULL (PackageVersionName);
1395 SHELL_FREE_NON_NULL (AttributeSettingStr);
1396
1397 return RetVal;
1398
1399 ERROR_EXIT:
1400 SHELL_FREE_NON_NULL (RetVal);
1401 SHELL_FREE_NON_NULL (ImageInfo);
1402 SHELL_FREE_NON_NULL (PackageVersionName);
1403 SHELL_FREE_NON_NULL (AttributeSettingStr);
1404
1405 return NULL;
1406 }
1407
1408 //
1409 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
1410 //
1411 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
1412 { \
1413 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1414 }
1415
1416 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
1417 { \
1418 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1419 }
1420
1421 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
1422 { \
1423 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
1424 }
1425 STATIC CONST EFI_GUID WinNtThunkProtocolGuid = LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID;
1426 STATIC CONST EFI_GUID WinNtIoProtocolGuid = LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID;
1427 STATIC CONST EFI_GUID WinNtSerialPortGuid = LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID;
1428
1429 //
1430 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg
1431 //
1432 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
1433 { \
1434 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
1435 }
1436 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
1437 { \
1438 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
1439 }
1440 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid = LOCAL_EFI_ISA_IO_PROTOCOL_GUID;
1441 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid = LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID;
1442
1443
1444 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {
1445 {STRING_TOKEN(STR_WINNT_THUNK), (EFI_GUID*)&WinNtThunkProtocolGuid, NULL},
1446 {STRING_TOKEN(STR_WINNT_DRIVER_IO), (EFI_GUID*)&WinNtIoProtocolGuid, NULL},
1447 {STRING_TOKEN(STR_WINNT_SERIAL_PORT), (EFI_GUID*)&WinNtSerialPortGuid, NULL},
1448 {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},
1449 };
1450
1451 STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
1452 {STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, LoadedImageProtocolDumpInformation},
1453 {STRING_TOKEN(STR_DEVICE_PATH), &gEfiDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
1454 {STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
1455 {STRING_TOKEN(STR_DEVICE_PATH_UTIL), &gEfiDevicePathUtilitiesProtocolGuid, NULL},
1456 {STRING_TOKEN(STR_DEVICE_PATH_TXT), &gEfiDevicePathToTextProtocolGuid, NULL},
1457 {STRING_TOKEN(STR_DEVICE_PATH_FTXT), &gEfiDevicePathFromTextProtocolGuid, NULL},
1458 {STRING_TOKEN(STR_DEVICE_PATH_PC), &gEfiPcAnsiGuid, NULL},
1459 {STRING_TOKEN(STR_DEVICE_PATH_VT100), &gEfiVT100Guid, NULL},
1460 {STRING_TOKEN(STR_DEVICE_PATH_VT100P), &gEfiVT100PlusGuid, NULL},
1461 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8), &gEfiVTUTF8Guid, NULL},
1462 {STRING_TOKEN(STR_DRIVER_BINDING), &gEfiDriverBindingProtocolGuid, NULL},
1463 {STRING_TOKEN(STR_PLATFORM_OVERRIDE), &gEfiPlatformDriverOverrideProtocolGuid, NULL},
1464 {STRING_TOKEN(STR_BUS_OVERRIDE), &gEfiBusSpecificDriverOverrideProtocolGuid, NULL},
1465 {STRING_TOKEN(STR_DRIVER_DIAG), &gEfiDriverDiagnosticsProtocolGuid, NULL},
1466 {STRING_TOKEN(STR_DRIVER_DIAG2), &gEfiDriverDiagnostics2ProtocolGuid, NULL},
1467 {STRING_TOKEN(STR_DRIVER_CN), &gEfiComponentNameProtocolGuid, NULL},
1468 {STRING_TOKEN(STR_DRIVER_CN2), &gEfiComponentName2ProtocolGuid, NULL},
1469 {STRING_TOKEN(STR_PLAT_DRV_CFG), &gEfiPlatformToDriverConfigurationProtocolGuid, NULL},
1470 {STRING_TOKEN(STR_DRIVER_VERSION), &gEfiDriverSupportedEfiVersionProtocolGuid, DriverEfiVersionProtocolDumpInformation},
1471 {STRING_TOKEN(STR_TXT_IN), &gEfiSimpleTextInProtocolGuid, NULL},
1472 {STRING_TOKEN(STR_TXT_IN_EX), &gEfiSimpleTextInputExProtocolGuid, NULL},
1473 {STRING_TOKEN(STR_TXT_OUT), &gEfiSimpleTextOutProtocolGuid, TxtOutProtocolDumpInformation},
1474 {STRING_TOKEN(STR_SIM_POINTER), &gEfiSimplePointerProtocolGuid, NULL},
1475 {STRING_TOKEN(STR_ABS_POINTER), &gEfiAbsolutePointerProtocolGuid, NULL},
1476 {STRING_TOKEN(STR_SERIAL_IO), &gEfiSerialIoProtocolGuid, NULL},
1477 {STRING_TOKEN(STR_GRAPHICS_OUTPUT), &gEfiGraphicsOutputProtocolGuid, GraphicsOutputProtocolDumpInformation},
1478 {STRING_TOKEN(STR_EDID_DISCOVERED), &gEfiEdidDiscoveredProtocolGuid, EdidDiscoveredProtocolDumpInformation},
1479 {STRING_TOKEN(STR_EDID_ACTIVE), &gEfiEdidActiveProtocolGuid, EdidActiveProtocolDumpInformation},
1480 {STRING_TOKEN(STR_EDID_OVERRIDE), &gEfiEdidOverrideProtocolGuid, NULL},
1481 {STRING_TOKEN(STR_CON_IN), &gEfiConsoleInDeviceGuid, NULL},
1482 {STRING_TOKEN(STR_CON_OUT), &gEfiConsoleOutDeviceGuid, NULL},
1483 {STRING_TOKEN(STR_STD_ERR), &gEfiStandardErrorDeviceGuid, NULL},
1484 {STRING_TOKEN(STR_LOAD_FILE), &gEfiLoadFileProtocolGuid, NULL},
1485 {STRING_TOKEN(STR_LOAD_FILE2), &gEfiLoadFile2ProtocolGuid, NULL},
1486 {STRING_TOKEN(STR_SIMPLE_FILE_SYS), &gEfiSimpleFileSystemProtocolGuid, NULL},
1487 {STRING_TOKEN(STR_TAPE_IO), &gEfiTapeIoProtocolGuid, NULL},
1488 {STRING_TOKEN(STR_DISK_IO), &gEfiDiskIoProtocolGuid, NULL},
1489 {STRING_TOKEN(STR_BLK_IO), &gEfiBlockIoProtocolGuid, NULL},
1490 {STRING_TOKEN(STR_UC), &gEfiUnicodeCollationProtocolGuid, NULL},
1491 {STRING_TOKEN(STR_UC2), &gEfiUnicodeCollation2ProtocolGuid, NULL},
1492 {STRING_TOKEN(STR_PCIRB_IO), &gEfiPciRootBridgeIoProtocolGuid, PciRootBridgeIoDumpInformation},
1493 {STRING_TOKEN(STR_PCI_IO), &gEfiPciIoProtocolGuid, NULL},
1494 {STRING_TOKEN(STR_SCSI_PT), &gEfiScsiPassThruProtocolGuid, NULL},
1495 {STRING_TOKEN(STR_SCSI_IO), &gEfiScsiIoProtocolGuid, NULL},
1496 {STRING_TOKEN(STR_SCSI_PT_EXT), &gEfiExtScsiPassThruProtocolGuid, NULL},
1497 {STRING_TOKEN(STR_ISCSI), &gEfiIScsiInitiatorNameProtocolGuid, NULL},
1498 {STRING_TOKEN(STR_USB_IO), &gEfiUsbIoProtocolGuid, NULL},
1499 {STRING_TOKEN(STR_USB_HC), &gEfiUsbHcProtocolGuid, NULL},
1500 {STRING_TOKEN(STR_USB_HC2), &gEfiUsb2HcProtocolGuid, NULL},
1501 {STRING_TOKEN(STR_DEBUG_SUPPORT), &gEfiDebugSupportProtocolGuid, NULL},
1502 {STRING_TOKEN(STR_DEBUG_PORT), &gEfiDebugPortProtocolGuid, NULL},
1503 {STRING_TOKEN(STR_DECOMPRESS), &gEfiDecompressProtocolGuid, NULL},
1504 {STRING_TOKEN(STR_ACPI_TABLE), &gEfiAcpiTableProtocolGuid, NULL},
1505 {STRING_TOKEN(STR_EBC_INTERPRETER), &gEfiEbcProtocolGuid, NULL},
1506 {STRING_TOKEN(STR_SNP), &gEfiSimpleNetworkProtocolGuid, NULL},
1507 {STRING_TOKEN(STR_NII), &gEfiNetworkInterfaceIdentifierProtocolGuid, NULL},
1508 {STRING_TOKEN(STR_NII_31), &gEfiNetworkInterfaceIdentifierProtocolGuid_31, NULL},
1509 {STRING_TOKEN(STR_PXE_BC), &gEfiPxeBaseCodeProtocolGuid, NULL},
1510 {STRING_TOKEN(STR_PXE_CB), &gEfiPxeBaseCodeCallbackProtocolGuid, NULL},
1511 {STRING_TOKEN(STR_BIS), &gEfiBisProtocolGuid, NULL},
1512 {STRING_TOKEN(STR_MNP_SB), &gEfiManagedNetworkServiceBindingProtocolGuid, NULL},
1513 {STRING_TOKEN(STR_MNP), &gEfiManagedNetworkProtocolGuid, NULL},
1514 {STRING_TOKEN(STR_ARP_SB), &gEfiArpServiceBindingProtocolGuid, NULL},
1515 {STRING_TOKEN(STR_ARP), &gEfiArpProtocolGuid, NULL},
1516 {STRING_TOKEN(STR_DHCPV4_SB), &gEfiDhcp4ServiceBindingProtocolGuid, NULL},
1517 {STRING_TOKEN(STR_DHCPV4), &gEfiDhcp4ProtocolGuid, NULL},
1518 {STRING_TOKEN(STR_TCPV4_SB), &gEfiTcp4ServiceBindingProtocolGuid, NULL},
1519 {STRING_TOKEN(STR_TCPV4), &gEfiTcp4ProtocolGuid, NULL},
1520 {STRING_TOKEN(STR_IPV4_SB), &gEfiIp4ServiceBindingProtocolGuid, NULL},
1521 {STRING_TOKEN(STR_IPV4), &gEfiIp4ProtocolGuid, NULL},
1522 {STRING_TOKEN(STR_IPV4_CFG), &gEfiIp4ConfigProtocolGuid, NULL},
1523 {STRING_TOKEN(STR_IPV4_CFG2), &gEfiIp4Config2ProtocolGuid, NULL},
1524 {STRING_TOKEN(STR_UDPV4_SB), &gEfiUdp4ServiceBindingProtocolGuid, NULL},
1525 {STRING_TOKEN(STR_UDPV4), &gEfiUdp4ProtocolGuid, NULL},
1526 {STRING_TOKEN(STR_MTFTPV4_SB), &gEfiMtftp4ServiceBindingProtocolGuid, NULL},
1527 {STRING_TOKEN(STR_MTFTPV4), &gEfiMtftp4ProtocolGuid, NULL},
1528 {STRING_TOKEN(STR_AUTH_INFO), &gEfiAuthenticationInfoProtocolGuid, NULL},
1529 {STRING_TOKEN(STR_HASH_SB), &gEfiHashServiceBindingProtocolGuid, NULL},
1530 {STRING_TOKEN(STR_HASH), &gEfiHashProtocolGuid, NULL},
1531 {STRING_TOKEN(STR_HII_FONT), &gEfiHiiFontProtocolGuid, NULL},
1532 {STRING_TOKEN(STR_HII_STRING), &gEfiHiiStringProtocolGuid, NULL},
1533 {STRING_TOKEN(STR_HII_IMAGE), &gEfiHiiImageProtocolGuid, NULL},
1534 {STRING_TOKEN(STR_HII_DATABASE), &gEfiHiiDatabaseProtocolGuid, NULL},
1535 {STRING_TOKEN(STR_HII_CONFIG_ROUT), &gEfiHiiConfigRoutingProtocolGuid, NULL},
1536 {STRING_TOKEN(STR_HII_CONFIG_ACC), &gEfiHiiConfigAccessProtocolGuid, NULL},
1537 {STRING_TOKEN(STR_HII_FORM_BROWSER2), &gEfiFormBrowser2ProtocolGuid, NULL},
1538 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE), &gEfiDriverFamilyOverrideProtocolGuid, NULL},
1539 {STRING_TOKEN(STR_PCD), &gPcdProtocolGuid, NULL},
1540 {STRING_TOKEN(STR_TCG), &gEfiTcgProtocolGuid, NULL},
1541 {STRING_TOKEN(STR_HII_PACKAGE_LIST), &gEfiHiiPackageListProtocolGuid, NULL},
1542
1543 //
1544 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
1545 //
1546 {STRING_TOKEN(STR_SHELL_INTERFACE), &gEfiShellInterfaceGuid, NULL},
1547 {STRING_TOKEN(STR_SHELL_ENV2), &gEfiShellEnvironment2Guid, NULL},
1548 {STRING_TOKEN(STR_SHELL_ENV), &gEfiShellEnvironment2Guid, NULL},
1549 {STRING_TOKEN(STR_DEVICE_IO), &gEfiDeviceIoProtocolGuid, NULL},
1550 {STRING_TOKEN(STR_UGA_DRAW), &gEfiUgaDrawProtocolGuid, NULL},
1551 {STRING_TOKEN(STR_UGA_IO), &gEfiUgaIoProtocolGuid, NULL},
1552 {STRING_TOKEN(STR_ESP), &gEfiPartTypeSystemPartGuid, NULL},
1553 {STRING_TOKEN(STR_GPT_NBR), &gEfiPartTypeLegacyMbrGuid, NULL},
1554 {STRING_TOKEN(STR_DRIVER_CONFIG), &gEfiDriverConfigurationProtocolGuid, NULL},
1555 {STRING_TOKEN(STR_DRIVER_CONFIG2), &gEfiDriverConfiguration2ProtocolGuid, NULL},
1556
1557 //
1558 // these are using local (non-global) definitions to reduce package dependancy.
1559 //
1560 {STRING_TOKEN(STR_ISA_IO), (EFI_GUID*)&EfiIsaIoProtocolGuid, NULL},
1561 {STRING_TOKEN(STR_ISA_ACPI), (EFI_GUID*)&EfiIsaAcpiProtocolGuid, NULL},
1562
1563 //
1564 // the ones under this are GUID identified structs, not protocols
1565 //
1566 {STRING_TOKEN(STR_FILE_INFO), &gEfiFileInfoGuid, NULL},
1567 {STRING_TOKEN(STR_FILE_SYS_INFO), &gEfiFileSystemInfoGuid, NULL},
1568
1569 //
1570 // the ones under this are misc GUIDS.
1571 //
1572 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE), &gEfiGlobalVariableGuid, NULL},
1573
1574 //
1575 // UEFI 2.2
1576 //
1577 {STRING_TOKEN(STR_IP6_SB), &gEfiIp6ServiceBindingProtocolGuid, NULL},
1578 {STRING_TOKEN(STR_IP6), &gEfiIp6ProtocolGuid, NULL},
1579 {STRING_TOKEN(STR_IP6_CONFIG), &gEfiIp6ConfigProtocolGuid, NULL},
1580 {STRING_TOKEN(STR_MTFTP6_SB), &gEfiMtftp6ServiceBindingProtocolGuid, NULL},
1581 {STRING_TOKEN(STR_MTFTP6), &gEfiMtftp6ProtocolGuid, NULL},
1582 {STRING_TOKEN(STR_DHCP6_SB), &gEfiDhcp6ServiceBindingProtocolGuid, NULL},
1583 {STRING_TOKEN(STR_DHCP6), &gEfiDhcp6ProtocolGuid, NULL},
1584 {STRING_TOKEN(STR_UDP6_SB), &gEfiUdp6ServiceBindingProtocolGuid, NULL},
1585 {STRING_TOKEN(STR_UDP6), &gEfiUdp6ProtocolGuid, NULL},
1586 {STRING_TOKEN(STR_TCP6_SB), &gEfiTcp6ServiceBindingProtocolGuid, NULL},
1587 {STRING_TOKEN(STR_TCP6), &gEfiTcp6ProtocolGuid, NULL},
1588 {STRING_TOKEN(STR_VLAN_CONFIG), &gEfiVlanConfigProtocolGuid, NULL},
1589 {STRING_TOKEN(STR_EAP), &gEfiEapProtocolGuid, NULL},
1590 {STRING_TOKEN(STR_EAP_MGMT), &gEfiEapManagementProtocolGuid, NULL},
1591 {STRING_TOKEN(STR_FTP4_SB), &gEfiFtp4ServiceBindingProtocolGuid, NULL},
1592 {STRING_TOKEN(STR_FTP4), &gEfiFtp4ProtocolGuid, NULL},
1593 {STRING_TOKEN(STR_IP_SEC_CONFIG), &gEfiIpSecConfigProtocolGuid, NULL},
1594 {STRING_TOKEN(STR_DH), &gEfiDriverHealthProtocolGuid, NULL},
1595 {STRING_TOKEN(STR_DEF_IMG_LOAD), &gEfiDeferredImageLoadProtocolGuid, NULL},
1596 {STRING_TOKEN(STR_USER_CRED), &gEfiUserCredentialProtocolGuid, NULL},
1597 {STRING_TOKEN(STR_USER_MNGR), &gEfiUserManagerProtocolGuid, NULL},
1598 {STRING_TOKEN(STR_ATA_PASS_THRU), &gEfiAtaPassThruProtocolGuid, NULL},
1599
1600 //
1601 // UEFI 2.3
1602 //
1603 {STRING_TOKEN(STR_FW_MGMT), &gEfiFirmwareManagementProtocolGuid, FirmwareManagementDumpInformation},
1604 {STRING_TOKEN(STR_IP_SEC), &gEfiIpSecProtocolGuid, NULL},
1605 {STRING_TOKEN(STR_IP_SEC2), &gEfiIpSec2ProtocolGuid, NULL},
1606
1607 //
1608 // UEFI 2.3.1
1609 //
1610 {STRING_TOKEN(STR_KMS), &gEfiKmsProtocolGuid, NULL},
1611 {STRING_TOKEN(STR_BLK_IO2), &gEfiBlockIo2ProtocolGuid, NULL},
1612 {STRING_TOKEN(STR_SSC), &gEfiStorageSecurityCommandProtocolGuid, NULL},
1613 {STRING_TOKEN(STR_UCRED2), &gEfiUserCredential2ProtocolGuid, NULL},
1614
1615 //
1616 // UEFI 2.4
1617 //
1618 {STRING_TOKEN(STR_DISK_IO2), &gEfiDiskIo2ProtocolGuid, NULL},
1619 {STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtocolGuid, AdapterInformationDumpInformation},
1620
1621 //
1622 // PI Spec ones
1623 //
1624 {STRING_TOKEN(STR_IDE_CONT_INIT), &gEfiIdeControllerInitProtocolGuid, NULL},
1625 {STRING_TOKEN(STR_DISK_INFO), &gEfiDiskInfoProtocolGuid, NULL},
1626
1627 //
1628 // PI Spec 1.0
1629 //
1630 {STRING_TOKEN(STR_BDS_ARCH), &gEfiBdsArchProtocolGuid, NULL},
1631 {STRING_TOKEN(STR_CPU_ARCH), &gEfiCpuArchProtocolGuid, NULL},
1632 {STRING_TOKEN(STR_MET_ARCH), &gEfiMetronomeArchProtocolGuid, NULL},
1633 {STRING_TOKEN(STR_MON_ARCH), &gEfiMonotonicCounterArchProtocolGuid, NULL},
1634 {STRING_TOKEN(STR_RTC_ARCH), &gEfiRealTimeClockArchProtocolGuid, NULL},
1635 {STRING_TOKEN(STR_RESET_ARCH), &gEfiResetArchProtocolGuid, NULL},
1636 {STRING_TOKEN(STR_RT_ARCH), &gEfiRuntimeArchProtocolGuid, NULL},
1637 {STRING_TOKEN(STR_SEC_ARCH), &gEfiSecurityArchProtocolGuid, NULL},
1638 {STRING_TOKEN(STR_TIMER_ARCH), &gEfiTimerArchProtocolGuid, NULL},
1639 {STRING_TOKEN(STR_VAR_ARCH), &gEfiVariableWriteArchProtocolGuid, NULL},
1640 {STRING_TOKEN(STR_V_ARCH), &gEfiVariableArchProtocolGuid, NULL},
1641 {STRING_TOKEN(STR_SECP), &gEfiSecurityPolicyProtocolGuid, NULL},
1642 {STRING_TOKEN(STR_WDT_ARCH), &gEfiWatchdogTimerArchProtocolGuid, NULL},
1643 {STRING_TOKEN(STR_SCR), &gEfiStatusCodeRuntimeProtocolGuid, NULL},
1644 {STRING_TOKEN(STR_SMB_HC), &gEfiSmbusHcProtocolGuid, NULL},
1645 {STRING_TOKEN(STR_FV_2), &gEfiFirmwareVolume2ProtocolGuid, NULL},
1646 {STRING_TOKEN(STR_FV_BLOCK), &gEfiFirmwareVolumeBlockProtocolGuid, NULL},
1647 {STRING_TOKEN(STR_CAP_ARCH), &gEfiCapsuleArchProtocolGuid, NULL},
1648 {STRING_TOKEN(STR_MP_SERVICE), &gEfiMpServiceProtocolGuid, NULL},
1649 {STRING_TOKEN(STR_HBRAP), &gEfiPciHostBridgeResourceAllocationProtocolGuid, NULL},
1650 {STRING_TOKEN(STR_PCIP), &gEfiPciPlatformProtocolGuid, NULL},
1651 {STRING_TOKEN(STR_PCIO), &gEfiPciOverrideProtocolGuid, NULL},
1652 {STRING_TOKEN(STR_PCIE), &gEfiPciEnumerationCompleteProtocolGuid, NULL},
1653 {STRING_TOKEN(STR_IPCID), &gEfiIncompatiblePciDeviceSupportProtocolGuid, NULL},
1654 {STRING_TOKEN(STR_PCIHPI), &gEfiPciHotPlugInitProtocolGuid, NULL},
1655 {STRING_TOKEN(STR_PCIHPR), &gEfiPciHotPlugRequestProtocolGuid, NULL},
1656 {STRING_TOKEN(STR_SMBIOS), &gEfiSmbiosProtocolGuid, NULL},
1657 {STRING_TOKEN(STR_S3_SAVE), &gEfiS3SaveStateProtocolGuid, NULL},
1658 {STRING_TOKEN(STR_S3_S_SMM), &gEfiS3SmmSaveStateProtocolGuid, NULL},
1659 {STRING_TOKEN(STR_RSC), &gEfiRscHandlerProtocolGuid, NULL},
1660 {STRING_TOKEN(STR_S_RSC), &gEfiSmmRscHandlerProtocolGuid, NULL},
1661 {STRING_TOKEN(STR_ACPI_SDT), &gEfiAcpiSdtProtocolGuid, NULL},
1662 {STRING_TOKEN(STR_SIO), &gEfiSioProtocolGuid, NULL},
1663 {STRING_TOKEN(STR_S_CPU2), &gEfiSmmCpuIo2ProtocolGuid, NULL},
1664 {STRING_TOKEN(STR_S_BASE2), &gEfiSmmBase2ProtocolGuid, NULL},
1665 {STRING_TOKEN(STR_S_ACC_2), &gEfiSmmAccess2ProtocolGuid, NULL},
1666 {STRING_TOKEN(STR_S_CON_2), &gEfiSmmControl2ProtocolGuid, NULL},
1667 {STRING_TOKEN(STR_S_CONFIG), &gEfiSmmConfigurationProtocolGuid, NULL},
1668 {STRING_TOKEN(STR_S_RTL), &gEfiSmmReadyToLockProtocolGuid, NULL},
1669 {STRING_TOKEN(STR_DS_RTL), &gEfiDxeSmmReadyToLockProtocolGuid, NULL},
1670 {STRING_TOKEN(STR_S_COMM), &gEfiSmmCommunicationProtocolGuid, NULL},
1671 {STRING_TOKEN(STR_S_STAT), &gEfiSmmStatusCodeProtocolGuid, NULL},
1672 {STRING_TOKEN(STR_S_CPU), &gEfiSmmCpuProtocolGuid, NULL},
1673 {STRING_TOKEN(STR_S_PCIRBIO), &gEfiPciRootBridgeIoProtocolGuid, NULL},
1674 {STRING_TOKEN(STR_S_SWD), &gEfiSmmSwDispatch2ProtocolGuid, NULL},
1675 {STRING_TOKEN(STR_S_SXD), &gEfiSmmSxDispatch2ProtocolGuid, NULL},
1676 {STRING_TOKEN(STR_S_PTD2), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid, NULL},
1677 {STRING_TOKEN(STR_S_UD2), &gEfiSmmUsbDispatch2ProtocolGuid, NULL},
1678 {STRING_TOKEN(STR_S_GD2), &gEfiSmmGpiDispatch2ProtocolGuid, NULL},
1679 {STRING_TOKEN(STR_S_SBD2), &gEfiSmmStandbyButtonDispatch2ProtocolGuid, NULL},
1680 {STRING_TOKEN(STR_S_PBD2), &gEfiSmmPowerButtonDispatch2ProtocolGuid, NULL},
1681 {STRING_TOKEN(STR_S_ITD2), &gEfiSmmIoTrapDispatch2ProtocolGuid, NULL},
1682 {STRING_TOKEN(STR_PCD), &gEfiPcdProtocolGuid, NULL},
1683 {STRING_TOKEN(STR_FVB2), &gEfiFirmwareVolumeBlock2ProtocolGuid, NULL},
1684 {STRING_TOKEN(STR_CPUIO2), &gEfiCpuIo2ProtocolGuid, NULL},
1685 {STRING_TOKEN(STR_LEGACY_R2), &gEfiLegacyRegion2ProtocolGuid, NULL},
1686 {STRING_TOKEN(STR_SAL_MIP), &gEfiSalMcaInitPmiProtocolGuid, NULL},
1687 {STRING_TOKEN(STR_ES_BS), &gEfiExtendedSalBootServiceProtocolGuid, NULL},
1688 {STRING_TOKEN(STR_ES_BIO), &gEfiExtendedSalBaseIoServicesProtocolGuid, NULL},
1689 {STRING_TOKEN(STR_ES_STALL), &gEfiExtendedSalStallServicesProtocolGuid, NULL},
1690 {STRING_TOKEN(STR_ES_RTC), &gEfiExtendedSalRtcServicesProtocolGuid, NULL},
1691 {STRING_TOKEN(STR_ES_VS), &gEfiExtendedSalVariableServicesProtocolGuid, NULL},
1692 {STRING_TOKEN(STR_ES_MTC), &gEfiExtendedSalMtcServicesProtocolGuid, NULL},
1693 {STRING_TOKEN(STR_ES_RESET), &gEfiExtendedSalResetServicesProtocolGuid, NULL},
1694 {STRING_TOKEN(STR_ES_SC), &gEfiExtendedSalStatusCodeServicesProtocolGuid, NULL},
1695 {STRING_TOKEN(STR_ES_FBS), &gEfiExtendedSalFvBlockServicesProtocolGuid, NULL},
1696 {STRING_TOKEN(STR_ES_MP), &gEfiExtendedSalMpServicesProtocolGuid, NULL},
1697 {STRING_TOKEN(STR_ES_PAL), &gEfiExtendedSalPalServicesProtocolGuid, NULL},
1698 {STRING_TOKEN(STR_ES_BASE), &gEfiExtendedSalBaseServicesProtocolGuid, NULL},
1699 {STRING_TOKEN(STR_ES_MCA), &gEfiExtendedSalMcaServicesProtocolGuid, NULL},
1700 {STRING_TOKEN(STR_ES_PCI), &gEfiExtendedSalPciServicesProtocolGuid, NULL},
1701 {STRING_TOKEN(STR_ES_CACHE), &gEfiExtendedSalCacheServicesProtocolGuid, NULL},
1702 {STRING_TOKEN(STR_ES_MCA_LOG), &gEfiExtendedSalMcaLogServicesProtocolGuid, NULL},
1703 {STRING_TOKEN(STR_S2ARCH), &gEfiSecurity2ArchProtocolGuid, NULL},
1704 {STRING_TOKEN(STR_EODXE), &gEfiSmmEndOfDxeProtocolGuid, NULL},
1705 {STRING_TOKEN(STR_ISAHC), &gEfiIsaHcProtocolGuid, NULL},
1706 {STRING_TOKEN(STR_ISAHC_B), &gEfiIsaHcServiceBindingProtocolGuid, NULL},
1707 {STRING_TOKEN(STR_SIO_C), &gEfiSioControlProtocolGuid, NULL},
1708 {STRING_TOKEN(STR_GET_PCD), &gEfiGetPcdInfoProtocolGuid, NULL},
1709 {STRING_TOKEN(STR_I2C_M), &gEfiI2cMasterProtocolGuid, NULL},
1710 {STRING_TOKEN(STR_I2CIO), &gEfiI2cIoProtocolGuid, NULL},
1711 {STRING_TOKEN(STR_I2CEN), &gEfiI2cEnumerateProtocolGuid, NULL},
1712 {STRING_TOKEN(STR_I2C_H), &gEfiI2cHostProtocolGuid, NULL},
1713 {STRING_TOKEN(STR_I2C_BCM), &gEfiI2cBusConfigurationManagementProtocolGuid, NULL},
1714 {STRING_TOKEN(STR_TREE), &gEfiTrEEProtocolGuid, NULL},
1715 {STRING_TOKEN(STR_TCG2), &gEfiTcg2ProtocolGuid, NULL},
1716 {STRING_TOKEN(STR_TIMESTAMP), &gEfiTimestampProtocolGuid, NULL},
1717 {STRING_TOKEN(STR_RNG), &gEfiRngProtocolGuid, NULL},
1718 {STRING_TOKEN(STR_NVMEPT), &gEfiNvmExpressPassThruProtocolGuid, NULL},
1719 {STRING_TOKEN(STR_H2_SB), &gEfiHash2ServiceBindingProtocolGuid, NULL},
1720 {STRING_TOKEN(STR_HASH2), &gEfiHash2ProtocolGuid, NULL},
1721 {STRING_TOKEN(STR_BIO_C), &gEfiBlockIoCryptoProtocolGuid, NULL},
1722 {STRING_TOKEN(STR_SCR), &gEfiSmartCardReaderProtocolGuid, NULL},
1723 {STRING_TOKEN(STR_SCE), &gEfiSmartCardEdgeProtocolGuid, NULL},
1724 {STRING_TOKEN(STR_USB_FIO), &gEfiUsbFunctionIoProtocolGuid, NULL},
1725 {STRING_TOKEN(STR_BC_HC), &gEfiBluetoothHcProtocolGuid, NULL},
1726 {STRING_TOKEN(STR_BC_IO_SB), &gEfiBluetoothIoServiceBindingProtocolGuid, NULL},
1727 {STRING_TOKEN(STR_BC_IO), &gEfiBluetoothIoProtocolGuid, NULL},
1728 {STRING_TOKEN(STR_BC_C), &gEfiBluetoothConfigProtocolGuid, NULL},
1729 {STRING_TOKEN(STR_REG_EXP), &gEfiRegularExpressionProtocolGuid, NULL},
1730 {STRING_TOKEN(STR_B_MGR_P), &gEfiBootManagerPolicyProtocolGuid, NULL},
1731 {STRING_TOKEN(STR_CKH), &gEfiConfigKeywordHandlerProtocolGuid, NULL},
1732 {STRING_TOKEN(STR_WIFI), &gEfiWiFiProtocolGuid, NULL},
1733 {STRING_TOKEN(STR_EAP_M), &gEfiEapManagement2ProtocolGuid, NULL},
1734 {STRING_TOKEN(STR_EAP_C), &gEfiEapConfigurationProtocolGuid, NULL},
1735 {STRING_TOKEN(STR_PKCS7), &gEfiPkcs7VerifyProtocolGuid, NULL},
1736 {STRING_TOKEN(STR_NET_DNS4_SB), &gEfiDns4ServiceBindingProtocolGuid, NULL},
1737 {STRING_TOKEN(STR_NET_DNS4), &gEfiDns4ProtocolGuid, NULL},
1738 {STRING_TOKEN(STR_NET_DNS6_SB), &gEfiDns6ServiceBindingProtocolGuid, NULL},
1739 {STRING_TOKEN(STR_NET_DNS6), &gEfiDns6ProtocolGuid, NULL},
1740 {STRING_TOKEN(STR_NET_HTTP_SB), &gEfiHttpServiceBindingProtocolGuid, NULL},
1741 {STRING_TOKEN(STR_NET_HTTP), &gEfiHttpProtocolGuid, NULL},
1742 {STRING_TOKEN(STR_NET_HTTP_U), &gEfiHttpUtilitiesProtocolGuid, NULL},
1743 {STRING_TOKEN(STR_REST), &gEfiRestProtocolGuid, NULL},
1744
1745 //
1746 // UEFI Shell Spec 2.0
1747 //
1748 {STRING_TOKEN(STR_SHELL_PARAMETERS), &gEfiShellParametersProtocolGuid, NULL},
1749 {STRING_TOKEN(STR_SHELL), &gEfiShellProtocolGuid, NULL},
1750
1751 //
1752 // UEFI Shell Spec 2.1
1753 //
1754 {STRING_TOKEN(STR_SHELL_DYNAMIC), &gEfiShellDynamicCommandProtocolGuid, NULL},
1755
1756 //
1757 // Misc
1758 //
1759 {STRING_TOKEN(STR_PCDINFOPROT), &gGetPcdInfoProtocolGuid, NULL},
1760
1761 //
1762 // terminator
1763 //
1764 {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},
1765 };
1766
1767 /**
1768 Function to get the node for a protocol or struct from it's GUID.
1769
1770 if Guid is NULL, then ASSERT.
1771
1772 @param[in] Guid The GUID to look for the name of.
1773
1774 @return The node.
1775 **/
1776 CONST GUID_INFO_BLOCK *
1777 EFIAPI
1778 InternalShellGetNodeFromGuid(
1779 IN CONST EFI_GUID* Guid
1780 )
1781 {
1782 CONST GUID_INFO_BLOCK *ListWalker;
1783 UINTN LoopCount;
1784
1785 ASSERT(Guid != NULL);
1786
1787 for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
1788 if (CompareGuid(ListWalker->GuidId, Guid)) {
1789 return (ListWalker);
1790 }
1791 }
1792
1793 if (PcdGetBool(PcdShellIncludeNtGuids)) {
1794 for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
1795 if (CompareGuid(ListWalker->GuidId, Guid)) {
1796 return (ListWalker);
1797 }
1798 }
1799 }
1800 for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
1801 if (CompareGuid(ListWalker->GuidId, Guid)) {
1802 return (ListWalker);
1803 }
1804 }
1805 return (NULL);
1806 }
1807
1808 /**
1809 Function to add a new GUID/Name mapping.
1810
1811 @param[in] Guid The Guid
1812 @param[in] NameID The STRING id of the HII string to use
1813 @param[in] DumpFunc The pointer to the dump function
1814
1815
1816 @retval EFI_SUCCESS The operation was sucessful
1817 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1818 @retval EFI_INVALID_PARAMETER Guid NameId was invalid
1819 **/
1820 EFI_STATUS
1821 EFIAPI
1822 InsertNewGuidNameMapping(
1823 IN CONST EFI_GUID *Guid,
1824 IN CONST EFI_STRING_ID NameID,
1825 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
1826 )
1827 {
1828 ASSERT(Guid != NULL);
1829 ASSERT(NameID != 0);
1830
1831 GuidList = ReallocatePool(GuidListCount * sizeof(GUID_INFO_BLOCK), GuidListCount+1 * sizeof(GUID_INFO_BLOCK), GuidList);
1832 if (GuidList == NULL) {
1833 GuidListCount = 0;
1834 return (EFI_OUT_OF_RESOURCES);
1835 }
1836 GuidListCount++;
1837
1838 GuidList[GuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);
1839 GuidList[GuidListCount - 1].StringId = NameID;
1840 GuidList[GuidListCount - 1].DumpInfo = DumpFunc;
1841
1842 if (GuidList[GuidListCount - 1].GuidId == NULL) {
1843 return (EFI_OUT_OF_RESOURCES);
1844 }
1845
1846 return (EFI_SUCCESS);
1847 }
1848
1849 /**
1850 Function to add a new GUID/Name mapping.
1851
1852 This cannot overwrite an existing mapping.
1853
1854 @param[in] Guid The Guid
1855 @param[in] TheName The Guid's name
1856 @param[in] Lang RFC4646 language code list or NULL
1857
1858 @retval EFI_SUCCESS The operation was sucessful
1859 @retval EFI_ACCESS_DENIED There was a duplicate
1860 @retval EFI_OUT_OF_RESOURCES A memory allocation failed
1861 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
1862 **/
1863 EFI_STATUS
1864 EFIAPI
1865 AddNewGuidNameMapping(
1866 IN CONST EFI_GUID *Guid,
1867 IN CONST CHAR16 *TheName,
1868 IN CONST CHAR8 *Lang OPTIONAL
1869 )
1870 {
1871 EFI_STRING_ID NameID;
1872
1873 HandleParsingHiiInit();
1874
1875 if (Guid == NULL || TheName == NULL){
1876 return (EFI_INVALID_PARAMETER);
1877 }
1878
1879 if ((InternalShellGetNodeFromGuid(Guid)) != NULL) {
1880 return (EFI_ACCESS_DENIED);
1881 }
1882
1883 NameID = HiiSetString(mHandleParsingHiiHandle, 0, (CHAR16*)TheName, Lang);
1884 if (NameID == 0) {
1885 return (EFI_OUT_OF_RESOURCES);
1886 }
1887
1888 return (InsertNewGuidNameMapping(Guid, NameID, NULL));
1889 }
1890
1891 /**
1892 Function to get the name of a protocol or struct from it's GUID.
1893
1894 if Guid is NULL, then ASSERT.
1895
1896 @param[in] Guid The GUID to look for the name of.
1897 @param[in] Lang The language to use.
1898
1899 @return pointer to string of the name. The caller
1900 is responsible to free this memory.
1901 **/
1902 CHAR16*
1903 EFIAPI
1904 GetStringNameFromGuid(
1905 IN CONST EFI_GUID *Guid,
1906 IN CONST CHAR8 *Lang OPTIONAL
1907 )
1908 {
1909 CONST GUID_INFO_BLOCK *Id;
1910
1911 HandleParsingHiiInit();
1912
1913 Id = InternalShellGetNodeFromGuid(Guid);
1914 return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang));
1915 }
1916
1917 /**
1918 Function to dump protocol information from a handle.
1919
1920 This function will return a allocated string buffer containing the
1921 information. The caller is responsible for freeing the memory.
1922
1923 If Guid is NULL, ASSERT().
1924 If TheHandle is NULL, ASSERT().
1925
1926 @param[in] TheHandle The handle to dump information from.
1927 @param[in] Guid The GUID of the protocol to dump.
1928 @param[in] Verbose TRUE for extra info. FALSE otherwise.
1929
1930 @return The pointer to string.
1931 @retval NULL An error was encountered.
1932 **/
1933 CHAR16*
1934 EFIAPI
1935 GetProtocolInformationDump(
1936 IN CONST EFI_HANDLE TheHandle,
1937 IN CONST EFI_GUID *Guid,
1938 IN CONST BOOLEAN Verbose
1939 )
1940 {
1941 CONST GUID_INFO_BLOCK *Id;
1942
1943 ASSERT(TheHandle != NULL);
1944 ASSERT(Guid != NULL);
1945
1946 if (TheHandle == NULL || Guid == NULL) {
1947 return (NULL);
1948 }
1949
1950 Id = InternalShellGetNodeFromGuid(Guid);
1951 if (Id != NULL && Id->DumpInfo != NULL) {
1952 return (Id->DumpInfo(TheHandle, Verbose));
1953 }
1954 return (NULL);
1955 }
1956
1957 /**
1958 Function to get the Guid for a protocol or struct based on it's string name.
1959
1960 do not modify the returned Guid.
1961
1962 @param[in] Name The pointer to the string name.
1963 @param[in] Lang The pointer to the language code.
1964 @param[out] Guid The pointer to the Guid.
1965
1966 @retval EFI_SUCCESS The operation was sucessful.
1967 **/
1968 EFI_STATUS
1969 EFIAPI
1970 GetGuidFromStringName(
1971 IN CONST CHAR16 *Name,
1972 IN CONST CHAR8 *Lang OPTIONAL,
1973 OUT EFI_GUID **Guid
1974 )
1975 {
1976 CONST GUID_INFO_BLOCK *ListWalker;
1977 CHAR16 *String;
1978 UINTN LoopCount;
1979
1980 HandleParsingHiiInit();
1981
1982 ASSERT(Guid != NULL);
1983 if (Guid == NULL) {
1984 return (EFI_INVALID_PARAMETER);
1985 }
1986 *Guid = NULL;
1987
1988 if (PcdGetBool(PcdShellIncludeNtGuids)) {
1989 for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
1990 String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
1991 if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
1992 *Guid = ListWalker->GuidId;
1993 }
1994 SHELL_FREE_NON_NULL(String);
1995 if (*Guid != NULL) {
1996 return (EFI_SUCCESS);
1997 }
1998 }
1999 }
2000 for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
2001 String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
2002 if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
2003 *Guid = ListWalker->GuidId;
2004 }
2005 SHELL_FREE_NON_NULL(String);
2006 if (*Guid != NULL) {
2007 return (EFI_SUCCESS);
2008 }
2009 }
2010
2011 for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
2012 String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
2013 if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
2014 *Guid = ListWalker->GuidId;
2015 }
2016 SHELL_FREE_NON_NULL(String);
2017 if (*Guid != NULL) {
2018 return (EFI_SUCCESS);
2019 }
2020 }
2021
2022 return (EFI_NOT_FOUND);
2023 }
2024
2025 /**
2026 Get best support language for this driver.
2027
2028 First base on the user input language to search, second base on the current
2029 platform used language to search, third get the first language from the
2030 support language list. The caller need to free the buffer of the best language.
2031
2032 @param[in] SupportedLanguages The support languages for this driver.
2033 @param[in] InputLanguage The user input language.
2034 @param[in] Iso639Language Whether get language for ISO639.
2035
2036 @return The best support language for this driver.
2037 **/
2038 CHAR8 *
2039 EFIAPI
2040 GetBestLanguageForDriver (
2041 IN CONST CHAR8 *SupportedLanguages,
2042 IN CONST CHAR8 *InputLanguage,
2043 IN BOOLEAN Iso639Language
2044 )
2045 {
2046 CHAR8 *LanguageVariable;
2047 CHAR8 *BestLanguage;
2048
2049 GetVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&LanguageVariable, NULL);
2050
2051 BestLanguage = GetBestLanguage(
2052 SupportedLanguages,
2053 Iso639Language,
2054 (InputLanguage != NULL) ? InputLanguage : "",
2055 (LanguageVariable != NULL) ? LanguageVariable : "",
2056 SupportedLanguages,
2057 NULL
2058 );
2059
2060 if (LanguageVariable != NULL) {
2061 FreePool (LanguageVariable);
2062 }
2063
2064 return BestLanguage;
2065 }
2066
2067 /**
2068 Function to retrieve the driver name (if possible) from the ComponentName or
2069 ComponentName2 protocol
2070
2071 @param[in] TheHandle The driver handle to get the name of.
2072 @param[in] Language The language to use.
2073
2074 @retval NULL The name could not be found.
2075 @return A pointer to the string name. Do not de-allocate the memory.
2076 **/
2077 CONST CHAR16*
2078 EFIAPI
2079 GetStringNameFromHandle(
2080 IN CONST EFI_HANDLE TheHandle,
2081 IN CONST CHAR8 *Language
2082 )
2083 {
2084 EFI_COMPONENT_NAME2_PROTOCOL *CompNameStruct;
2085 EFI_STATUS Status;
2086 CHAR16 *RetVal;
2087 CHAR8 *BestLang;
2088
2089 BestLang = NULL;
2090
2091 Status = gBS->OpenProtocol(
2092 TheHandle,
2093 &gEfiComponentName2ProtocolGuid,
2094 (VOID**)&CompNameStruct,
2095 gImageHandle,
2096 NULL,
2097 EFI_OPEN_PROTOCOL_GET_PROTOCOL);
2098 if (!EFI_ERROR(Status)) {
2099 BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
2100 Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
2101 if (BestLang != NULL) {
2102 FreePool (BestLang);
2103 BestLang = NULL;
2104 }
2105 if (!EFI_ERROR(Status)) {
2106 return (RetVal);
2107 }
2108 }
2109 Status = gBS->OpenProtocol(
2110 TheHandle,
2111 &gEfiComponentNameProtocolGuid,
2112 (VOID**)&CompNameStruct,
2113 gImageHandle,
2114 NULL,
2115 EFI_OPEN_PROTOCOL_GET_PROTOCOL);
2116 if (!EFI_ERROR(Status)) {
2117 BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
2118 Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
2119 if (BestLang != NULL) {
2120 FreePool (BestLang);
2121 }
2122 if (!EFI_ERROR(Status)) {
2123 return (RetVal);
2124 }
2125 }
2126 return (NULL);
2127 }
2128
2129 /**
2130 Function to initialize the file global mHandleList object for use in
2131 vonverting handles to index and index to handle.
2132
2133 @retval EFI_SUCCESS The operation was successful.
2134 **/
2135 EFI_STATUS
2136 EFIAPI
2137 InternalShellInitHandleList(
2138 VOID
2139 )
2140 {
2141 EFI_STATUS Status;
2142 EFI_HANDLE *HandleBuffer;
2143 UINTN HandleCount;
2144 HANDLE_LIST *ListWalker;
2145
2146 if (mHandleList.NextIndex != 0) {
2147 return EFI_SUCCESS;
2148 }
2149 InitializeListHead(&mHandleList.List.Link);
2150 mHandleList.NextIndex = 1;
2151 Status = gBS->LocateHandleBuffer (
2152 AllHandles,
2153 NULL,
2154 NULL,
2155 &HandleCount,
2156 &HandleBuffer
2157 );
2158 ASSERT_EFI_ERROR(Status);
2159 if (EFI_ERROR(Status)) {
2160 return (Status);
2161 }
2162 for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){
2163 ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
2164 ASSERT(ListWalker != NULL);
2165 ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex-1];
2166 ListWalker->TheIndex = mHandleList.NextIndex;
2167 InsertTailList(&mHandleList.List.Link,&ListWalker->Link);
2168 }
2169 FreePool(HandleBuffer);
2170 return (EFI_SUCCESS);
2171 }
2172
2173 /**
2174 Function to retrieve the human-friendly index of a given handle. If the handle
2175 does not have a index one will be automatically assigned. The index value is valid
2176 until the termination of the shell application.
2177
2178 @param[in] TheHandle The handle to retrieve an index for.
2179
2180 @retval 0 A memory allocation failed.
2181 @return The index of the handle.
2182
2183 **/
2184 UINTN
2185 EFIAPI
2186 ConvertHandleToHandleIndex(
2187 IN CONST EFI_HANDLE TheHandle
2188 )
2189 {
2190 EFI_STATUS Status;
2191 EFI_GUID **ProtocolBuffer;
2192 UINTN ProtocolCount;
2193 HANDLE_LIST *ListWalker;
2194
2195 if (TheHandle == NULL) {
2196 return 0;
2197 }
2198
2199 InternalShellInitHandleList();
2200
2201 for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)
2202 ; !IsNull(&mHandleList.List.Link,&ListWalker->Link)
2203 ; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
2204 ){
2205 if (ListWalker->TheHandle == TheHandle) {
2206 //
2207 // Verify that TheHandle is still present in the Handle Database
2208 //
2209 Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
2210 if (EFI_ERROR (Status)) {
2211 //
2212 // TheHandle is not present in the Handle Database, so delete from the handle list
2213 //
2214 RemoveEntryList (&ListWalker->Link);
2215 return 0;
2216 }
2217 FreePool (ProtocolBuffer);
2218 return (ListWalker->TheIndex);
2219 }
2220 }
2221
2222 //
2223 // Verify that TheHandle is valid handle
2224 //
2225 Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
2226 if (EFI_ERROR (Status)) {
2227 //
2228 // TheHandle is not valid, so do not add to handle list
2229 //
2230 return 0;
2231 }
2232 FreePool (ProtocolBuffer);
2233
2234 ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
2235 ASSERT(ListWalker != NULL);
2236 ListWalker->TheHandle = TheHandle;
2237 ListWalker->TheIndex = mHandleList.NextIndex++;
2238 InsertTailList(&mHandleList.List.Link,&ListWalker->Link);
2239 return (ListWalker->TheIndex);
2240 }
2241
2242
2243
2244 /**
2245 Function to retrieve the EFI_HANDLE from the human-friendly index.
2246
2247 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
2248
2249 @retval NULL The index was invalid.
2250 @return The EFI_HANDLE that index represents.
2251
2252 **/
2253 EFI_HANDLE
2254 EFIAPI
2255 ConvertHandleIndexToHandle(
2256 IN CONST UINTN TheIndex
2257 )
2258 {
2259 EFI_STATUS Status;
2260 EFI_GUID **ProtocolBuffer;
2261 UINTN ProtocolCount;
2262 HANDLE_LIST *ListWalker;
2263
2264 InternalShellInitHandleList();
2265
2266 if (TheIndex >= mHandleList.NextIndex) {
2267 return NULL;
2268 }
2269
2270 for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)
2271 ; !IsNull(&mHandleList.List.Link,&ListWalker->Link)
2272 ; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
2273 ){
2274 if (ListWalker->TheIndex == TheIndex && ListWalker->TheHandle != NULL) {
2275 //
2276 // Verify that LinkWalker->TheHandle is valid handle
2277 //
2278 Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);
2279 if (EFI_ERROR (Status)) {
2280 //
2281 // TheHandle is not valid, so do not add to handle list
2282 //
2283 ListWalker->TheHandle = NULL;
2284 }
2285 return (ListWalker->TheHandle);
2286 }
2287 }
2288 return NULL;
2289 }
2290
2291 /**
2292 Gets all the related EFI_HANDLEs based on the mask supplied.
2293
2294 This function scans all EFI_HANDLES in the UEFI environment's handle database
2295 and returns the ones with the specified relationship (Mask) to the specified
2296 controller handle.
2297
2298 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2299 If MatchingHandleCount is NULL, then ASSERT.
2300
2301 If MatchingHandleBuffer is not NULL upon a successful return the memory must be
2302 caller freed.
2303
2304 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
2305 @param[in] ControllerHandle The handle with Device Path protocol on it.
2306 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
2307 MatchingHandleBuffer.
2308 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
2309 EFI_HANDLEs with a terminating NULL EFI_HANDLE.
2310 @param[out] HandleType An array of type information.
2311
2312 @retval EFI_SUCCESS The operation was successful, and any related handles
2313 are in MatchingHandleBuffer.
2314 @retval EFI_NOT_FOUND No matching handles were found.
2315 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2316 **/
2317 EFI_STATUS
2318 EFIAPI
2319 ParseHandleDatabaseByRelationshipWithType (
2320 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
2321 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
2322 IN UINTN *HandleCount,
2323 OUT EFI_HANDLE **HandleBuffer,
2324 OUT UINTN **HandleType
2325 )
2326 {
2327 EFI_STATUS Status;
2328 UINTN HandleIndex;
2329 EFI_GUID **ProtocolGuidArray;
2330 UINTN ArrayCount;
2331 UINTN ProtocolIndex;
2332 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;
2333 UINTN OpenInfoCount;
2334 UINTN OpenInfoIndex;
2335 UINTN ChildIndex;
2336 INTN DriverBindingHandleIndex;
2337
2338 ASSERT(HandleCount != NULL);
2339 ASSERT(HandleBuffer != NULL);
2340 ASSERT(HandleType != NULL);
2341 ASSERT(DriverBindingHandle != NULL || ControllerHandle != NULL);
2342
2343 *HandleCount = 0;
2344 *HandleBuffer = NULL;
2345 *HandleType = NULL;
2346
2347 //
2348 // Retrieve the list of all handles from the handle database
2349 //
2350 Status = gBS->LocateHandleBuffer (
2351 AllHandles,
2352 NULL,
2353 NULL,
2354 HandleCount,
2355 HandleBuffer
2356 );
2357 if (EFI_ERROR (Status)) {
2358 return (Status);
2359 }
2360
2361 *HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
2362 ASSERT(*HandleType != NULL);
2363
2364 DriverBindingHandleIndex = -1;
2365 for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
2366 if (DriverBindingHandle != NULL && (*HandleBuffer)[HandleIndex] == DriverBindingHandle) {
2367 DriverBindingHandleIndex = (INTN)HandleIndex;
2368 }
2369 }
2370
2371 for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
2372 //
2373 // Retrieve the list of all the protocols on each handle
2374 //
2375 Status = gBS->ProtocolsPerHandle (
2376 (*HandleBuffer)[HandleIndex],
2377 &ProtocolGuidArray,
2378 &ArrayCount
2379 );
2380 if (EFI_ERROR (Status)) {
2381 continue;
2382 }
2383
2384 for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
2385
2386 //
2387 // Set the bit describing what this handle has
2388 //
2389 if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) {
2390 (*HandleType)[HandleIndex] |= (UINTN)HR_IMAGE_HANDLE;
2391 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) {
2392 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_BINDING_HANDLE;
2393 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {
2394 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;
2395 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {
2396 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;
2397 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) {
2398 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;
2399 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) {
2400 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;
2401 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) {
2402 (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;
2403 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) {
2404 (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;
2405 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) {
2406 (*HandleType)[HandleIndex] |= (UINTN)HR_DEVICE_HANDLE;
2407 } else {
2408 DEBUG_CODE_BEGIN();
2409 ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]);
2410 DEBUG_CODE_END();
2411 }
2412 //
2413 // Retrieve the list of agents that have opened each protocol
2414 //
2415 Status = gBS->OpenProtocolInformation (
2416 (*HandleBuffer)[HandleIndex],
2417 ProtocolGuidArray[ProtocolIndex],
2418 &OpenInfo,
2419 &OpenInfoCount
2420 );
2421 if (EFI_ERROR (Status)) {
2422 continue;
2423 }
2424
2425 if (ControllerHandle == NULL) {
2426 //
2427 // ControllerHandle == NULL and DriverBindingHandle != NULL.
2428 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
2429 //
2430 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
2431 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
2432 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
2433 if (DriverBindingHandleIndex != -1) {
2434 (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;
2435 }
2436 }
2437 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
2438 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
2439 if (DriverBindingHandleIndex != -1) {
2440 (*HandleType)[DriverBindingHandleIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);
2441 }
2442 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
2443 if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
2444 (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
2445 }
2446 }
2447 }
2448 }
2449 }
2450 if (DriverBindingHandle == NULL && ControllerHandle != NULL) {
2451 if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
2452 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
2453 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
2454 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
2455 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
2456 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
2457 (*HandleType)[ChildIndex] |= (UINTN)HR_DEVICE_DRIVER;
2458 }
2459 }
2460 }
2461 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
2462 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
2463 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
2464 (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);
2465 }
2466 if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
2467 (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
2468 }
2469 }
2470 }
2471 }
2472 } else {
2473 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
2474 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
2475 if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
2476 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
2477 }
2478 }
2479 }
2480 }
2481 }
2482 if (DriverBindingHandle != NULL && ControllerHandle != NULL) {
2483 if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
2484 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
2485 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
2486 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
2487 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
2488 if (DriverBindingHandleIndex != -1) {
2489 (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;
2490 }
2491 }
2492 }
2493 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
2494 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
2495 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
2496 if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
2497 (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
2498 }
2499 }
2500 }
2501
2502 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
2503 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
2504 (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);
2505 }
2506 }
2507 }
2508 }
2509 } else {
2510 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
2511 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
2512 if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
2513 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
2514 }
2515 }
2516 }
2517 }
2518 }
2519 FreePool (OpenInfo);
2520 }
2521 FreePool (ProtocolGuidArray);
2522 }
2523 return EFI_SUCCESS;
2524 }
2525
2526 /**
2527 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
2528 supplied.
2529
2530 This function will scan all EFI_HANDLES in the UEFI environment's handle database
2531 and return all the ones with the specified relationship (Mask) to the specified
2532 controller handle.
2533
2534 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
2535 If MatchingHandleCount is NULL, then ASSERT.
2536
2537 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
2538 caller freed.
2539
2540 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
2541 on it.
2542 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
2543 @param[in] Mask Mask of what relationship(s) is desired.
2544 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
2545 MatchingHandleBuffer.
2546 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
2547 EFI_HANDLEs and a terminating NULL EFI_HANDLE.
2548
2549 @retval EFI_SUCCESS The operation was sucessful and any related handles
2550 are in MatchingHandleBuffer;
2551 @retval EFI_NOT_FOUND No matching handles were found.
2552 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
2553 **/
2554 EFI_STATUS
2555 EFIAPI
2556 ParseHandleDatabaseByRelationship (
2557 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
2558 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
2559 IN CONST UINTN Mask,
2560 IN UINTN *MatchingHandleCount,
2561 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
2562 )
2563 {
2564 EFI_STATUS Status;
2565 UINTN HandleCount;
2566 EFI_HANDLE *HandleBuffer;
2567 UINTN *HandleType;
2568 UINTN HandleIndex;
2569
2570 ASSERT(MatchingHandleCount != NULL);
2571 ASSERT(DriverBindingHandle != NULL || ControllerHandle != NULL);
2572
2573 if ((Mask & HR_VALID_MASK) != Mask) {
2574 return (EFI_INVALID_PARAMETER);
2575 }
2576
2577 if ((Mask & HR_CHILD_HANDLE) != 0 && DriverBindingHandle == NULL) {
2578 return (EFI_INVALID_PARAMETER);
2579 }
2580
2581 *MatchingHandleCount = 0;
2582 if (MatchingHandleBuffer != NULL) {
2583 *MatchingHandleBuffer = NULL;
2584 }
2585
2586 HandleBuffer = NULL;
2587 HandleType = NULL;
2588
2589 Status = ParseHandleDatabaseByRelationshipWithType (
2590 DriverBindingHandle,
2591 ControllerHandle,
2592 &HandleCount,
2593 &HandleBuffer,
2594 &HandleType
2595 );
2596 if (!EFI_ERROR (Status)) {
2597 //
2598 // Count the number of handles that match the attributes in Mask
2599 //
2600 for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
2601 if ((HandleType[HandleIndex] & Mask) == Mask) {
2602 (*MatchingHandleCount)++;
2603 }
2604 }
2605 //
2606 // If no handles match the attributes in Mask then return EFI_NOT_FOUND
2607 //
2608 if (*MatchingHandleCount == 0) {
2609 Status = EFI_NOT_FOUND;
2610 } else {
2611
2612 if (MatchingHandleBuffer == NULL) {
2613 //
2614 // Someone just wanted the count...
2615 //
2616 Status = EFI_SUCCESS;
2617 } else {
2618 //
2619 // Allocate a handle buffer for the number of handles that matched the attributes in Mask
2620 //
2621 *MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));
2622 ASSERT(*MatchingHandleBuffer != NULL);
2623
2624 for (HandleIndex = 0,*MatchingHandleCount = 0
2625 ; HandleIndex < HandleCount
2626 ; HandleIndex++
2627 ){
2628 //
2629 // Fill the allocated buffer with the handles that matched the attributes in Mask
2630 //
2631 if ((HandleType[HandleIndex] & Mask) == Mask) {
2632 (*MatchingHandleBuffer)[(*MatchingHandleCount)++] = HandleBuffer[HandleIndex];
2633 }
2634 }
2635
2636 //
2637 // Make the last one NULL
2638 //
2639 (*MatchingHandleBuffer)[*MatchingHandleCount] = NULL;
2640
2641 Status = EFI_SUCCESS;
2642 } // MacthingHandleBuffer == NULL (ELSE)
2643 } // *MatchingHandleCount == 0 (ELSE)
2644 } // no error on ParseHandleDatabaseByRelationshipWithType
2645
2646 if (HandleBuffer != NULL) {
2647 FreePool (HandleBuffer);
2648 }
2649
2650 if (HandleType != NULL) {
2651 FreePool (HandleType);
2652 }
2653
2654 return Status;
2655 }
2656
2657 /**
2658 Gets handles for any child controllers of the passed in controller.
2659
2660 @param[in] ControllerHandle The handle of the "parent controller"
2661 @param[in] MatchingHandleCount Pointer to the number of handles in
2662 MatchingHandleBuffer on return.
2663 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2664 return.
2665
2666
2667 @retval EFI_SUCCESS The operation was sucessful.
2668 **/
2669 EFI_STATUS
2670 EFIAPI
2671 ParseHandleDatabaseForChildControllers(
2672 IN CONST EFI_HANDLE ControllerHandle,
2673 IN UINTN *MatchingHandleCount,
2674 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
2675 )
2676 {
2677 EFI_STATUS Status;
2678 UINTN HandleIndex;
2679 UINTN DriverBindingHandleCount;
2680 EFI_HANDLE *DriverBindingHandleBuffer;
2681 UINTN DriverBindingHandleIndex;
2682 UINTN ChildControllerHandleCount;
2683 EFI_HANDLE *ChildControllerHandleBuffer;
2684 UINTN ChildControllerHandleIndex;
2685 EFI_HANDLE *HandleBufferForReturn;
2686
2687 if (MatchingHandleCount == NULL) {
2688 return (EFI_INVALID_PARAMETER);
2689 }
2690 *MatchingHandleCount = 0;
2691
2692 Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
2693 ControllerHandle,
2694 &DriverBindingHandleCount,
2695 &DriverBindingHandleBuffer
2696 );
2697 if (EFI_ERROR (Status)) {
2698 return Status;
2699 }
2700
2701 //
2702 // Get a buffer big enough for all the controllers.
2703 //
2704 HandleBufferForReturn = GetHandleListByProtocol(NULL);
2705 if (HandleBufferForReturn == NULL) {
2706 FreePool (DriverBindingHandleBuffer);
2707 return (EFI_NOT_FOUND);
2708 }
2709
2710 for (DriverBindingHandleIndex = 0; DriverBindingHandleIndex < DriverBindingHandleCount; DriverBindingHandleIndex++) {
2711 Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2712 DriverBindingHandleBuffer[DriverBindingHandleIndex],
2713 ControllerHandle,
2714 &ChildControllerHandleCount,
2715 &ChildControllerHandleBuffer
2716 );
2717 if (EFI_ERROR (Status)) {
2718 continue;
2719 }
2720
2721 for (ChildControllerHandleIndex = 0;
2722 ChildControllerHandleIndex < ChildControllerHandleCount;
2723 ChildControllerHandleIndex++
2724 ) {
2725 for (HandleIndex = 0; HandleIndex < *MatchingHandleCount; HandleIndex++) {
2726 if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {
2727 break;
2728 }
2729 }
2730 if (HandleIndex >= *MatchingHandleCount) {
2731 HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
2732 }
2733 }
2734
2735 FreePool (ChildControllerHandleBuffer);
2736 }
2737
2738 FreePool (DriverBindingHandleBuffer);
2739
2740 if (MatchingHandleBuffer != NULL) {
2741 *MatchingHandleBuffer = HandleBufferForReturn;
2742 } else {
2743 FreePool(HandleBufferForReturn);
2744 }
2745
2746 return (EFI_SUCCESS);
2747 }
2748
2749 /**
2750 Appends 1 buffer to another buffer. This will re-allocate the destination buffer
2751 if necessary to fit all of the data.
2752
2753 If DestinationBuffer is NULL, then ASSERT().
2754
2755 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
2756 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
2757 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
2758 @param[in] SourceSize The number of bytes of SourceBuffer to append.
2759
2760 @retval NULL A memory allocation failed.
2761 @retval NULL A parameter was invalid.
2762 @return A pointer to (*DestinationBuffer).
2763 **/
2764 VOID*
2765 EFIAPI
2766 BuffernCatGrow (
2767 IN OUT VOID **DestinationBuffer,
2768 IN OUT UINTN *DestinationSize,
2769 IN VOID *SourceBuffer,
2770 IN UINTN SourceSize
2771 )
2772 {
2773 UINTN LocalDestinationSize;
2774 UINTN LocalDestinationFinalSize;
2775
2776 ASSERT(DestinationBuffer != NULL);
2777
2778 if (SourceSize == 0 || SourceBuffer == NULL) {
2779 return (*DestinationBuffer);
2780 }
2781
2782 if (DestinationSize == NULL) {
2783 LocalDestinationSize = 0;
2784 } else {
2785 LocalDestinationSize = *DestinationSize;
2786 }
2787
2788 LocalDestinationFinalSize = LocalDestinationSize + SourceSize;
2789
2790 if (DestinationSize != NULL) {
2791 *DestinationSize = LocalDestinationSize;
2792 }
2793
2794 if (LocalDestinationSize == 0) {
2795 // allcoate
2796 *DestinationBuffer = AllocateZeroPool(LocalDestinationFinalSize);
2797 } else {
2798 // reallocate
2799 *DestinationBuffer = ReallocatePool(LocalDestinationSize, LocalDestinationFinalSize, *DestinationBuffer);
2800 }
2801
2802 ASSERT(*DestinationBuffer != NULL);
2803
2804 // copy
2805 return (CopyMem(((UINT8*)(*DestinationBuffer)) + LocalDestinationSize, SourceBuffer, SourceSize));
2806 }
2807
2808 /**
2809 Gets handles for any child devices produced by the passed in driver.
2810
2811 @param[in] DriverHandle The handle of the driver.
2812 @param[in] MatchingHandleCount Pointer to the number of handles in
2813 MatchingHandleBuffer on return.
2814 @param[out] MatchingHandleBuffer Buffer containing handles on a successful
2815 return.
2816 @retval EFI_SUCCESS The operation was sucessful.
2817 @sa ParseHandleDatabaseByRelationship
2818 **/
2819 EFI_STATUS
2820 EFIAPI
2821 ParseHandleDatabaseForChildDevices(
2822 IN CONST EFI_HANDLE DriverHandle,
2823 IN UINTN *MatchingHandleCount,
2824 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
2825 )
2826 {
2827 EFI_HANDLE *Buffer;
2828 EFI_HANDLE *Buffer2;
2829 UINTN Count1;
2830 UINTN Count2;
2831 UINTN HandleIndex;
2832 EFI_STATUS Status;
2833 UINTN HandleBufferSize;
2834
2835 ASSERT(MatchingHandleCount != NULL);
2836
2837 HandleBufferSize = 0;
2838 Buffer = NULL;
2839 Buffer2 = NULL;
2840 *MatchingHandleCount = 0;
2841
2842 Status = PARSE_HANDLE_DATABASE_DEVICES (
2843 DriverHandle,
2844 &Count1,
2845 &Buffer
2846 );
2847 if (!EFI_ERROR (Status)) {
2848 for (HandleIndex = 0; HandleIndex < Count1; HandleIndex++) {
2849 //
2850 // now find the children
2851 //
2852 Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
2853 DriverHandle,
2854 Buffer[HandleIndex],
2855 &Count2,
2856 &Buffer2
2857 );
2858 if (EFI_ERROR(Status)) {
2859 break;
2860 }
2861 //
2862 // save out required and optional data elements
2863 //
2864 *MatchingHandleCount += Count2;
2865 if (MatchingHandleBuffer != NULL) {
2866 *MatchingHandleBuffer = BuffernCatGrow((VOID**)MatchingHandleBuffer, &HandleBufferSize, Buffer2, Count2 * sizeof(Buffer2[0]));
2867 }
2868
2869 //
2870 // free the memory
2871 //
2872 if (Buffer2 != NULL) {
2873 FreePool(Buffer2);
2874 }
2875 }
2876 }
2877
2878 if (Buffer != NULL) {
2879 FreePool(Buffer);
2880 }
2881 return (Status);
2882 }
2883
2884 /**
2885 Function to get all handles that support a given protocol or all handles.
2886
2887 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
2888 then the function will return all handles.
2889
2890 @retval NULL A memory allocation failed.
2891 @return A NULL terminated list of handles.
2892 **/
2893 EFI_HANDLE*
2894 EFIAPI
2895 GetHandleListByProtocol (
2896 IN CONST EFI_GUID *ProtocolGuid OPTIONAL
2897 )
2898 {
2899 EFI_HANDLE *HandleList;
2900 UINTN Size;
2901 EFI_STATUS Status;
2902
2903 Size = 0;
2904 HandleList = NULL;
2905
2906 //
2907 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
2908 //
2909 if (ProtocolGuid == NULL) {
2910 Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);
2911 if (Status == EFI_BUFFER_TOO_SMALL) {
2912 HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));
2913 if (HandleList == NULL) {
2914 return (NULL);
2915 }
2916 Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);
2917 HandleList[Size/sizeof(EFI_HANDLE)] = NULL;
2918 }
2919 } else {
2920 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);
2921 if (Status == EFI_BUFFER_TOO_SMALL) {
2922 HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));
2923 if (HandleList == NULL) {
2924 return (NULL);
2925 }
2926 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);
2927 HandleList[Size/sizeof(EFI_HANDLE)] = NULL;
2928 }
2929 }
2930 if (EFI_ERROR(Status)) {
2931 if (HandleList != NULL) {
2932 FreePool(HandleList);
2933 }
2934 return (NULL);
2935 }
2936 return (HandleList);
2937 }
2938
2939 /**
2940 Function to get all handles that support some protocols.
2941
2942 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
2943
2944 @retval NULL A memory allocation failed.
2945 @retval NULL ProtocolGuids was NULL.
2946 @return A NULL terminated list of EFI_HANDLEs.
2947 **/
2948 EFI_HANDLE*
2949 EFIAPI
2950 GetHandleListByProtocolList (
2951 IN CONST EFI_GUID **ProtocolGuids
2952 )
2953 {
2954 EFI_HANDLE *HandleList;
2955 UINTN Size;
2956 UINTN TotalSize;
2957 UINTN TempSize;
2958 EFI_STATUS Status;
2959 CONST EFI_GUID **GuidWalker;
2960 EFI_HANDLE *HandleWalker1;
2961 EFI_HANDLE *HandleWalker2;
2962
2963 Size = 0;
2964 HandleList = NULL;
2965 TotalSize = sizeof(EFI_HANDLE);
2966
2967 for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++,Size = 0){
2968 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &Size, NULL);
2969 if (Status == EFI_BUFFER_TOO_SMALL) {
2970 TotalSize += Size;
2971 }
2972 }
2973
2974 //
2975 // No handles were found...
2976 //
2977 if (TotalSize == sizeof(EFI_HANDLE)) {
2978 return (NULL);
2979 }
2980
2981 HandleList = AllocateZeroPool(TotalSize);
2982 if (HandleList == NULL) {
2983 return (NULL);
2984 }
2985
2986 Size = 0;
2987 for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++){
2988 TempSize = TotalSize - Size;
2989 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+(Size/sizeof(EFI_HANDLE)));
2990
2991 //
2992 // Allow for missing protocols... Only update the 'used' size upon success.
2993 //
2994 if (!EFI_ERROR(Status)) {
2995 Size += TempSize;
2996 }
2997 }
2998 ASSERT(HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] == NULL);
2999
3000 for (HandleWalker1 = HandleList ; HandleWalker1 != NULL && *HandleWalker1 != NULL ; HandleWalker1++) {
3001 for (HandleWalker2 = HandleWalker1 + 1; HandleWalker2 != NULL && *HandleWalker2 != NULL ; HandleWalker2++) {
3002 if (*HandleWalker1 == *HandleWalker2) {
3003 //
3004 // copy memory back 1 handle width.
3005 //
3006 CopyMem(HandleWalker2, HandleWalker2 + 1, TotalSize - ((HandleWalker2-HandleList+1)*sizeof(EFI_HANDLE)));
3007 }
3008 }
3009 }
3010
3011 return (HandleList);
3012 }
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022