]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c
ArmPkg: update InvalidateInstructionCacheRange to flush only to PoU
[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 - 2014, ARM Limited. All rights reserved.
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 #include <Base.h>
16 #include <Library/ArmLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/PcdLib.h>
19
20 VOID
21 CacheRangeOperation (
22 IN VOID *Start,
23 IN UINTN Length,
24 IN LINE_OPERATION LineOperation
25 )
26 {
27 UINTN ArmCacheLineLength = ArmDataCacheLineLength();
28 UINTN ArmCacheLineAlignmentMask = ArmCacheLineLength - 1;
29
30 // Align address (rounding down)
31 UINTN AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask);
32 UINTN EndAddress = (UINTN)Start + Length;
33
34 // Perform the line operation on an address in each cache line
35 while (AlignedAddress < EndAddress) {
36 LineOperation(AlignedAddress);
37 AlignedAddress += ArmCacheLineLength;
38 }
39 ArmDataSynchronizationBarrier ();
40 }
41
42 VOID
43 EFIAPI
44 InvalidateInstructionCache (
45 VOID
46 )
47 {
48 ASSERT (FALSE);
49 }
50
51 VOID
52 EFIAPI
53 InvalidateDataCache (
54 VOID
55 )
56 {
57 ASSERT (FALSE);
58 }
59
60 VOID *
61 EFIAPI
62 InvalidateInstructionCacheRange (
63 IN VOID *Address,
64 IN UINTN Length
65 )
66 {
67 CacheRangeOperation (Address, Length, ArmCleanDataCacheEntryToPoUByMVA);
68 ArmInvalidateInstructionCache ();
69 return Address;
70 }
71
72 VOID
73 EFIAPI
74 WriteBackInvalidateDataCache (
75 VOID
76 )
77 {
78 ASSERT (FALSE);
79 }
80
81 VOID *
82 EFIAPI
83 WriteBackInvalidateDataCacheRange (
84 IN VOID *Address,
85 IN UINTN Length
86 )
87 {
88 CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCacheEntryByMVA);
89 return Address;
90 }
91
92 VOID
93 EFIAPI
94 WriteBackDataCache (
95 VOID
96 )
97 {
98 ASSERT (FALSE);
99 }
100
101 VOID *
102 EFIAPI
103 WriteBackDataCacheRange (
104 IN VOID *Address,
105 IN UINTN Length
106 )
107 {
108 CacheRangeOperation(Address, Length, ArmCleanDataCacheEntryByMVA);
109 return Address;
110 }
111
112 VOID *
113 EFIAPI
114 InvalidateDataCacheRange (
115 IN VOID *Address,
116 IN UINTN Length
117 )
118 {
119 CacheRangeOperation(Address, Length, ArmInvalidateDataCacheEntryByMVA);
120 return Address;
121 }