From a1b4af4bbac503df88e89d68e8cb8041f397d24e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 20 Jul 2015 09:05:30 +0200 Subject: score: Add scheduler support --- cpukit/score/src/sched.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 cpukit/score/src/sched.c (limited to 'cpukit/score/src/sched.c') diff --git a/cpukit/score/src/sched.c b/cpukit/score/src/sched.c new file mode 100644 index 0000000000..e694564dca --- /dev/null +++ b/cpukit/score/src/sched.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2015 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 + +#if HAVE_STRUCT__THREAD_QUEUE_QUEUE + +int _Sched_Count( void ) +{ + return (int) _Scheduler_Count; +} + +int _Sched_Index( void ) +{ + Thread_Control *executing = _Thread_Get_executing(); + + return (int) _Scheduler_Get_index( _Scheduler_Get( executing ) ); +} + +int _Sched_Name_to_index( const char *name, size_t len ) +{ + uint32_t name_32 = 0; + size_t i = 0; + + while ( i < 4 && i < len ) { + name_32 |= ( (uint32_t) ( (uint8_t) *name ) ) << ( ( 3 - i ) * 8 ); + ++name; + ++i; + } + + for ( i = 0 ; i < _Scheduler_Count ; ++i ) { + const Scheduler_Control *scheduler = &_Scheduler_Table[ i ]; + + if ( scheduler->name == name_32 ) { + return (int) i; + } + } + + return -1; +} + +int _Sched_Processor_count( int index ) +{ + size_t i = (size_t) index; + + if ( i < _Scheduler_Count ) { + return _Scheduler_Get_processor_count( &_Scheduler_Table[ i ] ); + } else { + return 0; + } +} + +#endif /* HAVE_STRUCT__THREAD_QUEUE_QUEUE */ -- cgit v1.2.3