FreeNOS
ARM64Cache.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Ivan Tan
3 * Copyright (C) 2015 Niek Linnenbank
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
20 * Partly based on cache_v7.c from the Android project:
21 *
22 * https://android.googlesource.com/device/ti/bootloader/uboot/+/c0eec2d5698a6722a195f4545064dccfb4010c16/arch/arm/cpu/armv7/cache_v7.c
23 */
24
25#include "ARM64Cache.h"
26
28{
29 switch (type)
30 {
31 case Instruction:
32 return cleanInvalidate(type);
33
34 case Data:
35 return dataFlush(false);
36
37 case Unified:
40 break;
41 }
42 return Success;
43}
44
49
54
59
64
66{
67 return 0;
68}
69
71{
72 return 0;
73}
74
76{
77 return 0;
78}
79
80static inline s32 log_2_n_round_up(u32 n)
81{
82 s32 log2n = -1;
83 u32 temp = n;
84
85 while (temp) {
86 log2n++;
87 temp >>= 1;
88 }
89
90 if (n & (n - 1))
91 return log2n + 1; // not power of 2 - round up
92 else
93 return log2n; // power of 2
94}
95
96
98{
99 return Success;
100}
101
103{
104 return Success;
105}
106
static s32 log_2_n_round_up(u32 n)
u8 type
Definition IntelACPI.h:0
virtual Result cleanInvalidateAddress(Type type, Address addr)
Clean and invalidate one memory page.
u32 getCacheLevelId() const
Get cache level identifier.
virtual Result invalidate(Type type)
Invalidate the entire cache.
u32 readCacheSize(u32 level, u32 type) const
Get cache size.
virtual Result cleanInvalidate(Type type)
Clean and invalidate entire cache.
virtual Result cleanAddress(Type type, Address addr)
Clean one memory page.
Result dataFlush(bool clean)
Flush the entire data cache.
Result flushLevel(u32 level, bool clean)
Clean and Invalidate by cache level.
u32 getCacheLineSize() const
Get cache line size in bytes.
virtual Result invalidateAddress(Type type, Address addr)
Invalidate one memory page.
Result
Result codes.
Definition Cache.h:43
@ 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
signed int s32
Signed 32-bit number.
Definition Types.h:80
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned long Address
A memory address.
Definition Types.h:131