libparanut
A Hardware Abstraction Layer for ParaNut Architectures.
Cache Module

Special functions for controlling the shared ParaNut cache. More...

Collaboration diagram for Cache Module:
int pn_cache_init (void)
 Function that has to be called in the main function before any of the functions in the Cache Module can be called. Initializes some internal data and enables the cache. More...
 
int pn_cache_enable (void)
 Enables instruction and data cache. When changing this, make sure that the pn_cache_init() function is still correct! More...
 
int pn_cache_disable (void)
 Disables instruction and data cache. More...
 
unsigned long pn_cache_linesize (void)
 Returns the cache line size in bit. More...
 
unsigned long pn_cache_size (void)
 Returns the cache size in Byte. More...
 
int pn_cache_invalidate (void *addr, unsigned long size)
 Invalidates the cache entries containing the given address range. More...
 
int pn_cache_invalidate_all (void)
 Invalidates the whole cache. When changing this, make sure that the pn_cache_init() function is still correct! More...
 
int pn_cache_writeback (void *addr, unsigned long size)
 Writes back the cache lines that cached the given address range. More...
 
int pn_cache_writeback_all (void)
 Writes whole cache back. More...
 
int pn_cache_flush (void *addr, unsigned long size)
 Combination of pn_cache_invalidate() and pn_cache_writeback(). More...
 
int pn_cache_flush_all (void)
 Flushes the whole cache. More...
 

Detailed Description

Special functions for controlling the shared ParaNut cache.

Function Documentation

◆ pn_cache_disable()

int pn_cache_disable ( void  )

Disables instruction and data cache.

Attention
Careful here: ParaNut Cache is flushed completely before disabling.
Warning
Atomic memory operations (Spinlock Module) are not possible on a disabled cache.

Can only be used on CePU.

Returns
Either PN_SUCCESS or PN_ERR_COPU.

◆ pn_cache_enable()

int pn_cache_enable ( void  )

Enables instruction and data cache. When changing this, make sure that the pn_cache_init() function is still correct!

Attention
Careful here: ParaNut Cache is flushed completely before disabling.

Can only be used on CePU.

Returns
Either PN_SUCCESS or PN_ERR_COPU.

◆ pn_cache_flush()

int pn_cache_flush ( void *  addr,
unsigned long  size 
)

Combination of pn_cache_invalidate() and pn_cache_writeback().

Parameters
[in]addris the (virtual)start address of the memory you want flushed.
[in]sizeis the size of the address range you want flushed in byte. The size will always be aligned to the cache line size.
Returns
Either PN_SUCCESS or PN_ERR_PARAM if given size is bigger than memory size.

◆ pn_cache_flush_all()

int pn_cache_flush_all ( void  )

Flushes the whole cache.

Returns
Can only return PN_SUCCESS, is not made void for the sake of making the internal implementation more similar for cache functions.

◆ pn_cache_init()

int pn_cache_init ( void  )

Function that has to be called in the main function before any of the functions in the Cache Module can be called. Initializes some internal data and enables the cache.

Can only be used on CePU.

Returns
Either PN_SUCCESS, PN_ERR_COPU, or PN_CACHE_LINESIZE.

◆ pn_cache_invalidate()

int pn_cache_invalidate ( void *  addr,
unsigned long  size 
)

Invalidates the cache entries containing the given address range.

Parameters
[in]addris the (virtual) start address of the memory you want to invalidate.
[in]sizeis the size of the address range you want to invalidate in byte. The size will always be aligned to the cache line size.
Returns
Either PN_SUCCESS or PN_ERR_PARAM if given size is bigger than memory size.

◆ pn_cache_invalidate_all()

int pn_cache_invalidate_all ( void  )

Invalidates the whole cache. When changing this, make sure that the pn_cache_init() function is still correct!

Returns
Can only return PN_SUCCESS, is not made void for the sake of making the internal implementation more similar for cache functions.

◆ pn_cache_linesize()

unsigned long pn_cache_linesize ( void  )

Returns the cache line size in bit.

Returns
The cache line size in bit. Can not return an error.

◆ pn_cache_size()

unsigned long pn_cache_size ( void  )

Returns the cache size in Byte.

Returns
The cache size in byte. Can not return an error.

◆ pn_cache_writeback()

int pn_cache_writeback ( void *  addr,
unsigned long  size 
)

Writes back the cache lines that cached the given address range.

Parameters
[in]addris the (virtual) start address of the memory you want written back.
[in]sizeis the size of the address range you want written back in byte. The size will always be aligned to the cache line size.
Returns
Either PN_SUCCESS or PN_ERR_PARAM if given size is bigger than memory size.

◆ pn_cache_writeback_all()

int pn_cache_writeback_all ( void  )

Writes whole cache back.

Returns
Can only return PN_SUCCESS, is not made void for the sake of making the internal implementation more similar for cache functions.