Memory.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 /*
00034  *  ======== Memory.h ========
00035  */
00046 #ifndef ti_sdo_ce_osal_Memory_
00047 #define ti_sdo_ce_osal_Memory_
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00055 
00056 /*
00057  *  ======== Memory_DEFAULTALIGNMENT ========
00058  */
00059 #define Memory_DEFAULTALIGNMENT ((UInt)(-1))
00060 
00061 /*
00062  *  ======== Memory_GTNAME ========
00063  */
00064 #define Memory_GTNAME "OM"
00065 
00073 typedef struct Memory_Stat {
00074     String name;     
00075     Uint32 base;     
00076     UInt size;       
00077     UInt used;       
00078     UInt length;     
00079 } Memory_Stat;
00080 
00088 typedef enum {
00089     Memory_MALLOC = 0,        
00090     Memory_SEG = 1,           
00091     Memory_CONTIGPOOL = 2,    
00092     Memory_CONTIGHEAP =3      
00093 } Memory_type;
00094 
00100 typedef struct Memory_AllocParams {
00101     Memory_type type;   
00105     UInt flags;         
00110     UInt align;         
00111     UInt seg;           
00112 } Memory_AllocParams;
00113 
00114 
00115 #define Memory_CACHED           0x00000000  
00119 #define Memory_NONCACHED        0x00000001  
00124 #define Memory_CACHEDMASK       0x00000001  
00149 extern Memory_AllocParams Memory_DEFAULTPARAMS;
00150 
00151 /*
00152  *  ======== Memory_alloc ========
00153  */
00167 extern Ptr Memory_alloc(UInt size, Memory_AllocParams *params);
00168 
00169 /*
00170  *  ======== Memory_cacheInv ========
00171  */
00188 extern Void Memory_cacheInv(Ptr addr, Int sizeInBytes);
00189 
00190 
00191 /*
00192  *  ======== Memory_cacheWb ========
00193  */
00204 extern Void Memory_cacheWb(Ptr addr, Int sizeInBytes);
00205 
00206 
00207 /*
00208  *  ======== Memory_cacheWbInv ========
00209  */
00220 extern Void Memory_cacheWbInv(Ptr addr, Int sizeInBytes);
00221 
00224 /*
00225  *  ======== Memory_cacheWbInvAll ========
00226  */
00235 extern Void Memory_cacheWbInvAll();
00236 
00239 /*
00240  *  ======== Memory_contigAlloc ========
00241  */
00273 extern Ptr Memory_contigAlloc(UInt size, UInt align);
00274 
00275 
00276 /*
00277  *  ======== Memory_contigFree ========
00278  */
00297 extern Bool Memory_contigFree(Ptr addr, UInt size);
00298 
00299 
00302 /*
00303  *  ======== Memory_contigStat ========
00304  */
00323 extern Bool Memory_contigStat(Memory_Stat *statbuf);
00324 
00328 /*
00329  *  ======== Memory_free ========
00330  */
00350 extern Bool Memory_free(Ptr addr, UInt size, Memory_AllocParams *params);
00351 
00352 
00353 /*
00354  *  ======== Memory_dumpKnownContigBufs ========
00355  */
00371 extern Void Memory_dumpKnownContigBufsList(Void);
00372 
00373 
00374 /*
00375  *  ======== Memory_getBufferPhysicalAddress ========
00376  */
00413 extern UInt32 Memory_getBufferPhysicalAddress(Ptr virtualAddress,
00414     Int sizeInBytes, Bool *isContiguous);
00415 
00416 /*
00417  *  ======== Memory_getHeapId ========
00418  */
00432 extern Int Memory_getHeapId(String name);
00433 
00434 /*
00435  *  ======== Memory_getNumHeaps ========
00436  */
00446 extern Int Memory_getNumHeaps();
00447 
00448 
00451 #ifdef ti_sdo_ce_osal_Memory_USEDEPRECATEDAPIS
00452 
00453 /*
00454  *  ======== Memory_getPhysicalAddress ========
00455  *  Convert user virtual address to physical address
00456  *  (returns the exact same value everywhere other than on Linux)
00457  *
00458  *  This function is deprecated -- everyone should be calling 
00459  *  Memory_getBufferPhysicalAddress() instead.
00460  */
00461 static inline UInt32 Memory_getPhysicalAddress(Ptr virtualAddress)
00462 {
00463     return(Memory_getBufferPhysicalAddress(virtualAddress, 4, NULL));
00464 }
00465 
00466 #endif
00467 
00471 /*
00472  *  ======== Memory_getBufferVirtualAddress ========
00473  */
00503 extern Ptr Memory_getBufferVirtualAddress(UInt32 physicalAddress,
00504     Int sizeInBytes);
00505 
00508 /*
00509  *  ======== Memory_init ========
00510  */
00511 extern Bool Memory_init(Void);
00512 
00513 
00514 /*
00515  *  ======== Memory_exit ========
00516  */
00517 extern Void Memory_exit(Void);
00518 
00519 
00520 /*
00521  *  ======== Memory_redefine ========
00522  */
00539 extern Bool Memory_redefine(Int segId, Uint32 base, Uint32 size);
00540 
00543 /*
00544  *  ======== Memory_registerContigBuf ========
00545  */
00575 extern Void Memory_registerContigBuf(UInt32 virtualAddress, UInt32 sizeInBytes,
00576     UInt32 physicalAddress);
00577 
00580 /*
00581  *  ======== Memory_restoreHeap ========
00582  */
00596 extern Bool Memory_restoreHeap(Int segId);
00597 
00598 /*
00599  *  ======== Memory_segAlloc ========
00600  */
00619 extern Ptr Memory_segAlloc(Int segId, UInt size, UInt align);
00620 
00621 
00622 /*
00623  *  ======== Memory_segFree ========
00624  */
00650 extern Bool Memory_segFree(Int segId, Ptr addr, UInt size);
00651 
00652 
00653 /*
00654  *  ======== Memory_segStat ========
00655  */
00675 extern Bool Memory_segStat(Int segId, Memory_Stat *statbuf);
00676 
00679 /*
00680  *  ======== Memory_unregisterContigBuf ========
00681  */
00698 extern Void Memory_unregisterContigBuf(UInt32 virtualAddress,
00699     UInt32 sizeInBytes);
00700 
00701   /* ingroup */
00703 
00704 #ifdef __cplusplus
00705 }
00706 #endif
00707 
00708 #endif
00709 /*
00710  *  @(#) ti.sdo.ce.osal; 2, 0, 2,427; 12-2-2010 21:24:38; /db/atree/library/trees/ce/ce-r11x/src/ xlibrary
00711 
00712  */
00713 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Copyright 2010, Texas Instruments Incorporated