| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2001-2006, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bmem_config.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/6 $ |
|---|
| 12 | * $brcm_Date: 6/16/06 3:22p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/mem/bmem_config.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/6 6/16/06 3:22p albertl |
|---|
| 21 | * PR20247, PR20276, PR20354: Added the ability to control debug |
|---|
| 22 | * configuration at runtime. Added address and offset checking to |
|---|
| 23 | * conversion functions. BMEM_SetCache can now only be called before |
|---|
| 24 | * heaps are allocated from. Added BMEM_Heap functions. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/5 9/5/03 2:49p jasonh |
|---|
| 27 | * Moved ifdef to work with auto-documentation. |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/4 9/5/03 1:58p jasonh |
|---|
| 30 | * Added documentation. Removed values that aren't user-configurable and |
|---|
| 31 | * placed them in bmem_priv.h |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/3 3/21/03 6:03p erickson |
|---|
| 34 | * this version works |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/2 3/20/03 3:51p erickson |
|---|
| 37 | * renamed all MEM_ to BMEM_ |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/1 3/20/03 3:24p erickson |
|---|
| 40 | * initial bmem work, taken from SetTop/memorylib |
|---|
| 41 | * |
|---|
| 42 | ***************************************************************************/ |
|---|
| 43 | #ifndef BMEM_CONFIG_H__ |
|---|
| 44 | #define BMEM_CONFIG_H__ |
|---|
| 45 | |
|---|
| 46 | #ifndef BMEM_SAFETY_CONFIG |
|---|
| 47 | /*************************************************************************** |
|---|
| 48 | Summary: |
|---|
| 49 | Used to choose the overall policy the memory manager will follow. |
|---|
| 50 | |
|---|
| 51 | Description: |
|---|
| 52 | Selecting one of these policies applies a number of configuration |
|---|
| 53 | parameters. You can see exactly which ones by looking at the policy |
|---|
| 54 | definitions themselves. They can be one of BMEM_CONFIG_FASTEST, |
|---|
| 55 | BMEM_CONFIG_NORMAL, BMEM_CONFIG_TRACK, BMEM_CONFIG_SAFE, or |
|---|
| 56 | BMEM_CONFIG_SAFEST. The default is to use BMEM_CONFIG_SAFE. |
|---|
| 57 | |
|---|
| 58 | See Also: |
|---|
| 59 | BMEM_CONFIG_FASTEST, |
|---|
| 60 | BMEM_CONFIG_NORMAL, |
|---|
| 61 | BMEM_CONFIG_TRACK, |
|---|
| 62 | BMEM_CONFIG_SAFE, |
|---|
| 63 | BMEM_CONFIG_SAFEST |
|---|
| 64 | ****************************************************************************/ |
|---|
| 65 | #define BMEM_SAFETY_CONFIG BMEM_CONFIG_SAFE |
|---|
| 66 | #endif |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | #ifndef BMEM_BOOKKEEPING_CONFIG |
|---|
| 70 | /*************************************************************************** |
|---|
| 71 | Summary: |
|---|
| 72 | Used to choose the location of the bookkeeping information. |
|---|
| 73 | |
|---|
| 74 | Description: |
|---|
| 75 | This information can be located either right with the allocated memory |
|---|
| 76 | (typical for a UMA system) or in OS-allocated memory (typical for a |
|---|
| 77 | slave or client system). |
|---|
| 78 | |
|---|
| 79 | If there is no time penalty for accessing the managed memory with the |
|---|
| 80 | CPU, then it is recommended to use BMEM_BOOKKEEPING_LOCAL. Using OS- |
|---|
| 81 | allocated memory with BMEM_BOOKKEEPING_SYSTEM is significantly slower |
|---|
| 82 | since it uses a less efficient method of correlating bookkeeping to |
|---|
| 83 | addresses. |
|---|
| 84 | |
|---|
| 85 | The default is to use BMEM_BOOKKEEPING_LOCAL. |
|---|
| 86 | |
|---|
| 87 | See Also: |
|---|
| 88 | BMEM_BOOKKEEPING_LOCAL, |
|---|
| 89 | BMEM_BOOKKEEPING_SYSTEM |
|---|
| 90 | ****************************************************************************/ |
|---|
| 91 | #define BMEM_BOOKKEEPING_CONFIG BMEM_BOOKKEEPING_LOCAL |
|---|
| 92 | #endif |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | #ifndef BMEM_REENTRANT_CONFIG |
|---|
| 96 | /*************************************************************************** |
|---|
| 97 | Summary: |
|---|
| 98 | Used to determine whether the memory manager operates in a |
|---|
| 99 | reentrant manner. |
|---|
| 100 | |
|---|
| 101 | Description: |
|---|
| 102 | In most multithreaded situations this must be defined to ensure safe |
|---|
| 103 | operation. In guaranteed non-reentrant single-threaded operation this |
|---|
| 104 | may be undefined, which will result in a modest speed increase. |
|---|
| 105 | |
|---|
| 106 | Possible values are BMEM_REENTRANT or BMEM_NOT_REEENTRANT. The default |
|---|
| 107 | is to use BMEM_NOT_REENTRANT. |
|---|
| 108 | |
|---|
| 109 | See Also: |
|---|
| 110 | BMEM_REENTRANT, |
|---|
| 111 | BMEM_NOT_REEENTRANT |
|---|
| 112 | ****************************************************************************/ |
|---|
| 113 | #define BMEM_REENTRANT_CONFIG BMEM_NOT_REENTRANT |
|---|
| 114 | #endif |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | /*************************************************************************** |
|---|
| 118 | * There is rarely any need to modify anything below this line. |
|---|
| 119 | ***************************************************************************/ |
|---|
| 120 | |
|---|
| 121 | /*************************************************************************** |
|---|
| 122 | Summary: |
|---|
| 123 | Optimizes the settings for performance, but does no safety checks. |
|---|
| 124 | |
|---|
| 125 | Description: |
|---|
| 126 | The following settings are used: |
|---|
| 127 | |
|---|
| 128 | o No guard bytes |
|---|
| 129 | o No guard byte checking |
|---|
| 130 | o Don't track file and line number of allocations |
|---|
| 131 | o Don't check if a block is allocated before freeing |
|---|
| 132 | o Don't clear out free blocks |
|---|
| 133 | o Don't check for overlapping blocks before freeing |
|---|
| 134 | |
|---|
| 135 | See Also: |
|---|
| 136 | BMEM_SAFETY_CONFIG |
|---|
| 137 | ****************************************************************************/ |
|---|
| 138 | #define BMEM_CONFIG_FASTEST 0 |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | /*************************************************************************** |
|---|
| 142 | Summary: |
|---|
| 143 | Balances between performance and safety checks. |
|---|
| 144 | |
|---|
| 145 | Description: |
|---|
| 146 | The following settings are used: |
|---|
| 147 | |
|---|
| 148 | o Short guard byte series |
|---|
| 149 | o Check guard bytes of the block when freed |
|---|
| 150 | o Don't track file and line number of allocations |
|---|
| 151 | o Don't check if a block is allocated before freeing |
|---|
| 152 | o Don't clear out free blocks |
|---|
| 153 | o Don't Check for overlapping blocks before freeing |
|---|
| 154 | |
|---|
| 155 | See Also: |
|---|
| 156 | BMEM_SAFETY_CONFIG |
|---|
| 157 | ****************************************************************************/ |
|---|
| 158 | #define BMEM_CONFIG_NORMAL 1 |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | /*************************************************************************** |
|---|
| 162 | Summary: |
|---|
| 163 | Contains safety checks and tracks allocations. |
|---|
| 164 | |
|---|
| 165 | Description: |
|---|
| 166 | The following settings are used: |
|---|
| 167 | |
|---|
| 168 | o Short guard byte series |
|---|
| 169 | o Check guard bytes of the block when freed |
|---|
| 170 | o Track file and line number of allocations |
|---|
| 171 | o Don't check if a block is allocated before freeing |
|---|
| 172 | o Don't clear out free blocks |
|---|
| 173 | o Don't Check for overlapping blocks before freeing |
|---|
| 174 | |
|---|
| 175 | See Also: |
|---|
| 176 | BMEM_SAFETY_CONFIG |
|---|
| 177 | ****************************************************************************/ |
|---|
| 178 | #define BMEM_CONFIG_TRACK 2 |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | /*************************************************************************** |
|---|
| 182 | Summary: |
|---|
| 183 | Safe but slow. |
|---|
| 184 | |
|---|
| 185 | Description: |
|---|
| 186 | The following settings are used: |
|---|
| 187 | |
|---|
| 188 | o Medium guard byte series |
|---|
| 189 | o Check all guards on allocation and free |
|---|
| 190 | o Track file and line number of allocations |
|---|
| 191 | o Check if a block is allocated before freeing |
|---|
| 192 | o Don't clear out free blocks |
|---|
| 193 | o Don't Check for overlapping blocks before freeing |
|---|
| 194 | |
|---|
| 195 | See Also: |
|---|
| 196 | BMEM_SAFETY_CONFIG |
|---|
| 197 | ****************************************************************************/ |
|---|
| 198 | #define BMEM_CONFIG_SAFE 3 |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | /*************************************************************************** |
|---|
| 202 | Summary: |
|---|
| 203 | Safest configuration possible and very slow. |
|---|
| 204 | |
|---|
| 205 | Description: |
|---|
| 206 | The following settings are used: |
|---|
| 207 | |
|---|
| 208 | o Long guard byte series |
|---|
| 209 | o Check all guards on allocation and free |
|---|
| 210 | o Track file and line number of allocations |
|---|
| 211 | o Check if a block is allocated before freeing. |
|---|
| 212 | o Clear out free blocks |
|---|
| 213 | o Check for overlapping blocks on free. |
|---|
| 214 | |
|---|
| 215 | See Also: |
|---|
| 216 | BMEM_SAFETY_CONFIG |
|---|
| 217 | ****************************************************************************/ |
|---|
| 218 | #define BMEM_CONFIG_SAFEST 4 |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | /*************************************************************************** |
|---|
| 222 | Summary: |
|---|
| 223 | Use the managed memory to store bookkeeping information. |
|---|
| 224 | |
|---|
| 225 | See Also: |
|---|
| 226 | BMEM_BOOKKEEPING_CONFIG |
|---|
| 227 | ****************************************************************************/ |
|---|
| 228 | #define BMEM_BOOKKEEPING_LOCAL 0 |
|---|
| 229 | |
|---|
| 230 | /*************************************************************************** |
|---|
| 231 | Summary: |
|---|
| 232 | Use memory allocated by the OS to store bookkeeping information. |
|---|
| 233 | |
|---|
| 234 | See Also: |
|---|
| 235 | BMEM_BOOKKEEPING_CONFIG |
|---|
| 236 | ****************************************************************************/ |
|---|
| 237 | #define BMEM_BOOKKEEPING_SYSTEM 1 |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | /*************************************************************************** |
|---|
| 241 | Summary: |
|---|
| 242 | This module will use semaphores to protect against rentrancy. |
|---|
| 243 | |
|---|
| 244 | See Also: |
|---|
| 245 | BMEM_REENTRANT_CONFIG |
|---|
| 246 | ****************************************************************************/ |
|---|
| 247 | #define BMEM_REENTRANT 0 |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | /*************************************************************************** |
|---|
| 251 | Summary: |
|---|
| 252 | User guaranteed that reentrant calls won't be made into this module. |
|---|
| 253 | Semaphores will not be used. |
|---|
| 254 | |
|---|
| 255 | See Also: |
|---|
| 256 | BMEM_REENTRANT_CONFIG |
|---|
| 257 | ****************************************************************************/ |
|---|
| 258 | #define BMEM_NOT_REENTRANT 1 |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | #endif /* #ifndef BMEM_CONFIG_H__ */ |
|---|
| 262 | |
|---|
| 263 | /* End of File */ |
|---|
| 264 | |
|---|