126#include <sys/param.h>
128#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
133#if CPU_DATA_CACHE_ALIGNMENT > CPU_CACHE_LINE_BYTES
134#error "CPU_DATA_CACHE_ALIGNMENT is greater than CPU_CACHE_LINE_BYTES"
137#if CPU_INSTRUCTION_CACHE_ALIGNMENT > CPU_CACHE_LINE_BYTES
138#error "CPU_INSTRUCTION_CACHE_ALIGNMENT is greater than CPU_CACHE_LINE_BYTES"
161#if defined(CPU_DATA_CACHE_ALIGNMENT)
162#if defined(CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS)
163 _CPU_cache_flush_data_range( d_addr, n_bytes );
165 const void * final_address;
177 final_address = (
void *)((
size_t)d_addr + n_bytes - 1);
178 d_addr = (
void *)((
size_t)d_addr & ~(CPU_DATA_CACHE_ALIGNMENT - 1));
179 while( d_addr <= final_address ) {
180 _CPU_cache_flush_1_data_line( d_addr );
181 d_addr = (
void *)((
size_t)d_addr + CPU_DATA_CACHE_ALIGNMENT);
198#if defined(CPU_DATA_CACHE_ALIGNMENT)
199#if defined(CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS)
200 _CPU_cache_invalidate_data_range( d_addr, n_bytes );
202 const void * final_address;
214 final_address = (
void *)((
size_t)d_addr + n_bytes - 1);
215 d_addr = (
void *)((
size_t)d_addr & ~(CPU_DATA_CACHE_ALIGNMENT - 1));
216 while( final_address >= d_addr ) {
217 _CPU_cache_invalidate_1_data_line( d_addr );
218 d_addr = (
void *)((
size_t)d_addr + CPU_DATA_CACHE_ALIGNMENT);
234#if defined(CPU_DATA_CACHE_ALIGNMENT)
238 _CPU_cache_flush_entire_data();
249#if defined(CPU_DATA_CACHE_ALIGNMENT)
254 _CPU_cache_invalidate_entire_data();
264#if defined(CPU_DATA_CACHE_ALIGNMENT)
265 return CPU_DATA_CACHE_ALIGNMENT;
274#if defined(CPU_CACHE_SUPPORT_PROVIDES_CACHE_SIZE_FUNCTIONS)
275 return _CPU_cache_get_data_cache_size( level );
290#if defined(CPU_DATA_CACHE_ALIGNMENT)
291 _CPU_cache_freeze_data();
297#if defined(CPU_DATA_CACHE_ALIGNMENT)
298 _CPU_cache_unfreeze_data();
305#if defined(CPU_DATA_CACHE_ALIGNMENT)
306 _CPU_cache_enable_data();
310#if !defined(CPU_CACHE_SUPPORT_PROVIDES_DISABLE_DATA)
314#if defined(CPU_DATA_CACHE_ALIGNMENT)
315 _CPU_cache_disable_data();
324#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT) \
325 && defined(RTEMS_SMP) \
326 && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
333static void smp_cache_inst_inv(
void *arg)
335 smp_cache_area *area = arg;
337 _CPU_cache_invalidate_instruction_range(area->addr, area->size);
340static void smp_cache_inst_inv_all(
void *arg)
343 _CPU_cache_invalidate_entire_instruction();
346static void smp_cache_broadcast( SMP_Action_handler handler,
void *arg )
353 if ( isr_level == 0 ) {
354 cpu_self = _Thread_Dispatch_disable();
356 cpu_self = _Per_CPU_Get();
360 _SMP_Othercast_action( handler, arg );
362 if ( isr_level == 0 ) {
374#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT) \
375 && !defined(CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS)
377_CPU_cache_invalidate_instruction_range(
382 const void * final_address;
394 final_address = (
void *)((
size_t)i_addr + n_bytes - 1);
395 i_addr = (
void *)((
size_t)i_addr & ~(CPU_INSTRUCTION_CACHE_ALIGNMENT - 1));
396 while( final_address >= i_addr ) {
397 _CPU_cache_invalidate_1_instruction_line( i_addr );
398 i_addr = (
void *)((
size_t)i_addr + CPU_INSTRUCTION_CACHE_ALIGNMENT);
409#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
410#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
411 smp_cache_area area = { i_addr, n_bytes };
413 smp_cache_broadcast( smp_cache_inst_inv, &area );
415 _CPU_cache_invalidate_instruction_range( i_addr, n_bytes );
430#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
431#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
432 smp_cache_broadcast( smp_cache_inst_inv_all, NULL );
434 _CPU_cache_invalidate_entire_instruction();
445#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
446 return CPU_INSTRUCTION_CACHE_ALIGNMENT;
455#if defined(CPU_CACHE_SUPPORT_PROVIDES_CACHE_SIZE_FUNCTIONS)
456 return _CPU_cache_get_instruction_cache_size( level );
471#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
472 _CPU_cache_freeze_instruction();
478#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
479 _CPU_cache_unfreeze_instruction();
486#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
487 _CPU_cache_enable_instruction();
494#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
495 _CPU_cache_disable_instruction();
502#if defined(CPU_MAXIMAL_CACHE_ALIGNMENT)
503 return CPU_MAXIMAL_CACHE_ALIGNMENT;
505 size_t data_line_size =
506#if defined(CPU_DATA_CACHE_ALIGNMENT)
507 CPU_DATA_CACHE_ALIGNMENT;
511 size_t instruction_line_size =
512#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
513 CPU_INSTRUCTION_CACHE_ALIGNMENT;
517 return MAX( data_line_size, instruction_line_size );
528 const void *code_addr,
532#if defined(CPU_CACHE_SUPPORT_PROVIDES_INSTRUCTION_SYNC_FUNCTION)
533 _CPU_cache_instruction_sync_after_code_change( code_addr, n_bytes );
void rtems_cache_unfreeze_instruction(void)
Unfreezes the instruction cache.
Definition: cacheimpl.h:476
void rtems_cache_unfreeze_data(void)
Unfreezes the data cache.
Definition: cacheimpl.h:295
void rtems_cache_freeze_instruction(void)
Freezes the instruction caches.
Definition: cacheimpl.h:469
void rtems_cache_freeze_data(void)
Freezes the data caches.
Definition: cacheimpl.h:288
void rtems_cache_instruction_sync_after_code_change(const void *code_addr, size_t n_bytes)
Ensures necessary synchronization required after code changes.
Definition: cacheimpl.h:527
size_t rtems_cache_get_maximal_line_size(void)
Gets the maximal cache line size in bytes of all caches (data, instruction, or unified).
Definition: cacheimpl.h:500
void rtems_cache_invalidate_entire_instruction(void)
Invalidates the entire instruction cache.
Definition: cacheimpl.h:428
void rtems_cache_invalidate_entire_data(void)
Invalidates the entire data cache.
Definition: cacheimpl.h:247
void rtems_cache_invalidate_multiple_instruction_lines(const void *i_addr, size_t n_bytes)
Invalidates the instruction cache lines covering the memory area.
Definition: cacheimpl.h:404
size_t rtems_cache_get_data_cache_size(uint32_t level)
Gets the data cache size in bytes for the cache level.
Definition: cacheimpl.h:272
void rtems_cache_enable_data(void)
Enables the data cache.
Definition: cacheimpl.h:303
void rtems_cache_disable_instruction(void)
Disables the instruction cache.
Definition: cacheimpl.h:492
void rtems_cache_disable_data(void)
Disables the data cache.
Definition: cacheimpl.h:312
size_t rtems_cache_get_instruction_cache_size(uint32_t level)
Gets the instruction cache size in bytes for the cache level.
Definition: cacheimpl.h:453
void rtems_cache_invalidate_multiple_data_lines(const void *d_addr, size_t n_bytes)
Invalidates the data cache lines covering the memory area.
Definition: cacheimpl.h:196
void rtems_cache_flush_entire_data(void)
Flushes the entire data cache.
Definition: cacheimpl.h:232
void rtems_cache_flush_multiple_data_lines(const void *d_addr, size_t n_bytes)
Flushes the data cache lines covering the memory area.
Definition: cacheimpl.h:159
size_t rtems_cache_get_instruction_line_size(void)
Gets the instruction cache line size in bytes.
Definition: cacheimpl.h:443
size_t rtems_cache_get_data_line_size(void)
Gets the data cache line size in bytes.
Definition: cacheimpl.h:262
void rtems_cache_enable_instruction(void)
Enables the instruction cache.
Definition: cacheimpl.h:484
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:147
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
This header file defines the RTEMS Classic API.
This header file provides interfaces of the SMP Support which are only used by the implementation.
Per CPU Core Structure.
Definition: percpu.h:384
This header file provides the interfaces of the Thread Handler related to thread dispatching.