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 0x02300000U
00147
00148
00149 #define CMEM_WB 0x0100
00150 #define CMEM_INV 0x0200
00151 #define CMEM_HEAP 0x0400
00152 #define CMEM_POOL 0x0000
00153 #define CMEM_CACHED 0x0800
00154 #define CMEM_NONCACHED 0x0000
00155 #define CMEM_PHYS 0x1000
00156
00157
00158 #define CMEM_IOCALLOC 1
00159 #define CMEM_IOCALLOCHEAP 2
00160 #define CMEM_IOCFREE 3
00161 #define CMEM_IOCGETPHYS 4
00162 #define CMEM_IOCGETSIZE 5
00163 #define CMEM_IOCGETPOOL 6
00164 #define CMEM_IOCCACHE 7
00165 #define CMEM_IOCGETVERSION 8
00166 #define CMEM_IOCGETBLOCK 9
00167 #define CMEM_IOCREGUSER 10
00168
00169
00170
00171
00172
00173
00174 #define CMEM_IOCCACHEWBINV CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00175 #define CMEM_IOCCACHEWB CMEM_IOCCACHE | CMEM_WB
00176 #define CMEM_IOCCACHEINV CMEM_IOCCACHE | CMEM_INV
00177 #define CMEM_IOCALLOCCACHED CMEM_IOCALLOC | CMEM_CACHED
00178 #define CMEM_IOCALLOCHEAPCACHED CMEM_IOCALLOCHEAP | CMEM_CACHED
00179 #define CMEM_IOCFREEHEAP CMEM_IOCFREE | CMEM_HEAP
00180 #define CMEM_IOCFREEPHYS CMEM_IOCFREE | CMEM_PHYS
00181 #define CMEM_IOCFREEHEAPPHYS CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00182
00183 #define CMEM_IOCCMDMASK 0x000000ff
00184
00189 typedef struct CMEM_AllocParams {
00190 int type;
00191 int flags;
00192 size_t alignment;
00195 } CMEM_AllocParams;
00196
00197 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00198
00199 typedef struct CMEM_BlockAttrs {
00200 unsigned long phys_base;
00201 size_t size;
00202 } CMEM_BlockAttrs;
00203
00208 union CMEM_AllocUnion {
00209 struct {
00210 size_t size;
00211 size_t align;
00212 int blockid;
00213 } alloc_heap_inparams;
00214 struct {
00215 int poolid;
00216 int blockid;
00217 } alloc_pool_inparams;
00218 struct {
00219 int poolid;
00220 int blockid;
00221 } get_size_inparams;
00222 struct {
00223 size_t size;
00224 int blockid;
00225 } get_pool_inparams;
00226 struct {
00227 unsigned long physp;
00228 size_t size;
00229 } alloc_pool_outparams;
00230 struct {
00231 unsigned long physp;
00232 size_t size;
00233 } get_block_outparams;
00234 struct {
00235 int poolid;
00236 size_t size;
00237 } free_outparams;
00238 unsigned long physp;
00239 unsigned long virtp;
00240 size_t size;
00241 int poolid;
00242 int blockid;
00243 };
00244
00254 int CMEM_init(void);
00255
00271 int CMEM_getPool(size_t size);
00272
00289 int CMEM_getPool2(int blockid, size_t size);
00290
00312 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00313
00336 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00337
00362 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00363
00390 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00391
00415 void *CMEM_registerAlloc(unsigned long physp);
00416
00439 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00440
00463 int CMEM_unregister(void *ptr, CMEM_AllocParams *params);
00464
00474 unsigned long CMEM_getPhys(void *ptr);
00475
00489 int CMEM_cacheWb(void *ptr, size_t size);
00490
00504 int CMEM_cacheInv(void *ptr, size_t size);
00505
00520 int CMEM_cacheWbInv(void *ptr, size_t size);
00521
00529 int CMEM_getVersion(void);
00530
00544 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00545
00560 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00561
00574 int CMEM_exit(void);
00575
00578 #if defined (__cplusplus)
00579 }
00580 #endif
00581
00582 #endif
00583
00584
00585
00586