aboutsummaryrefslogtreecommitdiff
path: root/src/arch/mips/include/arch/cache.h
blob: c610c991cf7272e1278a48d43c1df71f025e75e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * This file is part of the coreboot project.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __MIPS_ARCH_CACHE_H
#define __MIPS_ARCH_CACHE_H

#include <stddef.h>
#include <stdint.h>

#define CACHE_TYPE_SHIFT	(0)
#define CACHE_OP_SHIFT		(2)
#define CACHE_TYPE_MASK		(0x3)
#define CACHE_OP_MASK		(0x7)

/* Cache type */
#define ICACHE			0x00
#define DCACHE			0x01
#define L2CACHE			0x03

/* Cache operation*/
#define WB_INVD			0x05

#define CACHE_CODE(type, op)	((((type) & (CACHE_TYPE_MASK)) <<	\
				(CACHE_TYPE_SHIFT)) |			\
				(((op) & (CACHE_OP_MASK)) << (CACHE_OP_SHIFT)))

/* Perform cache operation on cache lines for target addresses */
void perform_cache_operation(uintptr_t start, size_t size, uint8_t operation);
/* Invalidate all caches: instruction, data, L2 data */
void cache_invalidate_all(uintptr_t start, size_t size);

/* TODO: Global cache API. Implement properly once we finally have a MIPS board
   again where we can figure out what exactly these should be doing. */
static inline void dcache_clean_all(void) {}
static inline void dcache_invalidate_all(void) {}
static inline void dcache_clean_invalidate_all(void) {}

#endif /* __MIPS_ARCH_CACHE_H */