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 Memory */
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_trace.h"
29 #include "tx_block_pool.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _tx_block_pool_info_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* William E. Lamie, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function retrieves information from the specified block pool. */
45 /* */
46 /* INPUT */
47 /* */
48 /* pool_ptr Pointer to block pool control blk */
49 /* name Destination for the pool name */
50 /* available_blocks Number of free blocks in pool */
51 /* total_blocks Total number of blocks in pool */
52 /* first_suspended Destination for pointer of first */
53 /* thread suspended on block pool */
54 /* suspended_count Destination for suspended count */
55 /* next_pool Destination for pointer to next */
56 /* block pool on the created list */
57 /* */
58 /* OUTPUT */
59 /* */
60 /* status Completion status */
61 /* */
62 /* CALLS */
63 /* */
64 /* None */
65 /* */
66 /* CALLED BY */
67 /* */
68 /* Application Code */
69 /* */
70 /* RELEASE HISTORY */
71 /* */
72 /* DATE NAME DESCRIPTION */
73 /* */
74 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
75 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
76 /* resulting in version 6.1 */
77 /* */
78 /**************************************************************************/
_tx_block_pool_info_get(TX_BLOCK_POOL * pool_ptr,CHAR ** name,ULONG * available_blocks,ULONG * total_blocks,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_BLOCK_POOL ** next_pool)79 UINT _tx_block_pool_info_get(TX_BLOCK_POOL *pool_ptr, CHAR **name, ULONG *available_blocks,
80 ULONG *total_blocks, TX_THREAD **first_suspended,
81 ULONG *suspended_count, TX_BLOCK_POOL **next_pool)
82 {
83
84 TX_INTERRUPT_SAVE_AREA
85
86
87 /* Disable interrupts. */
88 TX_DISABLE
89
90 /* If trace is enabled, insert this event into the trace buffer. */
91 TX_TRACE_IN_LINE_INSERT(TX_TRACE_BLOCK_POOL_INFO_GET, pool_ptr, 0, 0, 0, TX_TRACE_BLOCK_POOL_EVENTS)
92
93 /* Log this kernel call. */
94 TX_EL_BLOCK_POOL_INFO_GET_INSERT
95
96 /* Retrieve all the pertinent information and return it in the supplied
97 destinations. */
98
99 /* Retrieve the name of the block pool. */
100 if (name != TX_NULL)
101 {
102
103 *name = pool_ptr -> tx_block_pool_name;
104 }
105
106 /* Retrieve the number of available blocks in the block pool. */
107 if (available_blocks != TX_NULL)
108 {
109
110 *available_blocks = (ULONG) pool_ptr -> tx_block_pool_available;
111 }
112
113 /* Retrieve the total number of blocks in the block pool. */
114 if (total_blocks != TX_NULL)
115 {
116
117 *total_blocks = (ULONG) pool_ptr -> tx_block_pool_total;
118 }
119
120 /* Retrieve the first thread suspended on this block pool. */
121 if (first_suspended != TX_NULL)
122 {
123
124 *first_suspended = pool_ptr -> tx_block_pool_suspension_list;
125 }
126
127 /* Retrieve the number of threads suspended on this block pool. */
128 if (suspended_count != TX_NULL)
129 {
130
131 *suspended_count = (ULONG) pool_ptr -> tx_block_pool_suspended_count;
132 }
133
134 /* Retrieve the pointer to the next block pool created. */
135 if (next_pool != TX_NULL)
136 {
137
138 *next_pool = pool_ptr -> tx_block_pool_created_next;
139 }
140
141 /* Restore interrupts. */
142 TX_RESTORE
143
144 /* Return completion status. */
145 return(TX_SUCCESS);
146 }
147
148