score: Introduce CPU_CACHE_LINE_BYTES

Add CPU_CACHE_LINE_BYTES for the maximum cache line size in bytes.  The
actual processor may use no cache or a smaller cache line size.
This commit is contained in:
Sebastian Huber
2016-01-25 10:20:28 +01:00
parent cd9ef18564
commit a8865f8b41
18 changed files with 73 additions and 254 deletions

View File

@@ -42,6 +42,14 @@
#include <rtems.h> #include <rtems.h>
#include "cache_.h" #include "cache_.h"
#if CPU_DATA_CACHE_ALIGNMENT > CPU_CACHE_LINE_BYTES
#error "CPU_DATA_CACHE_ALIGNMENT is greater than CPU_CACHE_LINE_BYTES"
#endif
#if CPU_INSTRUCTION_CACHE_ALIGNMENT > CPU_CACHE_LINE_BYTES
#error "CPU_INSTRUCTION_CACHE_ALIGNMENT is greater than CPU_CACHE_LINE_BYTES"
#endif
#if defined(RTEMS_SMP) #if defined(RTEMS_SMP)
#include <rtems/score/smpimpl.h> #include <rtems/score/smpimpl.h>

View File

@@ -144,8 +144,10 @@
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* XXX Why 32? */ /* FIXME: Is this the right value? */
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (32))) #define CPU_CACHE_LINE_BYTES 32
#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
/* /*
* The interrupt mask disables only normal interrupts (IRQ). * The interrupt mask disables only normal interrupts (IRQ).

View File

@@ -295,29 +295,9 @@ extern "C" {
*/ */
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/** /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 32
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* @note Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
* Port Specific Information:
*
* XXX document implementation including references if appropriate
*/
#define CPU_STRUCTURE_ALIGNMENT #define CPU_STRUCTURE_ALIGNMENT
/** /**

View File

@@ -260,28 +260,10 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 64
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
*/
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (64))) #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
/* /*
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -100,6 +100,10 @@ extern "C" {
#endif /* __SSE__ */ #endif /* __SSE__ */
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* FIXME: The Pentium 4 used 128 bytes, it this processor still relevant? */
#define CPU_CACHE_LINE_BYTES 64
#define CPU_STRUCTURE_ALIGNMENT #define CPU_STRUCTURE_ALIGNMENT
/* /*

View File

@@ -289,30 +289,10 @@ extern "C" {
*/ */
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/** /* L2 cache lines are 32 bytes in Milkymist SoC */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 32
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
* Port Specific Information:
*
* L2 cache lines are 32 bytes in Milkymist SoC
*/
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (32)))
/** /**
* @defgroup CPUEndian Processor Dependent Endianness Support * @defgroup CPUEndian Processor Dependent Endianness Support

View File

@@ -311,30 +311,10 @@ extern "C" {
*/ */
#define CPU_STACK_GROWS_UP TRUE #define CPU_STACK_GROWS_UP TRUE
/** /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 2
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
* Port Specific Information:
*
* XXX document implementation including references if appropriate
*/
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (2)))
/** /**
* @defgroup CPUEndian Processor Dependent Endianness Support * @defgroup CPUEndian Processor Dependent Endianness Support

View File

@@ -99,7 +99,11 @@ extern "C" {
#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (4)))
/* FIXME: Is this the right value? */
#define CPU_CACHE_LINE_BYTES 16
#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
/* /*
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -280,32 +280,10 @@ extern "C" {
/* our stack grows down */ /* our stack grows down */
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 16
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*/
/* our cache line size is 16 bytes */ #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
#if __GNUC__
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (16)))
#else
#define CPU_STRUCTURE_ALIGNMENT
#endif
/* /*
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -260,29 +260,9 @@ extern "C" {
*/ */
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 32
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
* MOXIE Specific Information:
*
* XXX
*/
#define CPU_STRUCTURE_ALIGNMENT #define CPU_STRUCTURE_ALIGNMENT
/* /*

View File

@@ -64,7 +64,11 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
#define CPU_STRUCTURE_ALIGNMENT __attribute__((section(".sdata"), aligned(32))) /* FIXME: Is this the right value? */
#define CPU_CACHE_LINE_BYTES 32
#define CPU_STRUCTURE_ALIGNMENT \
RTEMS_SECTION( ".sdata" ) RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
#define CPU_BIG_ENDIAN FALSE #define CPU_BIG_ENDIAN FALSE

