forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -188,6 +188,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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -343,6 +343,8 @@ extern "C" {
|
||||
|
||||
#define CPU_MODES_INTERRUPT_MASK 0x000000ff
|
||||
|
||||
#define CPU_SIZEOF_POINTER 4
|
||||
|
||||
/*
|
||||
* Processor defined structures
|
||||
*
|
||||
|
||||
@@ -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".
|
||||
|
||||
@@ -683,6 +683,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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
59
cpukit/score/src/percpuasm.c
Normal file
59
cpukit/score/src/percpuasm.c
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user