FreeNOS
ARMCacheV6.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ARMCore.h"
19#include "ARMCacheV6.h"
20
22{
23 switch (type)
24 {
25 case Instruction:
26 return cleanInvalidate(type);
27
28 case Data:
29 mcr(p15, 0, 0, c7, c6, 0);
30 dsb();
31 break;
32
33 case Unified:
36 break;
37 }
38 return Success;
39}
40
42{
43 switch (type)
44 {
45 case Instruction:
46 //
47 // Invalidate all instruction caches to PoU.
48 // Also flushes branch target cache.
49 //
50 mcr(p15, 0, 0, c7, c5, 0);
51
52 // Invalidate entire branch predictor array
54
55 // Full system DSB - make sure that the invalidation is complete
56 dsb();
57
58 // Make sure the instruction stream sees it
60 break;
61
62 case Data:
63 mcr(p15, 0, 0, c7, c14, 0);
64 break;
65
66 case Unified:
67 mcr(p15, 0, 0, c7, c5, 0); // invalidate entire instruction cache
68 mcr(p15, 0, 0, c7, c10, 0); // clean entire data cache
69 mcr(p15, 0, 0, c7, c7, 0); // invalidate entire cache
71 dsb();
73 break;
74 }
75 return Success;
76}
77
79{
80 switch (type)
81 {
82 case Instruction:
83 mcr(p15, 0, 1, c7, c5, addr);
84 break;
85
86 case Data:
87 mcr(p15, 0, 1, c7, c14, addr);
88 break;
89
90 case Unified:
91 break;
92 }
93 return Success;
94}
95
97{
98 switch (type)
99 {
100 case Instruction:
101 break;
102
103 case Data:
104 mcr(p15, 0, 1, c7, c10, addr);
105 break;
106
107 case Unified:
108 break;
109 }
110 return Success;
111}
112
#define dsb(type)
Data Memory Barrier.
u8 type
Definition IntelACPI.h:0
virtual Result cleanInvalidateAddress(Type type, Address addr)
Clean and invalidate one memory page.
virtual Result invalidateAddress(Type type, Address addr)
Invalidate one memory page.
virtual Result invalidate(Type type)
Invalidate the entire cache.
virtual Result cleanInvalidate(Type type)
Clean and invalidate entire cache.
virtual Result cleanAddress(Type type, Address addr)
Clean one memory page.
Result
Result codes.
Definition Cache.h:43
@ NotSupported
Definition Cache.h:47
@ Success
Definition Cache.h:44
Type
Cache types.
Definition Cache.h:54
@ Unified
Definition Cache.h:57
@ Data
Definition Cache.h:56
@ Instruction
Definition Cache.h:55
void flushPrefetchBuffer()
Flush Prefetch Buffer.
Definition ARMCore.h:230
void flushBranchPrediction()
Flush branch prediction.
Definition ARMCore.h:210
#define mcr(coproc, opcode1, opcode2, reg, subReg, value)
Move to CoProcessor from ARM (MCR).
Definition ARMCore.h:63
unsigned long Address
A memory address.
Definition Types.h:131