Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSScoreMessageQueue
0007  *
0008  * @brief This header file provides interfaces of the
0009  *   @ref RTEMSScoreMessageQueue which are only used by the implementation.
0010  */
0011 
0012 /*
0013  *  COPYRIGHT (c) 1989-2009.
0014  *  On-Line Applications Research Corporation (OAR).
0015  *
0016  * Redistribution and use in source and binary forms, with or without
0017  * modification, are permitted provided that the following conditions
0018  * are met:
0019  * 1. Redistributions of source code must retain the above copyright
0020  *    notice, this list of conditions and the following disclaimer.
0021  * 2. Redistributions in binary form must reproduce the above copyright
0022  *    notice, this list of conditions and the following disclaimer in the
0023  *    documentation and/or other materials provided with the distribution.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifndef _RTEMS_SCORE_COREMSG_H
0039 #define _RTEMS_SCORE_COREMSG_H
0040 
0041 #include <rtems/score/coremsgbuffer.h>
0042 #include <rtems/score/isrlock.h>
0043 #include <rtems/score/threadq.h>
0044 #include <rtems/score/watchdog.h>
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049 
0050 /**
0051  * @defgroup RTEMSScoreMessageQueue Message Queue Handler
0052  *
0053  * @ingroup RTEMSScore
0054  *
0055  * @brief This group contains the Message Queue Handler implementation.
0056  *
0057  * This handler encapsulates functionality which provides the foundation
0058  * Message Queue services used in all of the APIs supported by RTEMS.
0059  *
0060  * @{
0061  */
0062 
0063 #if defined(RTEMS_POSIX_API)
0064   /**
0065    *  This macro is defined when an API is enabled that requires that the
0066    *  Message Queue Handler include support for notification of enqueuing
0067    *  a message.
0068    */
0069   #define RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION
0070 #endif
0071 
0072 /**
0073  *  This macro is defined when an API is enabled that requires the
0074  *  Message Queue Handler include support for blocking send operations.
0075  */
0076 #define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND
0077 
0078 typedef struct CORE_message_queue_Control CORE_message_queue_Control;
0079 
0080 /**
0081  *  @brief The possible blocking disciplines for a message queue.
0082  *
0083  *  This enumerated types defines the possible blocking disciplines
0084  *  for a message queue.
0085  */
0086 typedef enum {
0087   /** This value indicates that blocking tasks are in FIFO order. */
0088   CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
0089   /** This value indicates that blocking tasks are in priority order. */
0090   CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY
0091 }   CORE_message_queue_Disciplines;
0092 
0093 #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
0094   /**
0095    *  @brief Type for a notification handler.
0096    *
0097    *  The following defines the type for a Notification handler.  A
0098    *  notification handler is invoked when the message queue makes a
0099    *  0->1 transition on pending messages.
0100    */
0101   typedef void (*CORE_message_queue_Notify_Handler)(
0102     CORE_message_queue_Control *,
0103     Thread_queue_Context *
0104   );
0105 #endif
0106 
0107 /**
0108  *  @brief Control block used to manage each message queue.
0109  *
0110  *  The following defines the control block used to manage each
0111  *  Message Queue.
0112  */
0113 struct CORE_message_queue_Control {
0114   /** This field is the Waiting Queue used to manage the set of tasks
0115    *  which are blocked waiting to receive a message from this queue.
0116    */
0117   Thread_queue_Control               Wait_queue;
0118 
0119   /**
0120    * @brief The thread queue operations according to the blocking discipline.
0121    */
0122   const Thread_queue_Operations     *operations;
0123 
0124   /** This element is maximum number of messages which may be pending
0125    *  at any given time.
0126    */
0127   uint32_t                           maximum_pending_messages;
0128   /** This element is the number of messages which are currently pending.
0129    */
0130   uint32_t                           number_of_pending_messages;
0131   /** This is the size in bytes of the largest message which may be
0132    *  sent via this queue.
0133    */
0134   size_t                             maximum_message_size;
0135   /** This chain is the set of pending messages.  It may be ordered by
0136    *  message priority or in FIFO order.
0137    */
0138   Chain_Control                      Pending_messages;
0139   /** This is the address of the memory allocated for message buffers.
0140    *  It is allocated are part of message queue initialization and freed
0141    *  as part of destroying it.
0142    */
0143   CORE_message_queue_Buffer         *message_buffers;
0144 
0145   /**
0146    * @brief This member contains the optional message buffer storage area free
0147    * handler.
0148    *
0149    * It may be NULL.  In this case no action is performed to free the message
0150    * buffer storage area.
0151    */
0152   void                            ( *free_message_buffers )( void * );
0153 
0154   #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
0155     /** This is the routine invoked when the message queue transitions
0156      *  from zero (0) messages pending to one (1) message pending.
0157      */
0158     CORE_message_queue_Notify_Handler  notify_handler;
0159   #endif
0160   /** This chain is the set of inactive messages.  A message is inactive
0161    *  when it does not contain a pending message.
0162    */
0163   Chain_Control                      Inactive_messages;
0164 };
0165 
0166 /** @} */
0167 
0168 #ifdef __cplusplus
0169 }
0170 #endif
0171 
0172 #endif
0173 /*  end of include file */