rtems: Rename rtems_smp_get_processor_count()

Rename rtems_smp_get_processor_count() in rtems_get_processor_count().
Make rtems_get_processor_count() a function in uni-processor
configurations to enable ABI compatibility with SMP configurations.
This commit is contained in:
Sebastian Huber
2014-04-10 10:58:27 +02:00
parent 263f4becea
commit 4bc8d2e717
29 changed files with 66 additions and 41 deletions

View File

@@ -32,7 +32,7 @@ void bsp_reset(void)
*/ */
uint32_t max_wait = 1234567; uint32_t max_wait = 1234567;
uint32_t cpu_count = rtems_smp_get_processor_count(); uint32_t cpu_count = rtems_get_processor_count();
uint32_t halt_mask = 0; uint32_t halt_mask = 0;
uint32_t i; uint32_t i;

View File

@@ -45,7 +45,7 @@ void rtems_cpu_usage_reset( void )
_TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset ); _TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
processor_count = rtems_smp_get_processor_count(); processor_count = rtems_get_processor_count();
for ( processor = 0 ; processor < processor_count ; ++processor ) { for ( processor = 0 ; processor < processor_count ; ++processor ) {
Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( processor ); Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( processor );

View File

@@ -259,6 +259,8 @@ librtems_a_SOURCES += src/modes.c
librtems_a_SOURCES += src/status.c librtems_a_SOURCES += src/status.c
librtems_a_SOURCES += src/statustext.c librtems_a_SOURCES += src/statustext.c
librtems_a_SOURCES += src/getprocessorcount.c
if HAS_MP if HAS_MP
# We only build multiprocessing related files if HAS_MP was defined # We only build multiprocessing related files if HAS_MP was defined
librtems_a_SOURCES += src/eventmp.c librtems_a_SOURCES += src/eventmp.c

View File

@@ -40,8 +40,7 @@ extern "C" {
/** /**
* @brief Returns the count of processors in the system. * @brief Returns the count of processors in the system.
* *
* On uni-processor configurations this is a compile time constant and defined * On uni-processor configurations a value of one will be returned.
* to be one.
* *
* On SMP configurations this returns the value of a global variable set during * On SMP configurations this returns the value of a global variable set during
* system initialization to indicate the count of processors. The processor * system initialization to indicate the count of processors. The processor
@@ -51,8 +50,7 @@ extern "C" {
* *
* @return The count of processors in the system. * @return The count of processors in the system.
*/ */
#define rtems_smp_get_processor_count() \ uint32_t rtems_get_processor_count(void);
_SMP_Get_processor_count()
/** /**
* @brief Returns the index of the current processor. * @brief Returns the index of the current processor.

View File

@@ -0,0 +1,25 @@
/*
* Copyright (c) 2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
* 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.org/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/rtems/smp.h>
#include <rtems/score/smp.h>
uint32_t rtems_get_processor_count(void)
{
return _SMP_Get_processor_count();
}

View File

@@ -30,7 +30,7 @@ static void per_cpu_stats_iterate(
) )
{ {
#ifdef RTEMS_PROFILING #ifdef RTEMS_PROFILING
uint32_t n = rtems_smp_get_processor_count(); uint32_t n = rtems_get_processor_count();
uint32_t i; uint32_t i;
memset(data, 0, sizeof(*data)); memset(data, 0, sizeof(*data));

View File

@@ -48,12 +48,12 @@ rtems_task Init(
locked_print_initialize(); locked_print_initialize();
/* Initialize the TaskRan array */ /* Initialize the TaskRan array */
for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) { for ( i=0; i<rtems_get_processor_count() ; i++ ) {
TaskRan[i] = false; TaskRan[i] = false;
} }
/* Create and start tasks for each processor */ /* Create and start tasks for each processor */
for ( i=0; i< rtems_smp_get_processor_count() ; i++ ) { for ( i=0; i< rtems_get_processor_count() ; i++ ) {
if ( i != cpu_self ) { if ( i != cpu_self ) {
ch = '0' + i; ch = '0' + i;
@@ -78,7 +78,7 @@ rtems_task Init(
/* Wait on the all tasks to run */ /* Wait on the all tasks to run */
while (1) { while (1) {
allDone = true; allDone = true;
for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) { for ( i=0; i<rtems_get_processor_count() ; i++ ) {
if ( i != cpu_self && TaskRan[i] == false) if ( i != cpu_self && TaskRan[i] == false)
allDone = false; allDone = false;
} }

View File

@@ -40,7 +40,7 @@ rtems_task Init(
locked_print_initialize(); locked_print_initialize();
if ( rtems_smp_get_processor_count() == 1 ) { if ( rtems_get_processor_count() == 1 ) {
success(); success();
} }
@@ -59,7 +59,7 @@ rtems_task Init(
status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0); status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
directive_failed( status,"rtems_semaphore_obtain of SEM1\n"); directive_failed( status,"rtems_semaphore_obtain of SEM1\n");
for ( i=1; i < rtems_smp_get_processor_count(); i++ ){ for ( i=1; i < rtems_get_processor_count(); i++ ){
/* Create and start tasks for each CPU */ /* Create and start tasks for each CPU */
ch = '0' + i; ch = '0' + i;

View File

@@ -57,13 +57,13 @@ rtems_task Init(
locked_print_initialize(); locked_print_initialize();
if ( rtems_smp_get_processor_count() == 1 ) { if ( rtems_get_processor_count() == 1 ) {
success(); success();
} }
/* Initialize the TaskRan array */ /* Initialize the TaskRan array */
TaskRan[0] = true; TaskRan[0] = true;
for ( i=1; i<rtems_smp_get_processor_count() ; i++ ) { for ( i=1; i<rtems_get_processor_count() ; i++ ) {
TaskRan[i] = false; TaskRan[i] = false;
} }
@@ -71,7 +71,7 @@ rtems_task Init(
PrintTaskInfo( "Init" ); PrintTaskInfo( "Init" );
/* for each remaining cpu create and start a task */ /* for each remaining cpu create and start a task */
for ( i=1; i < rtems_smp_get_processor_count(); i++ ){ for ( i=1; i < rtems_get_processor_count(); i++ ){
ch = '0' + i; ch = '0' + i;
@@ -101,12 +101,12 @@ rtems_task Init(
RTEMS_DEFAULT_ATTRIBUTES, RTEMS_DEFAULT_ATTRIBUTES,
&id &id
); );
status = rtems_task_start(id,Test_task,rtems_smp_get_processor_count()); status = rtems_task_start(id,Test_task,rtems_get_processor_count());
/* Wait on all tasks to run */ /* Wait on all tasks to run */
while (1) { while (1) {
TestFinished = true; TestFinished = true;
for ( i=1; i < (rtems_smp_get_processor_count()+1) ; i++ ) { for ( i=1; i < (rtems_get_processor_count()+1) ; i++ ) {
if (TaskRan[i] == false) if (TaskRan[i] == false)
TestFinished = false; TestFinished = false;
} }

View File

@@ -44,11 +44,11 @@ rtems_task Init(
locked_print_initialize(); locked_print_initialize();
if ( rtems_smp_get_processor_count() == 1 ) { if ( rtems_get_processor_count() == 1 ) {
success(); success();
} }
for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) { for ( i=0; i<rtems_get_processor_count() ; i++ ) {
ch = '1' + i; ch = '1' + i;
status = rtems_task_create( status = rtems_task_create(

View File

@@ -93,7 +93,7 @@ rtems_task Init(
locked_print_initialize(); locked_print_initialize();
if ( rtems_smp_get_processor_count() == 1 ) { if ( rtems_get_processor_count() == 1 ) {
success(); success();
} }

View File

@@ -76,7 +76,7 @@ rtems_task Init(
/* Show that the init task is running on this cpu */ /* Show that the init task is running on this cpu */
PrintTaskInfo( "Init", &time ); PrintTaskInfo( "Init", &time );
for ( i=1; i <= rtems_smp_get_processor_count() *3; i++ ) { for ( i=1; i <= rtems_get_processor_count() *3; i++ ) {
sprintf(ch, "%02" PRId32, i ); sprintf(ch, "%02" PRId32, i );
status = rtems_task_create( status = rtems_task_create(

View File

@@ -45,7 +45,7 @@ rtems_task Init(
for ( killtime=0; killtime<1000000; killtime++ ) for ( killtime=0; killtime<1000000; killtime++ )
; ;
for ( i=0; i<rtems_smp_get_processor_count() -1; i++ ) { for ( i=0; i<rtems_get_processor_count() -1; i++ ) {
ch = '1' + i; ch = '1' + i;
status = rtems_task_create( status = rtems_task_create(

View File

@@ -112,7 +112,7 @@ void Validate_affinity(void )
directive_failed( sc, "Get Affinity of Init Task" ); directive_failed( sc, "Get Affinity of Init Task" );
/* Get the number of processors that we are using. */ /* Get the number of processors that we are using. */
cpu_count = rtems_smp_get_processor_count(); cpu_count = rtems_get_processor_count();
/* Fill the remaining cpus with med priority tasks */ /* Fill the remaining cpus with med priority tasks */
puts( "Init - Create Medium priority tasks"); puts( "Init - Create Medium priority tasks");

View File

@@ -446,7 +446,7 @@ static void test(void)
test_static_and_dynamic_initialization(); test_static_and_dynamic_initialization();
ctx->worker_count = rtems_smp_get_processor_count(); ctx->worker_count = rtems_get_processor_count();
sc = rtems_timer_create( sc = rtems_timer_create(
rtems_build_name('S', 'T', 'O', 'P'), rtems_build_name('S', 'T', 'O', 'P'),

View File

@@ -69,7 +69,7 @@ static rtems_status_code test_driver_init(
) )
{ {
uint32_t self = rtems_smp_get_current_processor(); uint32_t self = rtems_smp_get_current_processor();
uint32_t cpu_count = rtems_smp_get_processor_count(); uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu; uint32_t cpu;
rtems_test_begink(); rtems_test_begink();

View File

@@ -77,7 +77,7 @@ static rtems_status_code test_driver_init(
) )
{ {
uint32_t self = rtems_smp_get_current_processor(); uint32_t self = rtems_smp_get_current_processor();
uint32_t cpu_count = rtems_smp_get_processor_count(); uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu; uint32_t cpu;
rtems_test_begink(); rtems_test_begink();

View File

@@ -68,7 +68,7 @@ static void wait_for_giant(void)
static void Init(rtems_task_argument arg) static void Init(rtems_task_argument arg)
{ {
uint32_t self = rtems_smp_get_current_processor(); uint32_t self = rtems_smp_get_current_processor();
uint32_t cpu_count = rtems_smp_get_processor_count(); uint32_t cpu_count = rtems_get_processor_count();
rtems_test_begink(); rtems_test_begink();

View File

@@ -81,7 +81,7 @@ static void inherit_obtain_task(rtems_task_argument arg)
test_context *ctx = &test_instance; test_context *ctx = &test_instance;
rtems_status_code sc; rtems_status_code sc;
SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER; SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER;
uint32_t cpu_count = rtems_smp_get_processor_count(); uint32_t cpu_count = rtems_get_processor_count();
rtems_counter_ticks delay = (cpu_count - 1 - arg) * ctx->inherit_obtain_delay; rtems_counter_ticks delay = (cpu_count - 1 - arg) * ctx->inherit_obtain_delay;
while (true) { while (true) {
@@ -338,7 +338,7 @@ static void test(void)
sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT); sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
rtems_test_assert(sc == RTEMS_SUCCESSFUL); rtems_test_assert(sc == RTEMS_SUCCESSFUL);
for (i = 0; i < rtems_smp_get_processor_count(); ++i) { for (i = 0; i < rtems_get_processor_count(); ++i) {
sc = rtems_task_create( sc = rtems_task_create(
rtems_build_name('I', 'N', 'H', 'O'), rtems_build_name('I', 'N', 'H', 'O'),
INHERIT_OBTAIN_PRIO_BASE + i, INHERIT_OBTAIN_PRIO_BASE + i,
@@ -373,7 +373,7 @@ static void test(void)
ctx->inherit_release_counter ctx->inherit_release_counter
); );
for (i = 0; i < rtems_smp_get_processor_count(); ++i) { for (i = 0; i < rtems_get_processor_count(); ++i) {
printf( printf(
"priority inheritance obtain count %2" PRIu32 ": %" PRIu64 "\n", "priority inheritance obtain count %2" PRIu32 ": %" PRIu64 "\n",
i, i,

View File

@@ -259,7 +259,7 @@ static void run_tests(
static void task(rtems_task_argument arg) static void task(rtems_task_argument arg)
{ {
global_context *ctx = (global_context *) arg; global_context *ctx = (global_context *) arg;
uint32_t cpu_count = rtems_smp_get_processor_count(); uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu_self = rtems_smp_get_current_processor(); uint32_t cpu_self = rtems_smp_get_current_processor();
rtems_status_code sc; rtems_status_code sc;
SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER; SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER;
@@ -273,7 +273,7 @@ static void task(rtems_task_argument arg)
static void test(void) static void test(void)
{ {
global_context *ctx = &context; global_context *ctx = &context;
uint32_t cpu_count = rtems_smp_get_processor_count(); uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu_self = rtems_smp_get_current_processor(); uint32_t cpu_self = rtems_smp_get_current_processor();
uint32_t cpu; uint32_t cpu;
int test; int test;

View File

@@ -224,7 +224,7 @@ static void Init(rtems_task_argument arg)
{ {
TEST_BEGIN(); TEST_BEGIN();
if (rtems_smp_get_processor_count() >= 2) { if (rtems_get_processor_count() >= 2) {
test(); test();
} }

View File

@@ -106,7 +106,7 @@ void Validate_attr(void )
rtems_test_assert( priority != -1 ); rtems_test_assert( priority != -1 );
cpus = rtems_smp_get_processor_count(); cpus = rtems_get_processor_count();
puts( puts(
"Init - Validate pthread_attr_setaffinity_np and " "Init - Validate pthread_attr_setaffinity_np and "
"pthread_attr_getaffinity_np" "pthread_attr_getaffinity_np"

View File

@@ -121,7 +121,7 @@ void Validate_affinity(void )
rtems_test_assert( !sc ); rtems_test_assert( !sc );
/* Get the number of processors that we are using. */ /* Get the number of processors that we are using. */
cpu_count = rtems_smp_get_processor_count(); cpu_count = rtems_get_processor_count();
/* Fill the remaining cpus with med priority tasks */ /* Fill the remaining cpus with med priority tasks */
puts( "Init - Create Medium priority tasks"); puts( "Init - Create Medium priority tasks");

View File

@@ -165,7 +165,7 @@ static void *POSIX_Init(void *arg)
{ {
TEST_BEGIN(); TEST_BEGIN();
if (rtems_smp_get_processor_count() >= 2) { if (rtems_get_processor_count() >= 2) {
test(); test();
} }

View File

@@ -69,7 +69,7 @@ static void task(rtems_task_argument arg)
static bool is_per_cpu_state_ok(void) static bool is_per_cpu_state_ok(void)
{ {
bool ok = true; bool ok = true;
uint32_t n = rtems_smp_get_processor_count(); uint32_t n = rtems_get_processor_count();
uint32_t i; uint32_t i;
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {

View File

@@ -166,7 +166,7 @@ static void Init(rtems_task_argument arg)
{ {
TEST_BEGIN(); TEST_BEGIN();
if (rtems_smp_get_processor_count() >= 2) { if (rtems_get_processor_count() >= 2) {
test(); test();
} }

View File

@@ -225,7 +225,7 @@ static void Init(rtems_task_argument arg)
{ {
TEST_BEGIN(); TEST_BEGIN();
if (rtems_smp_get_processor_count() >= 2) { if (rtems_get_processor_count() >= 2) {
test(); test();
} }

View File

@@ -298,7 +298,7 @@ static void Init(rtems_task_argument arg)
{ {
TEST_BEGIN(); TEST_BEGIN();
if (rtems_smp_get_processor_count() >= CPU_COUNT) { if (rtems_get_processor_count() >= CPU_COUNT) {
test_restart(); test_restart();
test_delete(); test_delete();
test_set_life_protection(); test_set_life_protection();

View File

@@ -214,7 +214,7 @@ static void Init(rtems_task_argument arg)
test(false, load); test(false, load);
test(true, load); test(true, load);
for (load = 1; load < rtems_smp_get_processor_count(); ++load) { for (load = 1; load < rtems_get_processor_count(); ++load) {
rtems_status_code sc; rtems_status_code sc;
rtems_id id; rtems_id id;
volatile int *load_data = NULL; volatile int *load_data = NULL;