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 /** Byte Memory */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /**************************************************************************/ 25 /* */ 26 /* COMPONENT DEFINITION RELEASE */ 27 /* */ 28 /* tx_byte_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 byte 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_BYTE_POOL_H 51 #define TX_BYTE_POOL_H 52 53 54 /* Define byte memory control specific data definitions. */ 55 56 #define TX_BYTE_POOL_ID ((ULONG) 0x42595445) 57 58 #ifndef TX_BYTE_BLOCK_FREE 59 #define TX_BYTE_BLOCK_FREE ((ULONG) 0xFFFFEEEEUL) 60 #endif 61 62 #ifndef TX_BYTE_BLOCK_MIN 63 #define TX_BYTE_BLOCK_MIN ((ULONG) 20) 64 #endif 65 66 #ifndef TX_BYTE_POOL_MIN 67 #define TX_BYTE_POOL_MIN ((ULONG) 100) 68 #endif 69 70 71 /* Determine if in-line component initialization is supported by the 72 caller. */ 73 74 #ifdef TX_INVOKE_INLINE_INITIALIZATION 75 76 /* Yes, in-line initialization is supported, remap the byte memory pool 77 initialization function. */ 78 79 #ifndef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO 80 #define _tx_byte_pool_initialize() \ 81 _tx_byte_pool_created_ptr = TX_NULL; \ 82 _tx_byte_pool_created_count = TX_EMPTY 83 #else 84 #define _tx_byte_pool_initialize() \ 85 _tx_byte_pool_created_ptr = TX_NULL; \ 86 _tx_byte_pool_created_count = TX_EMPTY; \ 87 _tx_byte_pool_performance_allocate_count = ((ULONG) 0); \ 88 _tx_byte_pool_performance_release_count = ((ULONG) 0); \ 89 _tx_byte_pool_performance_merge_count = ((ULONG) 0); \ 90 _tx_byte_pool_performance_split_count = ((ULONG) 0); \ 91 _tx_byte_pool_performance_search_count = ((ULONG) 0); \ 92 _tx_byte_pool_performance_suspension_count = ((ULONG) 0); \ 93 _tx_byte_pool_performance_timeout_count = ((ULONG) 0) 94 #endif 95 #define TX_BYTE_POOL_INIT 96 #else 97 98 /* No in-line initialization is supported, use standard function call. */ 99 VOID _tx_byte_pool_initialize(VOID); 100 #endif 101 102 103 /* Define internal byte memory pool management function prototypes. */ 104 105 UCHAR *_tx_byte_pool_search(TX_BYTE_POOL *pool_ptr, ULONG memory_size); 106 VOID _tx_byte_pool_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); 107 108 109 /* Byte pool management component data declarations follow. */ 110 111 /* Determine if the initialization function of this component is including 112 this file. If so, make the data definitions really happen. Otherwise, 113 make them extern so other functions in the component can access them. */ 114 115 #ifdef TX_BYTE_POOL_INIT 116 #define BYTE_POOL_DECLARE 117 #else 118 #define BYTE_POOL_DECLARE extern 119 #endif 120 121 122 /* Define the head pointer of the created byte pool list. */ 123 124 BYTE_POOL_DECLARE TX_BYTE_POOL * _tx_byte_pool_created_ptr; 125 126 127 /* Define the variable that holds the number of created byte pools. */ 128 129 BYTE_POOL_DECLARE ULONG _tx_byte_pool_created_count; 130 131 132 #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO 133 134 /* Define the total number of allocates. */ 135 136 BYTE_POOL_DECLARE ULONG _tx_byte_pool_performance_allocate_count; 137 138 139 /* Define the total number of releases. */ 140 141 BYTE_POOL_DECLARE ULONG _tx_byte_pool_performance_release_count; 142 143 144 /* Define the total number of adjacent memory fragment merges. */ 145 146 BYTE_POOL_DECLARE ULONG _tx_byte_pool_performance_merge_count; 147 148 149 /* Define the total number of memory fragment splits. */ 150 151 BYTE_POOL_DECLARE ULONG _tx_byte_pool_performance_split_count; 152 153 154 /* Define the total number of memory fragments searched during allocation. */ 155 156 BYTE_POOL_DECLARE ULONG _tx_byte_pool_performance_search_count; 157 158 159 /* Define the total number of byte pool suspensions. */ 160 161 BYTE_POOL_DECLARE ULONG _tx_byte_pool_performance_suspension_count; 162 163 164 /* Define the total number of byte pool timeouts. */ 165 166 BYTE_POOL_DECLARE ULONG _tx_byte_pool_performance_timeout_count; 167 168 169 #endif 170 171 172 /* Define default post byte pool delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h). */ 173 174 #ifndef TX_BYTE_POOL_DELETE_PORT_COMPLETION 175 #define TX_BYTE_POOL_DELETE_PORT_COMPLETION(p) 176 #endif 177 178 179 #endif 180