source: rtems/cpukit/include/rtems/score/coremsg.h @ 21275b58

5
Last change on this file since 21275b58 was fe7aefd5, checked in by Sebastian Huber <sebastian.huber@…>, on 10/25/18 at 08:12:39

posix: Provide message queues by default

Update #2514.

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