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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  cre_mbf.c,v 1.5 2002/07/01 22:35:43 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/msgbuffer.h>
21
#include <rtems/itron/task.h>
22
 
23
/*
24
 *  cre_mbf - Create MessageBuffer
25
 */
26
 
27
ER cre_mbf(
28
  ID      mbfid,
29
  T_CMBF *pk_cmbf
30
)
31
{
32
  CORE_message_queue_Attributes    the_msgq_attributes;
33
  ITRON_Message_buffer_Control    *the_message_buffer;
34
 
35
  /*
36
   *  Bad pointer to the attributes structure
37
   */
38
 
39
  if ( !pk_cmbf )
40
    return E_PAR;
41
 
42
  /*
43
   *  Bits were set that were note defined.
44
   */
45
 
46
  if (pk_cmbf->mbfatr & ~(TA_TPRI))
47
    return E_RSATR;
48
 
49
  if (pk_cmbf->bufsz < 0 || pk_cmbf->maxmsz < 0)
50
    return E_PAR;
51
 
52
  if (pk_cmbf->bufsz < pk_cmbf->maxmsz)
53
    return E_PAR;
54
 
55
  _Thread_Disable_dispatch();             /* prevents deletion */
56
 
57
  the_message_buffer = _ITRON_Message_buffer_Allocate(mbfid);
58
  if ( !the_message_buffer ) {
59
    _Thread_Enable_dispatch();
60
    return _ITRON_Message_buffer_Clarify_allocation_id_error(mbfid);
61
  }
62
 
63
  if ( pk_cmbf->mbfatr & TA_TPRI )
64
    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
65
  else
66
    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
67
 
68
  _CORE_message_queue_Initialize(
69
    &the_message_buffer->message_queue,
70
    &the_msgq_attributes,
71
    pk_cmbf->bufsz / pk_cmbf->maxmsz,
72
    pk_cmbf->maxmsz
73
  );
74
 
75
  _ITRON_Objects_Open( &_ITRON_Message_buffer_Information,
76
                       &the_message_buffer->Object );
77
 
78
  /*
79
   *  If multiprocessing were supported, this is where we would announce
80
   *  the existence of the semaphore to the rest of the system.
81
   */
82
 
83
#if defined(RTEMS_MULTIPROCESSING)
84
#endif
85
 
86
  _Thread_Enable_dispatch();
87
 
88
  return E_OK;
89
}

powered by: WebSVN 2.1.0

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