FreeNOS
lib
libarch
arm
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
21
ARMCacheV6::Result
ARMCacheV6::invalidate
(
ARMCacheV6::Type
type
)
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
:
34
invalidate
(
Instruction
);
35
invalidate
(
Data
);
36
break
;
37
}
38
return
Success
;
39
}
40
41
ARMCacheV6::Result
ARMCacheV6::cleanInvalidate
(
ARMCacheV6::Type
type
)
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
53
flushBranchPrediction
();
54
55
// Full system DSB - make sure that the invalidation is complete
56
dsb
();
57
58
// Make sure the instruction stream sees it
59
flushPrefetchBuffer
();
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
70
flushBranchPrediction
();
71
dsb
();
72
flushPrefetchBuffer
();
73
break
;
74
}
75
return
Success
;
76
}
77
78
ARMCacheV6::Result
ARMCacheV6::cleanInvalidateAddress
(
Type
type
,
Address
addr)
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
96
ARMCacheV6::Result
ARMCacheV6::cleanAddress
(
ARMCacheV6::Type
type
,
Address
addr)
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
113
ARMCacheV6::Result
ARMCacheV6::invalidateAddress
(
ARMCacheV6::Type
type
,
Address
addr)
114
{
115
return
ARMCacheV6::NotSupported
;
116
}
Cache::Type
Type
Cache types.
Definition:
Cache.h:53
ARMCacheV6::cleanInvalidate
virtual Result cleanInvalidate(Type type)
Clean and invalidate entire cache.
Definition:
ARMCacheV6.cpp:41
mcr
#define mcr(coproc, opcode1, opcode2, reg, subReg, value)
Move to CoProcessor from ARM (MCR).
Definition:
ARMCore.h:63
dsb
void dsb()
Data Synchronisation Barrier.
Definition:
ARMCore.h:198
flushPrefetchBuffer
void flushPrefetchBuffer()
Flush Prefetch Buffer.
Definition:
ARMCore.h:230
ARMCacheV6::cleanAddress
virtual Result cleanAddress(Type type, Address addr)
Clean one memory page.
Definition:
ARMCacheV6.cpp:96
Cache::Data
@ Data
Definition:
Cache.h:56
ARMCore.h
Address
unsigned long Address
A memory address.
Definition:
Types.h:131
ARMCacheV6.h
Cache::NotSupported
@ NotSupported
Definition:
Cache.h:47
Cache::Success
@ Success
Definition:
Cache.h:44
ARMCacheV6::cleanInvalidateAddress
virtual Result cleanInvalidateAddress(Type type, Address addr)
Clean and invalidate one memory page.
Definition:
ARMCacheV6.cpp:78
ARMCacheV6::invalidate
virtual Result invalidate(Type type)
Invalidate the entire cache.
Definition:
ARMCacheV6.cpp:21
ARMCacheV6::invalidateAddress
virtual Result invalidateAddress(Type type, Address addr)
Invalidate one memory page.
Definition:
ARMCacheV6.cpp:113
Cache::Result
Result
Result codes.
Definition:
Cache.h:42
Cache::Unified
@ Unified
Definition:
Cache.h:57
type
u8 type
Definition:
IntelACPI.h:63
flushBranchPrediction
void flushBranchPrediction()
Flush branch prediction.
Definition:
ARMCore.h:210
Cache::Instruction
@ Instruction
Definition:
Cache.h:55
Generated by
1.8.17