Caches¶
API for configuring caches.
Functions
- 
int 
metal_l2cache_init(void)¶ Initialize L2 cache controller. Enables all available cache ways.
- Return
 0 If no error
- Parameters
 None:
- 
int 
metal_l2cache_get_enabled_ways(void)¶ Get the current number of enabled L2 cache ways.
- Return
 The current number of enabled L2 cache ways
- Parameters
 None:
- 
int 
metal_l2cache_set_enabled_ways(int ways)¶ Enable the requested number of L2 cache ways.
- Return
 0 if the ways are successfully enabled
- Parameters
 ways: Number of ways to enable
- 
__inline__ void 
metal_cache_init(struct metal_cache *cache, int ways)¶ Initialize a cache.
Initializes a cache with the requested number of ways enabled. Note: API to be deprecated in next release.
- Parameters
 cache: The handle for the cache to initializeways: The number of ways to enable
- 
__inline__ int 
metal_cache_get_enabled_ways(struct metal_cache *cache)¶ Get the current number of enabled cache ways.
- Return
 The current number of enabled cache ways Note: API to be deprecated in next release.
- Parameters
 cache: The handle for the cache
- 
__inline__ int 
metal_cache_set_enabled_ways(struct metal_cache *cache, int ways)¶ Enable the requested number of cache ways.
- Return
 0 if the ways are successfully enabled Note: API to be deprecated in next release.
- Parameters
 cache: The handle for the cacheways: The number of ways to enabled
- 
int 
metal_dcache_l1_available(int hartid)¶ Check if dcache is supported on the core.
- Return
 1 if dcache is present
- Parameters
 hartid: The core to check
- 
void 
metal_dcache_l1_flush(int hartid, uintptr_t address)¶ Flush dcache for L1 on the requested core with write back.
- Return
 None
- Parameters
 hartid: The core to flushaddress: The virtual address of cacheline to invalidate
- 
void 
metal_dcache_l1_discard(int hartid, uintptr_t address)¶ Discard dcache for L1 on the requested core with no write back.
- Return
 None
- Parameters
 hartid: The core to discardaddress: The virtual address of cacheline to invalidate
- 
int 
metal_icache_l1_available(int hartid)¶ Check if icache is supported on the core.
- Return
 1 if icache is present
- Parameters
 hartid: The core to check
- 
struct 
metal_cache¶ - #include <cache.h>
a handle for a cache Note: To be deprecated in next release.