From 2f96c1ebef88c75757a1b1f7e76ec85cf2a5f78e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 28 Jun 2011 20:39:39 +0000 Subject: 2011-06-28 Joel Sherrill PR 1826/cpukit * libmisc/cpuuse/cpuusagereport.c, rtems/Makefile.am, rtems/preinstall.am, rtems/include/rtems.h: Add SMP Helper methods to Classic API. * rtems/include/rtems/rtems/smp.h: New file. --- cpukit/ChangeLog | 8 ++++ cpukit/libmisc/cpuuse/cpuusagereport.c | 2 +- cpukit/rtems/Makefile.am | 4 ++ cpukit/rtems/include/rtems.h | 4 ++ cpukit/rtems/include/rtems/rtems/smp.h | 82 ++++++++++++++++++++++++++++++++++ cpukit/rtems/preinstall.am | 5 +++ 6 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 cpukit/rtems/include/rtems/rtems/smp.h diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 20ce764519..82eb911235 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,11 @@ +2011-06-28 Joel Sherrill + + PR 1826/cpukit + * libmisc/cpuuse/cpuusagereport.c, rtems/Makefile.am, + rtems/preinstall.am, rtems/include/rtems.h: Add SMP Helper methods to + Classic API. + * rtems/include/rtems/rtems/smp.h: New file. + 2011-06-28 Joel Sherrill * score/Makefile.am, score/include/rtems/score/schedulersimplesmp.h, diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c index 4e2fe455e2..a0696ff6eb 100644 --- a/cpukit/libmisc/cpuuse/cpuusagereport.c +++ b/cpukit/libmisc/cpuuse/cpuusagereport.c @@ -49,7 +49,7 @@ } #else int cpu; - for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) { + for ( cpu=0 ; cpu < rtems_smp_get_number_of_processors() ; cpu++ ) { Per_CPU_Control *p = &_Per_CPU_Information[cpu]; if ( p->executing->Object.id == the_thread->Object.id ) { *time_of_context_switch = p->time_of_last_context_switch; diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index c93bf34e0e..af2926460e 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -57,6 +57,10 @@ include_rtems_rtems_HEADERS += include/rtems/rtems/signalmp.h include_rtems_rtems_HEADERS += include/rtems/rtems/taskmp.h endif +if HAS_SMP +include_rtems_rtems_HEADERS += include/rtems/rtems/smp.h +endif + include_rtems_rtems_HEADERS += inline/rtems/rtems/asr.inl include_rtems_rtems_HEADERS += inline/rtems/rtems/attr.inl include_rtems_rtems_HEADERS += inline/rtems/rtems/barrier.inl diff --git a/cpukit/rtems/include/rtems.h b/cpukit/rtems/include/rtems.h index 17b1ce0394..fab6a1e4ca 100644 --- a/cpukit/rtems/include/rtems.h +++ b/cpukit/rtems/include/rtems.h @@ -74,6 +74,10 @@ extern "C" { #if defined(RTEMS_MULTIPROCESSING) #include #endif +#if defined(RTEMS_SMP) +#include +#endif + #include #include diff --git a/cpukit/rtems/include/rtems/rtems/smp.h b/cpukit/rtems/include/rtems/rtems/smp.h new file mode 100644 index 0000000000..6ebe9502a6 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/smp.h @@ -0,0 +1,82 @@ +/** + * @file rtems/rtems/smp.h + * + * This include file provides the application interface + * to SMP information and services. + * + * Most of the SMP interface is hidden from the application + * and exists between the BSP and RTEMS. + */ + +/* COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * 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. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_SMP_H +#define _RTEMS_RTEMS_SMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * @defgroup ClassicSMP Classic API SMP Services + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which is useful for SMP applications. + */ +/**@{*/ + +extern uint32_t rtems_configuration_smp_maximum_processors; + +/** + * @brief Obtain Number of Cores in System + * + * This method returns the number of CPU cores that are currently in + * the system. This will always be less than or equal to the number + * of maximum number of cores which were configured. + * + * @return This method returns the number of cores in this system. + */ +#define rtems_smp_get_number_of_processors() \ + (_SMP_Processor_count) + +/** + * @brief Obtain Maximum Cores Configured + * + * This method returns the number of CPU cores that were configured + * in the system. The actual number of cores will always be less than + * or equal to the number of maximum number of cores which were configured. + * + * @return This method returns the number of cores configured. + */ +#define rtems_configuration_get_smp_maximum_processors() \ + (rtems_configuration_smp_maximum_processors) + +/** + * @brief Obtain Current Core Number + * + * This method returns the id of the current CPU core. + * + * @return This method returns the id of the current CPU core. + */ +#define rtems_smp_get_current_processor() \ + bsp_smp_processor_id() + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/rtems/preinstall.am b/cpukit/rtems/preinstall.am index 5d32ad7413..c91e508ef2 100644 --- a/cpukit/rtems/preinstall.am +++ b/cpukit/rtems/preinstall.am @@ -164,6 +164,11 @@ $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h: include/rtems/rtems/taskmp.h $(PROJECT_ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h endif +if HAS_SMP +$(PROJECT_INCLUDE)/rtems/rtems/smp.h: include/rtems/rtems/smp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/smp.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/smp.h +endif $(PROJECT_INCLUDE)/rtems/rtems/asr.inl: inline/rtems/rtems/asr.inl $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/asr.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/asr.inl -- cgit v1.2.3