SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Functions
cache.h File Reference

Cache control functions for RISC-V architecture. More...

#include <stdint.h>
#include "barrier.h"
#include "csr.h"
Include dependency graph for cache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void cache_init (void)
 Initialize the cache configuration.
 
void dcache_enable (void)
 Enable the data cache.
 
void icache_enable (void)
 Enable the instruction cache.
 
void flush_dcache_range (uint64_t start, uint64_t end)
 Flush a range of the data cache.
 
void invalidate_dcache_range (uint64_t start, uint64_t end)
 Invalidate a range of the data cache.
 
void flush_dcache_all ()
 Flushes the entire data cache.
 
void invalidate_dcache_all ()
 Invalidates the entire data cache.
 

Detailed Description

Cache control functions for RISC-V architecture.

This header file provides functions for initializing and controlling data and instruction caches on RISC-V architecture.

Function Documentation

◆ cache_init()

void cache_init ( void  )

Initialize the cache configuration.

This function configures the cache settings by writing specific values to the control and status registers.

◆ dcache_enable()

void dcache_enable ( void  )

Enable the data cache.

This function enables the data cache by writing to the machine cache control register.

◆ flush_dcache_all()

void flush_dcache_all ( )

Flushes the entire data cache.

This function flushes all data cache lines, ensuring that any modified or "dirty" cache lines are written back to the main memory. It ensures that the data in the cache is coherent with the memory.

◆ flush_dcache_range()

void flush_dcache_range ( uint64_t  start,
uint64_t  end 
)

Flush a range of the data cache.

This function flushes the data cache for a specified range, ensuring that any dirty cache lines are written back to memory.

Parameters
startThe starting address of the range to flush.
endThe ending address of the range to flush.

◆ icache_enable()

void icache_enable ( void  )

Enable the instruction cache.

This function enables the instruction cache by setting the appropriate control bits in the machine cache control register.

◆ invalidate_dcache_all()

void invalidate_dcache_all ( )

Invalidates the entire data cache.

This function invalidates all data cache lines, ensuring that no stale or outdated data remains in the cache. This operation discards the cache contents and ensures that the next access will fetch fresh data from memory.

◆ invalidate_dcache_range()

void invalidate_dcache_range ( uint64_t  start,
uint64_t  end 
)

Invalidate a range of the data cache.

This function invalidates the data cache for a specified range, ensuring that no stale data remains in the cache for the given addresses.

Parameters
startThe starting address of the range to invalidate.
endThe ending address of the range to invalidate.