31#define _DBGMSGID_ "[PRMLOADER]"
33UINTN mPrmHandlerCount;
60 CONST CHAR8 *CurrentExportDescriptorHandlerName;
72 UINT32 PrmAcpiDescriptionTableBufferSize;
74 UINT64 HandlerPhysicalAddress;
76 DEBUG ((DEBUG_INFO,
"%a %a - Entry.\n", _DBGMSGID_, __func__));
78 if (PrmAcpiDescriptionTable ==
NULL) {
79 return EFI_INVALID_PARAMETER;
82 *PrmAcpiDescriptionTable =
NULL;
87 if (
CompareGuid (&gEdkiiDscPlatformGuid, &gZeroGuid)) {
90 " %a %a: The Platform GUID in the DSC file must be set to a unique non-zero value.\n",
94 ASSERT (!
CompareGuid (&gEdkiiDscPlatformGuid, &gZeroGuid));
97 DEBUG ((DEBUG_INFO,
" %a %a: %d total PRM modules to process.\n", _DBGMSGID_, __func__, mPrmModuleCount));
98 DEBUG ((DEBUG_INFO,
" %a %a: %d total PRM handlers to process.\n", _DBGMSGID_, __func__, mPrmHandlerCount));
104 DEBUG ((DEBUG_INFO,
" %a %a: Total PRM ACPI table size: 0x%x.\n", _DBGMSGID_, __func__, PrmAcpiDescriptionTableBufferSize));
107 if (PrmAcpiTable ==
NULL) {
108 return EFI_OUT_OF_RESOURCES;
111 PrmAcpiTable->
Header.Signature = PRM_TABLE_SIGNATURE;
112 PrmAcpiTable->
Header.Length = PrmAcpiDescriptionTableBufferSize;
113 PrmAcpiTable->
Header.Revision = PRM_TABLE_REVISION;
114 PrmAcpiTable->
Header.Checksum = 0x0;
116 PrmAcpiTable->
Header.OemTableId =
PcdGet64 (PcdAcpiDefaultOemTableId);
117 PrmAcpiTable->
Header.OemRevision =
PcdGet32 (PcdAcpiDefaultOemRevision);
118 PrmAcpiTable->
Header.CreatorId =
PcdGet32 (PcdAcpiDefaultCreatorId);
119 PrmAcpiTable->
Header.CreatorRevision =
PcdGet32 (PcdAcpiDefaultCreatorRevision);
127 CurrentModuleInfoStruct = &PrmAcpiTable->PrmModuleInfoStructure[0];
133 CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.
ImageAddress;
134 CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
135 CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
136 CurrentModuleAcpiParamDescriptors =
NULL;
140 " %a %a: PRM Module - %a with %d handlers.\n",
143 (CHAR8 *)((
UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name),
144 CurrentExportDescriptorStruct->Header.NumberPrmHandlers
147 CurrentModuleInfoStruct->
StructureRevision = PRM_MODULE_INFORMATION_STRUCT_REVISION;
152 CopyGuid (&CurrentModuleInfoStruct->
Identifier, &CurrentExportDescriptorStruct->Header.ModuleGuid);
153 CurrentModuleInfoStruct->
HandlerCount = (UINT32)CurrentExportDescriptorStruct->Header.NumberPrmHandlers;
159 (VOID *)(
UINTN)CurrentImageAddress,
160 &CurrentPrmModuleImageContext->PeCoffImageContext,
172 ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
173 if (!EFI_ERROR (Status) && (CurrentModuleContextBuffers !=
NULL)) {
181 for (HandlerIndex = 0; HandlerIndex < CurrentExportDescriptorStruct->Header.NumberPrmHandlers; HandlerIndex++) {
182 CurrentHandlerInfoStruct = &(CurrentModuleInfoStruct->HandlerInfoStructure[HandlerIndex]);
184 CurrentHandlerInfoStruct->
StructureRevision = PRM_HANDLER_INFORMATION_STRUCT_REVISION;
188 &CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid
191 CurrentExportDescriptorHandlerName = (
CONST CHAR8 *)CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
195 CurrentModuleContextBuffers,
198 if (!EFI_ERROR (Status)) {
203 CurrentExportDescriptorHandlerName,
205 CurrentImageExportDirectory,
206 &HandlerPhysicalAddress
209 if (!EFI_ERROR (Status)) {
213 " %a %a: Found %a handler physical address at 0x%016x.\n",
216 CurrentExportDescriptorHandlerName,
224 if (CurrentModuleAcpiParamDescriptors !=
NULL) {
226 if (
CompareGuid (&CurrentModuleAcpiParamDescriptors[AcpiParamIndex].HandlerGuid, &CurrentHandlerInfoStruct->
Identifier)) {
228 CurrentModuleAcpiParamDescriptors[AcpiParamIndex].AcpiParameterBufferAddress
238 *PrmAcpiDescriptionTable = PrmAcpiTable;
265 if ((PrmAcpiDescriptionTable ==
NULL) || (PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE)) {
266 return EFI_INVALID_PARAMETER;
269 Status =
gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid,
NULL, (VOID **)&AcpiTableProtocol);
270 if (!EFI_ERROR (Status)) {
275 Status = AcpiTableProtocol->InstallAcpiTable (
277 PrmAcpiDescriptionTable,
278 PrmAcpiDescriptionTable->Header.Length,
281 if (!EFI_ERROR (Status)) {
282 DEBUG ((DEBUG_INFO,
"%a %a: The PRMT ACPI table was installed successfully.\n", _DBGMSGID_, __func__));
319 DEBUG ((DEBUG_INFO,
"%a %a - Entry.\n", _DBGMSGID_, __func__));
330 if (PrmAcpiDescriptionTable !=
NULL) {
334 gBS->CloseEvent (Event);
357 DEBUG ((DEBUG_INFO,
"%a %a - Entry.\n", _DBGMSGID_, __func__));
363 Status =
gBS->CreateEventEx (
368 &gEfiEndOfDxeEventGroupGuid,
371 if (EFI_ERROR (Status)) {
372 DEBUG ((DEBUG_ERROR,
"%a %a: EndOfDxe callback registration failed! %r.\n", _DBGMSGID_, __func__, Status));
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 AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define OFFSET_OF(TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet64(TokenName)
#define PcdGet32(TokenName)
#define PcdGetPtr(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)
EFI_STATUS EFIAPI PrmLoaderEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS ProcessPrmModules(OUT PRM_ACPI_DESCRIPTION_TABLE **PrmAcpiDescriptionTable)
VOID EFIAPI PrmLoaderEndOfDxeNotification(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS PublishPrmAcpiTable(IN PRM_ACPI_DESCRIPTION_TABLE *PrmAcpiDescriptionTable)
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)
UINT64 EFI_PHYSICAL_ADDRESS
PHYSICAL_ADDRESS ImageAddress
UINT32 PrmModuleInfoCount
Number of entries in the PRM Module Info array.
EFI_ACPI_DESCRIPTION_HEADER Header
Standard ACPI description header.
UINT32 PrmModuleInfoOffset
PRM_DATA_BUFFER * StaticDataBuffer
UINT16 StructureRevision
Revision of this structure.
UINT16 StructureLength
Length in bytes of this structure.
UINT64 AcpiParameterBuffer
GUID Identifier
GUID of the PRM handler for this structure.
UINT64 PhysicalAddress
Physical address of this PRM handler.
ACPI_PARAMETER_BUFFER_DESCRIPTOR * AcpiParameterBufferDescriptors
UINTN AcpiParameterBufferDescriptorCount
PRM_RUNTIME_MMIO_RANGES * RuntimeMmioRanges
UINT16 HandlerCount
Number of entries in the Handler Info array.
UINT16 StructureRevision
Revision of this structure.
UINT16 MinorRevision
PRM module minor revision.
GUID Identifier
GUID of the PRM module for this structure.
UINT16 MajorRevision
PRM module major revision.