41extern UINT8 PrmInfoStrings[];
71 if (ListHead ==
NULL) {
76 while (!
IsNull (&mPrmHandlerList, Link)) {
101 PrmHandlerContextListEntry =
AllocateZeroPool (
sizeof (*PrmHandlerContextListEntry));
102 if (PrmHandlerContextListEntry ==
NULL) {
106 PrmHandlerContextListEntry->Signature = PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE;
108 return PrmHandlerContextListEntry;
122 UINTN RuntimeMmioRangeCount;
123 UINTN RuntimeMmioRangeIndex;
125 if (RuntimeMmioRanges ==
NULL) {
129 RuntimeMmioRangeCount = (
UINTN)RuntimeMmioRanges->Count;
132 for (RuntimeMmioRangeIndex = 0; RuntimeMmioRangeIndex < RuntimeMmioRangeCount; RuntimeMmioRangeIndex++) {
139 RuntimeMmioRangeIndex,
140 RuntimeMmioRanges->Range[RuntimeMmioRangeIndex].PhysicalBaseAddress,
141 RuntimeMmioRanges->Range[RuntimeMmioRangeIndex].VirtualBaseAddress,
142 RuntimeMmioRanges->Range[RuntimeMmioRangeIndex].Length
158 IN BOOLEAN PrintInformation
178 ASSERT (mPrmModuleCount <= mPrmHandlerCount);
180 if (mPrmHandlerCount == 0) {
190 CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.
ImageAddress;
191 CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
192 CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
194 CurrentModuleGuid = &CurrentExportDescriptorStruct->Header.ModuleGuid;
195 HandlerCount = CurrentExportDescriptorStruct->Header.NumberPrmHandlers;
200 (VOID *)(
UINTN)CurrentImageAddress,
201 &CurrentPrmModuleImageContext->PeCoffImageContext,
207 if (PrintInformation) {
214 (CHAR8 *)((
UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name)
221 CurrentPrmModuleRuntimeMmioRanges =
NULL;
227 ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
228 if (!EFI_ERROR (Status) && (CurrentModuleContextBuffers !=
NULL)) {
229 CurrentPrmModuleRuntimeMmioRanges = CurrentModuleContextBuffers->
RuntimeMmioRanges;
232 if (PrintInformation) {
233 if (CurrentPrmModuleRuntimeMmioRanges !=
NULL) {
243 for (HandlerIndex = 0; HandlerIndex < HandlerCount; HandlerIndex++) {
244 ZeroMem (&CurrentHandlerContext,
sizeof (CurrentHandlerContext));
246 CurrentHandlerContext.ModuleName = (CHAR8 *)((
UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name);
247 CurrentHandlerContext.Guid = &CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid;
248 CurrentHandlerContext.Name = (CHAR8 *)CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
250 if (PrintInformation) {
256 CurrentHandlerContext.Name,
258 CurrentImageExportDirectory,
259 &CurrentHandlerPhysicalAddress
262 if (!EFI_ERROR (Status)) {
263 CurrentHandlerContext.Handler = (PRM_HANDLER *)(
UINTN)CurrentHandlerPhysicalAddress;
265 if (PrintInformation) {
269 if (PrintInformation) {
275 CurrentHandlerContext.Guid,
276 CurrentModuleContextBuffers,
279 if (!EFI_ERROR (Status)) {
280 CurrentHandlerContext.StaticDataBuffer = CurrentContextBuffer->
StaticDataBuffer;
283 if (PrintInformation) {
284 if (CurrentHandlerContext.StaticDataBuffer !=
NULL) {
291 (
UINTN)CurrentHandlerContext.StaticDataBuffer
300 ASSERT (CurrentHandlerContextListEntry !=
NULL);
301 if (CurrentHandlerContextListEntry !=
NULL) {
303 &CurrentHandlerContextListEntry->Context,
304 &CurrentHandlerContext,
305 sizeof (CurrentHandlerContextListEntry->Context)
307 InsertTailList (&mPrmHandlerList, &CurrentHandlerContextListEntry->Link);
334 if ((HandlerGuid ==
NULL) || (ContextBuffer ==
NULL)) {
335 return EFI_INVALID_PARAMETER;
338 ZeroMem (ContextBuffer,
sizeof (*ContextBuffer));
340 ContextBuffer->Signature = PRM_CONTEXT_BUFFER_SIGNATURE;
341 ContextBuffer->Version = PRM_CONTEXT_BUFFER_INTERFACE_VERSION;
342 CopyGuid (&ContextBuffer->HandlerGuid, HandlerGuid);
344 if (StaticDataBuffer !=
NULL) {
345 ContextBuffer->StaticDataBuffer = StaticDataBuffer;
359 IN UINT64 TimeInNanoSec
366 UINT64 RemainingTime;
372 RemainingTime = TimeInNanoSec;
374 if (RemainingTime > ONE_SECOND) {
375 Sec =
DivU64x32 (RemainingTime, ONE_SECOND);
376 RemainingTime -=
MultU64x32 (Sec, ONE_SECOND);
379 if (RemainingTime > ONE_MILLISECOND) {
380 MilliSec =
DivU64x32 (RemainingTime, ONE_MILLISECOND);
381 RemainingTime -=
MultU64x32 (MilliSec, ONE_MILLISECOND);
384 if (RemainingTime > ONE_MICROSECOND) {
385 MicroSec =
DivU64x32 (RemainingTime, ONE_MICROSECOND);
386 RemainingTime -=
MultU64x32 (MicroSec, ONE_MICROSECOND);
389 if (RemainingTime > 0) {
390 NanoSec = RemainingTime;
395 }
else if (MilliSec > 0) {
397 }
else if (MicroSec > 0) {
421 BOOLEAN ExecuteAllHandlers;
422 BOOLEAN HandlerFound;
431 HandlerFound =
FALSE;
433 if (HandlerGuid ==
NULL) {
434 return EFI_INVALID_PARAMETER;
440 ExecuteAllHandlers =
CompareGuid (HandlerGuid, &gZeroGuid);
442 EFI_LIST_FOR_EACH (Link, &mPrmHandlerList) {
444 HandlerContext = &HandlerContextListEntry->Context;
446 if (!ExecuteAllHandlers && !
CompareGuid (HandlerGuid, HandlerContext->Guid)) {
451 Status =
PopulateContextBuffer (HandlerContext->StaticDataBuffer, HandlerContext->Guid, &CurrentContextBuffer);
452 if (!EFI_ERROR (Status)) {
460 HandlerContext->ModuleName
467 if (
PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
471 Status = HandlerContext->Handler (
NULL, &CurrentContextBuffer);
472 if (
PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
476 if (EFI_ERROR (Status)) {
483 if ((StartTime == 0) && (EndTime == 0)) {
494 "%a - %a: An error occurred creating a context buffer for handler %g\n",
501 if (!ExecuteAllHandlers) {
507 return EFI_NOT_FOUND;
530 BOOLEAN PrintHandlerInfo;
533 CHAR16 *ProblemParam;
534 CONST CHAR16 *HandlerGuidStr;
536 HandlerGuidStr =
NULL;
538 PrintHandlerInfo =
FALSE;
547 if (EFI_ERROR (Status)) {
548 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam !=
NULL)) {
550 ReturnStatus = EFI_INVALID_PARAMETER;
553 ReturnStatus = EFI_LOAD_ERROR;
558 }
else if (Package ==
NULL) {
560 ReturnStatus = EFI_INVALID_PARAMETER;
568 ArgumentCount = 0, TempNode = Package;
570 ArgumentCount++, TempNode =
GetNextNode (Package, TempNode)
575 if (ArgumentCount == 1) {
577 ReturnStatus = EFI_INVALID_PARAMETER;
581 if (ArgumentCount > 6) {
583 ReturnStatus = EFI_INVALID_PARAMETER;
591 if (ArgumentCount <= 2) {
593 ReturnStatus = EFI_INVALID_PARAMETER;
601 PrintHandlerInfo =
TRUE;
606 if (HandlerGuidStr !=
NULL) {
607 if (
StrnCmp (HandlerGuidStr, L
"all",
StrLen (HandlerGuidStr)) == 0) {
608 CopyGuid (&HandlerGuid, &gZeroGuid);
610 Status =
StrToGuid (HandlerGuidStr, &HandlerGuid);
611 if (EFI_ERROR (Status) || (HandlerGuidStr[GUID_STRING_LENGTH] != L
'\0')) {
613 ReturnStatus = EFI_INVALID_PARAMETER;
619 ReturnStatus = EFI_INVALID_PARAMETER;
625 if (EFI_ERROR (Status)) {
629 "%a - %a: An error occurred during PRM module discovery (%r)\n",
634 ReturnStatus = Status;
638 if (PrintHandlerInfo) {
647 if (HandlerGuidStr !=
NULL) {
649 if (Status == EFI_NOT_FOUND) {
657 if (Package !=
NULL) {
687 Status =
gBS->OpenProtocol (
689 &gEfiHiiPackageListProtocolGuid,
690 (VOID **)&PackageList,
693 EFI_OPEN_PROTOCOL_GET_PROTOCOL
695 if (EFI_ERROR (Status)) {
708 if (EFI_ERROR (Status)) {
712 if (mPrmInfoHiiHandle ==
NULL) {
717 if (EFI_ERROR (Status)) {
720 "%a - %a: An error occurred parsing user-provided arguments (%r)\n",
727 if (mPrmInfoHiiHandle !=
NULL) {
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
UINT64 EFIAPI GetPerformanceCounter(VOID)
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
INTN EFIAPI StrnCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString, IN UINTN Length)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
RETURN_STATUS EFIAPI StrToGuid(IN CONST CHAR16 *String, OUT GUID *Guid)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
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)
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define CR(Record, TYPE, Field, TestSignature)
#define PcdGetBool(TokenName)
EFI_STATUS GetContextBuffer(IN CONST EFI_GUID *PrmHandlerGuid, IN CONST PRM_MODULE_CONTEXT_BUFFERS *PrmModuleContextBuffers OPTIONAL, OUT CONST PRM_CONTEXT_BUFFER **PrmContextBuffer)
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)
EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID GatherPrmHandlerInfo(IN BOOLEAN PrintInformation)
VOID PrintMmioRuntimeRangeInfo(IN PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges)
VOID PrintExecutionTime(IN UINT64 TimeInNanoSec)
EFI_STATUS ParseParameterList(VOID)
EFI_STATUS PopulateContextBuffer(IN PRM_DATA_BUFFER *StaticDataBuffer OPTIONAL, IN EFI_GUID *HandlerGuid, IN PRM_CONTEXT_BUFFER *ContextBuffer)
EFI_STATUS ExecutePrmHandlerByGuid(IN EFI_GUID *HandlerGuid)
VOID EFIAPI FreeList(IN LIST_ENTRY *ListHead)
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").
@ TypeFlag
A flag that is present or not present only (IE "-a").
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
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
PHYSICAL_ADDRESS ImageAddress
PRM_DATA_BUFFER * StaticDataBuffer
PRM_RUNTIME_MMIO_RANGES * RuntimeMmioRanges