• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
CacheRangeOperation(IN VOID * Start,IN UINTN Length,IN LINE_OPERATION LineOperation)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
InvalidateInstructionCache(VOID)44 InvalidateInstructionCache (
45   VOID
46   )
47 {
48   ASSERT (FALSE);
49 }
50 
51 VOID
52 EFIAPI
InvalidateDataCache(VOID)53 InvalidateDataCache (
54   VOID
55   )
56 {
57   ASSERT (FALSE);
58 }
59 
60 VOID *
61 EFIAPI
InvalidateInstructionCacheRange(IN VOID * Address,IN UINTN Length)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
WriteBackInvalidateDataCache(VOID)74 WriteBackInvalidateDataCache (
75   VOID
76   )
77 {
78   ASSERT (FALSE);
79 }
80 
81 VOID *
82 EFIAPI
WriteBackInvalidateDataCacheRange(IN VOID * Address,IN UINTN Length)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
WriteBackDataCache(VOID)94 WriteBackDataCache (
95   VOID
96   )
97 {
98   ASSERT (FALSE);
99 }
100 
101 VOID *
102 EFIAPI
WriteBackDataCacheRange(IN VOID * Address,IN UINTN Length)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
InvalidateDataCacheRange(IN VOID * Address,IN UINTN Length)114 InvalidateDataCacheRange (
115   IN      VOID                      *Address,
116   IN      UINTN                     Length
117   )
118 {
119   CacheRangeOperation(Address, Length, ArmInvalidateDataCacheEntryByMVA);
120   return Address;
121 }
122