TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmMmuPeiLibConstructor.c
Go to the documentation of this file.
1
9#include <Base.h>
10
11#include <Library/ArmLib.h>
12#include <Library/ArmMmuLib.h>
14#include <Library/DebugLib.h>
15#include <Library/HobLib.h>
16#include "ArmMmuLibInternal.h"
17
19EFIAPI
20ArmMmuPeiLibConstructor (
21 IN EFI_PEI_FILE_HANDLE FileHandle,
22 IN CONST EFI_PEI_SERVICES **PeiServices
23 )
24{
25 extern UINT32 ArmReplaceLiveTranslationEntrySize;
26 ARM_REPLACE_LIVE_TRANSLATION_ENTRY ArmReplaceLiveTranslationEntryFunc;
27 VOID *Hob;
28
30 EFI_STATUS Status;
31
32 ASSERT (FileHandle != NULL);
33
34 Status = (*PeiServices)->FfsGetFileInfo (FileHandle, &FileInfo);
35 ASSERT_EFI_ERROR (Status);
36
37 //
38 // Some platforms do not cope very well with cache maintenance being
39 // performed on regions backed by NOR flash. Since the firmware image
40 // can be assumed to be clean to the PoC when running XIP, even when PEI
41 // is executing from DRAM, we only need to perform the cache maintenance
42 // when not executing in place.
43 //
44 if (((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry) &&
45 ((UINTN)FileInfo.Buffer + FileInfo.BufferSize >=
46 (UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize))
47 {
48 DEBUG ((DEBUG_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));
49
50 //
51 // Expose the XIP version of the ArmReplaceLiveTranslationEntry() routine
52 // via a HOB so we can fall back to it later when we need to split block
53 // mappings in a way that adheres to break-before-make requirements.
54 //
55 ArmReplaceLiveTranslationEntryFunc = ArmReplaceLiveTranslationEntry;
56
57 Hob = BuildGuidDataHob (
58 &gArmMmuReplaceLiveTranslationEntryFuncGuid,
59 &ArmReplaceLiveTranslationEntryFunc,
60 sizeof ArmReplaceLiveTranslationEntryFunc
61 );
62 ASSERT (Hob != NULL);
63 } else {
64 DEBUG ((DEBUG_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));
65 //
66 // The ArmReplaceLiveTranslationEntry () helper function may be invoked
67 // with the MMU off so we have to ensure that it gets cleaned to the PoC
68 //
70 (VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
71 ArmReplaceLiveTranslationEntrySize
72 );
73 }
74
75 return RETURN_SUCCESS;
76}
UINT64 UINTN
VOID *EFIAPI WriteBackDataCacheRange(IN VOID *Address, IN UINTN Length)
VOID *EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
Definition: HobLib.c:375
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define RETURN_SUCCESS
Definition: Base.h:1066
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID * EFI_PEI_FILE_HANDLE
Definition: PiPeiCis.h:26
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29