View File

@@ -310,6 +310,13 @@ extern "C" {
*/ */
#define CPU_STACK_GROWS_UP TRUE #define CPU_STACK_GROWS_UP TRUE
/**
* The maximum cache line size in bytes.
*
* The actual processor may use no cache or a smaller cache line size.
*/
#define CPU_CACHE_LINE_BYTES 32
/** /**
* The following is the variable attribute used to force alignment * The following is the variable attribute used to force alignment
* of critical RTEMS structures. On some processors it may make * of critical RTEMS structures. On some processors it may make
@@ -317,23 +324,11 @@ extern "C" {
* the minimum requirements of the compiler in order to have as * the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line. * much of the critical data area as possible in a cache line.
* *
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
* Port Specific Information: * Port Specific Information:
* *
* XXX document implementation including references if appropriate * XXX document implementation including references if appropriate
*/ */
#define CPU_STRUCTURE_ALIGNMENT #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
/** /**
* @defgroup CPUEndian Processor Dependent Endianness Support * @defgroup CPUEndian Processor Dependent Endianness Support

View File

@@ -252,28 +252,10 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 32
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
*/
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (32))) #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
/* /*
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -101,28 +101,9 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* #define CPU_CACHE_LINE_BYTES PPC_STRUCTURE_ALIGNMENT
* The following is the variable attribute used to force alignment
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*/
#define CPU_STRUCTURE_ALIGNMENT \ #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
__attribute__ ((aligned (PPC_STRUCTURE_ALIGNMENT)))
/* /*
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -229,27 +229,10 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 16
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* NOTE: Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*/
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned(16))) #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
/* /*
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -210,17 +210,10 @@ extern "C" {
*/ */
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/** /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 32
* of critical data structures. On some processors it may make
* sense to have these aligned on tighter boundaries than #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The SPARC does not appear to have particularly strict alignment
* requirements. This value was chosen to take advantages of caches.
*/
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (32)))
/** /**
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -170,6 +170,9 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/* FIXME: Is this the right value? */
#define CPU_CACHE_LINE_BYTES 32
/* /*
* The following is the variable attribute used to force alignment * The following is the variable attribute used to force alignment
* of critical data structures. On some processors it may make * of critical data structures. On some processors it may make
@@ -184,7 +187,7 @@ extern "C" {
* and is 16 if quad-word fp instructions are available (e.g. LDQF). * and is 16 if quad-word fp instructions are available (e.g. LDQF).
*/ */
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (16))) #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( 16 )
/* /*
* Define what is required to specify how the network to host conversion * Define what is required to specify how the network to host conversion

View File

@@ -289,29 +289,9 @@ extern "C" {
*/ */
#define CPU_STACK_GROWS_UP FALSE #define CPU_STACK_GROWS_UP FALSE
/** /* FIXME: Is this the right value? */
* The following is the variable attribute used to force alignment #define CPU_CACHE_LINE_BYTES 32
* of critical RTEMS structures. On some processors it may make
* sense to have these aligned on tighter boundaries than
* the minimum requirements of the compiler in order to have as
* much of the critical data area as possible in a cache line.
*
* The placement of this macro in the declaration of the variables
* is based on the syntactically requirements of the GNU C
* "__attribute__" extension. For example with GNU C, use
* the following to force a structures to a 32 byte boundary.
*
* __attribute__ ((aligned (32)))
*
* @note Currently only the Priority Bit Map table uses this feature.
* To benefit from using this, the data must be heavily
* used so it will stay in the cache and used frequently enough
* in the executive to justify turning this on.
*
* Port Specific Information:
*
* Until proven otherwise, use the compiler default.
*/
#define CPU_STRUCTURE_ALIGNMENT #define CPU_STRUCTURE_ALIGNMENT
/** /**