Memory.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  *  ======== 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 
00222 
00223 /*
00224  *  ======== Memory_contigAlloc ========
00225  */
00257 extern Ptr Memory_contigAlloc(UInt size, UInt align);
00258 
00259 
00260 /*
00261  *  ======== Memory_contigFree ========
00262  */
00281 extern Bool Memory_contigFree(Ptr addr, UInt size);
00282 
00283 
00286 /*
00287  *  ======== Memory_contigStat ========
00288  */
00307 extern Bool Memory_contigStat(Memory_Stat *statbuf);
00308 
00312 /*
00313  *  ======== Memory_free ========
00314  */
00334 extern Bool Memory_free(Ptr addr, UInt size, Memory_AllocParams *params);
00335 
00336 
00337 /*
00338  *  ======== Memory_dumpKnownContigBufs ========
00339  */
00355 extern Void Memory_dumpKnownContigBufsList(Void);
00356 
00357 
00358 /*
00359  *  ======== Memory_getBufferPhysicalAddress ========
00360  */
00397 extern UInt32 Memory_getBufferPhysicalAddress(Ptr virtualAddress,
00398     Int sizeInBytes, Bool *isContiguous);
00399 
00400 /*
00401  *  ======== Memory_getHeapId ========
00402  */
00416 extern Int Memory_getHeapId(String name);
00417 
00418 /*
00419  *  ======== Memory_getNumHeaps ========
00420  */
00430 extern Int Memory_getNumHeaps();
00431 
00432 
00435 #ifdef ti_sdo_ce_osal_Memory_USEDEPRECATEDAPIS
00436 
00437 /*
00438  *  ======== Memory_getPhysicalAddress ========
00439  *  Convert user virtual address to physical address
00440  *  (returns the exact same value everywhere other than on Linux)
00441  *
00442  *  This function is deprecated -- everyone should be calling 
00443  *  Memory_getBufferPhysicalAddress() instead.
00444  */
00445 static inline UInt32 Memory_getPhysicalAddress(Ptr virtualAddress)
00446 {
00447     return(Memory_getBufferPhysicalAddress(virtualAddress, 4, NULL));
00448 }
00449 
00450 #endif
00451 
00455 /*
00456  *  ======== Memory_getBufferVirtualAddress ========
00457  */
00487 extern Ptr Memory_getBufferVirtualAddress(UInt32 physicalAddress,
00488     Int sizeInBytes);
00489 
00492 /*
00493  *  ======== Memory_init ========
00494  */
00495 extern Bool Memory_init(Void);
00496 
00497 
00498 /*
00499  *  ======== Memory_exit ========
00500  */
00501 extern Void Memory_exit(Void);
00502 
00503 
00504 /*
00505  *  ======== Memory_redefine ========
00506  */
00523 extern Bool Memory_redefine(Int segId, Uint32 base, Uint32 size);
00524 
00527 /*
00528  *  ======== Memory_registerContigBuf ========
00529  */
00559 extern Void Memory_registerContigBuf(UInt32 virtualAddress, UInt32 sizeInBytes,
00560     UInt32 physicalAddress);
00561 
00564 /*
00565  *  ======== Memory_restoreHeap ========
00566  */
00580 extern Bool Memory_restoreHeap(Int segId);
00581 
00582 /*
00583  *  ======== Memory_segAlloc ========
00584  */
00603 extern Ptr Memory_segAlloc(Int segId, UInt size, UInt align);
00604 
00605 
00606 /*
00607  *  ======== Memory_segFree ========
00608  */
00634 extern Bool Memory_segFree(Int segId, Ptr addr, UInt size);
00635 
00636 
00637 /*
00638  *  ======== Memory_segStat ========
00639  */
00659 extern Bool Memory_segStat(Int segId, Memory_Stat *statbuf);
00660 
00663 /*
00664  *  ======== Memory_unregisterContigBuf ========
00665  */
00682 extern Void Memory_unregisterContigBuf(UInt32 virtualAddress,
00683     UInt32 sizeInBytes);
00684 
00685   /* ingroup */
00687 
00688 #ifdef __cplusplus
00689 }
00690 #endif
00691 
00692 #endif
00693 /*
00694  *  @(#) ti.sdo.ce.osal; 2, 0, 2,384; 12-18-2009 17:43:18; /db/atree/library/trees/ce/ce-o06x/src/
00695  */
00696 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Copyright 2009, Texas Instruments Incorporated