source: rtems/cpukit/rtems/src/taskgetnote.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Get Task Node
5 *  @ingroup ClassicRTEMS
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/tasksimpl.h>
22#include <rtems/score/threadimpl.h>
23#include <rtems/config.h>
24
25rtems_status_code rtems_task_get_note(
26  rtems_id    id,
27  uint32_t    notepad,
28  uint32_t   *note
29)
30{
31  Thread_Control          *the_thread;
32  Objects_Locations        location;
33  RTEMS_API_Control       *api;
34  Thread_Control          *executing;
35
36  if ( !rtems_configuration_get_notepads_enabled() )
37    return RTEMS_NOT_CONFIGURED;
38
39  if ( !note )
40    return RTEMS_INVALID_ADDRESS;
41
42  /*
43   *  NOTE:  There is no check for < RTEMS_NOTEPAD_FIRST because that would
44   *         be checking an unsigned number for being negative.
45   */
46
47  if ( notepad > RTEMS_NOTEPAD_LAST )
48    return RTEMS_INVALID_NUMBER;
49
50  /*
51   *  Optimize the most likely case to avoid the Thread_Dispatch.
52   */
53
54  executing = _Thread_Get_executing();
55  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ||
56       _Objects_Are_ids_equal( id, executing->Object.id ) ) {
57      api = executing->API_Extensions[ THREAD_API_RTEMS ];
58      *note = api->Notepads[ notepad ];
59      return RTEMS_SUCCESSFUL;
60  }
61
62  the_thread = _Thread_Get( id, &location );
63  switch ( location ) {
64
65    case OBJECTS_LOCAL:
66      api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
67      *note = api->Notepads[ notepad ];
68      _Objects_Put( &the_thread->Object );
69      return RTEMS_SUCCESSFUL;
70
71#if defined(RTEMS_MULTIPROCESSING)
72    case OBJECTS_REMOTE:
73      executing->Wait.return_argument = note;
74
75      return _RTEMS_tasks_MP_Send_request_packet(
76        RTEMS_TASKS_MP_GET_NOTE_REQUEST,
77        id,
78        0,          /* Not used */
79        notepad,
80        0           /* Not used */
81      );
82#endif
83
84    case OBJECTS_ERROR:
85      break;
86  }
87
88  return RTEMS_INVALID_ID;
89}
Note: See TracBrowser for help on using the repository browser.