TianoCore EDK2 master
Loading...
Searching...
No Matches
PrmInfo.c
Go to the documentation of this file.
1
16#include <Guid/ZeroGuid.h>
17#include <Library/BaseLib.h>
19#include <Library/DebugLib.h>
20#include <Library/HiiLib.h>
22#include <Library/PcdLib.h>
26#include <Library/ShellLib.h>
27#include <Library/TimerLib.h>
31#include <Library/UefiLib.h>
32
33#include "PrmInfo.h"
34
35GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringPrmInfoHelpTokenId = STRING_TOKEN (STR_PRMINFO_HELP);
36//
37// This is the generated String package data for all .UNI files.
38// This data array is ready to be used as input of HiiAddPackages() to
39// create a packagelist (which contains Form packages, String packages, etc).
40//
41extern UINT8 PrmInfoStrings[];
42
43STATIC UINTN mPrmHandlerCount;
44STATIC UINTN mPrmModuleCount;
45
46STATIC EFI_HII_HANDLE mPrmInfoHiiHandle;
47STATIC LIST_ENTRY mPrmHandlerList;
48
49STATIC CONST SHELL_PARAM_ITEM mParamList[] = {
50 { L"-l", TypeFlag },
51 { L"-t", TypeValue },
52 { NULL, TypeMax }
53};
54
61VOID
62EFIAPI
64 IN LIST_ENTRY *ListHead
65 )
66{
67 LIST_ENTRY *Link;
68 LIST_ENTRY *NextLink;
70
71 if (ListHead == NULL) {
72 return;
73 }
74
75 Link = GetFirstNode (&mPrmHandlerList);
76 while (!IsNull (&mPrmHandlerList, Link)) {
77 ListEntry = CR (Link, PRM_HANDLER_CONTEXT_LIST_ENTRY, Link, PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE);
78 NextLink = GetNextNode (&mPrmHandlerList, Link);
79
80 RemoveEntryList (Link);
81 FreePool (ListEntry);
82
83 Link = NextLink;
84 }
85}
86
96 VOID
97 )
98{
99 PRM_HANDLER_CONTEXT_LIST_ENTRY *PrmHandlerContextListEntry;
100
101 PrmHandlerContextListEntry = AllocateZeroPool (sizeof (*PrmHandlerContextListEntry));
102 if (PrmHandlerContextListEntry == NULL) {
103 return NULL;
104 }
105
106 PrmHandlerContextListEntry->Signature = PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE;
107
108 return PrmHandlerContextListEntry;
109}
110
117VOID
119 IN PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges
120 )
121{
122 UINTN RuntimeMmioRangeCount;
123 UINTN RuntimeMmioRangeIndex;
124
125 if (RuntimeMmioRanges == NULL) {
126 return;
127 }
128
129 RuntimeMmioRangeCount = (UINTN)RuntimeMmioRanges->Count;
130 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_RUNTIME_MMIO_COUNT), mPrmInfoHiiHandle, RuntimeMmioRangeCount);
131
132 for (RuntimeMmioRangeIndex = 0; RuntimeMmioRangeIndex < RuntimeMmioRangeCount; RuntimeMmioRangeIndex++) {
134 -1,
135 -1,
136 NULL,
137 STRING_TOKEN (STR_PRMINFO_RUNTIME_MMIO_INFO),
138 mPrmInfoHiiHandle,
139 RuntimeMmioRangeIndex,
140 RuntimeMmioRanges->Range[RuntimeMmioRangeIndex].PhysicalBaseAddress,
141 RuntimeMmioRanges->Range[RuntimeMmioRangeIndex].VirtualBaseAddress,
142 RuntimeMmioRanges->Range[RuntimeMmioRangeIndex].Length
143 );
144 }
145}
146
156VOID
158 IN BOOLEAN PrintInformation
159 )
160{
161 EFI_STATUS Status;
162 UINT16 MajorVersion;
163 UINT16 MinorVersion;
164 UINT16 HandlerCount;
165 UINTN HandlerIndex;
166 EFI_PHYSICAL_ADDRESS CurrentHandlerPhysicalAddress;
167 EFI_PHYSICAL_ADDRESS CurrentImageAddress;
168 PRM_HANDLER_CONTEXT CurrentHandlerContext;
169 EFI_GUID *CurrentModuleGuid;
170 EFI_IMAGE_EXPORT_DIRECTORY *CurrentImageExportDirectory;
171 PRM_CONTEXT_BUFFER *CurrentContextBuffer;
172 PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *CurrentExportDescriptorStruct;
173 PRM_MODULE_CONTEXT_BUFFERS *CurrentModuleContextBuffers;
174 PRM_HANDLER_CONTEXT_LIST_ENTRY *CurrentHandlerContextListEntry;
175 PRM_MODULE_IMAGE_CONTEXT *CurrentPrmModuleImageContext;
176 PRM_RUNTIME_MMIO_RANGES *CurrentPrmModuleRuntimeMmioRanges;
177
178 ASSERT (mPrmModuleCount <= mPrmHandlerCount);
179
180 if (mPrmHandlerCount == 0) {
181 return;
182 }
183
184 // Iterate across all PRM modules discovered
185 for (
186 CurrentPrmModuleImageContext = NULL, Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext);
187 !EFI_ERROR (Status);
188 Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext))
189 {
190 CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.ImageAddress;
191 CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
192 CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
193
194 CurrentModuleGuid = &CurrentExportDescriptorStruct->Header.ModuleGuid;
195 HandlerCount = CurrentExportDescriptorStruct->Header.NumberPrmHandlers;
196
197 MajorVersion = 0;
198 MinorVersion = 0;
200 (VOID *)(UINTN)CurrentImageAddress,
201 &CurrentPrmModuleImageContext->PeCoffImageContext,
202 &MajorVersion,
203 &MinorVersion
204 );
205 ASSERT_EFI_ERROR (Status);
206
207 if (PrintInformation) {
209 -1,
210 -1,
211 NULL,
212 STRING_TOKEN (STR_PRMINFO_MODULE_NAME),
213 mPrmInfoHiiHandle,
214 (CHAR8 *)((UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name)
215 );
216 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MODULE_GUID), mPrmInfoHiiHandle, CurrentModuleGuid);
217 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MODULE_VERSION), mPrmInfoHiiHandle, MajorVersion, MinorVersion);
218 }
219
220 // It is currently valid for a PRM module not to use a context buffer
221 CurrentPrmModuleRuntimeMmioRanges = NULL;
222 Status = GetModuleContextBuffers (
224 CurrentModuleGuid,
225 (CONST PRM_MODULE_CONTEXT_BUFFERS **)&CurrentModuleContextBuffers
226 );
227 ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
228 if (!EFI_ERROR (Status) && (CurrentModuleContextBuffers != NULL)) {
229 CurrentPrmModuleRuntimeMmioRanges = CurrentModuleContextBuffers->RuntimeMmioRanges;
230 }
231
232 if (PrintInformation) {
233 if (CurrentPrmModuleRuntimeMmioRanges != NULL) {
234 PrintMmioRuntimeRangeInfo (CurrentPrmModuleRuntimeMmioRanges);
235 } else {
236 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_MMIO_RANGES), mPrmInfoHiiHandle);
237 }
238
239 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
240 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_COUNT), mPrmInfoHiiHandle, HandlerCount);
241 }
242
243 for (HandlerIndex = 0; HandlerIndex < HandlerCount; HandlerIndex++) {
244 ZeroMem (&CurrentHandlerContext, sizeof (CurrentHandlerContext));
245
246 CurrentHandlerContext.ModuleName = (CHAR8 *)((UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name);
247 CurrentHandlerContext.Guid = &CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid;
248 CurrentHandlerContext.Name = (CHAR8 *)CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
249
250 if (PrintInformation) {
251 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_NAME), mPrmInfoHiiHandle, CurrentHandlerContext.Name);
252 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_GUID), mPrmInfoHiiHandle, CurrentHandlerContext.Guid);
253 }
254
255 Status = GetExportEntryAddress (
256 CurrentHandlerContext.Name,
257 CurrentImageAddress,
258 CurrentImageExportDirectory,
259 &CurrentHandlerPhysicalAddress
260 );
261 ASSERT_EFI_ERROR (Status);
262 if (!EFI_ERROR (Status)) {
263 CurrentHandlerContext.Handler = (PRM_HANDLER *)(UINTN)CurrentHandlerPhysicalAddress;
264
265 if (PrintInformation) {
266 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_PA), mPrmInfoHiiHandle, CurrentHandlerPhysicalAddress);
267 }
268 } else {
269 if (PrintInformation) {
270 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_PA_ERROR), mPrmInfoHiiHandle, Status);
271 }
272 }
273
274 Status = GetContextBuffer (
275 CurrentHandlerContext.Guid,
276 CurrentModuleContextBuffers,
277 (CONST PRM_CONTEXT_BUFFER **)&CurrentContextBuffer
278 );
279 if (!EFI_ERROR (Status)) {
280 CurrentHandlerContext.StaticDataBuffer = CurrentContextBuffer->StaticDataBuffer;
281 }
282
283 if (PrintInformation) {
284 if (CurrentHandlerContext.StaticDataBuffer != NULL) {
286 -1,
287 -1,
288 NULL,
289 STRING_TOKEN (STR_PRMINFO_STATIC_DATA_BUFFER),
290 mPrmInfoHiiHandle,
291 (UINTN)CurrentHandlerContext.StaticDataBuffer
292 );
293 } else {
294 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
295 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_STATIC_BUFFER), mPrmInfoHiiHandle);
296 }
297 }
298
299 CurrentHandlerContextListEntry = CreateNewPrmHandlerListEntry ();
300 ASSERT (CurrentHandlerContextListEntry != NULL);
301 if (CurrentHandlerContextListEntry != NULL) {
302 CopyMem (
303 &CurrentHandlerContextListEntry->Context,
304 &CurrentHandlerContext,
305 sizeof (CurrentHandlerContextListEntry->Context)
306 );
307 InsertTailList (&mPrmHandlerList, &CurrentHandlerContextListEntry->Link);
308 }
309 }
310 }
311}
312
329 IN PRM_DATA_BUFFER *StaticDataBuffer OPTIONAL,
330 IN EFI_GUID *HandlerGuid,
331 IN PRM_CONTEXT_BUFFER *ContextBuffer
332 )
333{
334 if ((HandlerGuid == NULL) || (ContextBuffer == NULL)) {
335 return EFI_INVALID_PARAMETER;
336 }
337
338 ZeroMem (ContextBuffer, sizeof (*ContextBuffer));
339
340 ContextBuffer->Signature = PRM_CONTEXT_BUFFER_SIGNATURE;
341 ContextBuffer->Version = PRM_CONTEXT_BUFFER_INTERFACE_VERSION;
342 CopyGuid (&ContextBuffer->HandlerGuid, HandlerGuid);
343
344 if (StaticDataBuffer != NULL) {
345 ContextBuffer->StaticDataBuffer = StaticDataBuffer;
346 }
347
348 return EFI_SUCCESS;
349}
350
357VOID
359 IN UINT64 TimeInNanoSec
360 )
361{
362 UINT64 Sec;
363 UINT64 MilliSec;
364 UINT64 MicroSec;
365 UINT64 NanoSec;
366 UINT64 RemainingTime;
367
368 Sec = 0;
369 MilliSec = 0;
370 MicroSec = 0;
371 NanoSec = 0;
372 RemainingTime = TimeInNanoSec;
373
374 if (RemainingTime > ONE_SECOND) {
375 Sec = DivU64x32 (RemainingTime, ONE_SECOND);
376 RemainingTime -= MultU64x32 (Sec, ONE_SECOND);
377 }
378
379 if (RemainingTime > ONE_MILLISECOND) {
380 MilliSec = DivU64x32 (RemainingTime, ONE_MILLISECOND);
381 RemainingTime -= MultU64x32 (MilliSec, ONE_MILLISECOND);
382 }
383
384 if (RemainingTime > ONE_MICROSECOND) {
385 MicroSec = DivU64x32 (RemainingTime, ONE_MICROSECOND);
386 RemainingTime -= MultU64x32 (MicroSec, ONE_MICROSECOND);
387 }
388
389 if (RemainingTime > 0) {
390 NanoSec = RemainingTime;
391 }
392
393 if (Sec > 0) {
394 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_SECS), mPrmInfoHiiHandle, Sec, MilliSec, MicroSec, NanoSec);
395 } else if (MilliSec > 0) {
396 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MILLI_SECS), mPrmInfoHiiHandle, MilliSec, MicroSec, NanoSec);
397 } else if (MicroSec > 0) {
398 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_USECS), mPrmInfoHiiHandle, MicroSec, NanoSec);
399 } else {
400 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NANO_SECS), mPrmInfoHiiHandle, NanoSec);
401 }
402}
403
417 IN EFI_GUID *HandlerGuid
418 )
419{
420 EFI_STATUS Status;
421 BOOLEAN ExecuteAllHandlers;
422 BOOLEAN HandlerFound;
423 UINT64 StartTime;
424 UINT64 EndTime;
425 PRM_CONTEXT_BUFFER CurrentContextBuffer;
426 PRM_HANDLER_CONTEXT *HandlerContext;
427 PRM_HANDLER_CONTEXT_LIST_ENTRY *HandlerContextListEntry;
428 LIST_ENTRY *Link;
429
430 Link = NULL;
431 HandlerFound = FALSE;
432
433 if (HandlerGuid == NULL) {
434 return EFI_INVALID_PARAMETER;
435 }
436
437 //
438 // Zero GUID means execute all discovered handlers
439 //
440 ExecuteAllHandlers = CompareGuid (HandlerGuid, &gZeroGuid);
441
442 EFI_LIST_FOR_EACH (Link, &mPrmHandlerList) {
443 HandlerContextListEntry = CR (Link, PRM_HANDLER_CONTEXT_LIST_ENTRY, Link, PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE);
444 HandlerContext = &HandlerContextListEntry->Context;
445
446 if (!ExecuteAllHandlers && !CompareGuid (HandlerGuid, HandlerContext->Guid)) {
447 continue;
448 }
449
450 HandlerFound = TRUE;
451 Status = PopulateContextBuffer (HandlerContext->StaticDataBuffer, HandlerContext->Guid, &CurrentContextBuffer);
452 if (!EFI_ERROR (Status)) {
453 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
455 -1,
456 -1,
457 NULL,
458 STRING_TOKEN (STR_PRMINFO_MODULE_NAME),
459 mPrmInfoHiiHandle,
460 HandlerContext->ModuleName
461 );
462 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_NAME_HL), mPrmInfoHiiHandle, HandlerContext->Name);
463 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_GUID), mPrmInfoHiiHandle, HandlerContext->Guid);
464
465 StartTime = 0;
466 EndTime = 0;
467 if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
468 StartTime = GetPerformanceCounter ();
469 }
470
471 Status = HandlerContext->Handler (NULL, &CurrentContextBuffer);
472 if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
473 EndTime = GetPerformanceCounter ();
474 }
475
476 if (EFI_ERROR (Status)) {
477 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_ERR_STATUS), mPrmInfoHiiHandle, Status);
478 } else {
479 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_SUCC_STATUS), mPrmInfoHiiHandle, Status);
480 }
481
482 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_EXEC_TIME), mPrmInfoHiiHandle);
483 if ((StartTime == 0) && (EndTime == 0)) {
484 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_UNKNOWN), mPrmInfoHiiHandle);
485 } else {
486 PrintExecutionTime (GetTimeInNanoSecond (EndTime - StartTime));
487 }
488
489 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
490 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
491 } else {
492 DEBUG ((
493 DEBUG_ERROR,
494 "%a - %a: An error occurred creating a context buffer for handler %g\n",
495 gEfiCallerBaseName,
496 __func__,
497 HandlerContext->Guid
498 ));
499 }
500
501 if (!ExecuteAllHandlers) {
502 break;
503 }
504 }
505
506 if (!HandlerFound) {
507 return EFI_NOT_FOUND;
508 }
509
510 return EFI_SUCCESS;
511}
512
523 VOID
524 )
525{
526 EFI_STATUS Status;
527 EFI_STATUS ReturnStatus;
528 UINTN ArgumentCount;
529 EFI_GUID HandlerGuid;
530 BOOLEAN PrintHandlerInfo;
531 LIST_ENTRY *Package;
532 LIST_ENTRY *TempNode;
533 CHAR16 *ProblemParam;
534 CONST CHAR16 *HandlerGuidStr;
535
536 HandlerGuidStr = NULL;
537 Package = NULL;
538 PrintHandlerInfo = FALSE;
539 ReturnStatus = EFI_SUCCESS;
540
541 InitializeListHead (&mPrmHandlerList);
542
543 //
544 // Basic application parameter validation
545 //
546 Status = ShellCommandLineParseEx (mParamList, &Package, &ProblemParam, FALSE, FALSE);
547 if (EFI_ERROR (Status)) {
548 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
549 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_GEN_PROBLEM), mPrmInfoHiiHandle, APPLICATION_NAME, ProblemParam);
550 ReturnStatus = EFI_INVALID_PARAMETER;
551 FreePool (ProblemParam);
552 } else {
553 ReturnStatus = EFI_LOAD_ERROR;
554 ASSERT (FALSE);
555 }
556
557 goto Done;
558 } else if (Package == NULL) {
559 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_ARG), mPrmInfoHiiHandle, APPLICATION_NAME);
560 ReturnStatus = EFI_INVALID_PARAMETER;
561 goto Done;
562 }
563
564 //
565 // Get argument count including flags
566 //
567 for (
568 ArgumentCount = 0, TempNode = Package;
569 GetNextNode (Package, TempNode) != Package;
570 ArgumentCount++, TempNode = GetNextNode (Package, TempNode)
571 )
572 {
573 }
574
575 if (ArgumentCount == 1) {
576 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_ARG), mPrmInfoHiiHandle, APPLICATION_NAME);
577 ReturnStatus = EFI_INVALID_PARAMETER;
578 goto Done;
579 }
580
581 if (ArgumentCount > 6) {
582 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_TOO_MANY), mPrmInfoHiiHandle, APPLICATION_NAME);
583 ReturnStatus = EFI_INVALID_PARAMETER;
584 goto Done;
585 }
586
587 //
588 // Parse the actual arguments provided
589 //
590 if (ShellCommandLineGetFlag (Package, L"-b")) {
591 if (ArgumentCount <= 2) {
592 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_PARAM_INV), mPrmInfoHiiHandle, APPLICATION_NAME, L"-b");
593 ReturnStatus = EFI_INVALID_PARAMETER;
594 goto Done;
595 } else {
597 }
598 }
599
600 if (ShellCommandLineGetFlag (Package, L"-l")) {
601 PrintHandlerInfo = TRUE;
602 }
603
604 if (ShellCommandLineGetFlag (Package, L"-t")) {
605 HandlerGuidStr = ShellCommandLineGetValue (Package, L"-t");
606 if (HandlerGuidStr != NULL) {
607 if (StrnCmp (HandlerGuidStr, L"all", StrLen (HandlerGuidStr)) == 0) {
608 CopyGuid (&HandlerGuid, &gZeroGuid);
609 } else {
610 Status = StrToGuid (HandlerGuidStr, &HandlerGuid);
611 if (EFI_ERROR (Status) || (HandlerGuidStr[GUID_STRING_LENGTH] != L'\0')) {
612 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_GUID_INV), mPrmInfoHiiHandle, APPLICATION_NAME, HandlerGuidStr);
613 ReturnStatus = EFI_INVALID_PARAMETER;
614 goto Done;
615 }
616 }
617 } else {
618 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_VALUE), mPrmInfoHiiHandle, APPLICATION_NAME, L"-t");
619 ReturnStatus = EFI_INVALID_PARAMETER;
620 goto Done;
621 }
622 }
623
624 Status = DiscoverPrmModules (&mPrmModuleCount, &mPrmHandlerCount);
625 if (EFI_ERROR (Status)) {
626 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_DISCOVERY_FAILED), mPrmInfoHiiHandle, APPLICATION_NAME);
627 DEBUG ((
628 DEBUG_ERROR,
629 "%a - %a: An error occurred during PRM module discovery (%r)\n",
630 gEfiCallerBaseName,
631 __func__,
632 Status
633 ));
634 ReturnStatus = Status;
635 goto Done;
636 }
637
638 if (PrintHandlerInfo) {
639 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LIST_TITLE), mPrmInfoHiiHandle);
640 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MODULES_FOUND), mPrmInfoHiiHandle, mPrmModuleCount);
641 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLERS_FOUND), mPrmInfoHiiHandle, mPrmHandlerCount);
642 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
643 }
644
645 GatherPrmHandlerInfo (PrintHandlerInfo);
646
647 if (HandlerGuidStr != NULL) {
648 Status = ExecutePrmHandlerByGuid (&HandlerGuid);
649 if (Status == EFI_NOT_FOUND) {
650 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_NOT_FOUND), mPrmInfoHiiHandle, APPLICATION_NAME, HandlerGuid);
651 }
652 }
653
654Done:
655 FreeList (&mPrmHandlerList);
656
657 if (Package != NULL) {
659 }
660
661 return ReturnStatus;
662}
663
675EFIAPI
677 IN EFI_HANDLE ImageHandle,
678 IN EFI_SYSTEM_TABLE *SystemTable
679 )
680{
681 EFI_STATUS Status;
682 EFI_HII_PACKAGE_LIST_HEADER *PackageList;
683
684 //
685 // Retrieve the HII package list from ImageHandle
686 //
687 Status = gBS->OpenProtocol (
688 ImageHandle,
689 &gEfiHiiPackageListProtocolGuid,
690 (VOID **)&PackageList,
691 ImageHandle,
692 NULL,
693 EFI_OPEN_PROTOCOL_GET_PROTOCOL
694 );
695 if (EFI_ERROR (Status)) {
696 return Status;
697 }
698
699 //
700 // Publish the HII package list to the HII Database
701 //
702 Status = gHiiDatabase->NewPackageList (
704 PackageList,
705 NULL,
706 &mPrmInfoHiiHandle
707 );
708 if (EFI_ERROR (Status)) {
709 return Status;
710 }
711
712 if (mPrmInfoHiiHandle == NULL) {
713 return EFI_SUCCESS;
714 }
715
716 Status = ParseParameterList ();
717 if (EFI_ERROR (Status)) {
718 DEBUG ((
719 DEBUG_ERROR,
720 "%a - %a: An error occurred parsing user-provided arguments (%r)\n",
721 gEfiCallerBaseName,
722 __func__,
723 Status
724 ));
725 }
726
727 if (mPrmInfoHiiHandle != NULL) {
728 HiiRemovePackages (mPrmInfoHiiHandle);
729 }
730
731 return EFI_SUCCESS;
732}
UINT64 UINTN
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
UINT64 EFIAPI GetPerformanceCounter(VOID)
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:443
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
Definition: DivU64x32.c:29
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
INTN EFIAPI StrnCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString, IN UINTN Length)
Definition: String.c:162
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
Definition: MultU64x32.c:27
RETURN_STATUS EFIAPI StrToGuid(IN CONST CHAR16 *String, OUT GUID *Guid)
Definition: SafeString.c:1500
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
Definition: String.c:30
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLib.c:253
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define GLOBAL_REMOVE_IF_UNREFERENCED
Definition: Base.h:48
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define CR(Record, TYPE, Field, TestSignature)
Definition: DebugLib.h:659
#define PcdGetBool(TokenName)
Definition: PcdLib.h:401
EFI_STATUS GetContextBuffer(IN CONST EFI_GUID *PrmHandlerGuid, IN CONST PRM_MODULE_CONTEXT_BUFFERS *PrmModuleContextBuffers OPTIONAL, OUT CONST PRM_CONTEXT_BUFFER **PrmContextBuffer)
@ ByModuleGuid
EFI_STATUS GetModuleContextBuffers(IN PRM_GUID_SEARCH_TYPE GuidSearchType, IN CONST EFI_GUID *Guid, OUT CONST PRM_MODULE_CONTEXT_BUFFERS **PrmModuleContextBuffers)
PRM_HANDLER_CONTEXT_LIST_ENTRY * CreateNewPrmHandlerListEntry(VOID)
Definition: PrmInfo.c:95
EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: PrmInfo.c:676
VOID GatherPrmHandlerInfo(IN BOOLEAN PrintInformation)
Definition: PrmInfo.c:157
VOID PrintMmioRuntimeRangeInfo(IN PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges)
Definition: PrmInfo.c:118
VOID PrintExecutionTime(IN UINT64 TimeInNanoSec)
Definition: PrmInfo.c:358
EFI_STATUS ParseParameterList(VOID)
Definition: PrmInfo.c:522
EFI_STATUS PopulateContextBuffer(IN PRM_DATA_BUFFER *StaticDataBuffer OPTIONAL, IN EFI_GUID *HandlerGuid, IN PRM_CONTEXT_BUFFER *ContextBuffer)
Definition: PrmInfo.c:328
EFI_STATUS ExecutePrmHandlerByGuid(IN EFI_GUID *HandlerGuid)
Definition: PrmInfo.c:416
VOID EFIAPI FreeList(IN LIST_ENTRY *ListHead)
Definition: PrmInfo.c:63
EFI_STATUS EFIAPI GetNextPrmModuleEntry(IN OUT PRM_MODULE_IMAGE_CONTEXT **ModuleImageContext)
EFI_STATUS EFIAPI DiscoverPrmModules(OUT UINTN *ModuleCount OPTIONAL, OUT UINTN *HandlerCount OPTIONAL)
EFI_STATUS GetImageVersionInPeCoffImage(IN VOID *Image, IN PE_COFF_LOADER_IMAGE_CONTEXT *PeCoffLoaderImageContext, OUT UINT16 *ImageMajorVersion, OUT UINT16 *ImageMinorVersion)
EFI_STATUS GetExportEntryAddress(IN CONST CHAR8 *ExportName, IN EFI_PHYSICAL_ADDRESS ImageBaseAddress, IN EFI_IMAGE_EXPORT_DIRECTORY *ImageExportDirectory, OUT EFI_PHYSICAL_ADDRESS *ExportPhysicalAddress)
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
VOID EFIAPI ShellSetPageBreakMode(IN BOOLEAN CurrentState)
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeValue
A flag that has some data following it with a space (IE "-a 1").
Definition: ShellLib.h:700
@ TypeFlag
A flag that is present or not present only (IE "-a").
Definition: ShellLib.h:699
EFI_STATUS EFIAPI ShellCommandLineParseEx(IN CONST SHELL_PARAM_ITEM *CheckList, OUT LIST_ENTRY **CheckPackage, OUT CHAR16 **ProblemParam OPTIONAL, IN BOOLEAN AutoPageBreak, IN BOOLEAN AlwaysAllowNumbers)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
#define STRING_TOKEN(t)
VOID * EFI_HII_HANDLE
Definition: Base.h:213
PHYSICAL_ADDRESS ImageAddress
Definition: PeCoffLib.h:79
PRM_DATA_BUFFER * StaticDataBuffer
PRM_RUNTIME_MMIO_RANGES * RuntimeMmioRanges