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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [itron/] [src/] [task.c] - Blame information for rev 279

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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