MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
CACHE: CACHE Memory Controller

Overview

The MCUXpresso SDK provides a peripheral driver for the CACHE Controller of MCUXpresso SDK devices.

The CACHE driver is created to help the user more easily operate the cache memory. The APIs for basic operations are including the following three levels:

1L. The L1 cache driver API. This level provides the level 1 caches controller drivers. The L1 caches are mainly integrated in the Core memory system, Cortex-M7 L1 caches, etc. For our Cortex-M4 series platforms, the L1 cache is the local memory controller (LMEM) which is not integrated in the Cortex-M4 processer memory system.

2L. The L2 cache driver API. This level provides the level 2 cache controller drivers. The L2 cache could be integrated in the CORE memory system or an external L2 cache memory, PL310, etc.

3L. The combined cache driver API. This level provides many APIs for combined L1 and L2 cache maintain operations. This is provided for MCUXpresso SDK drivers (DMA, ENET, USDHC, etc) which should do the cache maintenance in their transactional APIs.

Function groups

L1 CACHE Operation

The L1 CACHE has both code cache and data cache. This function group provides independent two groups API for both code cache and data cache. There are Enable/Disable APIs for code cache and data cache control and cache maintenance operations as Invalidate/Clean/CleanInvalidate by all and by address range.

L2 CACHE Operation

The L2 CACHE does not divide the cache to data and code. Instead, this function group provides one group cache maintenance operations as Enable/Disable/Invalidate/Clean/CleanInvalidate by all and by address range. Except the maintenance operation APIs, the L2 CACHE has it's initialization/configure API. The user can use the default configure parameter by calling L2CACHE_GetDefaultConfig() or changing the parameters as they wish. Then, call L2CACHE_Init to do the L2 CACHE initialization. After initialization, the L2 cache can then be enabled.

Note: For the core external l2 Cache, the SoC usually has the control bit to select the SRAM to use as L2 Cache or normal SRAM. Make sure this selection is right when you use the L2 CACHE feature.

Macros

#define L1CODEBUSCACHE_LINESIZE_BYTE   FSL_FEATURE_L1ICACHE_LINESIZE_BYTE
 code bus cache line size is equal to system bus line size, so the unified I/D cache line size equals too. More...
 
#define L1SYSTEMBUSCACHE_LINESIZE_BYTE   L1CODEBUSCACHE_LINESIZE_BYTE
 The system bus CACHE line size is 16B = 128b. More...
 

Driver version

#define FSL_CACHE_DRIVER_VERSION   (MAKE_VERSION(2, 0, 3))
 cache driver version 2.0.3. More...
 

Control for cortex-m7 L1 cache

static void L1CACHE_EnableICache (void)
 Enables cortex-m7 L1 instruction cache.
 
static void L1CACHE_DisableICache (void)
 Disables cortex-m7 L1 instruction cache.
 
static void L1CACHE_InvalidateICache (void)
 Invalidate cortex-m7 L1 instruction cache.
 
void L1CACHE_InvalidateICacheByRange (uint32_t address, uint32_t size_byte)
 Invalidate cortex-m7 L1 instruction cache by range. More...
 
static void L1CACHE_EnableDCache (void)
 Enables cortex-m7 L1 data cache.
 
static void L1CACHE_DisableDCache (void)
 Disables cortex-m7 L1 data cache.
 
static void L1CACHE_InvalidateDCache (void)
 Invalidates cortex-m7 L1 data cache.
 
static void L1CACHE_CleanDCache (void)
 Cleans cortex-m7 L1 data cache.
 
static void L1CACHE_CleanInvalidateDCache (void)
 Cleans and Invalidates cortex-m7 L1 data cache.
 
static void L1CACHE_InvalidateDCacheByRange (uint32_t address, uint32_t size_byte)
 Invalidates cortex-m7 L1 data cache by range. More...
 
static void L1CACHE_CleanDCacheByRange (uint32_t address, uint32_t size_byte)
 Cleans cortex-m7 L1 data cache by range. More...
 
static void L1CACHE_CleanInvalidateDCacheByRange (uint32_t address, uint32_t size_byte)
 Cleans and Invalidates cortex-m7 L1 data cache by range. More...
 

Unified Cache Control for all caches (cortex-m7 L1 cache + l2 pl310)

Mainly used for many drivers for easy cache operation.

void ICACHE_InvalidateByRange (uint32_t address, uint32_t size_byte)
 Invalidates all instruction caches by range. More...
 
void DCACHE_InvalidateByRange (uint32_t address, uint32_t size_byte)
 Invalidates all data caches by range. More...
 
void DCACHE_CleanByRange (uint32_t address, uint32_t size_byte)
 Cleans all data caches by range. More...
 
void DCACHE_CleanInvalidateByRange (uint32_t address, uint32_t size_byte)
 Cleans and Invalidates all data caches by range. More...
 

