]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
ArmPkg: Apply uncrustify changes
[mirror_edk2.git] / ArmPkg / Library / ArmMmuLib / AArch64 / ArmMmuPeiLibConstructor.c
1 /** @file
2
3 Copyright (c) 2016, Linaro Limited. All rights reserved.
4 Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 */
8
9 #include <Base.h>
10
11 #include <Library/ArmLib.h>
12 #include <Library/ArmMmuLib.h>
13 #include <Library/CacheMaintenanceLib.h>
14 #include <Library/DebugLib.h>
15
16 EFI_STATUS
17 EFIAPI
18 ArmMmuPeiLibConstructor (
19 IN EFI_PEI_FILE_HANDLE FileHandle,
20 IN CONST EFI_PEI_SERVICES **PeiServices
21 )
22 {
23 extern UINT32 ArmReplaceLiveTranslationEntrySize;
24
25 EFI_FV_FILE_INFO FileInfo;
26 EFI_STATUS Status;
27
28 ASSERT (FileHandle != NULL);
29
30 Status = (*PeiServices)->FfsGetFileInfo (FileHandle, &FileInfo);
31 ASSERT_EFI_ERROR (Status);
32
33 //
34 // Some platforms do not cope very well with cache maintenance being
35 // performed on regions backed by NOR flash. Since the firmware image
36 // can be assumed to be clean to the PoC when running XIP, even when PEI
37 // is executing from DRAM, we only need to perform the cache maintenance
38 // when not executing in place.
39 //
40 if (((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry) &&
41 ((UINTN)FileInfo.Buffer + FileInfo.BufferSize >=
42 (UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize))
43 {
44 DEBUG ((DEBUG_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));
45 } else {
46 DEBUG ((DEBUG_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));
47 //
48 // The ArmReplaceLiveTranslationEntry () helper function may be invoked
49 // with the MMU off so we have to ensure that it gets cleaned to the PoC
50 //
51 WriteBackDataCacheRange (
52 (VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
53 ArmReplaceLiveTranslationEntrySize
54 );
55 }
56
57 return RETURN_SUCCESS;
58 }