[PATCH] score: Ensure right context for rtems_task_mode()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Jul 19 07:38:07 UTC 2013
---
cpukit/rtems/include/rtems/rtems/tasks.h | 5 +++--
cpukit/rtems/src/taskmode.c | 3 +++
doc/user/task.t | 3 ++-
testsuites/sptests/sp08/init.c | 13 +++++++++++++
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 3be3aeb..df62aa8 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -378,8 +378,9 @@ rtems_status_code rtems_task_set_note(
* @param[in] mask is the mask
* @param[in] previous_mode_set is the address of previous mode set
*
- * @retval RTEMS_SUCCESSFUL and previous_mode_set filled in with the
- * previous mode set
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS The @a previous_mode_set is NULL.
+ * @retval RTEMS_INCORRECT_STATE Must be called from task context.
*/
rtems_status_code rtems_task_mode(
rtems_mode mode_set,
diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c
index 0d8035d..5bfeb01 100644
--- a/cpukit/rtems/src/taskmode.c
+++ b/cpukit/rtems/src/taskmode.c
@@ -49,6 +49,9 @@ rtems_status_code rtems_task_mode(
if ( !previous_mode_set )
return RTEMS_INVALID_ADDRESS;
+ if ( !_Thread_Dispatch_is_enabled() )
+ return RTEMS_INCORRECT_STATE;
+
executing = _Thread_Get_executing();
api = executing->API_Extensions[ THREAD_API_RTEMS ];
asr = &api->Signal;
diff --git a/doc/user/task.t b/doc/user/task.t
index b55d9b7..2f9cc7c 100644
--- a/doc/user/task.t
+++ b/doc/user/task.t
@@ -1335,7 +1335,8 @@ procedure Task_Mode (
@subheading DIRECTIVE STATUS CODES:
@code{@value{RPREFIX}SUCCESSFUL} - task mode set successfully@*
- at code{@value{RPREFIX}INVALID_ADDRESS} - @code{previous_mode_set} is NULL
+ at code{@value{RPREFIX}INVALID_ADDRESS} - @code{previous_mode_set} is NULL@*
+ at code{@value{RPREFIX}INCORRECT_STATE} - must be called from task context@*
@subheading DESCRIPTION:
This directive manipulates the execution mode of the calling
diff --git a/testsuites/sptests/sp08/init.c b/testsuites/sptests/sp08/init.c
index 48ec913..e8db2ee 100644
--- a/testsuites/sptests/sp08/init.c
+++ b/testsuites/sptests/sp08/init.c
@@ -254,6 +254,19 @@ rtems_task Init(
/* END OF CURRENT MODE */
+/* BEGINNING OF INCORRECT STATE */
+
+ _Thread_Disable_dispatch();
+ status = rtems_task_mode(
+ RTEMS_CURRENT_MODE,
+ RTEMS_CURRENT_MODE,
+ &previous_mode
+ );
+ _Thread_Enable_dispatch();
+ rtems_test_assert( status == RTEMS_INCORRECT_STATE );
+
+/* END OF INCORRECT STATE */
+
/* TEST BEING IN A SYSTEM STATE OTHER THAN UP */
puts( "TA1 - FORCE system state to before multitasking" );
_System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
--
1.7.7
More information about the devel
mailing list