TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeAcpiParameterBufferModuleConfigLib.c
Go to the documentation of this file.
1
10#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
15#include <Protocol/PrmConfig.h>
16
17STATIC EFI_HANDLE mPrmConfigProtocolHandle;
18
19// {dc2a58a6-5927-4776-b995-d118a27335a2}
20STATIC CONST EFI_GUID mPrmModuleGuid = {
21 0xdc2a58a6, 0x5927, 0x4776, { 0xb9, 0x95, 0xd1, 0x18, 0xa2, 0x73, 0x35, 0xa2 }
22};
23
24// {2e4f2d13-6240-4ed0-a401-c723fbdc34e8}
25STATIC CONST EFI_GUID mCheckParamBufferPrmHandlerGuid = {
26 0x2e4f2d13, 0x6240, 0x4ed0, { 0xa4, 0x01, 0xc7, 0x23, 0xfb, 0xdc, 0x34, 0xe8 }
27};
28
39EFIAPI
41 IN EFI_HANDLE ImageHandle,
42 IN EFI_SYSTEM_TABLE *SystemTable
43 )
44{
45 EFI_STATUS Status;
46 VOID *AcpiParameterBuffer;
47 ACPI_PARAMETER_BUFFER_DESCRIPTOR *AcpiParamBufferDescriptor;
48 PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
49
50 AcpiParameterBuffer = NULL;
51 AcpiParamBufferDescriptor = NULL;
52 PrmConfigProtocol = NULL;
53
54 /*
55 In this sample PRM module, the protocol describing this sample module's resources is simply
56 installed in the constructor.
57
58 However, if some data is not available until later, this constructor could register a callback
59 on the dependency for the data to be available (e.g. ability to communicate with some device)
60 and then install the protocol. The requirement is that the protocol is installed before end of DXE.
61 */
62
63 // Allocate the ACPI parameter buffer
64
65 // A parameter buffer is arbitrary data that is handler specific. This handler buffer is specified
66 // to consist of a UINT32 that represents the test data signature ('T', 'E', 'S', 'T').
67 AcpiParameterBuffer = AllocateRuntimeZeroPool (sizeof (UINT32));
68 ASSERT (AcpiParameterBuffer != NULL);
69 if (AcpiParameterBuffer == NULL) {
70 Status = EFI_OUT_OF_RESOURCES;
71 goto Done;
72 }
73
74 // Allocate the ACPI Parameter Buffer Descriptor structure for a single PRM handler
75 AcpiParamBufferDescriptor = AllocateZeroPool (sizeof (*AcpiParamBufferDescriptor));
76 ASSERT (AcpiParamBufferDescriptor != NULL);
77 if (AcpiParamBufferDescriptor == NULL) {
78 Status = EFI_OUT_OF_RESOURCES;
79 goto Done;
80 }
81
82 // Allocate the PRM Configuration protocol structure for this PRM module
83 PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol));
84 ASSERT (PrmConfigProtocol != NULL);
85 if (PrmConfigProtocol == NULL) {
86 Status = EFI_OUT_OF_RESOURCES;
87 goto Done;
88 }
89
90 CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
91
92 // Populate the ACPI Parameter Buffer Descriptor structure
93 CopyGuid (&AcpiParamBufferDescriptor->HandlerGuid, &mCheckParamBufferPrmHandlerGuid);
94 AcpiParamBufferDescriptor->AcpiParameterBufferAddress = (UINT64)(UINTN)AcpiParameterBuffer;
95
96 // Populate the PRM Module Context Buffers structure
97 PrmConfigProtocol->ModuleContextBuffers.AcpiParameterBufferDescriptorCount = 1;
98 PrmConfigProtocol->ModuleContextBuffers.AcpiParameterBufferDescriptors = AcpiParamBufferDescriptor;
99
100 //
101 // Install the PRM Configuration Protocol for this module. This indicates the configuration
102 // library has completed resource initialization for the PRM module.
103 //
104 Status = gBS->InstallProtocolInterface (
105 &mPrmConfigProtocolHandle,
106 &gPrmConfigProtocolGuid,
108 (VOID *)PrmConfigProtocol
109 );
110
111Done:
112 if (EFI_ERROR (Status)) {
113 if (AcpiParameterBuffer != NULL) {
114 FreePool (AcpiParameterBuffer);
115 }
116
117 if (AcpiParamBufferDescriptor != NULL) {
118 FreePool (AcpiParamBufferDescriptor);
119 }
120
121 if (PrmConfigProtocol != NULL) {
122 FreePool (PrmConfigProtocol);
123 }
124 }
125
126 return Status;
127}
UINT64 UINTN
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
EFI_STATUS EFIAPI AcpiParameterBufferModuleConfigLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateRuntimeZeroPool(IN UINTN AllocationSize)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_BOOT_SERVICES * gBS
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
Definition: Base.h:213
ACPI_PARAMETER_BUFFER_DESCRIPTOR * AcpiParameterBufferDescriptors