OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [itron/] [src/] [task.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  task.c,v 1.6 2002/07/01 22:35:43 joel Exp
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
 
36
boolean _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
 
63
User_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
 
80
void _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
 
120
ER _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
 
148
API_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
 
155
User_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
 
180
void _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_API,          /* object API */
202
    OBJECTS_ITRON_TASKS,        /* 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
#if defined(RTEMS_MULTIPROCESSING)
208
    ,
209
    FALSE,                      /* TRUE if this is a global object class */
210
    NULL                        /* Proxy extraction support callout */
211
#endif
212
  );
213
 
214
  /*
215
   *  Add all the extensions for this API
216
   */
217
 
218
  _User_extensions_Add_API_set( &_ITRON_Task_User_extensions );
219
 
220
  _API_extensions_Add( &_ITRON_Task_API_extensions );
221
 
222
  /*
223
   *  XXX MP not supported
224
   *  Register the MP Process Packet routine.
225
   */
226
 
227
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.