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
00034
00035
00036
00053 #ifndef ti_sdo_winceutils_cmem_CMEM_H
00054 #define ti_sdo_winceutils_cmem_CMEM_H
00055
00056 #include <windows.h>
00057
00058 #if defined (__cplusplus)
00059 extern "C" {
00060 #endif
00061
00064
00065 #define CMEM_VERSION 0x02200000U
00066
00067
00068 #define CMEM_WB 0x0100
00069 #define CMEM_INV 0x0200
00070 #define CMEM_HEAP 0x0400
00071 #define CMEM_POOL 0x0000
00072 #define CMEM_CACHED 0x0800
00073 #define CMEM_NONCACHED 0x0000
00074 #define CMEM_PHYS 0x1000
00075
00076
00077 #define CMEM_IOCALLOC 1
00078 #define CMEM_IOCALLOCHEAP 2
00079 #define CMEM_IOCFREE 3
00080 #define CMEM_IOCGETPHYS 4
00081 #define CMEM_IOCGETSIZE 5
00082 #define CMEM_IOCGETPOOL 6
00083 #define CMEM_IOCCACHE 7
00084 #define CMEM_IOCGETVERSION 8
00085 #define CMEM_IOCGETBLOCK 9
00086 #define CMEM_IOCREGUSER 10
00087 #define CMEM_IOCGETNUMBLOCKS 11
00088 #define CMEM_IOCMAPADDRESS 12
00089 #define CMEM_IOCUNMAPADDRESS 13
00090
00091
00092
00093
00094
00095
00096
00097 #define CMEM_IOCCACHEWBINV CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00098 #define CMEM_IOCCACHEWB CMEM_IOCCACHE | CMEM_WB
00099 #define CMEM_IOCCACHEINV CMEM_IOCCACHE | CMEM_INV
00100 #define CMEM_IOCALLOCCACHED CMEM_IOCALLOC | CMEM_CACHED
00101 #define CMEM_IOCALLOCHEAPCACHED CMEM_IOCALLOCHEAP | CMEM_CACHED
00102 #define CMEM_IOCFREEHEAP CMEM_IOCFREE | CMEM_HEAP
00103 #define CMEM_IOCFREEPHYS CMEM_IOCFREE | CMEM_PHYS
00104 #define CMEM_IOCFREEHEAPPHYS CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00105
00106 #define CMEM_IOCCMDMASK 0x000000ff
00107
00112 typedef struct CMEM_AllocParams {
00113 int type;
00114 int flags;
00115 size_t alignment;
00118 } CMEM_AllocParams;
00119
00120 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00121
00122 typedef struct CMEM_BlockAttrs {
00123 unsigned long phys_base;
00124 size_t size;
00125 } CMEM_BlockAttrs;
00126
00131 union CMEM_AllocUnion {
00132 struct {
00133 size_t size;
00134 size_t align;
00135 int blockid;
00136 DWORD dwProcId;
00137 } alloc_heap_inparams;
00138 struct {
00139 int poolid;
00140 int blockid;
00141 DWORD dwProcId;
00142 } alloc_pool_inparams;
00143 struct {
00144 int poolid;
00145 int blockid;
00146 } get_size_inparams;
00147 struct {
00148 size_t size;
00149 int blockid;
00150 } get_pool_inparams;
00151 struct {
00152 unsigned long physp;
00153 unsigned long virtp;
00154 size_t size;
00155 } alloc_pool_outparams;
00156 struct {
00157 unsigned long physp;
00158 size_t size;
00159 } get_block_outparams;
00160 struct {
00161 int poolid;
00162 size_t size;
00163 } free_outparams;
00164 struct {
00165 unsigned long physp;
00166 size_t size;
00167 DWORD dwProcId;
00168 } map_inparams;
00169 struct {
00170 unsigned long virtp;
00171 size_t size;
00172 DWORD dwProcId;
00173 } unmap_inparams;
00174 unsigned long physp;
00175 unsigned long virtp;
00176 size_t size;
00177 int poolid;
00178 int blockid;
00179 };
00180
00190 int CMEM_init(void);
00191
00207 int CMEM_getPool(size_t size);
00208
00225 int CMEM_getPool2(int blockid, size_t size);
00226
00246 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00247
00268 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00269
00292 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00293
00318 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00319
00340 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00341
00351 unsigned long CMEM_getPhys(void *ptr);
00352
00366 int CMEM_cacheWb(void *ptr, size_t size);
00367
00381 int CMEM_cacheInv(void *ptr, size_t size);
00382
00397 int CMEM_cacheWbInv(void *ptr, size_t size);
00398
00406 int CMEM_getVersion(void);
00407
00422 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00423
00439 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00440
00457 int CMEM_getNumBlocks(int *pnblocks);
00458
00471 int CMEM_exit(void);
00472
00490 int CMEM_mapAddress(unsigned long physAddr, unsigned long length,
00491 unsigned int flags, unsigned long *pVirtAddr);
00492
00506 int CMEM_unmapAddress(unsigned long virtAddr, unsigned long length);
00507
00510 #if defined (__cplusplus)
00511 }
00512 #endif
00513
00514 #endif
00515
00516
00517
00518
00519