SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Macros | Functions
cache.c File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <types.h>
#include <mmu.h>
#include <timer.h>
#include <csr.h>
#include <common.h>
#include <log.h>
Include dependency graph for cache.c:

Macros

#define L1_CACHE_BYTES   (64)
 Size of L1 cache line in bytes.
 

Functions

void data_sync_barrier (void)
 Insert a data synchronization barrier.
 
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 mmu_enable (void)
 Enable the SV39 MMU with cache initialization.
 
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.
 

Macro Definition Documentation

◆ L1_CACHE_BYTES

#define L1_CACHE_BYTES   (64)

Size of L1 cache line in bytes.

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.

◆ data_sync_barrier()

void data_sync_barrier ( void  )

Insert a data synchronization barrier.

This function ensures that all previous instructions are completed before any subsequent instructions are executed, particularly useful for ensuring memory consistency.

◆ 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_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_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.

◆ mmu_enable()

void mmu_enable ( void  )

Enable the SV39 MMU with cache initialization.

This function initializes the cache and enables both data and instruction caches for the SV39 memory management unit.