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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [exec/] [itron/] [src/] [ref_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: ref_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
 *  ref_mbf - Reference Message Buffer Status
21
 */
22
 
23
ER ref_mbf(
24
  T_RMBF *pk_rmbf,
25
  ID      mbfid
26
)
27
{
28
  ITRON_Message_buffer_Control      *the_message_buffer;
29
  Objects_Locations                  location;
30
  CORE_message_queue_Control        *the_core_msgq;
31
 
32
  if ( !pk_rmbf )
33
    return E_PAR;   /* XXX check this error code */
34
 
35
  the_message_buffer = _ITRON_Message_buffer_Get( mbfid, &location );
36
  switch ( location ) {
37
  case OBJECTS_REMOTE:               /* Multiprocessing not supported */
38
  case OBJECTS_ERROR:
39
    return _ITRON_Message_buffer_Clarify_get_id_error( mbfid );
40
 
41
  case OBJECTS_LOCAL:
42
    the_core_msgq = &the_message_buffer->message_queue;
43
 
44
    /*
45
     *  Fill in the size of message to be sent
46
     */
47
 
48
    if (the_core_msgq->number_of_pending_messages == 0) {
49
      pk_rmbf->msgsz = 0;
50
    } else {
51
      pk_rmbf->msgsz = ((CORE_message_queue_Buffer_control *)
52
        the_core_msgq->Pending_messages.first)->Contents.size;
53
    }
54
 
55
    /*
56
     *  Fill in the size of free buffer
57
     */
58
 
59
    pk_rmbf->frbufsz =
60
      (the_core_msgq->maximum_pending_messages -
61
       the_core_msgq->number_of_pending_messages) *
62
       the_core_msgq->maximum_message_size;
63
 
64
 
65
    /*
66
     *  Fill in whether or not there is a waiting task
67
     */
68
 
69
    if ( !_Thread_queue_First(&the_core_msgq->Wait_queue ) )
70
       pk_rmbf->wtsk = FALSE;
71
    else
72
       pk_rmbf->wtsk =  TRUE;
73
 
74
    pk_rmbf->stsk = FALSE;
75
    _Thread_Enable_dispatch();
76
    return E_OK;
77
  }
78
  return E_OK;
79
}

powered by: WebSVN 2.1.0

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