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