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