cmem.h

Go to the documentation of this file.
00001 /* 
00002  * Copyright (c) 2009, Texas Instruments Incorporated
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * *  Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  *
00012  * *  Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  *
00016  * *  Neither the name of Texas Instruments Incorporated nor the names of
00017  *    its contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00021  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00022  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00023  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00024  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00026  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00027  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00028  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00029  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00030  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  * 
00032  */
00033 /*
00034  *  ======== cmem.h ========
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 /* ioctl cmd "flavors" */
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 /* supported "base" ioctl cmds for the driver. */
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 /*
00087  * New ioctl cmds should use integers greater than the largest current cmd
00088  * in order to not break backward compatibility.
00089  */
00090 
00091 /* supported "flavors" to "base" ioctl cmds for the driver. */
00092 #define CMEM_IOCCACHEWBINV              CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00093 #define CMEM_IOCCACHEWB                 CMEM_IOCCACHE | CMEM_WB
00094 #define CMEM_IOCCACHEINV                CMEM_IOCCACHE | CMEM_INV
00095 #define CMEM_IOCALLOCCACHED             CMEM_IOCALLOC | CMEM_CACHED
00096 #define CMEM_IOCALLOCHEAPCACHED         CMEM_IOCALLOCHEAP | CMEM_CACHED
00097 #define CMEM_IOCFREEHEAP                CMEM_IOCFREE | CMEM_HEAP
00098 #define CMEM_IOCFREEPHYS                CMEM_IOCFREE | CMEM_PHYS
00099 #define CMEM_IOCFREEHEAPPHYS            CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00100 
00101 #define CMEM_IOCCMDMASK                 0x000000ff
00102 
00107 typedef struct CMEM_AllocParams {
00108     int type;           
00109     int flags;          
00110     size_t alignment;   
00113 } CMEM_AllocParams;
00114 
00115 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00116 
00117 typedef struct CMEM_BlockAttrs {
00118     unsigned long phys_base;
00119     size_t size;
00120 } CMEM_BlockAttrs;
00121 
00126 union CMEM_AllocUnion {
00127     struct {                    
00128         size_t size;
00129         size_t align;
00130         int blockid;
00131         DWORD dwProcId; // caller process ID - used to call VirtualCopyEx()
00132     } alloc_heap_inparams;      
00133     struct {                    
00134         int poolid;
00135         int blockid;
00136         DWORD dwProcId; // caller process ID - used to call VirtualCopyEx()
00137     } alloc_pool_inparams;      
00138     struct {                    
00139         int poolid;
00140         int blockid;
00141     } get_size_inparams;        
00142     struct {                    
00143         size_t size;
00144         int blockid;
00145     } get_pool_inparams;        
00146     struct {                    
00147         unsigned long physp;
00148                 unsigned long virtp;
00149         size_t size;
00150     } alloc_pool_outparams;     
00151     struct {                    
00152         unsigned long physp;
00153         size_t size;
00154     } get_block_outparams;      
00155     struct {                    
00156         int poolid;
00157         size_t size;
00158     } free_outparams;           
00159     unsigned long physp;
00160     unsigned long virtp;
00161     int size;
00162     int poolid;
00163     int blockid;
00164 };
00165 
00175 int CMEM_init(void);
00176 
00192 int CMEM_getPool(size_t size);
00193 
00210 int CMEM_getPool2(int blockid, size_t size);
00211 
00231 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00232 
00253 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00254 
00277 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00278 
00303 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00304 
00325 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00326 
00336 unsigned long CMEM_getPhys(void *ptr);
00337 
00351 int CMEM_cacheWb(void *ptr, size_t size);
00352 
00366 int CMEM_cacheInv(void *ptr, size_t size);
00367 
00382 int CMEM_cacheWbInv(void *ptr, size_t size);
00383 
00391 int CMEM_getVersion(void);
00392 
00406 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00407 
00422 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00423 
00436 int CMEM_exit(void);
00437 
00440 #if defined (__cplusplus)
00441 }
00442 #endif
00443 
00444 #endif
00445 /*
00446  *  @(#) ti.sdo.winceutils.cmem; 1, 0, 0,31; 5-31-2009 09:39:52; /db/atree/library/trees/winceutils/winceutils-a08x/src/
00447  */
00448 

Copyright 2009, Texas Instruments Incorporated