cmem.h
Go to the documentation of this file.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
00158 #ifndef ti_sdo_linuxutils_cmem_CMEM_H
00159 #define ti_sdo_linuxutils_cmem_CMEM_H
00160
00161 #if defined (__cplusplus)
00162 extern "C" {
00163 #endif
00164
00167
00168 #define CMEM_VERSION 0x03000100U
00169
00170
00171 #define CMEM_WB 0x00010000
00172 #define CMEM_INV 0x00020000
00173 #define CMEM_HEAP 0x00040000
00174 #define CMEM_POOL 0x00000000
00175 #define CMEM_CACHED 0x00080000
00176 #define CMEM_NONCACHED 0x00000000
00177 #define CMEM_PHYS 0x00100000
00178
00179 #define CMEM_IOCMAGIC 0x0000fe00
00180
00181
00182 #define CMEM_IOCALLOC 1
00183 #define CMEM_IOCALLOCHEAP 2
00184 #define CMEM_IOCFREE 3
00185 #define CMEM_IOCGETPHYS 4
00186 #define CMEM_IOCGETSIZE 5
00187 #define CMEM_IOCGETPOOL 6
00188 #define CMEM_IOCCACHE 7
00189 #define CMEM_IOCGETVERSION 8
00190 #define CMEM_IOCGETBLOCK 9
00191 #define CMEM_IOCREGUSER 10
00192 #define CMEM_IOCGETNUMBLOCKS 11
00193
00194
00195
00196
00197
00198
00199 #define CMEM_IOCCACHEWBINV CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00200 #define CMEM_IOCCACHEWB CMEM_IOCCACHE | CMEM_WB
00201 #define CMEM_IOCCACHEINV CMEM_IOCCACHE | CMEM_INV
00202 #define CMEM_IOCALLOCCACHED CMEM_IOCALLOC | CMEM_CACHED
00203 #define CMEM_IOCALLOCHEAPCACHED CMEM_IOCALLOCHEAP | CMEM_CACHED
00204 #define CMEM_IOCFREEHEAP CMEM_IOCFREE | CMEM_HEAP
00205 #define CMEM_IOCFREEPHYS CMEM_IOCFREE | CMEM_PHYS
00206 #define CMEM_IOCFREEHEAPPHYS CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00207
00208 #define CMEM_IOCCMDMASK 0x000000ff
00209
00214 typedef struct CMEM_AllocParams {
00215 int type;
00216 int flags;
00217 size_t alignment;
00220 } CMEM_AllocParams;
00221
00222 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00223
00224 typedef struct CMEM_BlockAttrs {
00225 unsigned long phys_base;
00226 size_t size;
00227 } CMEM_BlockAttrs;
00228
00233 union CMEM_AllocUnion {
00234 struct {
00235 size_t size;
00236 size_t align;
00237 int blockid;
00238 } alloc_heap_inparams;
00239 struct {
00240 int poolid;
00241 int blockid;
00242 } alloc_pool_inparams;
00243 struct {
00244 int poolid;
00245 int blockid;
00246 } get_size_inparams;
00247 struct {
00248 size_t size;
00249 int blockid;
00250 } get_pool_inparams;
00251 struct {
00252 unsigned long physp;
00253 size_t size;
00254 } alloc_pool_outparams;
00255 struct {
00256 unsigned long physp;
00257 size_t size;
00258 } get_block_outparams;
00259 struct {
00260 int poolid;
00261 size_t size;
00262 } free_outparams;
00263 unsigned long physp;
00264 unsigned long virtp;
00265 size_t size;
00266 int poolid;
00267 int blockid;
00268 };
00269
00279 int CMEM_init(void);
00280
00296 int CMEM_getPool(size_t size);
00297
00314 int CMEM_getPool2(int blockid, size_t size);
00315
00337 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00338
00361 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00362
00387 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00388
00415 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00416
00440 void *CMEM_registerAlloc(unsigned long physp);
00441
00464 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00465
00488 int CMEM_unregister(void *ptr, CMEM_AllocParams *params);
00489
00499 unsigned long CMEM_getPhys(void *ptr);
00500
00514 int CMEM_cacheWb(void *ptr, size_t size);
00515
00529 int CMEM_cacheInv(void *ptr, size_t size);
00530
00545 int CMEM_cacheWbInv(void *ptr, size_t size);
00546
00554 int CMEM_getVersion(void);
00555
00570 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00571
00587 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00588
00605 int CMEM_getNumBlocks(int *pnblocks);
00606
00619 int CMEM_exit(void);
00620
00623 #if defined (__cplusplus)
00624 }
00625 #endif
00626
00627 #endif
00628
00629
00630
00631
00632