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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [exec/] [itron/] [src/] [cre_mbf.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 158 chris
/*
2
 *  ITRON Message Buffer Manager
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
5
 *  On-Line Applications Research Corporation (OAR).
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11 208 chris
 *  $Id: cre_mbf.c,v 1.2 2001-09-27 11:59:13 chris Exp $
12 158 chris
 */
13
 
14
#include <itron.h>
15
 
16
#include <rtems/itron/msgbuffer.h>
17
#include <rtems/itron/task.h>
18
 
19
/*
20
 *  cre_mbf - Create MessageBuffer
21
 */
22
 
23
ER cre_mbf(
24
  ID      mbfid,
25
  T_CMBF *pk_cmbf
26
)
27
{
28
  CORE_message_queue_Attributes    the_msgq_attributes;
29
  ITRON_Message_buffer_Control    *the_message_buffer;
30
 
31
  /*
32
   *  Bad pointer to the attributes structure
33
   */
34
 
35
  if ( !pk_cmbf )
36
    return E_PAR;
37
 
38
  /*
39
   *  Bits were set that were note defined.
40
   */
41
 
42
  if (pk_cmbf->mbfatr & ~(TA_TPRI))
43
    return E_RSATR;
44
 
45
  if (pk_cmbf->bufsz < 0 || pk_cmbf->maxmsz < 0)
46
    return E_PAR;
47
 
48
  if (pk_cmbf->bufsz < pk_cmbf->maxmsz)
49
    return E_PAR;
50
 
51
  _Thread_Disable_dispatch();             /* prevents deletion */
52
 
53
  the_message_buffer = _ITRON_Message_buffer_Allocate(mbfid);
54
  if ( !the_message_buffer ) {
55
    _Thread_Enable_dispatch();
56
    return _ITRON_Message_buffer_Clarify_allocation_id_error(mbfid);
57
  }
58
 
59
  if ( pk_cmbf->mbfatr & TA_TPRI )
60
    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
61
  else
62
    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
63
 
64
  _CORE_message_queue_Initialize(
65
    &the_message_buffer->message_queue,
66
    OBJECTS_ITRON_MESSAGE_BUFFERS,
67
    &the_msgq_attributes,
68
    pk_cmbf->bufsz / pk_cmbf->maxmsz,
69
    pk_cmbf->maxmsz,
70
    NULL                           /* Multiprocessing not supported */
71
  );
72
 
73
  _ITRON_Objects_Open( &_ITRON_Message_buffer_Information,
74
                       &the_message_buffer->Object );
75
 
76
  /*
77
   *  If multiprocessing were supported, this is where we would announce
78
   *  the existence of the semaphore to the rest of the system.
79
   */
80
 
81
#if defined(RTEMS_MULTIPROCESSING)
82
#endif
83
 
84
  _Thread_Enable_dispatch();
85
 
86
  return E_OK;
87
}

powered by: WebSVN 2.1.0

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