]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c
ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib
[mirror_edk2.git] / ArmPkg / Library / ArmCacheMaintenanceLib / ArmCacheMaintenanceLib.c
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2021, ARM Limited. All rights reserved.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9 #include <Base.h>
10 #include <Library/ArmLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/PcdLib.h>
13
14 STATIC
15 VOID
16 CacheRangeOperation (
17 IN VOID *Start,
18 IN UINTN Length,
19 IN LINE_OPERATION LineOperation,
20 IN UINTN LineLength
21 )
22 {
23 UINTN ArmCacheLineAlignmentMask;
24 // Align address (rounding down)
25 UINTN AlignedAddress;
26 UINTN EndAddress;
27
28 ArmCacheLineAlignmentMask = LineLength - 1;
29 AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask);
30 EndAddress = (UINTN)Start + Length;
31
32 // Perform the line operation on an address in each cache line
33 while (AlignedAddress < EndAddress) {
34 LineOperation(AlignedAddress);
35 AlignedAddress += LineLength;
36 }
37 ArmDataSynchronizationBarrier ();
38 }
39
40 VOID
41 EFIAPI
42 InvalidateInstructionCache (
43 VOID
44 )
45 {
46 ASSERT (FALSE);
47 }
48
49 VOID
50 EFIAPI
51 InvalidateDataCache (
52 VOID
53 )
54 {
55 ASSERT (FALSE);
56 }
57
58 VOID *
59 EFIAPI
60 InvalidateInstructionCacheRange (
61 IN VOID *Address,
62 IN UINTN Length
63 )
64 {
65 CacheRangeOperation (Address, Length, ArmCleanDataCacheEntryToPoUByMVA,
66 ArmDataCacheLineLength ());
67 CacheRangeOperation (Address, Length,
68 ArmInvalidateInstructionCacheEntryToPoUByMVA,
69 ArmInstructionCacheLineLength ());
70
71 ArmInstructionSynchronizationBarrier ();
72
73 return Address;
74 }
75
76 VOID
77 EFIAPI
78 WriteBackInvalidateDataCache (
79 VOID
80 )
81 {
82 ASSERT (FALSE);
83 }
84
85 VOID *
86 EFIAPI
87 WriteBackInvalidateDataCacheRange (
88 IN VOID *Address,
89 IN UINTN Length
90 )
91 {
92 CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCacheEntryByMVA,
93 ArmDataCacheLineLength ());
94 return Address;
95 }
96
97 VOID
98 EFIAPI
99 WriteBackDataCache (
100 VOID
101 )
102 {
103 ASSERT (FALSE);
104 }
105
106 VOID *
107 EFIAPI
108 WriteBackDataCacheRange (
109 IN VOID *Address,
110 IN UINTN Length
111 )
112 {
113 CacheRangeOperation(Address, Length, ArmCleanDataCacheEntryByMVA,
114 ArmDataCacheLineLength ());
115 return Address;
116 }
117
118 VOID *
119 EFIAPI
120 InvalidateDataCacheRange (
121 IN VOID *Address,
122 IN UINTN Length
123 )
124 {
125 CacheRangeOperation(Address, Length, ArmInvalidateDataCacheEntryByMVA,
126 ArmDataCacheLineLength ());
127 return Address;
128 }