tsi_malloc_intern.h
Go to the documentation of this file.
1
2
/** @addtogroup GRAPHICS_SDK Graphics
3
* @{
4
*/
5
6
/** @defgroup MALLOC_INTERNAL internal malloc
7
* @brief graphics malloc. internal used
8
* @{
9
*/
10
11
#ifndef TSI_MALLOC_INTERN_H__
12
#define TSI_MALLOC_INTERN_H__
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
18
19
/**
20
* @defgroup MALLOC_INTERNAL_MACRO Defines
21
* @{
22
*/
23
24
#ifndef MAX_MEM_POOLS
25
#define MAX_MEM_POOLS 4
/**< count of memory pool */
26
#endif // MAX_MEM_POOLS
27
28
#define ALIGNNUM (16)
/**< align bytes */
29
#define ALIGNMASK (ALIGNNUM-1)
/**< align mask */
30
#define ALIGN(s) ((((s)+ALIGNMASK)/ALIGNNUM)*ALIGNNUM)
/**< align address */
31
32
#define FLAG_EMPTY 0xf1fa1U
/**< empty flag */
33
#define FLAG_NONEMPTY 0xf1fa2U
/**< non-empty flag */
34
35
#define IS_LAST(c) ( (c)->next_offset == 0U )
/**< check is last or not */
36
#define OFFSET(c) ((uintptr_t)(c) - (uintptr_t)HEAD)
/**< offset from pool head */
37
/** @} */
38
39
/** @addtogroup MALLOC_INTERNAL_STRUCT Structure
40
* @{
41
*/
42
43
/**
44
* @brief memory cell structure
45
*/
46
typedef
struct
cell
{
47
int
size
;
/**< cell size */
48
unsigned
flags
;
/**< cell state flag */
49
uintptr_t
next_offset
;
/**< Next cell offset */
50
}
cell_t
;
51
52
/**
53
* @brief size of memory cell structure
54
*/
55
static
const
int
cell_t_size
= (
ALIGN
((
int
)
sizeof
(
cell_t
)));
56
57
/**
58
* @brief memory pool structure
59
*/
60
typedef
struct
pool
{
61
uintptr_t
base_phys
;
/**< base physical address for pool */
62
uintptr_t
base_virt
;
/**< base virtual address for pool */
63
uintptr_t
end_virt
;
/**< end virtual address for pool */
64
cell_t
*
head_of_empty_list
;
/**< list pointer */
65
int
size
;
/**< pool size in bytes */
66
}
pool_t
;
67
68
/** @} */
69
70
#ifdef __cplusplus
71
}
72
#endif
73
74
#endif
75
76
/** @} */
77
/** @} */
78
ALIGN
#define ALIGN(s)
Definition:
tsi_malloc_intern.h:30
pool::head_of_empty_list
cell_t * head_of_empty_list
Definition:
tsi_malloc_intern.h:64
cell_t
struct cell cell_t
memory cell structure
pool::end_virt
uintptr_t end_virt
Definition:
tsi_malloc_intern.h:63
pool::base_phys
uintptr_t base_phys
Definition:
tsi_malloc_intern.h:61
cell_t_size
static const int cell_t_size
size of memory cell structure
Definition:
tsi_malloc_intern.h:55
cell::next_offset
uintptr_t next_offset
Definition:
tsi_malloc_intern.h:49
pool_t
struct pool pool_t
memory pool structure
cell
memory cell structure
Definition:
tsi_malloc_intern.h:46
pool::base_virt
uintptr_t base_virt
Definition:
tsi_malloc_intern.h:62
cell::size
int size
Definition:
tsi_malloc_intern.h:47
pool
memory pool structure
Definition:
tsi_malloc_intern.h:60
pool::size
int size
Definition:
tsi_malloc_intern.h:65
cell::flags
unsigned flags
Definition:
tsi_malloc_intern.h:48