1 /* TSI 2023.xmo */
2 /*******************************************************************************
3  * Copyright (c) 2023 Think Silicon Single Member PC
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this header file and/or associated documentation files to use, copy,
7  * modify, merge, publish, distribute, sublicense, and/or sell copies of the
8  * Materials, and to permit persons to whom the Materials are furnished to do
9  * so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Materials.
13  *
14  * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
15  * NEMAGFX API. THE UNMODIFIED, NORMATIVE VERSIONS OF THINK-SILICON NEMAGFX
16  * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT:
17  *   https://think-silicon.com/products/software/nemagfx-api
18  *
19  *  The software is provided 'as is', without warranty of any kind, express or
20  *  implied, including but not limited to the warranties of merchantability,
21  *  fitness for a particular purpose and noninfringement. In no event shall
22  *  Think Silicon Single Member PC be liable for any claim, damages or other
23  *  liability, whether in an action of contract, tort or otherwise, arising
24  *  from, out of or in connection with the software or the use or other dealings
25  *  in the software.
26  ******************************************************************************/
27 
28 #ifndef TSI_MALLOC_H__
29 #define TSI_MALLOC_H__
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 
36 #define tsi_malloc_init(base_virt, base_phys, size, reset) \
37 		tsi_malloc_init_pool(0, base_virt, base_phys, size, reset)
38 
39 #define tsi_malloc(size) tsi_malloc_pool(0, size)
40 
41 int   tsi_malloc_init_pool(	int pool,
42 						   	void *base_virt,
43 						   	uintptr_t base_phys,
44 						   	int size,
45 						   	int reset);
46 
47 int   tsi_malloc_init_pool_aligned(	int pool,
48 						   	        void *base_virt,
49 						   	        uintptr_t base_phys,
50 						   	        int size,
51 						   	        int reset,
52 							        int alignment); /*alignment must be multiple of 4, otherwise it will be overwritten internaly to be multiple of 4*/
53 
54 void *tsi_malloc_pool(int pool, int size);
55 void  tsi_free(void *ptr);
56 uintptr_t tsi_virt2phys(void *addr);
57 void *tsi_phys2virt(uintptr_t addr);
58 
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif
65