1 | /* |
---|
2 | * RTEMS Task Manager |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/rtems/status.h> |
---|
21 | #include <rtems/rtems/support.h> |
---|
22 | #include <rtems/rtems/modes.h> |
---|
23 | #include <rtems/score/object.h> |
---|
24 | #include <rtems/score/stack.h> |
---|
25 | #include <rtems/score/states.h> |
---|
26 | #include <rtems/rtems/tasks.h> |
---|
27 | #include <rtems/score/thread.h> |
---|
28 | #include <rtems/score/threadq.h> |
---|
29 | #include <rtems/score/tod.h> |
---|
30 | #include <rtems/score/userext.h> |
---|
31 | #include <rtems/score/wkspace.h> |
---|
32 | #include <rtems/score/apiext.h> |
---|
33 | #include <rtems/score/sysstate.h> |
---|
34 | |
---|
35 | /*PAGE |
---|
36 | * |
---|
37 | * rtems_task_set_note |
---|
38 | * |
---|
39 | * This directive sets the specified notepad contents to the given |
---|
40 | * note. |
---|
41 | * |
---|
42 | * Input parameters: |
---|
43 | * id - thread id |
---|
44 | * notepad - notepad number |
---|
45 | * note - note value |
---|
46 | * |
---|
47 | * Output parameters: |
---|
48 | * RTEMS_SUCCESSFUL - if successful |
---|
49 | * error code - if unsuccessful |
---|
50 | */ |
---|
51 | |
---|
52 | rtems_status_code rtems_task_set_note( |
---|
53 | Objects_Id id, |
---|
54 | uint32_t notepad, |
---|
55 | uint32_t note |
---|
56 | ) |
---|
57 | { |
---|
58 | register Thread_Control *the_thread; |
---|
59 | Objects_Locations location; |
---|
60 | RTEMS_API_Control *api; |
---|
61 | |
---|
62 | /* |
---|
63 | * NOTE: There is no check for < RTEMS_NOTEPAD_FIRST because that would |
---|
64 | * be checking an unsigned number for being negative. |
---|
65 | */ |
---|
66 | |
---|
67 | if ( notepad > RTEMS_NOTEPAD_LAST ) |
---|
68 | return RTEMS_INVALID_NUMBER; |
---|
69 | |
---|
70 | /* |
---|
71 | * Optimize the most likely case to avoid the Thread_Dispatch. |
---|
72 | */ |
---|
73 | |
---|
74 | if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) || |
---|
75 | _Objects_Are_ids_equal( id, _Thread_Executing->Object.id ) ) { |
---|
76 | api = _Thread_Executing->API_Extensions[ THREAD_API_RTEMS ]; |
---|
77 | api->Notepads[ notepad ] = note; |
---|
78 | return RTEMS_SUCCESSFUL; |
---|
79 | } |
---|
80 | |
---|
81 | the_thread = _Thread_Get( id, &location ); |
---|
82 | switch ( location ) { |
---|
83 | |
---|
84 | case OBJECTS_REMOTE: |
---|
85 | #if defined(RTEMS_MULTIPROCESSING) |
---|
86 | return _RTEMS_tasks_MP_Send_request_packet( |
---|
87 | RTEMS_TASKS_MP_SET_NOTE_REQUEST, |
---|
88 | id, |
---|
89 | 0, /* Not used */ |
---|
90 | notepad, |
---|
91 | note |
---|
92 | ); |
---|
93 | #endif |
---|
94 | |
---|
95 | case OBJECTS_ERROR: |
---|
96 | return RTEMS_INVALID_ID; |
---|
97 | |
---|
98 | case OBJECTS_LOCAL: |
---|
99 | api = the_thread->API_Extensions[ THREAD_API_RTEMS ]; |
---|
100 | api->Notepads[ notepad ] = note; |
---|
101 | _Thread_Enable_dispatch(); |
---|
102 | return RTEMS_SUCCESSFUL; |
---|
103 | } |
---|
104 | |
---|
105 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
---|
106 | } |
---|