TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeHardwareAccessModuleConfigLib.c
Go to the documentation of this file.
1
10#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
15#include <Protocol/PrmConfig.h>
17
18STATIC EFI_HANDLE mPrmConfigProtocolHandle;
19
20// {0ef93ed7-14ae-425b-928f-b85a6213b57e}
21STATIC CONST EFI_GUID mPrmModuleGuid = {
22 0x0ef93ed7, 0x14ae, 0x425b, { 0x92, 0x8f, 0xb8, 0x5a, 0x62, 0x13, 0xb5, 0x7e }
23};
24
35EFIAPI
37 IN EFI_HANDLE ImageHandle,
38 IN EFI_SYSTEM_TABLE *SystemTable
39 )
40{
41 EFI_STATUS Status;
42 PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges;
43 PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
44
45 RuntimeMmioRanges = NULL;
46 PrmConfigProtocol = NULL;
47
48 /*
49 In this sample PRM module, the protocol describing this sample module's resources is simply
50 installed in the constructor.
51
52 However, if some data is not available until later, this constructor could register a callback
53 on the dependency for the data to be available (e.g. ability to communicate with some device)
54 and then install the protocol. The requirement is that the protocol is installed before end of DXE.
55 */
56
57 // Runtime MMIO Ranges structure
58
59 // Since this sample module only uses 1 runtime MMIO range, it can use the PRM_RUNTIME_MMIO_RANGES
60 // type directly without extending the size of the data buffer for additional MMIO ranges.
61 RuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*RuntimeMmioRanges));
62 ASSERT (RuntimeMmioRanges != NULL);
63 if (RuntimeMmioRanges == NULL) {
64 Status = EFI_OUT_OF_RESOURCES;
65 goto Done;
66 }
67
68 // Allocate the PRM Configuration protocol structure for this PRM module
69 PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol));
70 ASSERT (PrmConfigProtocol != NULL);
71 if (PrmConfigProtocol == NULL) {
72 Status = EFI_OUT_OF_RESOURCES;
73 goto Done;
74 }
75
76 CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
77
78 // Populate the Runtime MMIO Ranges structure
79 RuntimeMmioRanges->Count = 1;
80 RuntimeMmioRanges->Range[0].PhysicalBaseAddress = HPET_BASE_ADDRESS;
81 RuntimeMmioRanges->Range[0].Length = HPET_RANGE_LENGTH;
82
83 PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges = RuntimeMmioRanges;
84
85 //
86 // Install the PRM Configuration Protocol for this module. This indicates the configuration
87 // library has completed resource initialization for the PRM module.
88 //
89 Status = gBS->InstallProtocolInterface (
90 &mPrmConfigProtocolHandle,
91 &gPrmConfigProtocolGuid,
93 (VOID *)PrmConfigProtocol
94 );
95
96Done:
97 if (EFI_ERROR (Status)) {
98 if (RuntimeMmioRanges != NULL) {
99 FreePool (RuntimeMmioRanges);
100 }
101
102 if (PrmConfigProtocol != NULL) {
103 FreePool (PrmConfigProtocol);
104 }
105 }
106
107 return Status;
108}
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
EFI_STATUS EFIAPI HardwareAccessModuleConfigLibConstructor(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
PRM_RUNTIME_MMIO_RANGES * RuntimeMmioRanges
PRM_RUNTIME_MMIO_RANGE Range[1]
Definition: PrmMmio.h:40