00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00119 #ifndef ti_sdo_linuxutils_cmem_CMEM_H
00120 #define ti_sdo_linuxutils_cmem_CMEM_H
00121
00122 #if defined (__cplusplus)
00123 extern "C" {
00124 #endif
00125
00128
00129 #define CMEM_VERSION 0x02200000U
00130
00131
00132 #define CMEM_WB 0x0100
00133 #define CMEM_INV 0x0200
00134 #define CMEM_HEAP 0x0400
00135 #define CMEM_POOL 0x0000
00136 #define CMEM_CACHED 0x0800
00137 #define CMEM_NONCACHED 0x0000
00138 #define CMEM_PHYS 0x1000
00139
00140
00141 #define CMEM_IOCALLOC 1
00142 #define CMEM_IOCALLOCHEAP 2
00143 #define CMEM_IOCFREE 3
00144 #define CMEM_IOCGETPHYS 4
00145 #define CMEM_IOCGETSIZE 5
00146 #define CMEM_IOCGETPOOL 6
00147 #define CMEM_IOCCACHE 7
00148 #define CMEM_IOCGETVERSION 8
00149 #define CMEM_IOCGETBLOCK 9
00150
00151
00152
00153
00154
00155
00156 #define CMEM_IOCCACHEWBINV CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00157 #define CMEM_IOCCACHEWB CMEM_IOCCACHE | CMEM_WB
00158 #define CMEM_IOCCACHEINV CMEM_IOCCACHE | CMEM_INV
00159 #define CMEM_IOCALLOCCACHED CMEM_IOCALLOC | CMEM_CACHED
00160 #define CMEM_IOCALLOCHEAPCACHED CMEM_IOCALLOCHEAP | CMEM_CACHED
00161 #define CMEM_IOCFREEHEAP CMEM_IOCFREE | CMEM_HEAP
00162 #define CMEM_IOCFREEPHYS CMEM_IOCFREE | CMEM_PHYS
00163 #define CMEM_IOCFREEHEAPPHYS CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00164
00165 #define CMEM_IOCCMDMASK 0x000000ff
00166
00171 typedef struct CMEM_AllocParams {
00172 int type;
00173 int flags;
00174 size_t alignment;
00177 } CMEM_AllocParams;
00178
00179 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00180
00181 typedef struct CMEM_BlockAttrs {
00182 unsigned long phys_base;
00183 size_t size;
00184 } CMEM_BlockAttrs;
00185
00190 union CMEM_AllocUnion {
00191 struct {
00192 size_t size;
00193 size_t align;
00194 int blockid;
00195 } alloc_heap_inparams;
00196 struct {
00197 int poolid;
00198 int blockid;
00199 } alloc_pool_inparams;
00200 struct {
00201 int poolid;
00202 int blockid;
00203 } get_size_inparams;
00204 struct {
00205 size_t size;
00206 int blockid;
00207 } get_pool_inparams;
00208 struct {
00209 unsigned long physp;
00210 size_t size;
00211 } alloc_pool_outparams;
00212 struct {
00213 unsigned long physp;
00214 size_t size;
00215 } get_block_outparams;
00216 struct {
00217 int poolid;
00218 size_t size;
00219 } free_outparams;
00220 unsigned long physp;
00221 unsigned long virtp;
00222 int size;
00223 int poolid;
00224 int blockid;
00225 };
00226
00236 int CMEM_init(void);
00237
00253 int CMEM_getPool(size_t size);
00254
00271 int CMEM_getPool2(int blockid, size_t size);
00272
00292 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00293
00314 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00315
00338 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00339
00364 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00365
00386 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00387
00397 unsigned long CMEM_getPhys(void *ptr);
00398
00412 int CMEM_cacheWb(void *ptr, size_t size);
00413
00427 int CMEM_cacheInv(void *ptr, size_t size);
00428
00443 int CMEM_cacheWbInv(void *ptr, size_t size);
00444
00452 int CMEM_getVersion(void);
00453
00467 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00468
00483 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00484
00497 int CMEM_exit(void);
00498
00501 #if defined (__cplusplus)
00502 }
00503 #endif
00504
00505 #endif
00506
00507
00508
00509