1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Get Task Node |
---|
5 | * @ingroup ClassicRTEMS |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/config.h> |
---|
23 | #include <rtems/rtems/status.h> |
---|
24 | #include <rtems/rtems/support.h> |
---|
25 | #include <rtems/rtems/modes.h> |
---|
26 | #include <rtems/score/object.h> |
---|
27 | #include <rtems/score/stack.h> |
---|
28 | #include <rtems/score/states.h> |
---|
29 | #include <rtems/rtems/tasksimpl.h> |
---|
30 | #include <rtems/score/thread.h> |
---|
31 | #include <rtems/score/threadq.h> |
---|
32 | #include <rtems/score/tod.h> |
---|
33 | #include <rtems/score/wkspace.h> |
---|
34 | #include <rtems/score/apiext.h> |
---|
35 | |
---|
36 | rtems_status_code rtems_task_get_note( |
---|
37 | rtems_id id, |
---|
38 | uint32_t notepad, |
---|
39 | uint32_t *note |
---|
40 | ) |
---|
41 | { |
---|
42 | register Thread_Control *the_thread; |
---|
43 | Objects_Locations location; |
---|
44 | RTEMS_API_Control *api; |
---|
45 | Thread_Control *executing; |
---|
46 | |
---|
47 | if ( !rtems_configuration_get_notepads_enabled() ) |
---|
48 | return RTEMS_NOT_CONFIGURED; |
---|
49 | |
---|
50 | if ( !note ) |
---|
51 | return RTEMS_INVALID_ADDRESS; |
---|
52 | |
---|
53 | /* |
---|
54 | * NOTE: There is no check for < RTEMS_NOTEPAD_FIRST because that would |
---|
55 | * be checking an unsigned number for being negative. |
---|
56 | */ |
---|
57 | |
---|
58 | if ( notepad > RTEMS_NOTEPAD_LAST ) |
---|
59 | return RTEMS_INVALID_NUMBER; |
---|
60 | |
---|
61 | /* |
---|
62 | * Optimize the most likely case to avoid the Thread_Dispatch. |
---|
63 | */ |
---|
64 | |
---|
65 | executing = _Thread_Get_executing(); |
---|
66 | if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) || |
---|
67 | _Objects_Are_ids_equal( id, executing->Object.id ) ) { |
---|
68 | api = executing->API_Extensions[ THREAD_API_RTEMS ]; |
---|
69 | *note = api->Notepads[ notepad ]; |
---|
70 | return RTEMS_SUCCESSFUL; |
---|
71 | } |
---|
72 | |
---|
73 | the_thread = _Thread_Get( id, &location ); |
---|
74 | switch ( location ) { |
---|
75 | |
---|
76 | case OBJECTS_LOCAL: |
---|
77 | api = the_thread->API_Extensions[ THREAD_API_RTEMS ]; |
---|
78 | *note = api->Notepads[ notepad ]; |
---|
79 | _Objects_Put( &the_thread->Object ); |
---|
80 | return RTEMS_SUCCESSFUL; |
---|
81 | |
---|
82 | #if defined(RTEMS_MULTIPROCESSING) |
---|
83 | case OBJECTS_REMOTE: |
---|
84 | executing->Wait.return_argument = note; |
---|
85 | |
---|
86 | return _RTEMS_tasks_MP_Send_request_packet( |
---|
87 | RTEMS_TASKS_MP_GET_NOTE_REQUEST, |
---|
88 | id, |
---|
89 | 0, /* Not used */ |
---|
90 | notepad, |
---|
91 | 0 /* Not used */ |
---|
92 | ); |
---|
93 | #endif |
---|
94 | |
---|
95 | case OBJECTS_ERROR: |
---|
96 | break; |
---|
97 | } |
---|
98 | |
---|
99 | return RTEMS_INVALID_ID; |
---|
100 | } |
---|