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 /**   Block Memory                                                        */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  COMPONENT DEFINITION                                   RELEASE        */
27 /*                                                                        */
28 /*    tx_block_pool.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 block memory 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_BLOCK_POOL_H
51 #define TX_BLOCK_POOL_H
52 
53 
54 /* Define block memory control specific data definitions.  */
55 
56 #define TX_BLOCK_POOL_ID                        ((ULONG) 0x424C4F43)
57 
58 
59 /* Determine if in-line component initialization is supported by the
60    caller.  */
61 
62 #ifdef TX_INVOKE_INLINE_INITIALIZATION
63 
64 /* Yes, in-line initialization is supported, remap the block memory pool
65    initialization function.  */
66 
67 #ifndef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
68 #define _tx_block_pool_initialize() \
69                     _tx_block_pool_created_ptr =                   TX_NULL;     \
70                     _tx_block_pool_created_count =                 TX_EMPTY
71 #else
72 #define _tx_block_pool_initialize() \
73                     _tx_block_pool_created_ptr =                   TX_NULL;     \
74                     _tx_block_pool_created_count =                 TX_EMPTY;    \
75                     _tx_block_pool_performance_allocate_count =    ((ULONG) 0); \
76                     _tx_block_pool_performance_release_count =     ((ULONG) 0); \
77                     _tx_block_pool_performance_suspension_count =  ((ULONG) 0); \
78                     _tx_block_pool_performance_timeout_count =     ((ULONG) 0)
79 #endif
80 #define TX_BLOCK_POOL_INIT
81 #else
82 
83 /* No in-line initialization is supported, use standard function call.  */
84 VOID        _tx_block_pool_initialize(VOID);
85 #endif
86 
87 
88 /* Define internal block memory pool management function prototypes.  */
89 
90 VOID        _tx_block_pool_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence);
91 
92 
93 /* Block pool management component data declarations follow.  */
94 
95 /* Determine if the initialization function of this component is including
96    this file.  If so, make the data definitions really happen.  Otherwise,
97    make them extern so other functions in the component can access them.  */
98 
99 #ifdef TX_BLOCK_POOL_INIT
100 #define BLOCK_POOL_DECLARE
101 #else
102 #define BLOCK_POOL_DECLARE extern
103 #endif
104 
105 
106 /* Define the head pointer of the created block pool list.  */
107 
108 BLOCK_POOL_DECLARE  TX_BLOCK_POOL *         _tx_block_pool_created_ptr;
109 
110 
111 /* Define the variable that holds the number of created block pools. */
112 
113 BLOCK_POOL_DECLARE  ULONG                   _tx_block_pool_created_count;
114 
115 
116 #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
117 
118 /* Define the total number of block allocates.  */
119 
120 BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_allocate_count;
121 
122 
123 /* Define the total number of block releases.  */
124 
125 BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_release_count;
126 
127 
128 /* Define the total number of block pool suspensions.  */
129 
130 BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_suspension_count;
131 
132 
133 /* Define the total number of block pool timeouts.  */
134 
135 BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_timeout_count;
136 
137 
138 #endif
139 
140 
141 /* Define default post block pool delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */
142 
143 #ifndef TX_BLOCK_POOL_DELETE_PORT_COMPLETION
144 #define TX_BLOCK_POOL_DELETE_PORT_COMPLETION(p)
145 #endif
146 
147 
148 #endif
149