From cb5eaddf95d348c1c74aad3997fe012af5e7b02f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 10 Apr 2014 11:02:52 +0200 Subject: rtems: Rename rtems_smp_get_current_processor() Rename rtems_smp_get_current_processor() in rtems_get_current_processor(). Make rtems_get_current_processor() a function in uni-processor configurations to enable ABI compatibility with SMP configurations. --- .../libbsp/arm/altera-cyclone-v/startup/bspreset.c | 2 +- c/src/lib/libbsp/sparc/leon3/startup/bspreset.c | 2 +- cpukit/rtems/Makefile.am | 1 + cpukit/rtems/include/rtems/rtems/smp.h | 10 ++++----- cpukit/rtems/src/getcurrentprocessor.c | 25 ++++++++++++++++++++++ cpukit/sapi/src/testextension.c | 2 +- testsuites/smptests/smp01/init.c | 2 +- testsuites/smptests/smp01/tasks.c | 2 +- testsuites/smptests/smp02/init.c | 2 +- testsuites/smptests/smp02/tasks.c | 2 +- testsuites/smptests/smp03/init.c | 2 +- testsuites/smptests/smp05/init.c | 4 ++-- testsuites/smptests/smp07/init.c | 4 ++-- testsuites/smptests/smp08/init.c | 2 +- testsuites/smptests/smp08/tasks.c | 2 +- testsuites/smptests/smp09/init.c | 2 +- testsuites/smptests/smpfatal01/init.c | 4 ++-- testsuites/smptests/smpfatal02/init.c | 4 ++-- testsuites/smptests/smpfatal03/init.c | 4 ++-- testsuites/smptests/smplock01/init.c | 4 ++-- testsuites/smptests/smpmigration01/init.c | 2 +- testsuites/smptests/smppsxsignal01/init.c | 8 +++---- testsuites/smptests/smpsignal01/init.c | 8 +++---- 23 files changed, 62 insertions(+), 38 deletions(-) create mode 100644 cpukit/rtems/src/getcurrentprocessor.c diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspreset.c b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspreset.c index 9cf21a9734..3b7f10a822 100644 --- a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspreset.c +++ b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspreset.c @@ -19,7 +19,7 @@ void bsp_reset(void) { - uint32_t self_cpu = rtems_smp_get_current_processor(); + uint32_t self_cpu = rtems_get_current_processor(); volatile uint32_t *mpumodrst = ALT_RSTMGR_MPUMODRST_ADDR; if( self_cpu == 0 ) { diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c b/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c index c3c9e988cf..c642a75623 100644 --- a/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c +++ b/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c @@ -20,7 +20,7 @@ void bsp_reset(void) { - uint32_t self_cpu = rtems_smp_get_current_processor(); + uint32_t self_cpu = rtems_get_current_processor(); if (self_cpu == 0) { volatile struct irqmp_regs *irqmp = LEON3_IrqCtrl_Regs; diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index 4e6438c780..a279ed7ac2 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -259,6 +259,7 @@ librtems_a_SOURCES += src/modes.c librtems_a_SOURCES += src/status.c librtems_a_SOURCES += src/statustext.c +librtems_a_SOURCES += src/getcurrentprocessor.c librtems_a_SOURCES += src/getprocessorcount.c if HAS_MP diff --git a/cpukit/rtems/include/rtems/rtems/smp.h b/cpukit/rtems/include/rtems/rtems/smp.h index b327514c09..fa4d5d6e75 100644 --- a/cpukit/rtems/include/rtems/rtems/smp.h +++ b/cpukit/rtems/include/rtems/rtems/smp.h @@ -18,12 +18,12 @@ #ifndef _RTEMS_RTEMS_SMP_H #define _RTEMS_RTEMS_SMP_H +#include + #ifdef __cplusplus extern "C" { #endif -#include - /** * @defgroup ClassicSMP SMP Services * @@ -55,8 +55,7 @@ uint32_t rtems_get_processor_count(void); /** * @brief Returns the index of the current processor. * - * On uni-processor configurations this is a compile time constant and defined - * to be zero. + * On uni-processor configurations a value of zero will be returned. * * 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 @@ -70,8 +69,7 @@ uint32_t rtems_get_processor_count(void); * * @return The index of the current processor. */ -#define rtems_smp_get_current_processor() \ - _SMP_Get_current_processor() +uint32_t rtems_get_current_processor(void); /** @} */ diff --git a/cpukit/rtems/src/getcurrentprocessor.c b/cpukit/rtems/src/getcurrentprocessor.c new file mode 100644 index 0000000000..5fc48b9426 --- /dev/null +++ b/cpukit/rtems/src/getcurrentprocessor.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include +#include + +uint32_t rtems_get_current_processor(void) +{ + return _SMP_Get_current_processor(); +} diff --git a/cpukit/sapi/src/testextension.c b/cpukit/sapi/src/testextension.c index 76ac1e09bb..e21872a963 100644 --- a/cpukit/sapi/src/testextension.c +++ b/cpukit/sapi/src/testextension.c @@ -29,7 +29,7 @@ void rtems_test_fatal_extension( (void) is_internal; (void) code; - if (rtems_smp_get_current_processor() == 0) { + if (rtems_get_current_processor() == 0) { rtems_profiling_report_xml( rtems_test_name, printk_plugin, diff --git a/testsuites/smptests/smp01/init.c b/testsuites/smptests/smp01/init.c index 8439293d95..c77a192071 100644 --- a/testsuites/smptests/smp01/init.c +++ b/testsuites/smptests/smp01/init.c @@ -35,7 +35,7 @@ rtems_task Init( rtems_status_code status; bool allDone; - cpu_self = rtems_smp_get_current_processor(); + cpu_self = rtems_get_current_processor(); /* XXX - Delay a bit to allow debug messages from * startup to print. This may need to go away when diff --git a/testsuites/smptests/smp01/tasks.c b/testsuites/smptests/smp01/tasks.c index 12a74188e9..b8c766f1c8 100644 --- a/testsuites/smptests/smp01/tasks.c +++ b/testsuites/smptests/smp01/tasks.c @@ -28,7 +28,7 @@ rtems_task Test_task( rtems_test_assert( p != NULL ); /* Get the CPU Number */ - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); /* Print that the task is up and running. */ Loop(); diff --git a/testsuites/smptests/smp02/init.c b/testsuites/smptests/smp02/init.c index 05f6351b3a..e70eca3182 100644 --- a/testsuites/smptests/smp02/init.c +++ b/testsuites/smptests/smp02/init.c @@ -73,7 +73,7 @@ rtems_task Init( &id ); - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_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/tasks.c b/testsuites/smptests/smp02/tasks.c index 595954ee01..26ca851cc8 100644 --- a/testsuites/smptests/smp02/tasks.c +++ b/testsuites/smptests/smp02/tasks.c @@ -40,7 +40,7 @@ rtems_task Test_task( uint32_t cpu_num; rtems_status_code sc; - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); do { diff --git a/testsuites/smptests/smp03/init.c b/testsuites/smptests/smp03/init.c index 3acdfe981d..4b443d07fa 100644 --- a/testsuites/smptests/smp03/init.c +++ b/testsuites/smptests/smp03/init.c @@ -37,7 +37,7 @@ void PrintTaskInfo( { uint32_t cpu_num; - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); locked_printf(" CPU %" PRIu32 " running task %s\n", cpu_num, task_name ); } diff --git a/testsuites/smptests/smp05/init.c b/testsuites/smptests/smp05/init.c index cf7ea3a10a..33d958f25a 100644 --- a/testsuites/smptests/smp05/init.c +++ b/testsuites/smptests/smp05/init.c @@ -26,7 +26,7 @@ rtems_task Test_task( rtems_task_argument argument ) { - locked_printf( "Shut down from CPU %" PRIu32 "\n", rtems_smp_get_current_processor() ); + locked_printf( "Shut down from CPU %" PRIu32 "\n", rtems_get_current_processor() ); success(); } @@ -61,7 +61,7 @@ rtems_task Init( ); directive_failed( status, "task create" ); - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch); status = rtems_task_start( id, Test_task, i+1 ); diff --git a/testsuites/smptests/smp07/init.c b/testsuites/smptests/smp07/init.c index 53993ce9c0..7e3f6f521f 100644 --- a/testsuites/smptests/smp07/init.c +++ b/testsuites/smptests/smp07/init.c @@ -40,7 +40,7 @@ rtems_task Test_task( rtems_test_assert( p != NULL ); /* Get the CPU Number */ - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); /* Print that the task is up and running. */ locked_printf(" CPU %" PRIu32 " runnng Task %s and blocking\n", cpu_num, name); @@ -124,7 +124,7 @@ rtems_task Init( ); directive_failed( status, "task create" ); - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_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 d759c13165..d35f5186fb 100644 --- a/testsuites/smptests/smp08/init.c +++ b/testsuites/smptests/smp08/init.c @@ -23,7 +23,7 @@ void PrintTaskInfo( { uint32_t cpu_num; - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); /* Print the cpu number and task name */ locked_printf( diff --git a/testsuites/smptests/smp08/tasks.c b/testsuites/smptests/smp08/tasks.c index d9ddb327ee..deda4bfe63 100644 --- a/testsuites/smptests/smp08/tasks.c +++ b/testsuites/smptests/smp08/tasks.c @@ -34,7 +34,7 @@ rtems_task Test_task( for ( ; ; ) { /* Get the CPU Number */ - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); status = rtems_clock_get_tod( &time ); if ( time.second >= 35 ) { diff --git a/testsuites/smptests/smp09/init.c b/testsuites/smptests/smp09/init.c index 09e9c09297..8cf019ce80 100644 --- a/testsuites/smptests/smp09/init.c +++ b/testsuites/smptests/smp09/init.c @@ -58,7 +58,7 @@ rtems_task Init( ); directive_failed( status, "task create" ); - cpu_num = rtems_smp_get_current_processor(); + cpu_num = rtems_get_current_processor(); locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch); status = rtems_task_start( id, Test_task, i+1 ); diff --git a/testsuites/smptests/smpfatal01/init.c b/testsuites/smptests/smpfatal01/init.c index 178148b123..5ef9ffe41a 100644 --- a/testsuites/smptests/smpfatal01/init.c +++ b/testsuites/smptests/smpfatal01/init.c @@ -42,7 +42,7 @@ static void fatal_extension( ) { if (source == RTEMS_FATAL_SOURCE_SMP) { - uint32_t self = rtems_smp_get_current_processor(); + uint32_t self = rtems_get_current_processor(); assert(!is_internal); assert(code == SMP_FATAL_SHUTDOWN); @@ -68,7 +68,7 @@ static rtems_status_code test_driver_init( void *arg ) { - uint32_t self = rtems_smp_get_current_processor(); + uint32_t self = rtems_get_current_processor(); uint32_t cpu_count = rtems_get_processor_count(); uint32_t cpu; diff --git a/testsuites/smptests/smpfatal02/init.c b/testsuites/smptests/smpfatal02/init.c index fb42e5d411..266251f600 100644 --- a/testsuites/smptests/smpfatal02/init.c +++ b/testsuites/smptests/smpfatal02/init.c @@ -45,7 +45,7 @@ static void fatal_extension( source == RTEMS_FATAL_SOURCE_APPLICATION || source == RTEMS_FATAL_SOURCE_SMP ) { - uint32_t self = rtems_smp_get_current_processor(); + uint32_t self = rtems_get_current_processor(); assert(!is_internal); @@ -76,7 +76,7 @@ static rtems_status_code test_driver_init( void *arg ) { - uint32_t self = rtems_smp_get_current_processor(); + uint32_t self = rtems_get_current_processor(); uint32_t cpu_count = rtems_get_processor_count(); uint32_t cpu; diff --git a/testsuites/smptests/smpfatal03/init.c b/testsuites/smptests/smpfatal03/init.c index 13a9db511a..2ef17f06e9 100644 --- a/testsuites/smptests/smpfatal03/init.c +++ b/testsuites/smptests/smpfatal03/init.c @@ -67,7 +67,7 @@ static void wait_for_giant(void) static void Init(rtems_task_argument arg) { - uint32_t self = rtems_smp_get_current_processor(); + uint32_t self = rtems_get_current_processor(); uint32_t cpu_count = rtems_get_processor_count(); rtems_test_begink(); @@ -108,7 +108,7 @@ static void fatal_extension( source == RTEMS_FATAL_SOURCE_APPLICATION || source == RTEMS_FATAL_SOURCE_SMP ) { - uint32_t self = rtems_smp_get_current_processor(); + uint32_t self = rtems_get_current_processor(); SMP_barrier_State state = SMP_BARRIER_STATE_INITIALIZER; assert(!is_internal); diff --git a/testsuites/smptests/smplock01/init.c b/testsuites/smptests/smplock01/init.c index 85995e8e99..8cc10fac6e 100644 --- a/testsuites/smptests/smplock01/init.c +++ b/testsuites/smptests/smplock01/init.c @@ -260,7 +260,7 @@ static void task(rtems_task_argument arg) { global_context *ctx = (global_context *) arg; uint32_t cpu_count = rtems_get_processor_count(); - uint32_t cpu_self = rtems_smp_get_current_processor(); + uint32_t cpu_self = rtems_get_current_processor(); rtems_status_code sc; SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER; @@ -274,7 +274,7 @@ static void test(void) { global_context *ctx = &context; uint32_t cpu_count = rtems_get_processor_count(); - uint32_t cpu_self = rtems_smp_get_current_processor(); + uint32_t cpu_self = rtems_get_current_processor(); uint32_t cpu; int test; rtems_status_code sc; diff --git a/testsuites/smptests/smpmigration01/init.c b/testsuites/smptests/smpmigration01/init.c index fe321c8787..78d671d775 100644 --- a/testsuites/smptests/smpmigration01/init.c +++ b/testsuites/smptests/smpmigration01/init.c @@ -73,7 +73,7 @@ static void runner(rtems_task_argument self) test_counters *next_counters = &ctx->counters[next]; while (true) { - uint32_t current_cpu = rtems_smp_get_current_processor(); + uint32_t current_cpu = rtems_get_current_processor(); ++counters->cycles_per_cpu[current_cpu].counter; diff --git a/testsuites/smptests/smppsxsignal01/init.c b/testsuites/smptests/smppsxsignal01/init.c index 61eaec1667..b954cbdf08 100644 --- a/testsuites/smptests/smppsxsignal01/init.c +++ b/testsuites/smptests/smppsxsignal01/init.c @@ -82,14 +82,14 @@ static void signal_send(test_context *ctx, test_state new_state) static void check_consumer_processor(const test_context *ctx) { rtems_test_assert( - ctx->consumer_processor == rtems_smp_get_current_processor() + ctx->consumer_processor == rtems_get_current_processor() ); } static void check_producer_processor(const test_context *ctx) { rtems_test_assert( - ctx->producer_processor == rtems_smp_get_current_processor() + ctx->producer_processor == rtems_get_current_processor() ); } @@ -97,7 +97,7 @@ static void *producer(void *arg) { test_context *ctx = arg; - ctx->producer_processor = rtems_smp_get_current_processor(); + ctx->producer_processor = rtems_get_current_processor(); rtems_test_assert(ctx->consumer_processor != ctx->producer_processor); @@ -120,7 +120,7 @@ static void test(void) void *producer_status; ctx->consumer = pthread_self(); - ctx->consumer_processor = rtems_smp_get_current_processor(); + ctx->consumer_processor = rtems_get_current_processor(); memset(&new_action, 0, sizeof(new_action)); new_action.sa_handler = signal_handler; diff --git a/testsuites/smptests/smpsignal01/init.c b/testsuites/smptests/smpsignal01/init.c index 1aaa70090a..af524bf9b1 100644 --- a/testsuites/smptests/smpsignal01/init.c +++ b/testsuites/smptests/smpsignal01/init.c @@ -86,14 +86,14 @@ static void signal_send(test_context *ctx, test_state new_state) static void check_consumer_processor(const test_context *ctx) { rtems_test_assert( - ctx->consumer_processor == rtems_smp_get_current_processor() + ctx->consumer_processor == rtems_get_current_processor() ); } static void check_producer_processor(const test_context *ctx) { rtems_test_assert( - ctx->producer_processor == rtems_smp_get_current_processor() + ctx->producer_processor == rtems_get_current_processor() ); } @@ -101,7 +101,7 @@ static void producer(rtems_task_argument arg) { test_context *ctx = (test_context *) arg; - ctx->producer_processor = rtems_smp_get_current_processor(); + ctx->producer_processor = rtems_get_current_processor(); rtems_test_assert(ctx->consumer_processor != ctx->producer_processor); @@ -126,7 +126,7 @@ static void test(void) rtems_mode mode; ctx->consumer = rtems_task_self(); - ctx->consumer_processor = rtems_smp_get_current_processor(); + ctx->consumer_processor = rtems_get_current_processor(); sc = rtems_signal_catch(signal_handler, RTEMS_DEFAULT_MODES); rtems_test_assert(sc == RTEMS_SUCCESSFUL); -- cgit v1.2.3