tx_queue.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /***************************************************************************
  2. * Copyright (c) 2024 Microsoft Corporation
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the MIT License which is available at
  6. * https://opensource.org/licenses/MIT.
  7. *
  8. * SPDX-License-Identifier: MIT
  9. **************************************************************************/
  10. /**************************************************************************/
  11. /**************************************************************************/
  12. /** */
  13. /** ThreadX Component */
  14. /** */
  15. /** Queue */
  16. /** */
  17. /**************************************************************************/
  18. /**************************************************************************/
  19. /**************************************************************************/
  20. /* */
  21. /* COMPONENT DEFINITION RELEASE */
  22. /* */
  23. /* tx_queue.h PORTABLE C */
  24. /* 6.1 */
  25. /* AUTHOR */
  26. /* */
  27. /* William E. Lamie, Microsoft Corporation */
  28. /* */
  29. /* DESCRIPTION */
  30. /* */
  31. /* This file defines the ThreadX queue management component, */
  32. /* including all data types and external references. It is assumed */
  33. /* that tx_api.h and tx_port.h have already been included. */
  34. /* */
  35. /* RELEASE HISTORY */
  36. /* */
  37. /* DATE NAME DESCRIPTION */
  38. /* */
  39. /* 05-19-2020 William E. Lamie Initial Version 6.0 */
  40. /* 09-30-2020 Yuxin Zhou Modified comment(s), */
  41. /* resulting in version 6.1 */
  42. /* */
  43. /**************************************************************************/
  44. #ifndef TX_QUEUE_H
  45. #define TX_QUEUE_H
  46. /* Define queue control specific data definitions. */
  47. #define TX_QUEUE_ID ((ULONG) 0x51554555)
  48. /* Determine if in-line component initialization is supported by the
  49. caller. */
  50. #ifdef TX_INVOKE_INLINE_INITIALIZATION
  51. /* Yes, in-line initialization is supported, remap the queue initialization
  52. function. */
  53. #ifndef TX_QUEUE_ENABLE_PERFORMANCE_INFO
  54. #define _tx_queue_initialize() \
  55. _tx_queue_created_ptr = TX_NULL; \
  56. _tx_queue_created_count = TX_EMPTY
  57. #else
  58. #define _tx_queue_initialize() \
  59. _tx_queue_created_ptr = TX_NULL; \
  60. _tx_queue_created_count = TX_EMPTY; \
  61. _tx_queue_performance_messages_sent_count = ((ULONG) 0); \
  62. _tx_queue_performance__messages_received_count = ((ULONG) 0); \
  63. _tx_queue_performance_empty_suspension_count = ((ULONG) 0); \
  64. _tx_queue_performance_full_suspension_count = ((ULONG) 0); \
  65. _tx_queue_performance_timeout_count = ((ULONG) 0)
  66. #endif
  67. #define TX_QUEUE_INIT
  68. #else
  69. /* No in-line initialization is supported, use standard function call. */
  70. VOID _tx_queue_initialize(VOID);
  71. #endif
  72. /* Define the message copy macro. Note that the source and destination
  73. pointers must be modified since they are used subsequently. */
  74. #ifndef TX_QUEUE_MESSAGE_COPY
  75. #define TX_QUEUE_MESSAGE_COPY(s, d, z) \
  76. *(d)++ = *(s)++; \
  77. if ((z) > ((UINT) 1)) \
  78. { \
  79. while (--(z)) \
  80. { \
  81. *(d)++ = *(s)++; \
  82. } \
  83. }
  84. #endif
  85. /* Define internal queue management function prototypes. */
  86. VOID _tx_queue_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence);
  87. /* Queue management component data declarations follow. */
  88. /* Determine if the initialization function of this component is including
  89. this file. If so, make the data definitions really happen. Otherwise,
  90. make them extern so other functions in the component can access them. */
  91. #ifdef TX_QUEUE_INIT
  92. #define QUEUE_DECLARE
  93. #else
  94. #define QUEUE_DECLARE extern
  95. #endif
  96. /* Define the head pointer of the created queue list. */
  97. QUEUE_DECLARE TX_QUEUE * _tx_queue_created_ptr;
  98. /* Define the variable that holds the number of created queues. */
  99. QUEUE_DECLARE ULONG _tx_queue_created_count;
  100. #ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
  101. /* Define the total number of messages sent. */
  102. QUEUE_DECLARE ULONG _tx_queue_performance_messages_sent_count;
  103. /* Define the total number of messages received. */
  104. QUEUE_DECLARE ULONG _tx_queue_performance__messages_received_count;
  105. /* Define the total number of queue empty suspensions. */
  106. QUEUE_DECLARE ULONG _tx_queue_performance_empty_suspension_count;
  107. /* Define the total number of queue full suspensions. */
  108. QUEUE_DECLARE ULONG _tx_queue_performance_full_suspension_count;
  109. /* Define the total number of queue full errors. */
  110. QUEUE_DECLARE ULONG _tx_queue_performance_full_error_count;
  111. /* Define the total number of queue timeouts. */
  112. QUEUE_DECLARE ULONG _tx_queue_performance_timeout_count;
  113. #endif
  114. /* Define default post queue delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h). */
  115. #ifndef TX_QUEUE_DELETE_PORT_COMPLETION
  116. #define TX_QUEUE_DELETE_PORT_COMPLETION(q)
  117. #endif
  118. #endif