source:
rtems/cpukit/rtems/src/taskgetnote.c
@
e980b219
Last change on this file since e980b219 was e980b219, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/04 at 19:21:40 | |
---|---|
|
|
File size: 2.7 KB |
Line | |
---|---|
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 | #include <rtems/system.h> |
16 | #include <rtems/rtems/status.h> |
17 | #include <rtems/rtems/support.h> |
18 | #include <rtems/rtems/modes.h> |
19 | #include <rtems/score/object.h> |
20 | #include <rtems/score/stack.h> |
21 | #include <rtems/score/states.h> |
22 | #include <rtems/rtems/tasks.h> |
23 | #include <rtems/score/thread.h> |
24 | #include <rtems/score/threadq.h> |
25 | #include <rtems/score/tod.h> |
26 | #include <rtems/score/userext.h> |
27 | #include <rtems/score/wkspace.h> |
28 | #include <rtems/score/apiext.h> |
29 | #include <rtems/score/sysstate.h> |
30 | |
31 | /*PAGE |
32 | * |
33 | * rtems_task_get_note |
34 | * |
35 | * This directive obtains the note from the specified notepad |
36 | * of the specified thread. |
37 | * |
38 | * Input parameters: |
39 | * id - thread id |
40 | * notepad - notepad number |
41 | * note - pointer to note |
42 | * |
43 | * Output parameters: |
44 | * note - filled in if successful |
45 | * RTEMS_SUCCESSFUL - if successful |
46 | * error code - if unsuccessful |
47 | */ |
48 | |
49 | rtems_status_code rtems_task_get_note( |
50 | Objects_Id id, |
51 | uint32_t notepad, |
52 | uint32_t *note |
53 | ) |
54 | { |
55 | register Thread_Control *the_thread; |
56 | Objects_Locations location; |
57 | RTEMS_API_Control *api; |
58 | |
59 | if ( !note ) |
60 | return RTEMS_INVALID_ADDRESS; |
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 | *note = api->Notepads[ notepad ]; |
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 | _Thread_Executing->Wait.return_argument = note; |
87 | |
88 | return _RTEMS_tasks_MP_Send_request_packet( |
89 | RTEMS_TASKS_MP_GET_NOTE_REQUEST, |
90 | id, |
91 | 0, /* Not used */ |
92 | notepad, |
93 | 0 /* Not used */ |
94 | ); |
95 | #endif |
96 | |
97 | case OBJECTS_ERROR: |
98 | return RTEMS_INVALID_ID; |
99 | |
100 | case OBJECTS_LOCAL: |
101 | api = the_thread->API_Extensions[ THREAD_API_RTEMS ]; |
102 | *note = api->Notepads[ notepad ]; |
103 | _Thread_Enable_dispatch(); |
104 | return RTEMS_SUCCESSFUL; |
105 | } |
106 | |
107 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
108 | } |
Note: See TracBrowser
for help on using the repository browser.