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
00136 #ifndef ti_sdo_linuxutils_cmem_CMEM_H
00137 #define ti_sdo_linuxutils_cmem_CMEM_H
00138
00139 #if defined (__cplusplus)
00140 extern "C" {
00141 #endif
00142
00145
00146 #define CMEM_VERSION 0x03000000U
00147
00148
00149 #define CMEM_WB 0x00010000
00150 #define CMEM_INV 0x00020000
00151 #define CMEM_HEAP 0x00040000
00152 #define CMEM_POOL 0x00000000
00153 #define CMEM_CACHED 0x00080000
00154 #define CMEM_NONCACHED 0x00000000
00155 #define CMEM_PHYS 0x00100000
00156
00157 #define CMEM_IOCMAGIC 0x0000fe00
00158
00159
00160 #define CMEM_IOCALLOC 1
00161 #define CMEM_IOCALLOCHEAP 2
00162 #define CMEM_IOCFREE 3
00163 #define CMEM_IOCGETPHYS 4
00164 #define CMEM_IOCGETSIZE 5
00165 #define CMEM_IOCGETPOOL 6
00166 #define CMEM_IOCCACHE 7
00167 #define CMEM_IOCGETVERSION 8
00168 #define CMEM_IOCGETBLOCK 9
00169 #define CMEM_IOCREGUSER 10
00170
00171
00172
00173
00174
00175
00176 #define CMEM_IOCCACHEWBINV CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00177 #define CMEM_IOCCACHEWB CMEM_IOCCACHE | CMEM_WB
00178 #define CMEM_IOCCACHEINV CMEM_IOCCACHE | CMEM_INV
00179 #define CMEM_IOCALLOCCACHED CMEM_IOCALLOC | CMEM_CACHED
00180 #define CMEM_IOCALLOCHEAPCACHED CMEM_IOCALLOCHEAP | CMEM_CACHED
00181 #define CMEM_IOCFREEHEAP CMEM_IOCFREE | CMEM_HEAP
00182 #define CMEM_IOCFREEPHYS CMEM_IOCFREE | CMEM_PHYS
00183 #define CMEM_IOCFREEHEAPPHYS CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00184
00185 #define CMEM_IOCCMDMASK 0x000000ff
00186
00191 typedef struct CMEM_AllocParams {
00192 int type;
00193 int flags;
00194 size_t alignment;
00197 } CMEM_AllocParams;
00198
00199 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00200
00201 typedef struct CMEM_BlockAttrs {
00202 unsigned long phys_base;
00203 size_t size;
00204 } CMEM_BlockAttrs;
00205
00210 union CMEM_AllocUnion {
00211 struct {
00212 size_t size;
00213 size_t align;
00214 int blockid;
00215 } alloc_heap_inparams;
00216 struct {
00217 int poolid;
00218 int blockid;
00219 } alloc_pool_inparams;
00220 struct {
00221 int poolid;
00222 int blockid;
00223 } get_size_inparams;
00224 struct {
00225 size_t size;
00226 int blockid;
00227 } get_pool_inparams;
00228 struct {
00229 unsigned long physp;
00230 size_t size;
00231 } alloc_pool_outparams;
00232 struct {
00233 unsigned long physp;
00234 size_t size;
00235 } get_block_outparams;
00236 struct {
00237 int poolid;
00238 size_t size;
00239 } free_outparams;
00240 unsigned long physp;
00241 unsigned long virtp;
00242 size_t size;
00243 int poolid;
00244 int blockid;
00245 };
00246
00256 int CMEM_init(void);
00257
00273 int CMEM_getPool(size_t size);
00274
00291 int CMEM_getPool2(int blockid, size_t size);
00292
00314 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00315
00338 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00339
00364 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00365
00392 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00393
00417 void *CMEM_registerAlloc(unsigned long physp);
00418
00441 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00442
00465 int CMEM_unregister(void *ptr, CMEM_AllocParams *params);
00466
00476 unsigned long CMEM_getPhys(void *ptr);
00477
00491 int CMEM_cacheWb(void *ptr, size_t size);
00492
00506 int CMEM_cacheInv(void *ptr, size_t size);
00507
00522 int CMEM_cacheWbInv(void *ptr, size_t size);
00523
00531 int CMEM_getVersion(void);
00532
00546 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00547
00562 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00563
00576 int CMEM_exit(void);
00577
00580 #if defined (__cplusplus)
00581 }
00582 #endif
00583
00584 #endif
00585
00586
00587
00588