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.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #if HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <rtems/itron.h> |
---|
19 | |
---|
20 | #include <rtems/itron/msgbuffer.h> |
---|
21 | #include <rtems/itron/task.h> |
---|
22 | |
---|
23 | #include <assert.h> /* only for blocking */ |
---|
24 | |
---|
25 | /* |
---|
26 | * tsnd_mbf - Send Message to MessageBuffer with Timeout |
---|
27 | */ |
---|
28 | |
---|
29 | ER tsnd_mbf( |
---|
30 | ID mbfid, |
---|
31 | VP msg, |
---|
32 | INT msgsz, |
---|
33 | TMO tmout |
---|
34 | ) |
---|
35 | { |
---|
36 | ITRON_Message_buffer_Control *the_message_buffer; |
---|
37 | Objects_Locations location; |
---|
38 | Watchdog_Interval interval; |
---|
39 | boolean wait; |
---|
40 | CORE_message_queue_Status msg_status; |
---|
41 | |
---|
42 | if (msgsz <= 0 || !msg) |
---|
43 | return E_PAR; |
---|
44 | |
---|
45 | interval = 0; |
---|
46 | if ( tmout == TMO_POL ) { |
---|
47 | wait = FALSE; |
---|
48 | } else { |
---|
49 | wait = TRUE; |
---|
50 | if ( tmout != TMO_FEVR ) |
---|
51 | interval = TOD_MILLISECONDS_TO_TICKS(tmout); |
---|
52 | } |
---|
53 | |
---|
54 | if ( wait && _ITRON_Is_in_non_task_state() ) |
---|
55 | return E_CTX; |
---|
56 | |
---|
57 | the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location); |
---|
58 | switch (location) { |
---|
59 | case OBJECTS_REMOTE: |
---|
60 | case OBJECTS_ERROR: /* Multiprocessing not supported */ |
---|
61 | return _ITRON_Message_buffer_Clarify_get_id_error(mbfid); |
---|
62 | |
---|
63 | case OBJECTS_LOCAL: |
---|
64 | /* XXX Submit needs to take into account blocking */ |
---|
65 | msg_status = _CORE_message_queue_Submit( |
---|
66 | &the_message_buffer->message_queue, |
---|
67 | msg, |
---|
68 | msgsz, |
---|
69 | the_message_buffer->Object.id, |
---|
70 | NULL, |
---|
71 | CORE_MESSAGE_QUEUE_SEND_REQUEST, |
---|
72 | wait, /* sender may block */ |
---|
73 | interval /* timeout interval */ |
---|
74 | ); |
---|
75 | _Thread_Enable_dispatch(); |
---|
76 | return _ITRON_Message_buffer_Translate_core_message_buffer_return_code( |
---|
77 | msg_status |
---|
78 | ); |
---|
79 | } |
---|
80 | |
---|
81 | /* |
---|
82 | * If multiprocessing were supported, this is where we would announce |
---|
83 | * the existence of the semaphore to the rest of the system. |
---|
84 | */ |
---|
85 | |
---|
86 | #if defined(RTEMS_MULTIPROCESSING) |
---|
87 | #endif |
---|
88 | |
---|
89 | return E_OK; |
---|
90 | } |
---|