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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [itron/] [src/] [cre_tsk.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
 *  cre_tsk.c,v 1.8 2001/01/24 14:15:04 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
/*
28
 *  cre_tsk - Create Task
29
 */
30
 
31
ER cre_tsk(
32
  ID      tskid,
33
  T_CTSK *pk_ctsk
34
)
35
{
36
  register Thread_Control     *the_thread;
37
  boolean                      status;
38
  Priority_Control             core_priority;
39
 
40
  /*
41
   * Validate Parameters.
42
   */
43
 
44
 if ( pk_ctsk == NULL )
45
    return E_PAR;
46
 
47
  if ((pk_ctsk->tskatr != TA_ASM ) &&
48
      (pk_ctsk->tskatr != TA_HLNG) &&
49
      (pk_ctsk->tskatr != TA_COP0) &&
50
      (pk_ctsk->tskatr != TA_COP1) &&
51
      (pk_ctsk->tskatr != TA_COP2) &&
52
      (pk_ctsk->tskatr != TA_COP3) &&
53
      (pk_ctsk->tskatr != TA_COP4) &&
54
      (pk_ctsk->tskatr != TA_COP5) &&
55
      (pk_ctsk->tskatr != TA_COP6) &&
56
      (pk_ctsk->tskatr != TA_COP7))
57
    return E_RSATR;
58
 
59
  if (( pk_ctsk->itskpri <= 0 ) || ( pk_ctsk->itskpri >= 256 ))
60
    return E_PAR;
61
  if ( pk_ctsk->task == NULL )
62
    return E_PAR;
63
  if ( pk_ctsk->stksz < 0 )
64
    return E_PAR;
65
 
66
  /*
67
   * Disable dispatching.
68
   */
69
 
70
  _Thread_Disable_dispatch();
71
 
72
  /*
73
   * allocate the thread.
74
   */
75
 
76
  the_thread = _ITRON_Task_Allocate( tskid );
77
  if ( !the_thread )
78
    _ITRON_return_errorno( _ITRON_Task_Clarify_allocation_id_error( tskid ) );
79
 
80
  /*
81
   *  Initialize the core thread for this task.
82
   */
83
 
84
  core_priority = _ITRON_Task_Priority_to_Core( pk_ctsk->itskpri );
85
  status = _Thread_Initialize(
86
    &_ITRON_Task_Information,
87
    the_thread,
88
    NULL,
89
    pk_ctsk->stksz,
90
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
91
    TRUE,          /* XXX - All tasks FP (if the HW supports it) for now */
92
#else
93
    FALSE,
94
#endif
95
    core_priority,
96
    TRUE,        /* preemptible */
97
    THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE,
98
    NULL,        /* no budget algorithm callout */
99
    0,
100
    NULL
101
  );
102
 
103
  if ( !status ) {
104
    _ITRON_Task_Free( the_thread );
105
    _ITRON_return_errorno( E_NOMEM );
106
  }
107
 
108
  /*
109
   *  This insures we evaluate the process-wide signals pending when we
110
   *  first run.
111
   *
112
   *  NOTE:  Since the thread starts with all unblocked, this is necessary.
113
   */
114
 
115
  the_thread->do_post_task_switch_extension = TRUE;
116
 
117
  the_thread->Start.entry_point = (Thread_Entry) pk_ctsk->task;
118
 
119
  _ITRON_return_errorno( E_OK );
120
}
121
 
122
 
123
 
124
 

powered by: WebSVN 2.1.0

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