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