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