[sub1ghz-sensor-to-cloud/tida01476.git] / sensor_cc1310lp / Application / MAC / OSAL / osal_memory.h
1 /******************************************************************************
3 @file osal_memory.h
5 @brief This module defines the OSAL memory control functions.
7 Group: WCS, LPC, BTS
8 Target Device: CC13xx
10 ******************************************************************************
12 Copyright (c) 2004-2017, Texas Instruments Incorporated
13 All rights reserved.
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions
17 are met:
19 * Redistributions of source code must retain the above copyright
20 notice, this list of conditions and the following disclaimer.
22 * Redistributions in binary form must reproduce the above copyright
23 notice, this list of conditions and the following disclaimer in the
24 documentation and/or other materials provided with the distribution.
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 its contributors may be used to endorse or promote products derived
28 from this software without specific prior written permission.
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 ******************************************************************************
43 Release Name: simplelink_cc13x0_sdk_1_30_00_06"
44 Release Date: 2017-03-08 14:43:25
45 *****************************************************************************/
47 #ifndef OSAL_MEMORY_H
48 #define OSAL_MEMORY_H
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
55 /*********************************************************************
56 * INCLUDES
57 */
58 #include "comdef.h"
60 /*********************************************************************
61 * CONSTANTS
62 */
64 #if !defined ( OSALMEM_METRICS )
65 #define OSALMEM_METRICS FALSE
66 #endif
68 /*********************************************************************
69 * MACROS
70 */
72 #define osal_stack_used() OnBoard_stack_used()
74 /*********************************************************************
75 * TYPEDEFS
76 */
78 /*********************************************************************
79 * GLOBAL VARIABLES
80 */
82 /*********************************************************************
83 * FUNCTIONS
84 */
86 /*
87 * Initialize memory manager.
88 */
89 void osal_mem_init( void );
91 /*
92 * Setup efficient search for the first free block of heap.
93 */
94 void osal_mem_kick( void );
96 /*
97 * Allocate a block of memory.
98 */
99 #ifdef DPRINTF_OSALHEAPTRACE
100 void *osal_mem_alloc_dbg( uint16 size, const char *fname, unsigned lnum );
101 #define osal_mem_alloc(_size ) osal_mem_alloc_dbg(_size, __FILE__, __LINE__)
102 #else /* DPRINTF_OSALHEAPTRACE */
103 void *osal_mem_alloc( uint16 size );
104 #endif /* DPRINTF_OSALHEAPTRACE */
106 /*
107 * Free a block of memory.
108 */
109 #ifdef DPRINTF_OSALHEAPTRACE
110 void osal_mem_free_dbg( void *ptr, const char *fname, unsigned lnum );
111 #define osal_mem_free(_ptr ) osal_mem_free_dbg(_ptr, __FILE__, __LINE__)
112 #else /* DPRINTF_OSALHEAPTRACE */
113 void osal_mem_free( void *ptr );
114 #endif /* DPRINTF_OSALHEAPTRACE */
116 #if ( OSALMEM_METRICS )
117 /*
118 * Return the maximum number of blocks ever allocated at once.
119 */
120 uint16 osal_heap_block_max( void );
122 /*
123 * Return the current number of blocks now allocated.
124 */
125 uint16 osal_heap_block_cnt( void );
127 /*
128 * Return the current number of free blocks.
129 */
130 uint16 osal_heap_block_free( void );
132 /*
133 * Return the current number of bytes allocated.
134 */
135 uint16 osal_heap_mem_used( void );
136 #endif
138 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
139 /*
140 * Return the highest number of bytes ever used in the heap.
141 */
142 uint16 osal_heap_high_water( void );
143 #endif
145 /*********************************************************************
146 *********************************************************************/
148 #ifdef __cplusplus
149 }
150 #endif
152 #endif /* #ifndef OSAL_MEMORY_H */