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 
00132 #ifndef ti_sdo_linuxutils_cmem_CMEM_H
00133 #define ti_sdo_linuxutils_cmem_CMEM_H
00134 
00135 #if defined (__cplusplus)
00136 extern "C" {
00137 #endif
00138 
00141 
00142 #define CMEM_VERSION    0x02300000U
00143 
00144 /* ioctl cmd "flavors" */
00145 #define CMEM_WB                         0x0100
00146 #define CMEM_INV                        0x0200
00147 #define CMEM_HEAP                       0x0400  
00148 #define CMEM_POOL                       0x0000  
00149 #define CMEM_CACHED                     0x0800  
00150 #define CMEM_NONCACHED                  0x0000  
00151 #define CMEM_PHYS                       0x1000
00152 
00153 /* supported "base" ioctl cmds for the driver. */
00154 #define CMEM_IOCALLOC                   1
00155 #define CMEM_IOCALLOCHEAP               2
00156 #define CMEM_IOCFREE                    3
00157 #define CMEM_IOCGETPHYS                 4
00158 #define CMEM_IOCGETSIZE                 5
00159 #define CMEM_IOCGETPOOL                 6
00160 #define CMEM_IOCCACHE                   7
00161 #define CMEM_IOCGETVERSION              8
00162 #define CMEM_IOCGETBLOCK                9
00163 #define CMEM_IOCREGUSER                 10
00164 /*
00165  * New ioctl cmds should use integers greater than the largest current cmd
00166  * in order to not break backward compatibility.
00167  */
00168 
00169 /* supported "flavors" to "base" ioctl cmds for the driver. */
00170 #define CMEM_IOCCACHEWBINV              CMEM_IOCCACHE | CMEM_WB | CMEM_INV
00171 #define CMEM_IOCCACHEWB                 CMEM_IOCCACHE | CMEM_WB
00172 #define CMEM_IOCCACHEINV                CMEM_IOCCACHE | CMEM_INV
00173 #define CMEM_IOCALLOCCACHED             CMEM_IOCALLOC | CMEM_CACHED
00174 #define CMEM_IOCALLOCHEAPCACHED         CMEM_IOCALLOCHEAP | CMEM_CACHED
00175 #define CMEM_IOCFREEHEAP                CMEM_IOCFREE | CMEM_HEAP
00176 #define CMEM_IOCFREEPHYS                CMEM_IOCFREE | CMEM_PHYS
00177 #define CMEM_IOCFREEHEAPPHYS            CMEM_IOCFREE | CMEM_HEAP | CMEM_PHYS
00178 
00179 #define CMEM_IOCCMDMASK                 0x000000ff
00180 
00185 typedef struct CMEM_AllocParams {
00186     int type;           
00187     int flags;          
00188     size_t alignment;   
00191 } CMEM_AllocParams;
00192 
00193 extern CMEM_AllocParams CMEM_DEFAULTPARAMS;
00194 
00195 typedef struct CMEM_BlockAttrs {
00196     unsigned long phys_base;
00197     size_t size;
00198 } CMEM_BlockAttrs;
00199 
00204 union CMEM_AllocUnion {
00205     struct {                    
00206         size_t size;
00207         size_t align;
00208         int blockid;
00209     } alloc_heap_inparams;      
00210     struct {                    
00211         int poolid;
00212         int blockid;
00213     } alloc_pool_inparams;      
00214     struct {                    
00215         int poolid;
00216         int blockid;
00217     } get_size_inparams;        
00218     struct {                    
00219         size_t size;
00220         int blockid;
00221     } get_pool_inparams;        
00222     struct {                    
00223         unsigned long physp;
00224         size_t size;
00225     } alloc_pool_outparams;     
00226     struct {                    
00227         unsigned long physp;
00228         size_t size;
00229     } get_block_outparams;      
00230     struct {                    
00231         int poolid;
00232         size_t size;
00233     } free_outparams;           
00234     unsigned long physp;
00235     unsigned long virtp;
00236     size_t size;
00237     int poolid;
00238     int blockid;
00239 };
00240 
00250 int CMEM_init(void);
00251 
00267 int CMEM_getPool(size_t size);
00268 
00285 int CMEM_getPool2(int blockid, size_t size);
00286 
00308 void *CMEM_allocPool(int poolid, CMEM_AllocParams *params);
00309 
00332 void *CMEM_allocPool2(int blockid, int poolid, CMEM_AllocParams *params);
00333 
00358 void *CMEM_alloc(size_t size, CMEM_AllocParams *params);
00359 
00386 void *CMEM_alloc2(int blockid, size_t size, CMEM_AllocParams *params);
00387 
00411 void *CMEM_registerAlloc(unsigned long physp);
00412 
00435 int CMEM_free(void *ptr, CMEM_AllocParams *params);
00436 
00459 int CMEM_unregister(void *ptr, CMEM_AllocParams *params);
00460 
00470 unsigned long CMEM_getPhys(void *ptr);
00471 
00485 int CMEM_cacheWb(void *ptr, size_t size);
00486 
00500 int CMEM_cacheInv(void *ptr, size_t size);
00501 
00516 int CMEM_cacheWbInv(void *ptr, size_t size);
00517 
00525 int CMEM_getVersion(void);
00526 
00540 int CMEM_getBlock(unsigned long *pphys_base, size_t *psize);
00541 
00556 int CMEM_getBlockAttrs(int blockid, CMEM_BlockAttrs *pattrs);
00557 
00570 int CMEM_exit(void);
00571 
00574 #if defined (__cplusplus)
00575 }
00576 #endif
00577 
00578 #endif
00579 /*
00580  *  @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,104; 4-20-2009 11:43:31; /db/atree/library/trees/linuxutils/linuxutils-d06x/src/
00581  */
00582 

Copyright 2009, Texas Instruments Incorporated