cmem.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010, 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 
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 /* ioctl cmd "flavors" */
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 /* supported "base" ioctl cmds for the driver. */
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 #define CMEM_IOCGETNUMBLOCKS            11
00171 /*
00172  * New ioctl cmds should use integers greater than the largest current cmd
00173  * in order to not break backward compatibility.
00174  */
00175 
00176 /* supported "flavors" to "base" ioctl cmds for the driver. */
00177 #define CMEM_IOCCACHEWBINV              CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00178 #define CMEM_IOCCACHEWB                 CMEM_IOCCACHE | CMEM_WB
00179 #define CMEM_IOCCACHEINV                CMEM_IOCCACHE | CMEM_INV
00180 #define CMEM_IOCALLOCCACHED             CMEM_IOCALLOC | CMEM_CACHED
00181 #define CMEM_IOCALLOCHEAPCACHED         CMEM_IOCALLOCHEAP | CMEM_CACHED
00182 #define CMEM_IOCFREEHEAP                CMEM_IOCFREE | CMEM_HEAP
00183 #define CMEM_IOCFREEPHYS                CMEM_IOCFREE | CMEM_PHYS
00184 #define CMEM_IOCFREEHEAPPHYS            CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00185 
00186 #define CMEM_IOCCMDMASK                 0x000000ff
00187 
00192 typedef struct CMEM_AllocParams {
00193     int type;           
00194     int flags;          
00195     size_t alignment;   
00198 } CMEM_AllocParams;
00199 
00200 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00201 
00202 typedef struct CMEM_BlockAttrs {
00203     unsigned long phys_base;
00204     size_t size;
00205 } CMEM_BlockAttrs;
00206 
00211 union CMEM_AllocUnion {
00212     struct {                    
00213         size_t size;
00214         size_t align;
00215         int blockid;
00216     } alloc_heap_inparams;      
00217     struct {                    
00218         int poolid;
00219         int blockid;
00220     } alloc_pool_inparams;      
00221     struct {                    
00222         int poolid;
00223         int blockid;
00224     } get_size_inparams;        
00225     struct {                    
00226         size_t size;
00227         int blockid;
00228     } get_pool_inparams;        
00229     struct {                    
00230         unsigned long physp;
00231         size_t size;
00232     } alloc_pool_outparams;     
00233     struct {                    
00234         unsigned long physp;
00235         size_t size;
00236     } get_block_outparams;      
00237     struct {                    
00238         int poolid;
00239         size_t size;
00240     } free_outparams;           
00241     unsigned long physp;
00242     unsigned long virtp;
00243     size_t size;
00244     int poolid;
00245     int blockid;
00246 };
00247 
00257 int CMEM_init(void);
00258 
00274 int CMEM_getPool(size_t size);
00275 
00292 int CMEM_getPool2(int blockid, size_t size);
00293 
00315 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00316 
00339 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00340 
00365 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00366 
00393 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00394 
00418 void *CMEM_registerAlloc(unsigned long physp);
00419 
00442 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00443 
00466 int CMEM_unregister(void *ptr, CMEM_AllocParams *params);
00467 
00477 unsigned long CMEM_getPhys(void *ptr);
00478 
00492 int CMEM_cacheWb(void *ptr, size_t size);
00493 
00507 int CMEM_cacheInv(void *ptr, size_t size);
00508 
00523 int CMEM_cacheWbInv(void *ptr, size_t size);
00524 
00532 int CMEM_getVersion(void);
00533 
00548 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00549 
00565 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00566 
00583 int CMEM_getNumBlocks(int *pnblocks);
00584 
00597 int CMEM_exit(void);
00598 
00601 #if defined (__cplusplus)
00602 }
00603 #endif
00604 
00605 #endif
00606 /*
00607  *  @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,127; 3-10-2010 11:01:48; /db/atree/library/trees/linuxutils/linuxutils-f08x/src/
00608  */
00609 
 All Data Structures Files Functions Variables Enumerations Enumerator Defines

Copyright 2010, Texas Instruments Incorporated