summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-11-04 21:04:39 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-11-22 16:35:07 +0100
commitf1738ed619ed01199535410887a81c6ac99e482c (patch)
tree2578ed634fd96ffc933ec3470e2d06ff82cd8e5a
parent74d22fd1a9633efe12a7a9c6b7662d80c0185f87 (diff)
downloadrtems-f1738ed619ed01199535410887a81c6ac99e482c.tar.bz2
score: PR1607: Add and use CPU_SIZEOF_POINTER
Add and use new CPU port define CPU_SIZEOF_POINTER. It must be an integer literal that can be used by the assembler. This value will be used to calculate offsets of structure members. These offsets will be used in assembler code. The size of a pointer is part of the application binary interface (ABI) and thus independent of the actual programming language. The compiler will provide defines to determine the current ABI. We use these defines to select the appropriate CPU_SIZEOF_POINTER value. Static assertions in the new file "cpukit/score/src/percpuasm.c" will ensure that the value of CPU_SIZEOF_POINTER is consistent with the current compiler settings. Also the offset values used by assembler code are verfied.
-rw-r--r--cpukit/configure.ac9
-rw-r--r--cpukit/score/Makefile.am1
-rw-r--r--cpukit/score/cpu/arm/rtems/score/cpu.h3
-rw-r--r--cpukit/score/cpu/avr/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/bfin/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/h8300/rtems/score/cpu.h6
-rw-r--r--cpukit/score/cpu/i386/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/lm32/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/m32c/rtems/score/cpu.h6
-rw-r--r--cpukit/score/cpu/m32r/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/m68k/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/mips/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/nios2/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/no_cpu/rtems/score/cpu.h9
-rw-r--r--cpukit/score/cpu/powerpc/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/sh/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/sparc/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/sparc64/rtems/score/cpu.h2
-rw-r--r--cpukit/score/cpu/v850/rtems/score/cpu.h2
-rw-r--r--cpukit/score/include/rtems/score/percpu.h8
-rw-r--r--cpukit/score/src/percpuasm.c59
21 files changed, 114 insertions, 13 deletions
diff --git a/cpukit/configure.ac b/cpukit/configure.ac
index d0d957d723..e3c4dd4d1e 100644
--- a/cpukit/configure.ac
+++ b/cpukit/configure.ac
@@ -154,10 +154,6 @@ rtems_major=`echo _RTEMS_VERSION | sed "s/\..*//"`
rtems_minor=`echo _RTEMS_VERSION | sed "s/[[0-9]][[0-9]]*\.//;s/\..*//"`
rtems_revision=`echo _RTEMS_VERSION | sed "s/[[0-9]][[0-9]]*\.//;s/[[0-9]][[0-9]]*\.//;s/\..*//"`
-## This is needed to generate the field offsets of the per CPU
-## data structure so they can be accessed from assembly code.
-AC_CHECK_SIZEOF([void *])
-
_RTEMS_CPUOPT_INIT
RTEMS_CPUOPT([RTEMS_DEBUG],
@@ -233,11 +229,6 @@ RTEMS_CPUOPT([__RTEMS_ADA__],
## Then we propagate a private copy of the value into cpuopts.h
## so it is always available to the RTEMS header files.
-RTEMS_CPUOPT([__RTEMS_SIZEOF_VOID_P__],
- [true],
- [$ac_cv_sizeof_void_p],
- [Size of a void * pointer])
-
RTEMS_CPUOPT([__RTEMS_MAJOR__],
[true],
[$rtems_major],
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 1b3d13bee9..cc252db0b9 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -158,6 +158,7 @@ libscore_a_SOURCES += src/coremutex.c src/coremutexflush.c \
## CORE_PERCPU_C_FILES
libscore_a_SOURCES += src/percpu.c
+libscore_a_SOURCES += src/percpuasm.c
## CORE_RWLOCK_C_FILES
if HAS_PTHREADS
diff --git a/cpukit/score/cpu/arm/rtems/score/cpu.h b/cpukit/score/cpu/arm/rtems/score/cpu.h
index 5cc378a8c8..1528533d5e 100644
--- a/cpukit/score/cpu/arm/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/rtems/score/cpu.h
@@ -189,6 +189,9 @@
#define CPU_STACK_MINIMUM_SIZE (1024 * 4)
/* AAPCS, section 4.1, Fundamental Data Types */
+#define CPU_SIZEOF_POINTER 4
+
+/* AAPCS, section 4.1, Fundamental Data Types */
#define CPU_ALIGNMENT 8
#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
diff --git a/cpukit/score/cpu/avr/rtems/score/cpu.h b/cpukit/score/cpu/avr/rtems/score/cpu.h
index f085cf4646..5436c2181f 100644
--- a/cpukit/score/cpu/avr/rtems/score/cpu.h
+++ b/cpukit/score/cpu/avr/rtems/score/cpu.h
@@ -527,6 +527,8 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
*/
#define CPU_PRIORITY_MAXIMUM 15
+#define CPU_SIZEOF_POINTER 2
+
/*
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/bfin/rtems/score/cpu.h b/cpukit/score/cpu/bfin/rtems/score/cpu.h
index 479311df1c..a8cfc17d6d 100644
--- a/cpukit/score/cpu/bfin/rtems/score/cpu.h
+++ b/cpukit/score/cpu/bfin/rtems/score/cpu.h
@@ -615,6 +615,8 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
*/
#define CPU_STACK_MINIMUM_SIZE (1024*8)
+#define CPU_SIZEOF_POINTER 4
+
/**
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/h8300/rtems/score/cpu.h b/cpukit/score/cpu/h8300/rtems/score/cpu.h
index ea9d443e25..1811ce779a 100644
--- a/cpukit/score/cpu/h8300/rtems/score/cpu.h
+++ b/cpukit/score/cpu/h8300/rtems/score/cpu.h
@@ -497,6 +497,12 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
#define CPU_STACK_MINIMUM_SIZE (1536)
+#if defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+ #define CPU_SIZEOF_POINTER 4
+#else
+ #define CPU_SIZEOF_POINTER 2
+#endif
+
/*
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h
index a8d23f955c..2a48711cd7 100644
--- a/cpukit/score/cpu/i386/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/rtems/score/cpu.h
@@ -323,6 +323,8 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
#define CPU_STACK_MINIMUM_SIZE 4096
+#define CPU_SIZEOF_POINTER 4
+
/*
* i386 is pretty tolerant of alignment. Just put things on 4 byte boundaries.
*/
diff --git a/cpukit/score/cpu/lm32/rtems/score/cpu.h b/cpukit/score/cpu/lm32/rtems/score/cpu.h
index 19f3017e8f..9f0876a3f4 100644
--- a/cpukit/score/cpu/lm32/rtems/score/cpu.h
+++ b/cpukit/score/cpu/lm32/rtems/score/cpu.h
@@ -615,6 +615,8 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
*/
#define CPU_STACK_MINIMUM_SIZE (1024*4)
+#define CPU_SIZEOF_POINTER 4
+
/**
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/m32c/rtems/score/cpu.h b/cpukit/score/cpu/m32c/rtems/score/cpu.h
index c1d1db876d..d83e93d009 100644
--- a/cpukit/score/cpu/m32c/rtems/score/cpu.h
+++ b/cpukit/score/cpu/m32c/rtems/score/cpu.h
@@ -575,6 +575,12 @@ typedef struct {
*/
#define CPU_STACK_MINIMUM_SIZE (2048L)
+#ifdef __m32cm_cpu__
+ #define CPU_SIZEOF_POINTER 4
+#else
+ #define CPU_SIZEOF_POINTER 2
+#endif
+
/**
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/m32r/rtems/score/cpu.h b/cpukit/score/cpu/m32r/rtems/score/cpu.h
index 4e4c01f5aa..02bc928617 100644
--- a/cpukit/score/cpu/m32r/rtems/score/cpu.h
+++ b/cpukit/score/cpu/m32r/rtems/score/cpu.h
@@ -622,6 +622,8 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
*/
#define CPU_STACK_MINIMUM_SIZE (1024)
+#define CPU_SIZEOF_POINTER 4
+
/**
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/m68k/rtems/score/cpu.h b/cpukit/score/cpu/m68k/rtems/score/cpu.h
index 013f1b51ce..89b0295f60 100644
--- a/cpukit/score/cpu/m68k/rtems/score/cpu.h
+++ b/cpukit/score/cpu/m68k/rtems/score/cpu.h
@@ -380,6 +380,8 @@ SCORE_EXTERN _CPU_ISR_handler_entry _CPU_ISR_jump_table[256];
*/
#define CPU_PRIORITY_MAXIMUM M68K_CPU_PRIORITY_MAXIMUM
+#define CPU_SIZEOF_POINTER 4
+
/*
* m68k is pretty tolerant of alignment. Just put things on 4 byte boundaries.
*/
diff --git a/cpukit/score/cpu/mips/rtems/score/cpu.h b/cpukit/score/cpu/mips/rtems/score/cpu.h
index d0f7c05483..9aa72d41d4 100644
--- a/cpukit/score/cpu/mips/rtems/score/cpu.h
+++ b/cpukit/score/cpu/mips/rtems/score/cpu.h
@@ -343,6 +343,8 @@ extern "C" {
#define CPU_MODES_INTERRUPT_MASK 0x000000ff
+#define CPU_SIZEOF_POINTER 4
+
/*
* Processor defined structures
*
diff --git a/cpukit/score/cpu/nios2/rtems/score/cpu.h b/cpukit/score/cpu/nios2/rtems/score/cpu.h
index 0632aa9548..4d61c42021 100644
--- a/cpukit/score/cpu/nios2/rtems/score/cpu.h
+++ b/cpukit/score/cpu/nios2/rtems/score/cpu.h
@@ -73,6 +73,8 @@ extern "C" {
#define CPU_STACK_MINIMUM_SIZE (4 * 1024)
+#define CPU_SIZEOF_POINTER 4
+
/*
* Alignment value according to "Nios II Processor Reference" chapter 7
* "Application Binary Interface" section "Memory Alignment".
diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
index 8a00c19dc0..9ab1f264c8 100644
--- a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
+++ b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
@@ -684,6 +684,15 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
#define CPU_STACK_MINIMUM_SIZE (1024*4)
/**
+ * Size of a pointer.
+ *
+ * This must be an integer literal that can be used by the assembler. This
+ * value will be used to calculate offsets of structure members. These
+ * offsets will be used in assembler code.
+ */
+#define CPU_SIZEOF_POINTER 4
+
+/**
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
*
diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
index 9ae0cca6d8..31b4e7c9b5 100644
--- a/cpukit/score/cpu/powerpc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
@@ -668,6 +668,8 @@ void _BSP_Fatal_error(unsigned int);
#define CPU_STACK_MINIMUM_SIZE (1024*8)
+#define CPU_SIZEOF_POINTER 4
+
/*
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/sh/rtems/score/cpu.h b/cpukit/score/cpu/sh/rtems/score/cpu.h
index 29319da596..789024e781 100644
--- a/cpukit/score/cpu/sh/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sh/rtems/score/cpu.h
@@ -456,6 +456,8 @@ SCORE_EXTERN void CPU_delay( uint32_t microseconds );
#define CPU_STACK_MINIMUM_SIZE 4096
+#define CPU_SIZEOF_POINTER 4
+
/*
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/sparc/rtems/score/cpu.h b/cpukit/score/cpu/sparc/rtems/score/cpu.h
index 06bb26e724..d92b63c14e 100644
--- a/cpukit/score/cpu/sparc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sparc/rtems/score/cpu.h
@@ -874,6 +874,8 @@ extern const CPU_Trap_table_entry _CPU_Trap_slot_template;
*/
#define CPU_STACK_MINIMUM_SIZE (1024*4)
+#define CPU_SIZEOF_POINTER 4
+
/**
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/sparc64/rtems/score/cpu.h b/cpukit/score/cpu/sparc64/rtems/score/cpu.h
index 0f69c6d3ac..f821e96d42 100644
--- a/cpukit/score/cpu/sparc64/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sparc64/rtems/score/cpu.h
@@ -696,6 +696,8 @@ extern const CPU_Trap_table_entry _CPU_Trap_slot_template;
#define CPU_STACK_MINIMUM_SIZE (1024*8)
+#define CPU_SIZEOF_POINTER 8
+
/*
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/cpu/v850/rtems/score/cpu.h b/cpukit/score/cpu/v850/rtems/score/cpu.h
index 875f1607c7..371bc327e0 100644
--- a/cpukit/score/cpu/v850/rtems/score/cpu.h
+++ b/cpukit/score/cpu/v850/rtems/score/cpu.h
@@ -581,6 +581,8 @@ typedef struct {
*/
#define CPU_STACK_MINIMUM_SIZE (1024*4)
+#define CPU_SIZEOF_POINTER 4
+
/**
* CPU's worst alignment requirement for data types on a byte boundary. This
* alignment does not take into account the requirements for the stack.
diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
index 9442b6e7f0..3e4712d43d 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -150,7 +150,7 @@ typedef struct {
} Per_CPU_Control;
#endif
-#if defined(ASM)
+#if defined(ASM) || defined(_RTEMS_PERCPU_DEFINE_OFFSETS)
#if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \
(CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
@@ -161,9 +161,9 @@ typedef struct {
#define PER_CPU_INTERRUPT_STACK_LOW \
0
#define PER_CPU_INTERRUPT_STACK_HIGH \
- PER_CPU_INTERRUPT_STACK_LOW + __RTEMS_SIZEOF_VOID_P__
+ PER_CPU_INTERRUPT_STACK_LOW + CPU_SIZEOF_POINTER
#define PER_CPU_END_STACK \
- PER_CPU_INTERRUPT_STACK_HIGH + __RTEMS_SIZEOF_VOID_P__
+ PER_CPU_INTERRUPT_STACK_HIGH + CPU_SIZEOF_POINTER
#define INTERRUPT_STACK_LOW \
(SYM(_Per_CPU_Information) + PER_CPU_INTERRUPT_STACK_LOW)
@@ -187,7 +187,7 @@ typedef struct {
#define DISPATCH_NEEDED \
(SYM(_Per_CPU_Information) + PER_CPU_DISPATCH_NEEDED)
-#endif /* defined(ASM) */
+#endif /* defined(ASM) || defined(_RTEMS_PERCPU_DEFINE_OFFSETS) */
#ifndef ASM
diff --git a/cpukit/score/src/percpuasm.c b/cpukit/score/src/percpuasm.c
new file mode 100644
index 0000000000..a79936bab4
--- /dev/null
+++ b/cpukit/score/src/percpuasm.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/score/cpu.h>
+
+#define _RTEMS_PERCPU_DEFINE_OFFSETS
+#include <rtems/score/percpu.h>
+
+RTEMS_STATIC_ASSERT(
+ sizeof(void *) == CPU_SIZEOF_POINTER,
+ CPU_SIZEOF_POINTER
+);
+
+#ifdef __SIZEOF_POINTER__
+ RTEMS_STATIC_ASSERT(
+ CPU_SIZEOF_POINTER == __SIZEOF_POINTER__,
+ __SIZEOF_POINTER__
+ );
+#endif
+
+RTEMS_STATIC_ASSERT(
+ offsetof(Per_CPU_Control, isr_nest_level) == PER_CPU_ISR_NEST_LEVEL,
+ PER_CPU_ISR_NEST_LEVEL
+);
+
+RTEMS_STATIC_ASSERT(
+ offsetof(Per_CPU_Control, dispatch_necessary) == PER_CPU_DISPATCH_NEEDED,
+ PER_CPU_DISPATCH_NEEDED
+);
+
+#if CPU_ALLOCATE_INTERRUPT_STACK == TRUE \
+ || CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE
+ RTEMS_STATIC_ASSERT(
+ offsetof(Per_CPU_Control, interrupt_stack_low)
+ == PER_CPU_INTERRUPT_STACK_LOW,
+ PER_CPU_INTERRUPT_STACK_LOW
+ );
+
+ RTEMS_STATIC_ASSERT(
+ offsetof(Per_CPU_Control, interrupt_stack_high)
+ == PER_CPU_INTERRUPT_STACK_HIGH,
+ PER_CPU_INTERRUPT_STACK_HIGH
+ );
+#endif