1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** ThreadX Component */ 17 /** */ 18 /** Queue */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /**************************************************************************/ 25 /* */ 26 /* COMPONENT DEFINITION RELEASE */ 27 /* */ 28 /* tx_queue.h PORTABLE C */ 29 /* 6.1 */ 30 /* AUTHOR */ 31 /* */ 32 /* William E. Lamie, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file defines the ThreadX queue management component, */ 37 /* including all data types and external references. It is assumed */ 38 /* that tx_api.h and tx_port.h have already been included. */ 39 /* */ 40 /* RELEASE HISTORY */ 41 /* */ 42 /* DATE NAME DESCRIPTION */ 43 /* */ 44 /* 05-19-2020 William E. Lamie Initial Version 6.0 */ 45 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 46 /* resulting in version 6.1 */ 47 /* */ 48 /**************************************************************************/ 49 50 #ifndef TX_QUEUE_H 51 #define TX_QUEUE_H 52 53 54 /* Define queue control specific data definitions. */ 55 56 #define TX_QUEUE_ID ((ULONG) 0x51554555) 57 58 59 /* Determine if in-line component initialization is supported by the 60 caller. */ 61 #ifdef TX_INVOKE_INLINE_INITIALIZATION 62 63 /* Yes, in-line initialization is supported, remap the queue initialization 64 function. */ 65 66 #ifndef TX_QUEUE_ENABLE_PERFORMANCE_INFO 67 #define _tx_queue_initialize() \ 68 _tx_queue_created_ptr = TX_NULL; \ 69 _tx_queue_created_count = TX_EMPTY 70 #else 71 #define _tx_queue_initialize() \ 72 _tx_queue_created_ptr = TX_NULL; \ 73 _tx_queue_created_count = TX_EMPTY; \ 74 _tx_queue_performance_messages_sent_count = ((ULONG) 0); \ 75 _tx_queue_performance__messages_received_count = ((ULONG) 0); \ 76 _tx_queue_performance_empty_suspension_count = ((ULONG) 0); \ 77 _tx_queue_performance_full_suspension_count = ((ULONG) 0); \ 78 _tx_queue_performance_timeout_count = ((ULONG) 0) 79 #endif 80 #define TX_QUEUE_INIT 81 #else 82 83 /* No in-line initialization is supported, use standard function call. */ 84 VOID _tx_queue_initialize(VOID); 85 #endif 86 87 88 /* Define the message copy macro. Note that the source and destination 89 pointers must be modified since they are used subsequently. */ 90 91 #ifndef TX_QUEUE_MESSAGE_COPY 92 #define TX_QUEUE_MESSAGE_COPY(s, d, z) \ 93 *(d)++ = *(s)++; \ 94 if ((z) > ((UINT) 1)) \ 95 { \ 96 while (--(z)) \ 97 { \ 98 *(d)++ = *(s)++; \ 99 } \ 100 } 101 #endif 102 103 104 /* Define internal queue management function prototypes. */ 105 106 VOID _tx_queue_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); 107 108 109 /* Queue management component data declarations follow. */ 110 111 /* Determine if the initialization function of this component is including 112 this file. If so, make the data definitions really happen. Otherwise, 113 make them extern so other functions in the component can access them. */ 114 115 #ifdef TX_QUEUE_INIT 116 #define QUEUE_DECLARE 117 #else 118 #define QUEUE_DECLARE extern 119 #endif 120 121 122 /* Define the head pointer of the created queue list. */ 123 124 QUEUE_DECLARE TX_QUEUE * _tx_queue_created_ptr; 125 126 127 /* Define the variable that holds the number of created queues. */ 128 129 QUEUE_DECLARE ULONG _tx_queue_created_count; 130 131 132 #ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO 133 134 /* Define the total number of messages sent. */ 135 136 QUEUE_DECLARE ULONG _tx_queue_performance_messages_sent_count; 137 138 139 /* Define the total number of messages received. */ 140 141 QUEUE_DECLARE ULONG _tx_queue_performance__messages_received_count; 142 143 144 /* Define the total number of queue empty suspensions. */ 145 146 QUEUE_DECLARE ULONG _tx_queue_performance_empty_suspension_count; 147 148 149 /* Define the total number of queue full suspensions. */ 150 151 QUEUE_DECLARE ULONG _tx_queue_performance_full_suspension_count; 152 153 154 /* Define the total number of queue full errors. */ 155 156 QUEUE_DECLARE ULONG _tx_queue_performance_full_error_count; 157 158 159 /* Define the total number of queue timeouts. */ 160 161 QUEUE_DECLARE ULONG _tx_queue_performance_timeout_count; 162 163 164 #endif 165 166 167 /* Define default post queue delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h). */ 168 169 #ifndef TX_QUEUE_DELETE_PORT_COMPLETION 170 #define TX_QUEUE_DELETE_PORT_COMPLETION(q) 171 #endif 172 173 174 #endif 175 176