tx_block_pool.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. /** Block Memory */
  16. /** */
  17. /**************************************************************************/
  18. /**************************************************************************/
  19. /**************************************************************************/
  20. /* */
  21. /* COMPONENT DEFINITION RELEASE */
  22. /* */
  23. /* tx_block_pool.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 block memory 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_BLOCK_POOL_H
  45. #define TX_BLOCK_POOL_H
  46. /* Define block memory control specific data definitions. */
  47. #define TX_BLOCK_POOL_ID ((ULONG) 0x424C4F43)
  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 block memory pool
  52. initialization function. */
  53. #ifndef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
  54. #define _tx_block_pool_initialize() \
  55. _tx_block_pool_created_ptr = TX_NULL; \
  56. _tx_block_pool_created_count = TX_EMPTY
  57. #else
  58. #define _tx_block_pool_initialize() \
  59. _tx_block_pool_created_ptr = TX_NULL; \
  60. _tx_block_pool_created_count = TX_EMPTY; \
  61. _tx_block_pool_performance_allocate_count = ((ULONG) 0); \
  62. _tx_block_pool_performance_release_count = ((ULONG) 0); \
  63. _tx_block_pool_performance_suspension_count = ((ULONG) 0); \
  64. _tx_block_pool_performance_timeout_count = ((ULONG) 0)
  65. #endif
  66. #define TX_BLOCK_POOL_INIT
  67. #else
  68. /* No in-line initialization is supported, use standard function call. */
  69. VOID _tx_block_pool_initialize(VOID);
  70. #endif
  71. /* Define internal block memory pool management function prototypes. */
  72. VOID _tx_block_pool_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence);
  73. /* Block pool management component data declarations follow. */
  74. /* Determine if the initialization function of this component is including
  75. this file. If so, make the data definitions really happen. Otherwise,
  76. make them extern so other functions in the component can access them. */
  77. #ifdef TX_BLOCK_POOL_INIT
  78. #define BLOCK_POOL_DECLARE
  79. #else
  80. #define BLOCK_POOL_DECLARE extern
  81. #endif
  82. /* Define the head pointer of the created block pool list. */
  83. BLOCK_POOL_DECLARE TX_BLOCK_POOL * _tx_block_pool_created_ptr;
  84. /* Define the variable that holds the number of created block pools. */
  85. BLOCK_POOL_DECLARE ULONG _tx_block_pool_created_count;
  86. #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
  87. /* Define the total number of block allocates. */
  88. BLOCK_POOL_DECLARE ULONG _tx_block_pool_performance_allocate_count;
  89. /* Define the total number of block releases. */
  90. BLOCK_POOL_DECLARE ULONG _tx_block_pool_performance_release_count;
  91. /* Define the total number of block pool suspensions. */
  92. BLOCK_POOL_DECLARE ULONG _tx_block_pool_performance_suspension_count;
  93. /* Define the total number of block pool timeouts. */
  94. BLOCK_POOL_DECLARE ULONG _tx_block_pool_performance_timeout_count;
  95. #endif
  96. /* Define default post block pool delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h). */
  97. #ifndef TX_BLOCK_POOL_DELETE_PORT_COMPLETION
  98. #define TX_BLOCK_POOL_DELETE_PORT_COMPLETION(p)
  99. #endif
  100. #endif