source: rtems/cpukit/itron/src/task.c @ 6236b47

4.104.114.84.95
Last change on this file since 6236b47 was 6236b47, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/02 at 12:17:03

2001-04-22 Joel Sherrill <joel@…>

  • src/task.c (_ITRON_Task_User_extensions): Add new fields to be correct in respect to newly added fields for separate switch list.
  • Property mode set to 100644
File size: 5.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-1999.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.OARcorp.com/rtems/license.html.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <itron.h>
17
18#include <rtems/score/thread.h>
19#include <rtems/score/userext.h>
20#include <rtems/score/wkspace.h>
21#include <rtems/score/apiext.h>
22#include <rtems/score/sysstate.h>
23
24#include <rtems/itron/task.h>
25
26/*
27 *  _ITRON_Task_Create_extension
28 *
29 *  This routine is an extension routine that is invoked as part
30 *  of creating any type of task or thread in the system.  If the
31 *  task is created via another API, then this routine is invoked
32 *  and this API given the opportunity to initialize its extension
33 *  area.
34 */
35
36boolean _ITRON_Task_Create_extension(
37  Thread_Control *executing,
38  Thread_Control *created
39)
40{
41  ITRON_API_Control *api;
42
43  api = _Workspace_Allocate( sizeof( ITRON_API_Control ) );
44
45  if ( !api )
46    return FALSE;
47
48  created->API_Extensions[ THREAD_API_ITRON ] = api;
49
50  /*
51   *  Initialize the ITRON API extension
52   */
53
54  return TRUE;
55}
56
57/*
58 *  _ITRON_Task_Delete_extension
59 *
60 *  This extension routine is invoked when a task is deleted.
61 */
62
63User_extensions_routine _ITRON_Task_Delete_extension(
64  Thread_Control *executing,
65  Thread_Control *deleted
66)
67{
68  (void) _Workspace_Free( deleted->API_Extensions[ THREAD_API_ITRON ] );
69 
70  deleted->API_Extensions[ THREAD_API_ITRON ] = NULL;
71}
72
73/*
74 *  _ITRON_Task_Initialize_user_tasks
75 *
76 *  This routine creates and starts all configured user
77 *  initialzation threads.
78 */
79
80void _ITRON_Task_Initialize_user_tasks( void )
81{
82  unsigned32                        index;
83  unsigned32                        maximum;
84  ER                                return_value;
85  itron_initialization_tasks_table *user_tasks;
86
87  /*
88   *  NOTE:  This is slightly different from the Ada implementation.
89   */
90
91  user_tasks = _ITRON_Task_User_initialization_tasks;
92  maximum    = _ITRON_Task_Number_of_initialization_tasks;
93
94  if ( !user_tasks || maximum == 0 )
95    return;
96
97  for ( index=0 ; index < maximum ; index++ ) {
98   
99    return_value = cre_tsk(
100       user_tasks[ index ].id,
101       &user_tasks[ index ].attributes
102    );
103
104    if ( return_value != E_OK )
105      _Internal_error_Occurred( INTERNAL_ERROR_ITRON_API, TRUE, return_value );
106
107    return_value = sta_tsk( user_tasks[ index ].id, 0 );
108
109    if ( return_value != E_OK )
110      _Internal_error_Occurred( INTERNAL_ERROR_ITRON_API, TRUE, return_value );
111
112  }
113}
114
115/*PAGE
116 *
117 *  _ITRON_Delete_task
118 */
119
120ER _ITRON_Delete_task(
121  Thread_Control *the_thread
122)
123{
124  Objects_Information     *the_information;
125
126  the_information = _Objects_Get_information( the_thread->Object.id );
127  if ( !the_information ) {
128    return E_OBJ;             /* XXX - should never happen */
129  }
130
131  _Thread_Close( the_information, the_thread );
132
133  _ITRON_Task_Free( the_thread );
134
135  return E_OK;
136}
137
138/*
139 *  At this point in time, the ITRON API does not need any other
140 *  extensions.  See the POSIX and RTEMS API extensions for
141 *  examples of how they can be used.
142 */
143
144/*
145 *  Extension Tables
146 */
147
148API_extensions_Control _ITRON_Task_API_extensions = {
149  { NULL, NULL },
150  NULL,                                     /* predriver */
151  _ITRON_Task_Initialize_user_tasks,       /* postdriver */
152  NULL                                      /* post switch */
153};
154
155User_extensions_Control _ITRON_Task_User_extensions = {
156  { NULL, NULL },
157  { { NULL, NULL }, NULL },
158  { _ITRON_Task_Create_extension,             /* create */
159    NULL,                                     /* start */
160    NULL,                                     /* restart */
161    _ITRON_Task_Delete_extension,             /* delete */
162    NULL,                                     /* switch */
163    NULL,                                     /* begin */
164    NULL,                                     /* exitted */
165    NULL                                      /* fatal */
166  }
167};
168
169/*
170 *  _ITRON_Task_Manager_initialization
171 *
172 *  This routine initializes all Task Manager related data structures.
173 *
174 *  Input parameters:
175 *    maximum_tasks       - number of tasks to initialize
176 *
177 *  Output parameters:  NONE
178 */
179
180void _ITRON_Task_Manager_initialization(
181  unsigned32                        maximum_tasks,
182  unsigned32                        number_of_initialization_tasks,
183  itron_initialization_tasks_table *user_tasks
184)
185{
186
187  _ITRON_Task_Number_of_initialization_tasks = number_of_initialization_tasks;
188  _ITRON_Task_User_initialization_tasks = user_tasks;
189
190  /*
191   *  There may not be any ITRON_initialization tasks configured.
192   */
193
194#if 0
195  if ( user_tasks == NULL || number_of_initialization_tasks == 0 )
196    _Internal_error_Occurred( INTERNAL_ERROR_ITRON_API, TRUE, -1 );
197#endif
198
199  _Objects_Initialize_information(
200    &_ITRON_Task_Information,   /* object information table */
201    OBJECTS_ITRON_TASKS,        /* object class */
202    FALSE,                      /* TRUE if this is a global object class */
203    maximum_tasks,              /* maximum objects of this class */
204    sizeof( Thread_Control ),   /* size of this object's control block */
205    FALSE,                      /* TRUE if names for this object are strings */
206    ITRON_MAXIMUM_NAME_LENGTH,  /* maximum length of each object's name */
207    TRUE                        /* TRUE if this class is threads */
208  );
209
210  /*
211   *  Add all the extensions for this API
212   */
213
214  _User_extensions_Add_API_set( &_ITRON_Task_User_extensions );
215
216  _API_extensions_Add( &_ITRON_Task_API_extensions );
217
218  /*
219   *  XXX MP not supported
220   *  Register the MP Process Packet routine.
221   */
222
223}
Note: See TracBrowser for help on using the repository browser.