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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [itron/] [src/] [cre_mbx.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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