Driver version

#define FSL_CACHE_DRIVER_VERSION   (MAKE_VERSION(2, 0, 5))
 cache driver version. More...
 

cache control for L1 cache (local memory controller for code/system bus cache)

void L1CACHE_EnableCodeCache (void)
 Enables the processor code bus cache.
 
void L1CACHE_DisableCodeCache (void)
 Disables the processor code bus cache.
 
void L1CACHE_InvalidateCodeCache (void)
 Invalidates the processor code bus cache.
 
void L1CACHE_InvalidateCodeCacheByRange (uint32_t address, uint32_t size_byte)
 Invalidates processor code bus cache by range. More...
 
void L1CACHE_CleanCodeCache (void)
 Cleans the processor code bus cache.
 
void L1CACHE_CleanCodeCacheByRange (uint32_t address, uint32_t size_byte)
 Cleans processor code bus cache by range. More...
 
void L1CACHE_CleanInvalidateCodeCache (void)
 Cleans and invalidates the processor code bus cache.
 
void L1CACHE_CleanInvalidateCodeCacheByRange (uint32_t address, uint32_t size_byte)
 Cleans and invalidate processor code bus cache by range. More...
 
static void L1CACHE_EnableCodeCacheWriteBuffer (bool enable)
 Enables/disables the processor code bus write buffer. More...
 
void L1CACHE_EnableSystemCache (void)
 Enables the processor system bus cache.
 
void L1CACHE_DisableSystemCache (void)
 Disables the processor system bus cache.
 
void L1CACHE_InvalidateSystemCache (void)
 Invalidates the processor system bus cache.
 
void L1CACHE_InvalidateSystemCacheByRange (uint32_t address, uint32_t size_byte)
 Invalidates processor system bus cache by range. More...
 
void L1CACHE_CleanSystemCache (void)
 Cleans the processor system bus cache.
 
void L1CACHE_CleanSystemCacheByRange (uint32_t address, uint32_t size_byte)
 Cleans processor system bus cache by range. More...
 
void L1CACHE_CleanInvalidateSystemCache (void)
 Cleans and invalidates the processor system bus cache.
 
void L1CACHE_CleanInvalidateSystemCacheByRange (uint32_t address, uint32_t size_byte)
 Cleans and Invalidates processor system bus cache by range. More...
 
static void L1CACHE_EnableSystemCacheWriteBuffer (bool enable)
 Enables/disables the processor system bus write buffer. More...
 

Macro Definition Documentation

#define FSL_CACHE_DRIVER_VERSION   (MAKE_VERSION(2, 0, 3))
#define FSL_CACHE_DRIVER_VERSION   (MAKE_VERSION(2, 0, 5))
#define L1CODEBUSCACHE_LINESIZE_BYTE   FSL_FEATURE_L1ICACHE_LINESIZE_BYTE

The code bus CACHE line size is 16B = 128b.

#define L1SYSTEMBUSCACHE_LINESIZE_BYTE   L1CODEBUSCACHE_LINESIZE_BYTE

Function Documentation

void L1CACHE_InvalidateICacheByRange ( uint32_t  address,
uint32_t  size_byte 
)

Invalidates cortex-m4 L1 instrument cache by range.

Parameters
addressThe start address of the memory to be invalidated.
size_byteThe memory size.
Note
The start address and size_byte should be 32-byte(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE) aligned. The startAddr here will be forced to align to L1 I-cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
Parameters
addressThe start address of the memory to be invalidated.
size_byteThe memory size.
Note
The start address and size_byte should be 16-Byte(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE) aligned.
static void L1CACHE_InvalidateDCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
inlinestatic
Parameters
addressThe start address of the memory to be invalidated.
size_byteThe memory size.
Note
The start address and size_byte should be 32-byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned. The startAddr here will be forced to align to L1 D-cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
void L1CACHE_CleanDCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
inlinestatic

Cleans cortex-m4 L1 data cache by range.

Parameters
addressThe start address of the memory to be cleaned.
size_byteThe memory size.
Note
The start address and size_byte should be 32-byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned. The startAddr here will be forced to align to L1 D-cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
Parameters
addressThe start address of the memory to be cleaned.
size_byteThe memory size.
Note
The start address and size_byte should be 16-Byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned.
void L1CACHE_CleanInvalidateDCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
inlinestatic

Cleans and Invalidates cortex-m4 L1 data cache by range.

Parameters
addressThe start address of the memory to be clean and invalidated.
size_byteThe memory size.
Note
The start address and size_byte should be 32-byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned. The startAddr here will be forced to align to L1 D-cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
Parameters
addressThe start address of the memory to be clean and invalidated.
size_byteThe memory size.
Note
The start address and size_byte should be 16-Byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned.
static void ICACHE_InvalidateByRange ( uint32_t  address,
uint32_t  size_byte 
)
inline

