summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-09 10:09:24 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-15 09:29:31 +0200
commitb427a92adfd16e8d68b275b44337f54f6ab0a3ca (patch)
tree07d5c10ecb3fec438ef9fcacf9d5960b3e558d9e /cpukit/rtems
parentscore: Add scheduler name (diff)
downloadrtems-b427a92adfd16e8d68b275b44337f54f6ab0a3ca.tar.bz2
rtems: Add scheduler identification
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/Makefile.am1
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h17
-rw-r--r--cpukit/rtems/src/schedulerident.c46
3 files changed, 64 insertions, 0 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index b6a19c4f14..57b15ca097 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -116,6 +116,7 @@ librtems_a_SOURCES += src/taskvariableget.c
librtems_a_SOURCES += src/taskvariable_invoke_dtor.c
endif
librtems_a_SOURCES += src/taskdata.c
+librtems_a_SOURCES += src/schedulerident.c
## RATEMON_C_FILES
librtems_a_SOURCES += src/ratemon.c
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 87128be5f5..5816e7d884 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -548,6 +548,23 @@ rtems_status_code rtems_task_set_affinity(
*/
rtems_id rtems_task_self(void);
+/**
+ * @brief Identifies a scheduler by its name.
+ *
+ * The scheduler name is determined by the scheduler configuration.
+ *
+ * @param[in] name The scheduler name.
+ * @param[out] id The scheduler identifier associated with the name.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL.
+ * @retval RTEMS_INVALID_NAME Invalid scheduler name.
+ */
+rtems_status_code rtems_scheduler_ident(
+ rtems_name name,
+ rtems_id *id
+);
+
/**@}*/
/**
diff --git a/cpukit/rtems/src/schedulerident.c b/cpukit/rtems/src/schedulerident.c
new file mode 100644
index 0000000000..d9e913c946
--- /dev/null
+++ b/cpukit/rtems/src/schedulerident.c
@@ -0,0 +1,46 @@
+/*
+ * 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/tasks.h>
+#include <rtems/score/schedulerimpl.h>
+
+rtems_status_code rtems_scheduler_ident(
+ rtems_name name,
+ rtems_id *id
+)
+{
+ rtems_status_code sc;
+
+ if ( id != NULL ) {
+ size_t n = _Scheduler_Count;
+ size_t i;
+
+ sc = RTEMS_INVALID_NAME;
+
+ for ( i = 0 ; i < n && sc == RTEMS_INVALID_NAME ; ++i ) {
+ if ( _Scheduler_Table[ i ].name == name ) {
+ *id = _Scheduler_Build_id( i );
+ sc = RTEMS_SUCCESSFUL;
+ }
+ }
+ } else {
+ sc = RTEMS_INVALID_ADDRESS;
+ }
+
+ return sc;
+}