tsi_malloc.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file tsi_malloc.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of Graphics library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup GRAPHICS_SDK Graphics
39  * @{
40  */
41 
42 /** @addtogroup GRAPHICS_COMMON Common
43  * @{
44  */
45 
46 /** @defgroup TSI_MALLOC GPU Memory Interfaces
47  * @brief GPU memory manage interfaces
48  * @{
49  */
50 
51 #ifndef TSI_MALLOC_H__
52 #define TSI_MALLOC_H__
53 
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /**
60  * @defgroup TSI_MALLOC_MACRO Definations
61  * @{
62  */
63 
64 #define tsi_malloc_init(base_virt, base_phys, size, reset) \
65  tsi_malloc_init_pool(0, base_virt, base_phys, size, reset) /**< Tsi_malloc_init define */
66 
67 #define tsi_malloc(size) tsi_malloc_pool(0, size) /**< Tsi_malloc define */
68 
69 /** @} */
70 
71 /**
72  * @defgroup TSI_MALLOC_FUNCTION Functions
73  * @{
74  */
75 
76 /**
77  *****************************************************************************************
78  * @brief Initial memory pool, command list memory malloc base on pool
79  * @param[in] pool: Pool id, the value is fixed -- 0
80  * @param[in] base_virt: Virtual addr, equel physical address
81  * @param[in] base_phys: Physical address
82  * @param[in] size: Pool memory size
83  * @param[in] reset: If 0, reset the memory
84  * @return Return Negative mean initial failure
85  *****************************************************************************************
86  */
88  void *base_virt,
89  uintptr_t base_phys,
90  int size,
91  int reset);
92 
93 /**
94  *****************************************************************************************
95  * @brief Malloc memory from pool
96  * @param[in] pool: Pool id, the value is fixed -- 0
97  * @param[in] size: Malloc size
98  * @return Return the malloc memory addr
99  *****************************************************************************************
100  */
101 void *tsi_malloc_pool(int pool, int size);
102 
103 /**
104  *****************************************************************************************
105  * @brief Free memory
106  * @param[in] ptr: Memory addr
107  *****************************************************************************************
108  */
109 void tsi_free(void *ptr);
110 
111 /**
112  *****************************************************************************************
113  * @brief Free memory
114  * @param[in] addr: Memory virtual addr, equel physical address
115  * @return Return memory addr
116  *****************************************************************************************
117  */
118 uintptr_t tsi_virt2phys(void *addr);
119 
120 /** @} */
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif
127 
128 /** @} */
129 /** @} */
130 /** @} */
131 
tsi_malloc_init_pool
int tsi_malloc_init_pool(int pool, void *base_virt, uintptr_t base_phys, int size, int reset)
Initial memory pool, command list memory malloc base on pool.
tsi_free
void tsi_free(void *ptr)
Free memory.
tsi_malloc_pool
void * tsi_malloc_pool(int pool, int size)
Malloc memory from pool.
tsi_virt2phys
uintptr_t tsi_virt2phys(void *addr)
Free memory.
pool
memory pool structure
Definition: tsi_malloc_intern.h:100