]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/bsp/install/include/metal/cache.h
Update RISCC-V-RV32-SiFive_HiFive1_FreedomStudio project to latest tools and metal...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / bsp / install / include / metal / cache.h
1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #ifndef METAL__CACHE_H
5 #define METAL__CACHE_H
6
7 /*!
8  * @file cache.h
9  *
10  * @brief API for configuring caches
11  */
12
13 struct metal_cache;
14
15 struct __metal_cache_vtable {
16         void (*init)(struct metal_cache *cache, int ways);
17         int (*get_enabled_ways)(struct metal_cache *cache);
18         int (*set_enabled_ways)(struct metal_cache *cache, int ways);
19 };
20
21 /*!
22  * @brief a handle for a cache
23  */
24 struct metal_cache {
25         const struct __metal_cache_vtable *vtable;
26 };
27
28 /*!
29  * @brief Initialize a cache
30  * @param cache The handle for the cache to initialize
31  * @param ways The number of ways to enable
32  *
33  * Initializes a cache with the requested number of ways enabled.
34  */
35 inline void metal_cache_init(struct metal_cache *cache, int ways) {
36         return cache->vtable->init(cache, ways);
37 }
38
39 /*!
40  * @brief Get the current number of enabled cache ways
41  * @param cache The handle for the cache
42  * @return The current number of enabled cache ways
43  */
44 inline int metal_cache_get_enabled_ways(struct metal_cache *cache) {
45         return cache->vtable->get_enabled_ways(cache);
46 }
47
48 /*!
49  * @brief Enable the requested number of cache ways
50  * @param cache The handle for the cache
51  * @param ways The number of ways to enabled
52  * @return 0 if the ways are successfully enabled
53  */
54 inline int metal_cache_set_enabled_ways(struct metal_cache *cache, int ways) {
55         return cache->vtable->set_enabled_ways(cache, ways);
56 }
57
58 #endif