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

Subversion Repositories openrisc

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

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: cre_tsk.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
/*
24
 *  cre_tsk - Create Task
25
 */
26
 
27
ER cre_tsk(
28
  ID      tskid,
29
  T_CTSK *pk_ctsk
30
)
31
{
32
  register Thread_Control     *the_thread;
33
  boolean                      status;
34
  Priority_Control             core_priority;
35
 
36
  /*
37
   * Validate Parameters.
38
   */
39
 
40
 if ( pk_ctsk == NULL )
41
    return E_PAR;
42
 
43
  if ((pk_ctsk->tskatr != TA_ASM ) &&
44
      (pk_ctsk->tskatr != TA_HLNG) &&
45
      (pk_ctsk->tskatr != TA_COP0) &&
46
      (pk_ctsk->tskatr != TA_COP1) &&
47
      (pk_ctsk->tskatr != TA_COP2) &&
48
      (pk_ctsk->tskatr != TA_COP3) &&
49
      (pk_ctsk->tskatr != TA_COP4) &&
50
      (pk_ctsk->tskatr != TA_COP5) &&
51
      (pk_ctsk->tskatr != TA_COP6) &&
52
      (pk_ctsk->tskatr != TA_COP7))
53
    return E_RSATR;
54
 
55
  if (( pk_ctsk->itskpri <= 0 ) || ( pk_ctsk->itskpri >= 256 ))
56
    return E_PAR;
57
  if ( pk_ctsk->task == NULL )
58
    return E_PAR;
59
  if ( pk_ctsk->stksz < 0 )
60
    return E_PAR;
61
 
62
  /*
63
   * Disable dispatching.
64
   */
65
 
66
  _Thread_Disable_dispatch();
67
 
68
  /*
69
   * allocate the thread.
70
   */
71
 
72
  the_thread = _ITRON_Task_Allocate( tskid );
73
  if ( !the_thread )
74
    _ITRON_return_errorno( _ITRON_Task_Clarify_allocation_id_error( tskid ) );
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 for now */
87
    core_priority,
88
    TRUE,
89
    THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE,
90
    NULL,        /* no budget algorithm callout */
91
    0,
92
    NULL
93
  );
94
 
95
  if ( !status ) {
96
    _ITRON_Task_Free( the_thread );
97
    _ITRON_return_errorno( E_NOMEM );
98
  }
99
 
100
  /*
101
   *  This insures we evaluate the process-wide signals pending when we
102
   *  first run.
103
   *
104
   *  NOTE:  Since the thread starts with all unblocked, this is necessary.
105
   */
106
 
107
  the_thread->do_post_task_switch_extension = TRUE;
108
 
109
  the_thread->Start.entry_point = (Thread_Entry) pk_ctsk->task;
110
 
111
  _ITRON_return_errorno( E_OK );
112
}
113
 
114
 
115
 
116
 

powered by: WebSVN 2.1.0

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