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 /**************************************************************************/
14 /**                                                                       */
15 /** ThreadX Component                                                     */
16 /**                                                                       */
17 /**   Block Pool                                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define TX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "tx_api.h"
28 #include "tx_block_pool.h"
29 
30 
31 #ifndef TX_INLINE_INITIALIZATION
32 
33 /* Locate block pool component data in this file.  */
34 
35 /* Define the head pointer of the created block pool list.  */
36 
37 TX_BLOCK_POOL *  _tx_block_pool_created_ptr;
38 
39 
40 /* Define the variable that holds the number of created block pools. */
41 
42 ULONG            _tx_block_pool_created_count;
43 
44 
45 #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
46 
47 /* Define the total number of block allocates.  */
48 
49 ULONG            _tx_block_pool_performance_allocate_count;
50 
51 
52 /* Define the total number of block releases.  */
53 
54 ULONG            _tx_block_pool_performance_release_count;
55 
56 
57 /* Define the total number of block pool suspensions.  */
58 
59 ULONG            _tx_block_pool_performance_suspension_count;
60 
61 
62 /* Define the total number of block pool timeouts.  */
63 
64 ULONG            _tx_block_pool_performance_timeout_count;
65 
66 #endif
67 
68 
69 /**************************************************************************/
70 /*                                                                        */
71 /*  FUNCTION                                               RELEASE        */
72 /*                                                                        */
73 /*    _tx_block pool_initialize                           PORTABLE C      */
74 /*                                                           6.1          */
75 /*  AUTHOR                                                                */
76 /*                                                                        */
77 /*    William E. Lamie, Microsoft Corporation                             */
78 /*                                                                        */
79 /*  DESCRIPTION                                                           */
80 /*                                                                        */
81 /*    This function initializes the various control data structures for   */
82 /*    the block pool component.                                           */
83 /*                                                                        */
84 /*  INPUT                                                                 */
85 /*                                                                        */
86 /*    None                                                                */
87 /*                                                                        */
88 /*  OUTPUT                                                                */
89 /*                                                                        */
90 /*    None                                                                */
91 /*                                                                        */
92 /*  CALLS                                                                 */
93 /*                                                                        */
94 /*    None                                                                */
95 /*                                                                        */
96 /*  CALLED BY                                                             */
97 /*                                                                        */
98 /*    _tx_initialize_high_level         High level initialization         */
99 /*                                                                        */
100 /*  RELEASE HISTORY                                                       */
101 /*                                                                        */
102 /*    DATE              NAME                      DESCRIPTION             */
103 /*                                                                        */
104 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
105 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
106 /*                                            opt out of function when    */
107 /*                                            TX_INLINE_INITIALIZATION is */
108 /*                                            defined,                    */
109 /*                                            resulting in version 6.1    */
110 /*                                                                        */
111 /**************************************************************************/
_tx_block_pool_initialize(VOID)112 VOID  _tx_block_pool_initialize(VOID)
113 {
114 
115 #ifndef TX_DISABLE_REDUNDANT_CLEARING
116 
117     /* Initialize the head pointer of the created block pools list and the
118        number of block pools created.  */
119     _tx_block_pool_created_ptr =        TX_NULL;
120     _tx_block_pool_created_count =      TX_EMPTY;
121 
122 #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
123 
124     /* Initialize block pool performance counters.  */
125     _tx_block_pool_performance_allocate_count =    ((ULONG) 0);
126     _tx_block_pool_performance_release_count =     ((ULONG) 0);
127     _tx_block_pool_performance_suspension_count =  ((ULONG) 0);
128     _tx_block_pool_performance_timeout_count =     ((ULONG) 0);
129 #endif
130 #endif
131 }
132 #endif
133