source: rtems/c/src/exec/itron/src/cre_tsk.c @ 352c9b2

4.104.114.84.95
Last change on this file since 352c9b2 was 352c9b2, checked in by Joel Sherrill <joel.sherrill@…>, on 11/09/99 at 22:07:23

This patch adds the basic framework for the ITRON 3.0 API implementation
for RTEMS.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  The license and distribution terms for this file may be
3 *  found in the file LICENSE in this distribution or at
4 *  http://www.OARcorp.com/rtems/license.html.
5 *
6 *  $Id$
7 */
8
9#include <itron.h>
10
11#include <rtems/score/thread.h>
12#include <rtems/score/userext.h>
13#include <rtems/score/wkspace.h>
14#include <rtems/score/apiext.h>
15#include <rtems/score/sysstate.h>
16
17#include <rtems/itron/task.h>
18
19
20/*
21 *  cre_tsk - Create Task
22 */
23
24/*
25 * XXX - How do I return these errors ???  Do I have to validate the ID
26         prior to calling the ID routine ??
27  E_NOMEM   Insufficient memory (Memory for control block and/or user stack
28            cannot be allocated)
29  E_ID      Invalid ID Number (tskid was invalid or could not be used)
30  E_RSATR   Reserved attribute (tskatr was invalid or could not be used)
31  E_OBJ     Invalid object state (a task of the same ID already exists)
32  E_OACV    Object access violation (A tskid less than -4 was specified from
33            a user task.  This is implementation dependent.)
34  E_PAR     Parameter error (pk_ctsk, task, itskpri and/or stksz is invalid)
35  EN_OBJNO  An object number which could not be accessed on the target node
36            is specified.
37  EN_CTXID  Specified an object on another node when the system call was
38            issued from a task in dispatch disabled state or from a task-
39            independent portion
40  EN_PAR    A value outside the range supported by the target node and/or
41            transmission packet format was specified as a parameter (a value
42            outside supported range was specified for exinf, tskatr, task,
43            itskpri and/or stksz)
44 */
45
46ER cre_tsk(
47  ID      tskid,
48  T_CTSK *pk_ctsk
49)
50{
51  register Thread_Control     *the_thread;
52  char                        *name = "trn";
53  boolean                      status;
54  Priority_Control             core_priority; 
55
56  /*
57   * Disable dispatching.
58   */
59 
60  _Thread_Disable_dispatch();
61
62  /*
63   * allocate the thread.
64   */
65
66  the_thread = _ITRON_Task_Allocate( tskid );
67  if ( !the_thread ) {
68    ena_dsp();
69    return _ITRON_Task_Clarify_allocation_id_error( tskid );
70  }
71
72  /*
73   * XXX - FIX THE VARIABLES TO THE CORRECT VALUES!!!
74   */
75
76  /*
77   *  Initialize the core thread for this task.
78   */
79
80  core_priority = _ITRON_Task_Priority_to_Core( pk_ctsk->itskpri );
81  status = _Thread_Initialize(
82    &_ITRON_Task_Information,
83    the_thread,
84    NULL,
85    pk_ctsk->stksz,
86    TRUE,          /* XXX - All tasks FP ??? */
87    core_priority,
88    TRUE,
89    THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE,
90    NULL,        /* no budget algorithm callout */
91    0,
92    &name
93  );
94
95  if ( !status ) {
96    _ITRON_Task_Free( the_thread );
97    _Thread_Enable_dispatch();
98    return -1;
99#if (0)
100/* XXX */
101#endif
102  }
103
104#if (0)  /* XXX We have any thing else to set per API structure? */
105  api = the_thread->API_Extensions[ THREAD_API_ITRON ];
106  asr = &api->Signal;
107 
108  asr->is_enabled = FALSE;
109
110  *id = the_thread->Object.id;
111#endif
112
113  /*
114   *  This insures we evaluate the process-wide signals pending when we
115   *  first run.
116   *
117   *  NOTE:  Since the thread starts with all unblocked, this is necessary.
118   */
119
120  the_thread->do_post_task_switch_extension = TRUE;
121
122  the_thread->Start.entry_point = (Thread_Entry) pk_ctsk->task;
123
124  _Thread_Enable_dispatch();
125  return E_OK;
126}
127
Note: See TracBrowser for help on using the repository browser.