[PATCH 2/6] smp: Add and use _CPU_SMP_Get_current_processor()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Jun 14 14:31:57 UTC 2013
Add and use _SMP_Get_current_processor() and
rtems_smp_get_current_processor().
Delete bsp_smp_interrupt_cpu().
Change type of current processor index from int to uint32_t to match
_SMP_Processor_count type.
---
c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c | 5 ---
c/src/lib/libbsp/i386/shared/irq/irq_asm.S | 2 +-
c/src/lib/libbsp/i386/shared/smp/getcpuid.c | 4 ++-
c/src/lib/libbsp/powerpc/qoriq/startup/smp.c | 5 ---
c/src/lib/libbsp/shared/smp/getcpuid.c | 5 ++-
c/src/lib/libbsp/sparc/leon3/smp/getcpuid.c | 6 +++-
c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c | 10 +++---
cpukit/rtems/include/rtems.h | 1 -
cpukit/rtems/include/rtems/rtems/smp.h | 19 ++++++++++---
cpukit/score/cpu/arm/rtems/score/cpu.h | 14 +++++++++
cpukit/score/cpu/i386/rtems/score/cpu.h | 2 +
cpukit/score/cpu/no_cpu/rtems/score/cpu.h | 13 +++++++++
cpukit/score/cpu/powerpc/rtems/score/cpu.h | 15 ++++++++++
cpukit/score/cpu/sparc/rtems/score/cpu.h | 2 +
cpukit/score/include/rtems/bspsmp.h | 25 -----------------
cpukit/score/include/rtems/score/percpu.h | 23 ++++++---------
cpukit/score/include/rtems/score/smp.h | 12 +++++++-
cpukit/score/include/rtems/score/threaddispatch.h | 4 +-
cpukit/score/src/smp.c | 30 ++++++++++----------
cpukit/score/src/threaddispatchdisablelevel.c | 6 ++--
testsuites/smptests/smp01/init.c | 10 ++++---
testsuites/smptests/smp01/tasks.c | 8 +++--
testsuites/smptests/smp02/init.c | 7 +++--
testsuites/smptests/smp02/system.h | 2 +-
testsuites/smptests/smp02/tasks.c | 6 ++--
testsuites/smptests/smp03/init.c | 9 +++---
testsuites/smptests/smp04/init.c | 13 +++++----
testsuites/smptests/smp05/init.c | 10 +++---
testsuites/smptests/smp06/init.c | 16 +++++-----
testsuites/smptests/smp07/init.c | 10 +++---
testsuites/smptests/smp08/init.c | 6 ++--
testsuites/smptests/smp08/tasks.c | 4 +-
testsuites/smptests/smp09/init.c | 8 +++---
testsuites/smptests/smpatomic01/tasks.c | 4 +-
testsuites/smptests/smpatomic02/tasks.c | 4 +-
testsuites/smptests/smpatomic03/tasks.c | 4 +-
testsuites/smptests/smpatomic04/tasks.c | 4 +-
testsuites/smptests/smpatomic05/tasks.c | 4 +-
testsuites/smptests/smpatomic06/tasks.c | 4 +-
testsuites/smptests/smpatomic07/tasks.c | 4 +-
testsuites/smptests/smplock01/init.c | 12 ++++----
41 files changed, 195 insertions(+), 157 deletions(-)
diff --git a/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c b/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c
index b94bcec..e647b4f 100644
--- a/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c
+++ b/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c
@@ -20,11 +20,6 @@
#include <bsp/irq.h>
-int bsp_smp_processor_id(void)
-{
- return (int) arm_cortex_a9_get_multiprocessor_cpu_id();
-}
-
static void ipi_handler(void *arg)
{
rtems_smp_process_interrupt();
diff --git a/c/src/lib/libbsp/i386/shared/irq/irq_asm.S b/c/src/lib/libbsp/i386/shared/irq/irq_asm.S
index d07ae2c..2b16234 100644
--- a/c/src/lib/libbsp/i386/shared/irq/irq_asm.S
+++ b/c/src/lib/libbsp/i386/shared/irq/irq_asm.S
@@ -100,7 +100,7 @@ SYM (_ISR_Handler):
movl esp, ebp /* ebp = previous stack pointer */
#if defined(RTEMS_SMP) && defined(BSP_HAS_SMP)
movl $SYM(_Per_CPU_Information_p), ebx
- call SYM(bsp_smp_processor_id)
+ call SYM(_CPU_SMP_Get_current_processor)
mov (ebx,eax,4), ebx
pushl ecx
call SYM(_ISR_SMP_Enter)
diff --git a/c/src/lib/libbsp/i386/shared/smp/getcpuid.c b/c/src/lib/libbsp/i386/shared/smp/getcpuid.c
index dc82d3f..dec8166 100644
--- a/c/src/lib/libbsp/i386/shared/smp/getcpuid.c
+++ b/c/src/lib/libbsp/i386/shared/smp/getcpuid.c
@@ -7,13 +7,15 @@
* http://www.rtems.com/license/LICENSE.
*/
+#include <rtems/score/cpu.h>
+
#include <bsp/apic.h>
#include <bsp/smp-imps.h>
static int lapic_dummy = 0;
unsigned imps_lapic_addr = ((unsigned)(&lapic_dummy)) - LAPIC_ID;
-int bsp_smp_processor_id(void)
+uint32_t _CPU_SMP_Get_current_processor( void )
{
return APIC_ID(IMPS_LAPIC_READ(LAPIC_ID));
}
diff --git a/c/src/lib/libbsp/powerpc/qoriq/startup/smp.c b/c/src/lib/libbsp/powerpc/qoriq/startup/smp.c
index 24d6a9b..b16adb8 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/startup/smp.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/startup/smp.c
@@ -43,11 +43,6 @@ void _start_core_1(void);
#define TLB_COUNT (TLB_END - TLB_BEGIN)
-int bsp_smp_processor_id(void)
-{
- return (int) ppc_processor_id();
-}
-
/*
* These values can be obtained with the debugger or a look into the
* U-Boot sources (arch/powerpc/cpu/mpc85xx/release.S).
diff --git a/c/src/lib/libbsp/shared/smp/getcpuid.c b/c/src/lib/libbsp/shared/smp/getcpuid.c
index c1806c8..8d57b78 100644
--- a/c/src/lib/libbsp/shared/smp/getcpuid.c
+++ b/c/src/lib/libbsp/shared/smp/getcpuid.c
@@ -7,8 +7,9 @@
* http://www.rtems.com/license/LICENSE.
*/
-int bsp_smp_processor_id(void)
+#include <rtems/score/cpu.h>
+
+uint32_t _CPU_SMP_Get_current_processor( void )
{
return 0;
}
-
diff --git a/c/src/lib/libbsp/sparc/leon3/smp/getcpuid.c b/c/src/lib/libbsp/sparc/leon3/smp/getcpuid.c
index 5678fd4..824278d 100644
--- a/c/src/lib/libbsp/sparc/leon3/smp/getcpuid.c
+++ b/c/src/lib/libbsp/sparc/leon3/smp/getcpuid.c
@@ -13,9 +13,11 @@
* http://www.rtems.com/license/LICENSE.
*/
-int bsp_smp_processor_id(void)
+#include <rtems/score/cpu.h>
+
+uint32_t _CPU_SMP_Get_current_processor( void )
{
- unsigned int id;
+ uint32_t id;
__asm__ __volatile__( "rd %%asr17,%0\n\t" : "=r" (id) : );
return ((id >> 28) & 0xff);
diff --git a/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c b/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c
index 7dbd5bb..39fc9f9 100644
--- a/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c
+++ b/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c
@@ -43,7 +43,7 @@ static rtems_isr bsp_ap_ipi_isr(
static void leon3_secondary_cpu_initialize(void)
{
- int cpu = bsp_smp_processor_id();
+ uint32_t cpu = rtems_smp_get_current_processor();
sparc_leon3_set_cctrl( 0x80000F );
LEON_Unmask_interrupt(LEON3_MP_IRQ);
@@ -125,11 +125,11 @@ void bsp_smp_interrupt_cpu(
void bsp_smp_broadcast_interrupt(void)
{
- int dest_cpu;
- int cpu;
- int max_cpus;
+ uint32_t dest_cpu;
+ uint32_t cpu;
+ uint32_t max_cpus;
- cpu = bsp_smp_processor_id();
+ cpu = rtems_smp_get_current_processor();
max_cpus = rtems_smp_get_processor_count();
for ( dest_cpu=0 ; dest_cpu < max_cpus ; dest_cpu++ ) {
diff --git a/cpukit/rtems/include/rtems.h b/cpukit/rtems/include/rtems.h
index ab727b2..9b94804 100644
--- a/cpukit/rtems/include/rtems.h
+++ b/cpukit/rtems/include/rtems.h
@@ -75,7 +75,6 @@ extern "C" {
#endif
#include <rtems/rtems/smp.h>
-
#include <rtems/rtems/support.h>
#include <rtems/score/sysstate.h>
diff --git a/cpukit/rtems/include/rtems/rtems/smp.h b/cpukit/rtems/include/rtems/rtems/smp.h
index d8431b0..6e45671 100644
--- a/cpukit/rtems/include/rtems/rtems/smp.h
+++ b/cpukit/rtems/include/rtems/rtems/smp.h
@@ -55,14 +55,25 @@ extern "C" {
_SMP_Get_processor_count()
/**
- * @brief Obtain Current Core Number
+ * @brief Returns the index of the current processor.
*
- * This method returns the id of the current CPU core.
+ * On uni-processor configurations this is a compile time constant and defined
+ * to be zero.
+ *
+ * On SMP configurations an architecture specific method is used to obtain the
+ * index of the current processor in the system. The set of processor indices
+ * is the range of integers starting with zero up to the processor count minus
+ * one.
+ *
+ * Outside of sections with disabled thread dispatching the current processor
+ * index may change after every instruction since the thread may migrate from
+ * one processor to another. Sections with disabled interrupts are sections
+ * with thread dispatching disabled.
*
- * @retval This method returns the id of the current CPU core.
+ * @return The index of the current processor.
*/
#define rtems_smp_get_current_processor() \
- bsp_smp_processor_id()
+ _SMP_Get_current_processor()
/** @} */
diff --git a/cpukit/score/cpu/arm/rtems/score/cpu.h b/cpukit/score/cpu/arm/rtems/score/cpu.h
index 7020261..ed1b605 100644
--- a/cpukit/score/cpu/arm/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/rtems/score/cpu.h
@@ -443,6 +443,20 @@ void _CPU_Context_validate( uintptr_t pattern );
#define _CPU_Context_switch_to_first_task_smp( _context ) \
_CPU_Context_restore( _context )
+ RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
+ _CPU_SMP_Get_current_processor( void )
+ {
+ uint32_t mpidr;
+
+ /* Use ARMv7 Multiprocessor Affinity Register (MPIDR) */
+ __asm__ volatile (
+ "mrc p15, 0, %[mpidr], c0, c0, 5\n"
+ : [mpidr] "=&r" (mpidr)
+ );
+
+ return mpidr & 0xffU;
+ }
+
static inline void _ARM_Data_memory_barrier( void )
{
__asm__ volatile ( "dmb" : : : "memory" );
diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h
index 3f7a331..b00ae3b 100644
--- a/cpukit/score/cpu/i386/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/rtems/score/cpu.h
@@ -455,6 +455,8 @@ uint32_t _CPU_ISR_Get_level( void );
#define _CPU_Context_switch_to_first_task_smp( _the_context ) \
_CPU_Context_restore( (_the_context) );
+ RTEMS_COMPILER_PURE_ATTRIBUTE uint32_t _CPU_SMP_Get_current_processor( void );
+
static inline void _CPU_Processor_event_broadcast( void )
{
__asm__ volatile ( "" : : : "memory" );
diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
index e2c6d94..d368e51 100644
--- a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
+++ b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
@@ -1404,6 +1404,19 @@ static inline uint32_t CPU_swap_u32(
#ifdef RTEMS_SMP
/**
+ * @brief Returns the index of the current processor.
+ *
+ * An architecture specific method must be used to obtain the index of the
+ * current processor in the system. The set of processor indices is the
+ * range of integers starting with zero up to the processor count minus one.
+ */
+ RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
+ _CPU_SMP_Get_current_processor( void )
+ {
+ return 123;
+ }
+
+ /**
* @brief Broadcasts a processor event.
*
* Some architectures provide a low-level synchronization primitive for
diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
index fdb2886..9b1917e 100644
--- a/cpukit/score/cpu/powerpc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
@@ -1000,6 +1000,21 @@ void _CPU_Context_validate( uintptr_t pattern );
#define _CPU_Context_switch_to_first_task_smp( _context ) \
_CPU_Context_restore( _context )
+ RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
+ _CPU_SMP_Get_current_processor( void )
+ {
+ uint32_t pir;
+
+ /* Use Book E Processor ID Register (PIR) */
+ __asm__ volatile (
+ "mfspr %[pir], 286"
+ : [pir] "=&r" (pir)
+ );
+
+ return pir;
+ }
+
+
static inline void _CPU_Processor_event_broadcast( void )
{
__asm__ volatile ( "" : : : "memory" );
diff --git a/cpukit/score/cpu/sparc/rtems/score/cpu.h b/cpukit/score/cpu/sparc/rtems/score/cpu.h
index defc01a..e4eb65e 100644
--- a/cpukit/score/cpu/sparc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sparc/rtems/score/cpu.h
@@ -1186,6 +1186,8 @@ void _CPU_Context_restore(
Context_Control *new_context
);
+ RTEMS_COMPILER_PURE_ATTRIBUTE uint32_t _CPU_SMP_Get_current_processor( void );
+
static inline void _CPU_Processor_event_broadcast( void )
{
__asm__ volatile ( "" : : : "memory" );
diff --git a/cpukit/score/include/rtems/bspsmp.h b/cpukit/score/include/rtems/bspsmp.h
index b712c4f..57f5a7a 100644
--- a/cpukit/score/include/rtems/bspsmp.h
+++ b/cpukit/score/include/rtems/bspsmp.h
@@ -70,16 +70,6 @@ extern "C" {
uint32_t bsp_smp_initialize( uint32_t configured_cpu_count );
/**
- * @brief Obtain current CPU index.
- *
- * This method is invoked by RTEMS when it needs to know the index
- * of the CPU it is executing on.
- *
- * @retval This method returns the current CPU index.
- */
-int bsp_smp_processor_id(void) RTEMS_COMPILER_PURE_ATTRIBUTE;
-
-/**
* @brief Generate an interprocessor broadcast interrupt.
*
* This method is invoked when RTEMS wants to let all of the other
@@ -106,19 +96,6 @@ void bsp_smp_interrupt_cpu(
);
/**
- * @brief Obtain CPU core number.
- *
- * This method is invoked by RTEMS when it needs to know which core
- * number it is executing on. This is used when it needs to perform
- * some action or bookkeeping and needs to distinguish itself from
- * the other cores. For example, it may need to realize it needs to
- * preempt a thread on another node.
- *
- * @retval This method returns the Id of the current CPU core.
- */
-int bsp_smp_processor_id( void );
-
-/**
* @brief Performs high-level initialization of a secondary processor and runs
* the application threads.
*
@@ -156,8 +133,6 @@ void rtems_smp_process_interrupt(void);
}
#endif
-#else
- #define bsp_smp_processor_id() 0
#endif
/**@}*/
diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
index bb565d9..383202c 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -25,12 +25,7 @@
#include <rtems/score/isrlevel.h>
#include <rtems/score/timestamp.h>
#include <rtems/score/smplock.h>
-
- /*
- * NOTE: This file MUST be included on non-smp systems as well
- * in order to define bsp_smp_processor_id.
- */
- #include <rtems/bspsmp.h>
+ #include <rtems/score/smp.h>
#endif
/**
@@ -277,23 +272,23 @@ void _Per_CPU_Wait_for_state(
#endif
/*
- * On a non SMP system, the bsp_smp_processor_id is defined to 0.
+ * On a non SMP system, the _SMP_Get_current_processor() is defined to 0.
* Thus when built for non-SMP, there should be no performance penalty.
*/
#define _Thread_Heir \
- _Per_CPU_Information[bsp_smp_processor_id()].heir
+ _Per_CPU_Information[_SMP_Get_current_processor()].heir
#define _Thread_Executing \
- _Per_CPU_Information[bsp_smp_processor_id()].executing
+ _Per_CPU_Information[_SMP_Get_current_processor()].executing
#define _ISR_Nest_level \
- _Per_CPU_Information[bsp_smp_processor_id()].isr_nest_level
+ _Per_CPU_Information[_SMP_Get_current_processor()].isr_nest_level
#define _CPU_Interrupt_stack_low \
- _Per_CPU_Information[bsp_smp_processor_id()].interrupt_stack_low
+ _Per_CPU_Information[_SMP_Get_current_processor()].interrupt_stack_low
#define _CPU_Interrupt_stack_high \
- _Per_CPU_Information[bsp_smp_processor_id()].interrupt_stack_high
+ _Per_CPU_Information[_SMP_Get_current_processor()].interrupt_stack_high
#define _Thread_Dispatch_necessary \
- _Per_CPU_Information[bsp_smp_processor_id()].dispatch_necessary
+ _Per_CPU_Information[_SMP_Get_current_processor()].dispatch_necessary
#define _Thread_Time_of_last_context_switch \
- _Per_CPU_Information[bsp_smp_processor_id()].time_of_last_context_switch
+ _Per_CPU_Information[_SMP_Get_current_processor()].time_of_last_context_switch
#endif /* ASM */
diff --git a/cpukit/score/include/rtems/score/smp.h b/cpukit/score/include/rtems/score/smp.h
index a015156..fedf9ab 100644
--- a/cpukit/score/include/rtems/score/smp.h
+++ b/cpukit/score/include/rtems/score/smp.h
@@ -71,7 +71,7 @@ extern "C" {
* @param[in] cpu The target processor of the message.
* @param[in] message The message.
*/
-void _SMP_Send_message( int cpu, uint32_t message );
+void _SMP_Send_message( uint32_t cpu, uint32_t message );
/**
* @brief Request of others CPUs.
@@ -116,6 +116,16 @@ void _SMP_Request_other_cores_to_shutdown(void);
/** @} */
+#if defined( RTEMS_SMP )
+ RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
+ _SMP_Get_current_processor( void )
+ {
+ return _CPU_SMP_Get_current_processor();
+ }
+#else
+ #define _SMP_Get_current_processor() ( ( uint32_t ) 0 )
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/score/include/rtems/score/threaddispatch.h b/cpukit/score/include/rtems/score/threaddispatch.h
index e3065da..7e7afb9 100644
--- a/cpukit/score/include/rtems/score/threaddispatch.h
+++ b/cpukit/score/include/rtems/score/threaddispatch.h
@@ -62,8 +62,8 @@ RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_is_enabled(void)
#if defined(RTEMS_SMP)
typedef struct {
SMP_lock_Control lock;
- int owner_cpu;
- int nest_level;
+ uint32_t owner_cpu;
+ uint32_t nest_level;
} Thread_Dispatch_disable_level_lock_control;
/**
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index fce9275..8e06d04 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -30,7 +30,7 @@
void rtems_smp_secondary_cpu_initialize( void )
{
- int self = bsp_smp_processor_id();
+ uint32_t self = _SMP_Get_current_processor();
Per_CPU_Control *per_cpu = &_Per_CPU_Information[ self ];
Thread_Control *heir;
@@ -67,7 +67,7 @@ void rtems_smp_secondary_cpu_initialize( void )
void rtems_smp_process_interrupt( void )
{
- int self = bsp_smp_processor_id();
+ uint32_t self = _SMP_Get_current_processor();
Per_CPU_Control *per_cpu = &_Per_CPU_Information[ self ];
@@ -107,7 +107,7 @@ void rtems_smp_process_interrupt( void )
}
}
-void _SMP_Send_message( int cpu, uint32_t message )
+void _SMP_Send_message( uint32_t cpu, uint32_t message )
{
Per_CPU_Control *per_cpu = &_Per_CPU_Information[ cpu ];
ISR_Level level;
@@ -126,9 +126,9 @@ void _SMP_Send_message( int cpu, uint32_t message )
void _SMP_Broadcast_message( uint32_t message )
{
- int self = bsp_smp_processor_id();
- int ncpus = _SMP_Get_processor_count();
- int cpu;
+ uint32_t self = _SMP_Get_current_processor();
+ uint32_t ncpus = _SMP_Get_processor_count();
+ uint32_t cpu;
for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
if ( cpu != self ) {
@@ -146,9 +146,9 @@ void _SMP_Broadcast_message( uint32_t message )
void _SMP_Request_other_cores_to_perform_first_context_switch( void )
{
- int self = bsp_smp_processor_id();
- int ncpus = _SMP_Get_processor_count();
- int cpu;
+ uint32_t self = _SMP_Get_current_processor();
+ uint32_t ncpus = _SMP_Get_processor_count();
+ uint32_t cpu;
for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
Per_CPU_Control *per_cpu = &_Per_CPU_Information[ cpu ];
@@ -165,9 +165,9 @@ void _SMP_Request_other_cores_to_perform_first_context_switch( void )
void _SMP_Request_other_cores_to_dispatch( void )
{
if ( _System_state_Is_up( _System_state_Get() ) ) {
- int self = bsp_smp_processor_id();
- int ncpus = _SMP_Get_processor_count();
- int cpu;
+ uint32_t self = _SMP_Get_current_processor();
+ uint32_t ncpus = _SMP_Get_processor_count();
+ uint32_t cpu;
for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
const Per_CPU_Control *per_cpu = &_Per_CPU_Information[ cpu ];
@@ -185,9 +185,9 @@ void _SMP_Request_other_cores_to_dispatch( void )
void _SMP_Request_other_cores_to_shutdown( void )
{
- int self = bsp_smp_processor_id();
- int ncpus = _SMP_Get_processor_count();
- int cpu;
+ uint32_t self = _SMP_Get_current_processor();
+ uint32_t ncpus = _SMP_Get_processor_count();
+ uint32_t cpu;
_SMP_Broadcast_message( RTEMS_BSP_SMP_SHUTDOWN );
diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c
index 1f84bfe..d5f3ff6 100644
--- a/cpukit/score/src/threaddispatchdisablelevel.c
+++ b/cpukit/score/src/threaddispatchdisablelevel.c
@@ -26,7 +26,7 @@
#include <rtems/score/sysstate.h>
#include <rtems/score/threaddispatch.h>
-#define NO_OWNER_CPU (-1)
+#define NO_OWNER_CPU 0xffffffffU
void _Thread_Dispatch_initialization( void )
{
@@ -48,8 +48,8 @@ uint32_t _Thread_Dispatch_increment_disable_level( void )
{
Thread_Dispatch_disable_level_lock_control *level_lock =
&_Thread_Dispatch_disable_level_lock;
- int self_cpu;
ISR_Level isr_level;
+ uint32_t self_cpu;
uint32_t disable_level;
_ISR_Disable_on_this_core( isr_level );
@@ -58,7 +58,7 @@ uint32_t _Thread_Dispatch_increment_disable_level( void )
* We must obtain the processor ID after interrupts are disabled since a
* non-optimizing compiler may store the value on the stack and read it back.
*/
- self_cpu = bsp_smp_processor_id();
+ self_cpu = _SMP_Get_current_processor();
if ( level_lock->owner_cpu != self_cpu ) {
_SMP_lock_Acquire( &level_lock->lock );
diff --git a/testsuites/smptests/smp01/init.c b/testsuites/smptests/smp01/init.c
index b47f1b4..3e12726 100644
--- a/testsuites/smptests/smp01/init.c
+++ b/testsuites/smptests/smp01/init.c
@@ -14,6 +14,8 @@
#define CONFIGURE_INIT
#include "system.h"
+#include <inttypes.h>
+
void Loop() {
volatile int i;
@@ -24,14 +26,14 @@ rtems_task Init(
rtems_task_argument argument
)
{
- int i;
+ uint32_t i;
char ch;
- int cpu_self;
+ uint32_t cpu_self;
rtems_id id;
rtems_status_code status;
bool allDone;
- cpu_self = bsp_smp_processor_id();
+ cpu_self = rtems_smp_get_current_processor();
/* XXX - Delay a bit to allow debug messages from
* startup to print. This may need to go away when
@@ -63,7 +65,7 @@ rtems_task Init(
);
directive_failed( status, "task create" );
- locked_printf(" CPU %d start task TA%c\n", cpu_self, ch);
+ locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_self, ch);
status = rtems_task_start( id, Test_task, i+1 );
directive_failed( status, "task start" );
diff --git a/testsuites/smptests/smp01/tasks.c b/testsuites/smptests/smp01/tasks.c
index 1b3b5fb..4eb81f1 100644
--- a/testsuites/smptests/smp01/tasks.c
+++ b/testsuites/smptests/smp01/tasks.c
@@ -13,11 +13,13 @@
#include "system.h"
+#include <inttypes.h>
+
rtems_task Test_task(
rtems_task_argument task_index
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -26,11 +28,11 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
Loop();
- locked_printf(" CPU %d running Task %s\n", cpu_num, name);
+ locked_printf(" CPU %" PRIu32 " running Task %s\n", cpu_num, name);
/* Set the flag that the task is up and running */
TaskRan[cpu_num] = true;
diff --git a/testsuites/smptests/smp02/init.c b/testsuites/smptests/smp02/init.c
index a5ad24b..d053b31 100644
--- a/testsuites/smptests/smp02/init.c
+++ b/testsuites/smptests/smp02/init.c
@@ -15,6 +15,7 @@
#include "system.h"
#include <stdio.h>
+#include <inttypes.h>
rtems_task Init(
rtems_task_argument argument
@@ -22,7 +23,7 @@ rtems_task Init(
{
int i;
char ch;
- int cpu_num;
+ uint32_t cpu_num;
rtems_id id;
rtems_status_code status;
char str[80];
@@ -59,8 +60,8 @@ rtems_task Init(
&id
);
- cpu_num = bsp_smp_processor_id();
- locked_printf(" CPU %d start task TA%c\n", cpu_num, ch);
+ cpu_num = rtems_smp_get_current_processor();
+ locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
status = rtems_task_start( id, Test_task, i+1 );
directive_failed( status, str );
}
diff --git a/testsuites/smptests/smp02/system.h b/testsuites/smptests/smp02/system.h
index 269c7c0..ebe243f 100644
--- a/testsuites/smptests/smp02/system.h
+++ b/testsuites/smptests/smp02/system.h
@@ -50,7 +50,7 @@ rtems_task Test_task(
typedef struct {
bool IsLocked;
- int cpu_num;
+ uint32_t cpu_num;
uint32_t task_index;
} Log_t;
diff --git a/testsuites/smptests/smp02/tasks.c b/testsuites/smptests/smp02/tasks.c
index e3ac062..4e7a625 100644
--- a/testsuites/smptests/smp02/tasks.c
+++ b/testsuites/smptests/smp02/tasks.c
@@ -21,7 +21,7 @@ void Loop(void) {
void LogSemaphore(
bool obtained,
- int cpu_num,
+ uint32_t cpu_num,
uint32_t task_index
){
if (Log_index < LOG_SIZE) {
@@ -37,10 +37,10 @@ rtems_task Test_task(
rtems_task_argument task_index
)
{
- int cpu_num;
+ uint32_t cpu_num;
rtems_status_code sc;
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
do {
diff --git a/testsuites/smptests/smp03/init.c b/testsuites/smptests/smp03/init.c
index 47441b3..40b7593 100644
--- a/testsuites/smptests/smp03/init.c
+++ b/testsuites/smptests/smp03/init.c
@@ -15,6 +15,7 @@
#include "system.h"
#include <stdio.h>
+#include <inttypes.h>
void Loop() {
volatile int i;
@@ -26,18 +27,18 @@ void PrintTaskInfo(
const char *task_name
)
{
- int cpu_num;
+ uint32_t cpu_num;
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
- locked_printf(" CPU %d running task %s\n", cpu_num, task_name );
+ locked_printf(" CPU %" PRIu32 " running task %s\n", cpu_num, task_name );
}
rtems_task Init(
rtems_task_argument argument
)
{
- int i;
+ uint32_t i;
char ch = '0';
rtems_id id;
rtems_status_code status;
diff --git a/testsuites/smptests/smp04/init.c b/testsuites/smptests/smp04/init.c
index a532d46..8cbfbb8 100644
--- a/testsuites/smptests/smp04/init.c
+++ b/testsuites/smptests/smp04/init.c
@@ -15,6 +15,7 @@
#include "system.h"
#include <stdio.h>
+#include <inttypes.h>
void Loop() {
@@ -27,9 +28,9 @@ rtems_task Test_task(
rtems_task_argument task_index
)
{
- int cpu_num;
+ uint32_t cpu_num;
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
locked_printf(" CPU %d running task TA%" PRIu32 "\n", cpu_num, task_index );
Loop();
TaskRan[task_index] = true;
@@ -41,20 +42,20 @@ rtems_task Init(
rtems_task_argument argument
)
{
- int i;
+ uint32_t i;
char ch;
rtems_id id;
rtems_status_code status;
bool allDone;
- int cpu_num;
+ uint32_t cpu_num;
Loop();
locked_print_initialize();
locked_printf( "\n\n*** SMP04 TEST ***\n" );
/* Display which cpu is running this init thread. */
- cpu_num = bsp_smp_processor_id();
- locked_printf(" CPU %d running task Init\n", cpu_num );
+ cpu_num = rtems_smp_get_current_processor();
+ locked_printf(" CPU %" PRIu32 " running task Init\n", cpu_num );
/* Set all Tasks to not ran except for the init task */
TaskRan[0] = true;
diff --git a/testsuites/smptests/smp05/init.c b/testsuites/smptests/smp05/init.c
index eaa08f5..db36e03 100644
--- a/testsuites/smptests/smp05/init.c
+++ b/testsuites/smptests/smp05/init.c
@@ -18,7 +18,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- locked_printf( "Shut down from CPU %d\n", bsp_smp_processor_id() );
+ locked_printf( "Shut down from CPU %" PRIu32 "\n", rtems_smp_get_current_processor() );
locked_printf( "*** END OF TEST SMP05 ***\n" );
rtems_test_exit(0);
}
@@ -27,9 +27,9 @@ rtems_task Init(
rtems_task_argument argument
)
{
- int i;
+ uint32_t i;
char ch;
- int cpu_num;
+ uint32_t cpu_num;
rtems_id id;
rtems_status_code status;
@@ -49,8 +49,8 @@ rtems_task Init(
);
directive_failed( status, "task create" );
- cpu_num = bsp_smp_processor_id();
- locked_printf(" CPU %d start task TA%c\n", cpu_num, ch);
+ cpu_num = rtems_smp_get_current_processor();
+ locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
status = rtems_task_start( id, Test_task, i+1 );
directive_failed( status, "task start" );
diff --git a/testsuites/smptests/smp06/init.c b/testsuites/smptests/smp06/init.c
index 170479b..ae3ca76 100644
--- a/testsuites/smptests/smp06/init.c
+++ b/testsuites/smptests/smp06/init.c
@@ -20,15 +20,15 @@ rtems_task Test_task(
rtems_task_argument do_exit
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
p = rtems_object_get_name( RTEMS_SELF, 5, name );
rtems_test_assert( p != NULL );
- cpu_num = bsp_smp_processor_id();
- locked_printf(" CPU %d running Task %s\n", cpu_num, name);
+ cpu_num = rtems_smp_get_current_processor();
+ locked_printf(" CPU %" PRIu32 " running Task %s\n", cpu_num, name);
Ran = true;
@@ -44,7 +44,7 @@ rtems_task Init(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
rtems_id id;
rtems_status_code status;
@@ -56,7 +56,7 @@ rtems_task Init(
rtems_test_assert( rtems_smp_get_processor_count() > 1 );
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/*
* Create a task at equal priority.
@@ -72,7 +72,7 @@ rtems_task Init(
);
directive_failed( status, "task create" );
- locked_printf(" CPU %d start task TA1\n", cpu_num );
+ locked_printf(" CPU %" PRIu32 " start task TA1\n", cpu_num );
status = rtems_task_start( id, Test_task, 0 );
directive_failed( status, "task start" );
@@ -94,8 +94,8 @@ rtems_task Init(
);
directive_failed( status, "task create" );
- cpu_num = bsp_smp_processor_id();
- locked_printf(" CPU %d start task TA2\n", cpu_num );
+ cpu_num = rtems_smp_get_current_processor();
+ locked_printf(" CPU %" PRIu32 " start task TA2\n", cpu_num );
status = rtems_task_start( id, Test_task, 1 );
directive_failed( status, "task start" );
diff --git a/testsuites/smptests/smp07/init.c b/testsuites/smptests/smp07/init.c
index 04bf4f2..f631554 100644
--- a/testsuites/smptests/smp07/init.c
+++ b/testsuites/smptests/smp07/init.c
@@ -22,7 +22,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
rtems_status_code sc;
char name[5];
char *p;
@@ -32,10 +32,10 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
- locked_printf(" CPU %d runnng Task %s and blocking\n", cpu_num, name);
+ locked_printf(" CPU %" PRIu32 " runnng Task %s and blocking\n", cpu_num, name);
sc = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
directive_failed( sc,"obtain in test task");
@@ -47,7 +47,7 @@ rtems_task Test_task(
/* Print that the task is up and running. */
locked_printf(
- " CPU %d running Task %s after semaphore release\n",
+ " CPU %" PRIu32 " running Task %s after semaphore release\n",
cpu_num,
name
);
@@ -110,7 +110,7 @@ rtems_task Init(
);
directive_failed( status, "task create" );
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
locked_printf(" CPU %d start task TA1\n", cpu_num );
status = rtems_task_start( id, Test_task, 1 );
directive_failed( status, "task start" );
diff --git a/testsuites/smptests/smp08/init.c b/testsuites/smptests/smp08/init.c
index e1e2e3a..76c4481 100644
--- a/testsuites/smptests/smp08/init.c
+++ b/testsuites/smptests/smp08/init.c
@@ -19,13 +19,13 @@ void PrintTaskInfo(
rtems_time_of_day *_tb
)
{
- int cpu_num;
+ uint32_t cpu_num;
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print the cpu number and task name */
locked_printf(
- " CPU %d running task %s - rtems_clock_get_tod "
+ " CPU %" PRIu32 " running task %s - rtems_clock_get_tod "
"%02" PRId32 ":%02" PRId32 ":%02" PRId32 " %02" PRId32
"/%02" PRId32 "/%04" PRId32 "\n",
cpu_num,
diff --git a/testsuites/smptests/smp08/tasks.c b/testsuites/smptests/smp08/tasks.c
index b2effa3..957e0b1 100644
--- a/testsuites/smptests/smp08/tasks.c
+++ b/testsuites/smptests/smp08/tasks.c
@@ -21,7 +21,7 @@ rtems_task Test_task(
rtems_time_of_day time;
uint32_t task_index;
rtems_status_code status;
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -34,7 +34,7 @@ rtems_task Test_task(
for ( ; ; ) {
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
status = rtems_clock_get_tod( &time );
if ( time.second >= 35 && 0 ) {
diff --git a/testsuites/smptests/smp09/init.c b/testsuites/smptests/smp09/init.c
index 976cb35..e21ef68 100644
--- a/testsuites/smptests/smp09/init.c
+++ b/testsuites/smptests/smp09/init.c
@@ -30,9 +30,9 @@ rtems_task Init(
rtems_task_argument argument
)
{
- int i;
+ uint32_t i;
char ch;
- int cpu_num;
+ uint32_t cpu_num;
rtems_id id;
rtems_status_code status;
@@ -55,8 +55,8 @@ rtems_task Init(
);
directive_failed( status, "task create" );
- cpu_num = bsp_smp_processor_id();
- locked_printf(" CPU %d start task TA%c\n", cpu_num, ch);
+ cpu_num = rtems_smp_get_current_processor();
+ locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
status = rtems_task_start( id, Test_task, i+1 );
directive_failed( status, "task start" );
diff --git a/testsuites/smptests/smpatomic01/tasks.c b/testsuites/smptests/smpatomic01/tasks.c
index 36bb431..8ffa6b6 100644
--- a/testsuites/smptests/smpatomic01/tasks.c
+++ b/testsuites/smptests/smpatomic01/tasks.c
@@ -38,7 +38,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -47,7 +47,7 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
/* test relaxed barrier */
diff --git a/testsuites/smptests/smpatomic02/tasks.c b/testsuites/smptests/smpatomic02/tasks.c
index a85f58c..da72fb4 100644
--- a/testsuites/smptests/smpatomic02/tasks.c
+++ b/testsuites/smptests/smpatomic02/tasks.c
@@ -38,7 +38,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -47,7 +47,7 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
/* test relaxed barrier */
diff --git a/testsuites/smptests/smpatomic03/tasks.c b/testsuites/smptests/smpatomic03/tasks.c
index fdf81ab..98b30c7 100644
--- a/testsuites/smptests/smpatomic03/tasks.c
+++ b/testsuites/smptests/smpatomic03/tasks.c
@@ -38,7 +38,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -47,7 +47,7 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
/* test relaxed barrier */
diff --git a/testsuites/smptests/smpatomic04/tasks.c b/testsuites/smptests/smpatomic04/tasks.c
index 006c80e..149e669 100644
--- a/testsuites/smptests/smpatomic04/tasks.c
+++ b/testsuites/smptests/smpatomic04/tasks.c
@@ -38,7 +38,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -47,7 +47,7 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
/* test relaxed barrier */
diff --git a/testsuites/smptests/smpatomic05/tasks.c b/testsuites/smptests/smpatomic05/tasks.c
index 0061c82..7f58cec 100644
--- a/testsuites/smptests/smpatomic05/tasks.c
+++ b/testsuites/smptests/smpatomic05/tasks.c
@@ -38,7 +38,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -47,7 +47,7 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
/* test relaxed barrier */
diff --git a/testsuites/smptests/smpatomic06/tasks.c b/testsuites/smptests/smpatomic06/tasks.c
index ec29b28..826cc89 100644
--- a/testsuites/smptests/smpatomic06/tasks.c
+++ b/testsuites/smptests/smpatomic06/tasks.c
@@ -38,7 +38,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -47,7 +47,7 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
/* test relaxed barrier */
diff --git a/testsuites/smptests/smpatomic07/tasks.c b/testsuites/smptests/smpatomic07/tasks.c
index 88c69be..c0dd4ca 100644
--- a/testsuites/smptests/smpatomic07/tasks.c
+++ b/testsuites/smptests/smpatomic07/tasks.c
@@ -53,7 +53,7 @@ rtems_task Test_task(
rtems_task_argument argument
)
{
- int cpu_num;
+ uint32_t cpu_num;
char name[5];
char *p;
@@ -62,7 +62,7 @@ rtems_task Test_task(
rtems_test_assert( p != NULL );
/* Get the CPU Number */
- cpu_num = bsp_smp_processor_id();
+ cpu_num = rtems_smp_get_current_processor();
/* Print that the task is up and running. */
/* test relaxed barrier */
diff --git a/testsuites/smptests/smplock01/init.c b/testsuites/smptests/smplock01/init.c
index 2fcc507..ed578cb 100644
--- a/testsuites/smptests/smplock01/init.c
+++ b/testsuites/smptests/smplock01/init.c
@@ -298,8 +298,8 @@ static void run_tests(
static void task(rtems_task_argument arg)
{
global_context *ctx = (global_context *) arg;
- int cpu_count = (int) rtems_smp_get_processor_count();
- int cpu_self = rtems_smp_get_current_processor();
+ uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_self = rtems_smp_get_current_processor();
rtems_status_code sc;
barrier_state bs = BARRIER_STATE_INITIALIZER;
@@ -312,9 +312,9 @@ static void task(rtems_task_argument arg)
static void test(void)
{
global_context *ctx = &context;
- int cpu_count = (int) rtems_smp_get_processor_count();
- int cpu_self = rtems_smp_get_current_processor();
- int cpu;
+ uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_self = rtems_smp_get_current_processor();
+ uint32_t cpu;
int test;
rtems_status_code sc;
barrier_state bs = BARRIER_STATE_INITIALIZER;
@@ -356,7 +356,7 @@ static void test(void)
sum += local_counter;
printf(
- "\tprocessor %i, local counter %lu\n",
+ "\tprocessor %" PRIu32 ", local counter %lu\n",
cpu,
local_counter
);
--
1.7.7
More information about the devel
mailing list