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