From 0edf263139088e8ac0ff1f0d52513f6fc85677d2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 26 Oct 2012 10:05:07 +0200 Subject: rtems: Add system events System events are similar to normal events. They offer a second set of events. These events are intended for internal RTEMS use and should not be used by applications (with the exception of the transient system event). --- cpukit/rtems/src/event.c | 1 + cpukit/rtems/src/systemeventreceive.c | 68 +++++++++++++++++++++++++++++++++++ cpukit/rtems/src/systemeventsend.c | 65 +++++++++++++++++++++++++++++++++ cpukit/rtems/src/tasks.c | 2 ++ 4 files changed, 136 insertions(+) create mode 100644 cpukit/rtems/src/systemeventreceive.c create mode 100644 cpukit/rtems/src/systemeventsend.c (limited to 'cpukit/rtems/src') diff --git a/cpukit/rtems/src/event.c b/cpukit/rtems/src/event.c index ed148e8b37..d5c29f6a3e 100644 --- a/cpukit/rtems/src/event.c +++ b/cpukit/rtems/src/event.c @@ -34,6 +34,7 @@ void _Event_Manager_initialization( void ) { _Event_Sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED; + _System_event_Sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED; /* * Register the MP Process Packet routine. diff --git a/cpukit/rtems/src/systemeventreceive.c b/cpukit/rtems/src/systemeventreceive.c new file mode 100644 index 0000000000..43f2bec048 --- /dev/null +++ b/cpukit/rtems/src/systemeventreceive.c @@ -0,0 +1,68 @@ +/** + * @file + * + * @ingroup ClassicEventSystem + * + * @brief rtems_event_system_receive() implementation. + */ + +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 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.com/license/LICENSE. + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include +#include + +rtems_status_code rtems_event_system_receive( + rtems_event_set event_in, + rtems_option option_set, + rtems_interval ticks, + rtems_event_set *event_out +) +{ + rtems_status_code sc; + + if ( event_out != NULL ) { + Thread_Control *executing = _Thread_Executing; + RTEMS_API_Control *api = executing->API_Extensions[ THREAD_API_RTEMS ]; + Event_Control *event = &api->System_event; + + if ( !_Event_sets_Is_empty( event_in ) ) { + _Thread_Disable_dispatch(); + _Event_Seize( + event_in, + option_set, + ticks, + event_out, + executing, + event, + &_System_event_Sync_state, + STATES_WAITING_FOR_SYSTEM_EVENT + ); + _Thread_Enable_dispatch(); + + sc = executing->Wait.return_code; + } else { + *event_out = event->pending_events; + sc = RTEMS_SUCCESSFUL; + } + } else { + sc = RTEMS_INVALID_ADDRESS; + } + + return sc; +} diff --git a/cpukit/rtems/src/systemeventsend.c b/cpukit/rtems/src/systemeventsend.c new file mode 100644 index 0000000000..13d31ccf85 --- /dev/null +++ b/cpukit/rtems/src/systemeventsend.c @@ -0,0 +1,65 @@ +/** + * @file + * + * @ingroup ClassicEventSystem + * + * @brief rtems_event_system_send() implementation. + */ + +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 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.com/license/LICENSE. + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include +#include + +rtems_status_code rtems_event_system_send( + rtems_id id, + rtems_event_set event_in +) +{ + rtems_status_code sc; + Thread_Control *thread; + Objects_Locations location; + RTEMS_API_Control *api; + + thread = _Thread_Get( id, &location ); + switch ( location ) { + case OBJECTS_LOCAL: + api = thread->API_Extensions[ THREAD_API_RTEMS ]; + _Event_Surrender( + thread, + event_in, + &api->System_event, + &_System_event_Sync_state, + STATES_WAITING_FOR_SYSTEM_EVENT + ); + _Thread_Enable_dispatch(); + sc = RTEMS_SUCCESSFUL; + break; +#ifdef RTEMS_MULTIPROCESSING + case OBJECTS_REMOTE: + sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT; + break; +#endif + default: + sc = RTEMS_INVALID_ID; + break; + } + + return sc; +} diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c index 325eba0546..c679f1e6f2 100644 --- a/cpukit/rtems/src/tasks.c +++ b/cpukit/rtems/src/tasks.c @@ -65,6 +65,7 @@ static bool _RTEMS_tasks_Create_extension( created->API_Extensions[ THREAD_API_RTEMS ] = api; _Event_Initialize( &api->Event ); + _Event_Initialize( &api->System_event ); _ASR_Initialize( &api->Signal ); created->task_variables = NULL; @@ -93,6 +94,7 @@ static void _RTEMS_tasks_Start_extension( api = started->API_Extensions[ THREAD_API_RTEMS ]; _Event_Initialize( &api->Event ); + _Event_Initialize( &api->System_event ); } /* -- cgit v1.2.3