12
12
#include <Library/AcpiLib.h>
13
13
#include <Library/BaseMemoryLib.h>
14
14
#include <Library/DebugLib.h>
15
+ #include <Library/UefiBootServicesTableLib.h>
16
+ #include <AcpiTables.h>
15
17
#include <VarStoreData.h>
16
18
17
19
STATIC CONST EFI_GUID mAcpiTableFile = {
@@ -153,12 +155,26 @@ AcpiVerifyUpdateTable (
153
155
return Result ;
154
156
}
155
157
156
- //
157
- // Monitor the ACPI tables being installed and when
158
- // a DSDT/SSDT is detected validate that we want to
159
- // install it, and if so update any "NameOp" defined
160
- // variables contained in the table from PCD values
161
- //
158
+ STATIC
159
+ BOOLEAN
160
+ AcpiFixupMcfg (
161
+ IN EFI_ACPI_DESCRIPTION_HEADER * AcpiHeader
162
+ )
163
+ {
164
+ RK3588_MCFG_TABLE * Table ;
165
+ UINT32 Seg ;
166
+
167
+ Table = (RK3588_MCFG_TABLE * ) AcpiHeader ;
168
+
169
+ for (Seg = 0 ; Seg < ARRAY_SIZE (Table -> Entry ); Seg ++ ) {
170
+ if ((PcdGet32 (PcdPcieEcamCompliantSegmentsMask ) & (1 << Seg )) != 0 ) {
171
+ Table -> Entry [Seg ].BaseAddress -= 0x8000 ;
172
+ }
173
+ }
174
+
175
+ return TRUE;
176
+ }
177
+
162
178
STATIC
163
179
BOOLEAN
164
180
AcpiHandleDynamicNamespace (
@@ -169,11 +185,30 @@ AcpiHandleDynamicNamespace (
169
185
case SIGNATURE_32 ('D' , 'S' , 'D' , 'T' ):
170
186
case SIGNATURE_32 ('S' , 'S' , 'D' , 'T' ):
171
187
return AcpiVerifyUpdateTable (AcpiHeader );
188
+ case SIGNATURE_32 ('M' , 'C' , 'F' , 'G' ):
189
+ return AcpiFixupMcfg (AcpiHeader );
172
190
}
173
191
174
192
return TRUE;
175
193
}
176
194
195
+ STATIC
196
+ VOID
197
+ EFIAPI
198
+ NotifyEndOfDxeEvent (
199
+ IN EFI_EVENT Event ,
200
+ IN VOID * Context
201
+ )
202
+ {
203
+ EFI_STATUS Status ;
204
+
205
+ Status = LocateAndInstallAcpiFromFvConditional (& mAcpiTableFile , & AcpiHandleDynamicNamespace );
206
+ if (EFI_ERROR (Status )) {
207
+ DEBUG ((DEBUG_WARN , "AcpiPlatform: Failed to install firmware ACPI as config table. Status=%r\n" ,
208
+ Status ));
209
+ }
210
+ }
211
+
177
212
EFI_STATUS
178
213
EFIAPI
179
214
AcpiPlatformDxeInitialize (
@@ -182,18 +217,22 @@ AcpiPlatformDxeInitialize (
182
217
)
183
218
{
184
219
EFI_STATUS Status ;
220
+ EFI_EVENT Event ;
185
221
186
222
if ((PcdGet32 (PcdConfigTableMode ) & CONFIG_TABLE_MODE_ACPI ) == 0 ) {
187
223
DEBUG ((DEBUG_WARN , "AcpiPlatform: ACPI support is disabled by the settings.\n" ));
188
224
return EFI_UNSUPPORTED ;
189
225
}
190
226
191
- Status = LocateAndInstallAcpiFromFvConditional (& mAcpiTableFile , & AcpiHandleDynamicNamespace );
192
- if (EFI_ERROR (Status )) {
193
- DEBUG ((DEBUG_WARN , "AcpiPlatform: Failed to install firmware ACPI as config table. Status=%r\n" ,
194
- Status ));
195
- return Status ;
196
- }
227
+ Status = gBS -> CreateEventEx (
228
+ EVT_NOTIFY_SIGNAL , // Type
229
+ TPL_CALLBACK , // NotifyTpl
230
+ NotifyEndOfDxeEvent , // NotifyFunction
231
+ NULL , // NotifyContext
232
+ & gEfiEndOfDxeEventGroupGuid , // EventGroup
233
+ & Event // Event
234
+ );
235
+ ASSERT_EFI_ERROR (Status );
197
236
198
237
return EFI_SUCCESS ;
199
238
}
0 commit comments