source: rtems/cpukit/itron/src/cre_mbx.c @ 4bf1801

4.104.114.84.95
Last change on this file since 4bf1801 was 9d9a3dd, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/17/99 at 16:47:58

+ Updated copyright information.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  ITRON 3.0 Mailbox 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 *  $Id$
12 */
13
14#include <itron.h>
15
16#include <rtems/itron/mbox.h>
17#include <rtems/itron/task.h>
18
19/*
20 *  cre_mbx - Create Mailbox
21 *
22 *      Creates a Mailbox according to the following spec:
23 *
24 * ------Parameters-------------------------
25 *  ID      mbxid   MailboxID
26 *  T_CMBX *pk_cmbx Packet to Create Mailbox
27 * -----------------------------------------
28 *   -*pk_cmbx members*-
29 *    VP                exinf   ExtendedInformation
30 *    ATR               mbxatr  MailboxAttributes
31 *                      (the use of the following information
32 *                        is implementation dependent)
33 *    INT               bufcnt  BufferMessageCount
34 *                      (CPU and/or implementation-dependent information
35 *                         may also be included)
36 *
37 * ----Return Parameters--------------------
38 *  ER      ercd    ErrorCode
39 * -----------------------------------------
40 *
41 *
42 * ----C Language Interface-----------------
43 *  ER ercd = cre_mbx ( ID mbxid, T_CMBX *pk_cmbx ) ;
44 * -----------------------------------------
45 *
46 */
47
48ER cre_mbx(
49  ID      mbxid,
50  T_CMBX *pk_cmbx
51)
52{
53  register ITRON_Mailbox_Control *the_mailbox;
54  CORE_message_queue_Attributes   the_mailbox_attributes;
55
56  if ( !pk_cmbx )
57    return E_PAR;
58
59  if ((pk_cmbx->mbxatr & (TA_TPRI | TA_MPRI)) != 0 )
60    return E_RSATR;
61
62  _Thread_Disable_dispatch();              /* protects object pointer */
63
64  the_mailbox = _ITRON_Mailbox_Allocate( mbxid );
65  if ( !the_mailbox ) {
66    _Thread_Enable_dispatch();
67    return _ITRON_Mailbox_Clarify_allocation_id_error( mbxid );
68  }
69
70  the_mailbox->count = pk_cmbx->bufcnt;
71  if (pk_cmbx->mbxatr & TA_MPRI)
72    the_mailbox->do_message_priority = TRUE;
73  else
74    the_mailbox->do_message_priority = FALSE;
75
76  if (pk_cmbx->mbxatr & TA_TPRI)
77    the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
78  else
79    the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
80
81  if ( !_CORE_message_queue_Initialize(
82           &the_mailbox->message_queue,
83           OBJECTS_ITRON_MAILBOXES,
84           &the_mailbox_attributes,
85           the_mailbox->count,
86           sizeof(T_MSG *),
87           NULL ) ) {                      /* Multiprocessing not supported */
88    _ITRON_Mailbox_Free(the_mailbox);
89    _ITRON_return_errorno( E_OBJ );
90  }
91
92  _ITRON_Objects_Open( &_ITRON_Mailbox_Information, &the_mailbox->Object );
93
94  /*
95   *  If multiprocessing were supported, this is where we would announce
96   *  the existence of the semaphore to the rest of the system.
97   */
98
99#if defined(RTEMS_MULTIPROCESSING)
100#endif
101
102  _ITRON_return_errorno( E_OK );
103}
Note: See TracBrowser for help on using the repository browser.