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

Subversion Repositories openrisc_me

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

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_sem.c,v 1.2 2001-09-27 11:59:13 chris Exp $
10
 */
11
 
12
#include <itron.h>
13
 
14
#include <rtems/itron/semaphore.h>
15
#include <rtems/itron/task.h>
16
#include <rtems/score/tod.h>
17
 
18
/*
19
 *  cre_sem - Create Semaphore
20
 *
21
 *  This function implements the ITRON 3.0 cre_sem() service.
22
 */
23
 
24
ER cre_sem(
25
  ID      semid,
26
  T_CSEM *pk_csem
27
)
28
{
29
  CORE_semaphore_Attributes   the_semaphore_attributes;
30
  ITRON_Semaphore_Control    *the_semaphore;
31
 
32
  /*
33
   *  Bad pointer to the attributes structure
34
   */
35
 
36
  if ( !pk_csem )
37
    return E_PAR;
38
 
39
  /*
40
   *  Bits were set that were note defined.
41
   */
42
 
43
  if ( pk_csem->sematr & _ITRON_SEMAPHORE_UNUSED_ATTRIBUTES )
44
    return E_RSATR;
45
 
46
  /*
47
   *  Initial semaphore count exceeds the maximum.
48
   */
49
 
50
  if ( pk_csem->isemcnt > pk_csem->maxsem )
51
    return E_PAR;
52
 
53
  /*
54
   *  This error is not in the specification but this condition
55
   *  does not make sense.
56
   */
57
 
58
  if ( pk_csem->maxsem == 0 )
59
    return E_PAR;
60
 
61
  _Thread_Disable_dispatch();             /* prevents deletion */
62
 
63
  the_semaphore = _ITRON_Semaphore_Allocate( semid );
64
  if ( !the_semaphore ) {
65
    _Thread_Enable_dispatch();
66
    return _ITRON_Semaphore_Clarify_allocation_id_error( semid );
67
  }
68
 
69
  if ( pk_csem->sematr & TA_TPRI )
70
    the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY;
71
  else
72
    the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
73
 
74
  the_semaphore_attributes.maximum_count = pk_csem->maxsem;
75
 
76
  _CORE_semaphore_Initialize(
77
    &the_semaphore->semaphore,
78
    OBJECTS_ITRON_SEMAPHORES,
79
    &the_semaphore_attributes,
80
    pk_csem->isemcnt,
81
    NULL                           /* Multiprocessing not supported */
82
  );
83
 
84
  _ITRON_Objects_Open( &_ITRON_Semaphore_Information, &the_semaphore->Object );
85
 
86
  /*
87
   *  If multiprocessing were supported, this is where we would announce
88
   *  the existence of the semaphore to the rest of the system.
89
   */
90
 
91
#if defined(RTEMS_MULTIPROCESSING)
92
#endif
93
 
94
  _Thread_Enable_dispatch();
95
  return E_OK;
96
}

powered by: WebSVN 2.1.0

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