tsi_malloc_intern.h
Go to the documentation of this file.
1
/**
2
****************************************************************************************
3
*
4
* @file tsi_malloc_intern.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 MALLOC_INTERNAL GPU Internal Malloc
47
* @brief graphics malloc. internal used
48
* @{
49
*/
50
51
#ifndef TSI_MALLOC_INTERN_H__
52
#define TSI_MALLOC_INTERN_H__
53
54
#ifdef __cplusplus
55
extern
"C"
{
56
#endif
57
58
59
/**
60
* @defgroup MALLOC_INTERNAL_MACRO Defines
61
* @{
62
*/
63
64
#ifndef MAX_MEM_POOLS
65
#define MAX_MEM_POOLS 4
/**< count of memory pool */
66
#endif // MAX_MEM_POOLS
67
68
#define ALIGNNUM (16)
/**< align bytes */
69
#define ALIGNMASK (ALIGNNUM-1)
/**< align mask */
70
#define ALIGN(s) ((((s)+ALIGNMASK)/ALIGNNUM)*ALIGNNUM)
/**< align address */
71
72
#define FLAG_EMPTY 0xf1fa1U
/**< empty flag */
73
#define FLAG_NONEMPTY 0xf1fa2U
/**< non-empty flag */
74
75
#define IS_LAST(c) ( (c)->next_offset == 0U )
/**< check is last or not */
76
#define OFFSET(c) ((uintptr_t)(c) - (uintptr_t)HEAD)
/**< offset from pool head */
77
/** @} */
78
79
/** @addtogroup MALLOC_INTERNAL_STRUCT Structure
80
* @{
81
*/
82
83
/**
84
* @brief memory cell structure
85
*/
86
typedef
struct
cell
{
87
int
size
;
/**< cell size */
88
unsigned
flags
;
/**< cell state flag */
89
uintptr_t
next_offset
;
/**< Next cell offset */
90
}
cell_t
;
91
92
/**
93
* @brief size of memory cell structure
94
*/
95
static
const
int
cell_t_size
= (
ALIGN
((
int
)
sizeof
(
cell_t
)));
96
97
/**
98
* @brief memory pool structure
99
*/
100
typedef
struct
pool
{
101
uintptr_t
base_phys
;
/**< base physical address for pool */
102
uintptr_t
base_virt
;
/**< base virtual address for pool */
103
uintptr_t
end_virt
;
/**< end virtual address for pool */
104
cell_t
*
head_of_empty_list
;
/**< list pointer */
105
int
size
;
/**< pool size in bytes */
106
}
pool_t
;
107
108
/** @} */
109
110
#ifdef __cplusplus
111
}
112
#endif
113
114
#endif
115
116
/** @} */
117
/** @} */
118
/** @} */
119
ALIGN
#define ALIGN(s)
align address
Definition:
tsi_malloc_intern.h:70
pool::head_of_empty_list
cell_t * head_of_empty_list
list pointer
Definition:
tsi_malloc_intern.h:104
cell_t
struct cell cell_t
memory cell structure
pool::end_virt
uintptr_t end_virt
end virtual address for pool
Definition:
tsi_malloc_intern.h:103
pool::base_phys
uintptr_t base_phys
base physical address for pool
Definition:
tsi_malloc_intern.h:101
cell_t_size
static const int cell_t_size
size of memory cell structure
Definition:
tsi_malloc_intern.h:95
cell::next_offset
uintptr_t next_offset
Next cell offset.
Definition:
tsi_malloc_intern.h:89
pool_t
struct pool pool_t
memory pool structure
cell
memory cell structure
Definition:
tsi_malloc_intern.h:86
pool::base_virt
uintptr_t base_virt
base virtual address for pool
Definition:
tsi_malloc_intern.h:102
cell::size
int size
cell size
Definition:
tsi_malloc_intern.h:87
pool
memory pool structure
Definition:
tsi_malloc_intern.h:100
pool::size
int size
pool size in bytes
Definition:
tsi_malloc_intern.h:105
cell::flags
unsigned flags
cell state flag
Definition:
tsi_malloc_intern.h:88