source: rtems/cpukit/itron/src/cre_mbf.c @ 9da0994

4.104.114.84.95
Last change on this file since 9da0994 was 9da0994, checked in by Joel Sherrill <joel.sherrill@…>, on 11/15/99 at 17:15:58

Split ITRON Message Buffer Manager into multiple files.

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