KallistiOS git master
Independent SDK for the Sega Dreamcast
|
Driver and API for managing the SH4's cache More...
Files | |
file | cache.h |
Cache management functionality. | |
Macros | |
#define | CPU_CACHE_BLOCK_SIZE 32 |
SH4 cache block size. | |
#define | dcache_wback_sq(ptr) |
Write-back Store Queue buffer to external memory. | |
Functions | |
void | icache_flush_range (uintptr_t start, size_t count) |
Flush the instruction cache. | |
void | dcache_inval_range (uintptr_t start, size_t count) |
Invalidate the data/operand cache. | |
void | dcache_flush_range (uintptr_t start, size_t count) |
Flush the data/operand cache. | |
void | dcache_flush_all (void) |
Flush all the data/operand cache. | |
void | dcache_purge_range (uintptr_t start, size_t count) |
Purge the data/operand cache. | |
void | dcache_purge_all (void) |
Purge all the data/operand cache. | |
void | dcache_purge_all_with_buffer (uintptr_t start, size_t count) |
Purge all the data/operand cache with buffer. | |
static __always_inline void | dcache_pref_block (const void *src) |
Prefetch one block to the data/operand cache. | |
static __always_inline void | dcache_alloc_block (const void *src, uint32_t value) |
Allocate one block of the data/operand cache. | |
Driver and API for managing the SH4's cache
#define CPU_CACHE_BLOCK_SIZE 32 |
SH4 cache block size.
The size of a cache block.
#define dcache_wback_sq | ( | ptr | ) |
Write-back Store Queue buffer to external memory.
This function initiates write-back for one Store Queue.
ptr | The SQ mapped address to write-back. |
|
static |
Allocate one block of the data/operand cache.
This function allocate a block of the data/operand cache.
src | The physical address to allocate. |
value | The value written to first 4-byte. |
void dcache_flush_all | ( | void | ) |
Flush all the data/operand cache.
This function flushes all the data/operand cache, forcing a write- back on all of the cache blocks that are marked as dirty.
void dcache_flush_range | ( | uintptr_t | start, |
size_t | count ) |
Flush the data/operand cache.
This function flushes a range of the data/operand cache, forcing a write- back on all of the data in the specified range. This does not invalidate the cache in the process (meaning the blocks will still be in the cache, just not marked as dirty after this has completed). If you wish to invalidate the cache as well, call dcache_inval_range() after calling this function or use dcache_purge_range() instead of dcache_flush_range().
start | The physical address to begin flushing at. |
count | The number of bytes to flush. |
void dcache_inval_range | ( | uintptr_t | start, |
size_t | count ) |
Invalidate the data/operand cache.
This function invalidates a range of the data/operand cache. If you care about the contents of the cache that have not been written back yet, use dcache_flush_range() before using this function.
start | The physical address to begin invalidating at. |
count | The number of bytes to invalidate. |
|
static |
Prefetch one block to the data/operand cache.
This function prefetch a block of the data/operand cache.
src | The physical address to prefetch. |
void dcache_purge_all | ( | void | ) |
Purge all the data/operand cache.
This function flushes the entire data/operand cache, ensuring that all cache blocks marked as dirty are written back to memory and all cache entries are invalidated. It does not require an additional buffer and is preferred when memory resources are constrained.
void dcache_purge_all_with_buffer | ( | uintptr_t | start, |
size_t | count ) |
Purge all the data/operand cache with buffer.
This function performs a purge of all data/operand cache blocks by utilizing an external buffer to speed up the write-back and invalidation process. It is always faster than dcache_purge_all() and is recommended where maximum speed is required.
start | The physical address for temporary buffer (32-byte aligned) |
count | The size of the temporary buffer, which can be either 8 KB or 16 KB, depending on cache configuration - 8 KB buffer with OCRAM enabled, otherwise 16 KB. |
void dcache_purge_range | ( | uintptr_t | start, |
size_t | count ) |
Purge the data/operand cache.
This function flushes a range of the data/operand cache, forcing a write- back and then invalidates all of the data in the specified range.
start | The physical address to begin purging at. |
count | The number of bytes to purge. |
void icache_flush_range | ( | uintptr_t | start, |
size_t | count ) |
Flush the instruction cache.
This function flushes a range of the instruction cache.
start | The physical address to begin flushing at. |
count | The number of bytes to flush. |