]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
ArmPkg/ArmMmuLib: support page tables in cacheable memory only
[mirror_edk2.git] / ArmPkg / Library / ArmMmuLib / AArch64 / ArmMmuPeiLibConstructor.c
CommitLineData
87bcfe13
AB
1#/* @file\r
2#\r
3# Copyright (c) 2016, Linaro Limited. All rights reserved.\r
4#\r
5# This program and the accompanying materials\r
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13#*/\r
14\r
15#include <Base.h>\r
16\r
17#include <Library/ArmLib.h>\r
18#include <Library/ArmMmuLib.h>\r
19#include <Library/CacheMaintenanceLib.h>\r
20#include <Library/DebugLib.h>\r
21\r
22EFI_STATUS\r
23EFIAPI\r
24ArmMmuPeiLibConstructor (\r
25 IN EFI_PEI_FILE_HANDLE FileHandle,\r
26 IN CONST EFI_PEI_SERVICES **PeiServices\r
27 )\r
28{\r
29 extern UINT32 ArmReplaceLiveTranslationEntrySize;\r
30\r
31 EFI_FV_FILE_INFO FileInfo;\r
32 EFI_STATUS Status;\r
33\r
34 ASSERT (FileHandle != NULL);\r
35\r
36 Status = (*PeiServices)->FfsGetFileInfo (FileHandle, &FileInfo);\r
37 ASSERT_EFI_ERROR (Status);\r
38\r
39 //\r
40 // Some platforms do not cope very well with cache maintenance being\r
41 // performed on regions backed by NOR flash. Since the firmware image\r
42 // can be assumed to be clean to the PoC when running XIP, even when PEI\r
43 // is executing from DRAM, we only need to perform the cache maintenance\r
44 // when not executing in place.\r
45 //\r
46 if ((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry &&\r
47 ((UINTN)FileInfo.Buffer + FileInfo.BufferSize >=\r
48 (UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize)) {\r
49 DEBUG ((EFI_D_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));\r
50 } else {\r
51 DEBUG ((EFI_D_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));\r
52 //\r
53 // The ArmReplaceLiveTranslationEntry () helper function may be invoked\r
54 // with the MMU off so we have to ensure that it gets cleaned to the PoC\r
55 //\r
56 WriteBackDataCacheRange (ArmReplaceLiveTranslationEntry,\r
57 ArmReplaceLiveTranslationEntrySize);\r
58 }\r
59\r
60 return RETURN_SUCCESS;\r
61}\r