Invalidates instruction cache by range.

Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.

Parameters
addressThe physical address.
size_bytesize of the memory to be invalidated.
Note
address and size should be aligned to cache line size 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
Parameters
addressThe physical address.
size_bytesize of the memory to be invalidated.
Note
Address and size should be aligned to 16-Byte due to the cache operation unit FSL_FEATURE_L1ICACHE_LINESIZE_BYTE. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
static void DCACHE_InvalidateByRange ( uint32_t  address,
uint32_t  size_byte 
)
inline

Invalidates data cache by range.

Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.

Parameters
addressThe physical address.
size_bytesize of the memory to be invalidated.
Note
address and size should be aligned to cache line size 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
Parameters
addressThe physical address.
size_bytesize of the memory to be invalidated.
Note
Address and size should be aligned to 16-Byte due to the cache operation unit FSL_FEATURE_L1DCACHE_LINESIZE_BYTE. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
static void DCACHE_CleanByRange ( uint32_t  address,
uint32_t  size_byte 
)
inline

Clean data cache by range.

Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.

Parameters
addressThe physical address.
size_bytesize of the memory to be cleaned.
Note
address and size should be aligned to cache line size 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
Parameters
addressThe physical address.
size_bytesize of the memory to be cleaned.
Note
Address and size should be aligned to 16-Byte due to the cache operation unit FSL_FEATURE_L1DCACHE_LINESIZE_BYTE. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
static void DCACHE_CleanInvalidateByRange ( uint32_t  address,
uint32_t  size_byte 
)
inline

Cleans and Invalidates data cache by range.

Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.

Parameters
addressThe physical address.
size_bytesize of the memory to be cleaned and invalidated.
Note
address and size should be aligned to cache line size 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
Parameters
addressThe physical address.
size_bytesize of the memory to be Cleaned and Invalidated.
Note
Address and size should be aligned to 16-Byte due to the cache operation unit FSL_FEATURE_L1DCACHE_LINESIZE_BYTE. The startAddr here will be forced to align to the cache line size if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
void L1CACHE_InvalidateCodeCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
Parameters
addressThe physical address of cache.
size_bytesize of the memory to be invalidated.
Note
Address and size should be aligned to "L1CODCACHE_LINESIZE_BYTE". The startAddr here will be forced to align to L1CODEBUSCACHE_LINESIZE_BYTE if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
void L1CACHE_CleanCodeCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
Parameters
addressThe physical address of cache.
size_bytesize of the memory to be cleaned.
Note
Address and size should be aligned to "L1CODEBUSCACHE_LINESIZE_BYTE". The startAddr here will be forced to align to L1CODEBUSCACHE_LINESIZE_BYTE if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
void L1CACHE_CleanInvalidateCodeCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
Parameters
addressThe physical address of cache.
size_bytesize of the memory to be Cleaned and Invalidated.
Note
Address and size should be aligned to "L1CODEBUSCACHE_LINESIZE_BYTE". The startAddr here will be forced to align to L1CODEBUSCACHE_LINESIZE_BYTE if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
static void L1CACHE_EnableCodeCacheWriteBuffer ( bool  enable)
inlinestatic
Parameters
enableThe enable or disable flag. true - enable the code bus write buffer. false - disable the code bus write buffer.
void L1CACHE_InvalidateSystemCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
Parameters
addressThe physical address of cache.
size_bytesize of the memory to be invalidated.
Note
Address and size should be aligned to "L1SYSTEMBUSCACHE_LINESIZE_BYTE". The startAddr here will be forced to align to L1SYSTEMBUSCACHE_LINESIZE_BYTE if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
void L1CACHE_CleanSystemCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
Parameters
addressThe physical address of cache.
size_bytesize of the memory to be cleaned.
Note
Address and size should be aligned to "L1SYSTEMBUSCACHE_LINESIZE_BYTE". The startAddr here will be forced to align to L1SYSTEMBUSCACHE_LINESIZE_BYTE if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
void L1CACHE_CleanInvalidateSystemCacheByRange ( uint32_t  address,
uint32_t  size_byte 
)
Parameters
addressThe physical address of cache.
size_bytesize of the memory to be Clean and Invalidated.
Note
Address and size should be aligned to "L1SYSTEMBUSCACHE_LINESIZE_BYTE". The startAddr here will be forced to align to L1SYSTEMBUSCACHE_LINESIZE_BYTE if startAddr is not aligned. For the size_byte, application should make sure the alignment or make sure the right operation order if the size_byte is not aligned.
static void L1CACHE_EnableSystemCacheWriteBuffer ( bool  enable)
inlinestatic
Parameters
enableThe enable or disable flag. true - enable the code bus write buffer. false - disable the code bus write buffer.