diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-11-04 21:04:39 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-11-22 16:35:07 +0100 |
commit | f1738ed619ed01199535410887a81c6ac99e482c (patch) | |
tree | 2578ed634fd96ffc933ec3470e2d06ff82cd8e5a /cpukit/score/src/percpuasm.c | |
parent | score: Inline _API_extensions_Run_postswitch() (diff) | |
download | rtems-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.
Diffstat (limited to 'cpukit/score/src/percpuasm.c')
-rw-r--r-- | cpukit/score/src/percpuasm.c | 59 |
1 files changed, 59 insertions, 0 deletions
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 |