source: rtems/cpukit/score/include/rtems/score/coremsg.h @ 864d3475

4.115
Last change on this file since 864d3475 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/**
2 *  @file  rtems/score/coremsg.h
3 *
4 *  @brief Constants and Structures Associated with the Message Queue Handler.
5 *
6 *  This include file contains all the constants and structures associated
7 *  with the Message queue Handler.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2009.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_COREMSG_H
20#define _RTEMS_SCORE_COREMSG_H
21
22#include <rtems/score/chain.h>
23#include <rtems/score/threadq.h>
24#include <rtems/score/watchdog.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 *  @defgroup ScoreMessageQueue Message Queue Handler
32 *
33 *  @ingroup Score
34 *
35 *  This handler encapsulates functionality which provides the foundation
36 *  Message Queue services used in all of the APIs supported by RTEMS.
37 */
38/**@{*/
39
40#if defined(RTEMS_POSIX_API)
41  /**
42   *  This macro is defined when an API is enabled that requires that the
43   *  Message Queue Handler include support for priority based enqueuing
44   *  of messages.
45   */
46  #define RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY
47#endif
48
49#if defined(RTEMS_POSIX_API)
50  /**
51   *  This macro is defined when an API is enabled that requires that the
52   *  Message Queue Handler include support for notification of enqueuing
53   *  a message.
54   */
55  #define RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION
56#endif
57
58#if defined(RTEMS_POSIX_API)
59  /**
60   *  This macro is defined when an API is enabled that requires the
61   *  Message Queue Handler include support for blocking send operations.
62   */
63  #define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND
64#endif
65
66/**
67 *  @brief Data types needed to manipulate the contents of message buffers.
68 *
69 *  The following defines the data types needed to manipulate
70 *  the contents of message buffers.
71 *
72 *  @note  The buffer field is normally longer than a single uint32_t
73 *         but since messages are variable length we just make a ptr to 1.
74 */
75typedef struct {
76  /** This field is the size of this message. */
77  size_t      size;
78  /** This field contains the actual message. */
79  uint32_t    buffer[1];
80} CORE_message_queue_Buffer;
81
82/**
83 *  @brief The organization of a message buffer.
84 *
85 *  The following records define the organization of a message
86 *  buffer.
87 */
88typedef struct {
89  /** This element allows this structure to be placed on chains. */
90  Chain_Node                 Node;
91  #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
92    /** This field is the priority of this message. */
93    int                        priority;
94  #endif
95  /** This field points to the contents of the message. */
96  CORE_message_queue_Buffer  Contents;
97}   CORE_message_queue_Buffer_control;
98
99/**
100 *  @brief The possible blocking disciplines for a message queue.
101 *
102 *  This enumerated types defines the possible blocking disciplines
103 *  for a message queue.
104 */
105typedef enum {
106  /** This value indicates that blocking tasks are in FIFO order. */
107  CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
108  /** This value indicates that blocking tasks are in priority order. */
109  CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY
110}   CORE_message_queue_Disciplines;
111
112/**
113 *  @brief Control block used to manage the attributes of each message queue.
114 *
115 *  The following defines the control block used to manage the
116 *  attributes of each message queue.
117 */
118typedef struct {
119  /** This field specifies the order in which blocking tasks will be ordered. */
120  CORE_message_queue_Disciplines  discipline;
121}   CORE_message_queue_Attributes;
122
123#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
124  /**
125   *  @brief Type for a notification handler.
126   *
127   *  The following defines the type for a Notification handler.  A
128   *  notification handler is invoked when the message queue makes a
129   *  0->1 transition on pending messages.
130   */
131  typedef void (*CORE_message_queue_Notify_Handler)( void * );
132#endif
133
134/**
135 *  @brief Control block used to manage each message queue.
136 *
137 *  The following defines the control block used to manage each
138 *  Message Queue.
139 */
140typedef struct {
141  /** This field is the Waiting Queue used to manage the set of tasks
142   *  which are blocked waiting to receive a message from this queue.
143   */
144  Thread_queue_Control               Wait_queue;
145  /** This element is the set of attributes which define this instance's
146   *  behavior.
147   */
148  CORE_message_queue_Attributes      Attributes;
149  /** This element is maximum number of messages which may be pending
150   *  at any given time.
151   */
152  uint32_t                           maximum_pending_messages;
153  /** This element is the number of messages which are currently pending.
154   */
155  uint32_t                           number_of_pending_messages;
156  /** This is the size in bytes of the largest message which may be
157   *  sent via this queue.
158   */
159  size_t                             maximum_message_size;
160  /** This chain is the set of pending messages.  It may be ordered by
161   *  message priority or in FIFO order.
162   */
163  Chain_Control                      Pending_messages;
164  /** This is the address of the memory allocated for message buffers.
165   *  It is allocated are part of message queue initialization and freed
166   *  as part of destroying it.
167   */
168  CORE_message_queue_Buffer         *message_buffers;
169  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
170    /** This is the routine invoked when the message queue transitions
171     *  from zero (0) messages pending to one (1) message pending.
172     */
173    CORE_message_queue_Notify_Handler  notify_handler;
174    /** This field is the argument passed to the @ref notify_argument. */
175    void                              *notify_argument;
176  #endif
177  /** This chain is the set of inactive messages.  A message is inactive
178   *  when it does not contain a pending message.
179   */
180  Chain_Control                      Inactive_messages;
181}   CORE_message_queue_Control;
182
183/**@}*/
184
185#ifdef __cplusplus
186}
187#endif
188
189#endif
190/*  end of include file */
Note: See TracBrowser for help on using the repository browser.