Data Structures | Defines | Typedefs | Enumerations | Functions | Variables

Memory - OS Independent Memory Interface

Data Structures

struct  ti_sdo_ce_osal_Memory_AllocParams
 Parameters for ti_sdo_ce_osal_Memory_alloc() & ti_sdo_ce_osal_Memory_free() More...

Defines

#define ti_sdo_ce_osal_Memory_DEFAULTALIGNMENT   ((UInt)(-1))
 Default Alignment.
#define Memory_MODNAME   "ti.sdo.ce.osal.Memory"
 Name to pass to Diags_setMask() to enable logging for Memory functions. For example, Diags_setMask(Memory_MODNAME"+EX1234567"); turns on all Log statements in this module. Diags_setMask() must be called after initialization to take effect.
#define ti_sdo_ce_osal_Memory_GTNAME   "OM"
 GT name containing the trace mask for this module.
#define ti_sdo_ce_osal_Memory_CACHED   0x00000000
 Cached allocation.
#define ti_sdo_ce_osal_Memory_NONCACHED   0x00000001
 Non-cached allocation.
#define ti_sdo_ce_osal_Memory_CACHEDMASK   0x00000001
 Mask to isolate cache flag.

Typedefs

typedef struct
ti_sdo_ce_osal_Memory_AllocParams 
ti_sdo_ce_osal_Memory_AllocParams
 Parameters for ti_sdo_ce_osal_Memory_alloc() & ti_sdo_ce_osal_Memory_free()

Enumerations

enum  ti_sdo_ce_osal_Memory_type {
  ti_sdo_ce_osal_Memory_MALLOC = 0,
  ti_sdo_ce_osal_Memory_SEG = 1,
  ti_sdo_ce_osal_Memory_CONTIGPOOL = 2,
  ti_sdo_ce_osal_Memory_CONTIGHEAP = 3
}
 

Enum values for ti_sdo_ce_osal_Memory_AllocParams.type.

More...

Functions

Ptr ti_sdo_ce_osal_Memory_alloc (UInt size, ti_sdo_ce_osal_Memory_AllocParams *params)
 General memory allocation.
Void ti_sdo_ce_osal_Memory_cacheInv (Ptr addr, Int sizeInBytes)
 Invalidate a range of cache.
Void ti_sdo_ce_osal_Memory_cacheWb (Ptr addr, Int sizeInBytes)
 Write back cache.
Void ti_sdo_ce_osal_Memory_cacheWbInv (Ptr addr, Int sizeInBytes)
 Write back and invalidate cache.
Void ti_sdo_ce_osal_Memory_cacheWbInvAll ()
 Write back and invalidate the entire cache. Not supported yet on all OS's.
Ptr ti_sdo_ce_osal_Memory_contigAlloc (UInt size, UInt align)
 Allocate physically contiguous blocks of memory.
Bool ti_sdo_ce_osal_Memory_contigFree (Ptr addr, UInt size)
 Free memory allocated by ti_sdo_ce_osal_Memory_contigAlloc()
Bool ti_sdo_ce_osal_Memory_free (Ptr addr, UInt size, ti_sdo_ce_osal_Memory_AllocParams *params)
 Free memory allocated with ti_sdo_ce_osal_Memory_alloc().
Void ti_sdo_ce_osal_Memory_dumpKnownContigBufsList (Void)
 Dumps the list of all translated/registered bufs.
UInt32 ti_sdo_ce_osal_Memory_getBufferPhysicalAddress (Ptr virtualAddress, Int sizeInBytes, Bool *isContiguous)
 Converts application virtual address to a physical address.
Int ti_sdo_ce_osal_Memory_getHeapId (String name)
 Get the heap heap ID corresponding to a heap name. This number will be between 0 and the value returned by ti_sdo_ce_osal_Memory_getNumHeaps(). The heap Id can be passed to ti_sdo_ce_osal_Memory_redefine() and ti_sdo_ce_osal_Memory_restoreHeap().
Int ti_sdo_ce_osal_Memory_getNumHeaps ()
 Get the number of memory heaps.
Ptr ti_sdo_ce_osal_Memory_getBufferVirtualAddress (UInt32 physicalAddress, Int sizeInBytes)
 Obtains the virtual address of a physically contiguous buffer.
Void ti_sdo_ce_osal_Memory_registerContigBuf (UInt32 virtualAddress, UInt32 sizeInBytes, UInt32 physicalAddress)
 Register a physical buffer allocated without ti_sdo_ce_osal_Memory_contigAlloc()
Void ti_sdo_ce_osal_Memory_unregisterContigBuf (UInt32 virtualAddress, UInt32 sizeInBytes)
 Unregisters a physical buffer allocated without ti_sdo_ce_osal_Memory_contigAlloc().

Variables

ti_sdo_ce_osal_Memory_AllocParams ti_sdo_ce_osal_Memory_DEFAULTPARAMS
 Default parameters for ti_sdo_ce_osal_Memory_alloc() & ti_sdo_ce_osal_Memory_free()

Detailed Description

This Memory module provides services to manage memory in OS independent environments.

Package Prefix

In order to avoid global namespace collisions, this module prefixes all its exports with the globally unique package name it's contained in (ti_sdo_ce_osal). As a usability feature (and to remain backward compatible with previous releases), these exports are also made available via the more traditional 'short' name - without the package name prefix.

For example, although the actual export may be named 'ti_sdo_ce_osal_Memory_alloc', it's generally usable via the shorter name 'Memory_alloc'. In the rare case where a namespace collision occurs, users can disable the definitions of the 'short' name by defining the symbol 'ti_sdo_ce_osal_Memory__nolocalnames' before including this module's header. For example:

 #define ti_sdo_ce_osal_Memory__nolocalnames
 #include <ti/sdo/ce/osal/Memory.h>


This follows the same approach the XDCtools takes, and further explaination is available here: http://rtsc.eclipse.org/docs-tip/Integrating_RTSC_Modules#Eliminating_Identifier_Conflicts.


Define Documentation

#define ti_sdo_ce_osal_Memory_DEFAULTALIGNMENT   ((UInt)(-1))

Default Alignment.

Remarks:
This definition also has a short name alias of Memory_DEFAULTALIGNMENT.
See also:
ti_sdo_ce_osal_Memory_AllocParams.align
#define Memory_MODNAME   "ti.sdo.ce.osal.Memory"

Name to pass to Diags_setMask() to enable logging for Memory functions. For example, Diags_setMask(Memory_MODNAME"+EX1234567"); turns on all Log statements in this module. Diags_setMask() must be called after initialization to take effect.

#define ti_sdo_ce_osal_Memory_GTNAME   "OM"

GT name containing the trace mask for this module.

Remarks:
This definition also has a short name alias of Memory_GTNAME.
#define ti_sdo_ce_osal_Memory_CACHED   0x00000000

Cached allocation.

Remarks:
This definition also has a short name alias of Memory_CACHED.
See also:
ti_sdo_ce_osal_Memory_AllocParams.flags
#define ti_sdo_ce_osal_Memory_NONCACHED   0x00000001

Non-cached allocation.

Remarks:
This definition also has a short name alias of Memory_NONCACHED.
See also:
ti_sdo_ce_osal_Memory_AllocParams.flags
#define ti_sdo_ce_osal_Memory_CACHEDMASK   0x00000001

Mask to isolate cache flag.

Remarks:
This definition also has a short name alias of Memory_NONCACHEDMASK.
See also:
ti_sdo_ce_osal_Memory_AllocParams.flags

Typedef Documentation

Parameters for ti_sdo_ce_osal_Memory_alloc() & ti_sdo_ce_osal_Memory_free()

Remarks:
This definition also has a short name alias of Memory_AllocParams.
See also:
ti_sdo_ce_osal_Memory_DEFAULTPARAMS

Enumeration Type Documentation

Enum values for ti_sdo_ce_osal_Memory_AllocParams.type.

Remarks:
This definition also has a short name alias of Memory_type.
See also:
ti_sdo_ce_osal_Memory_AllocParams
Enumerator:
ti_sdo_ce_osal_Memory_MALLOC 

malloc()-based allocation

Remarks:
This definition also has a short name alias of Memory_MALLOC.
ti_sdo_ce_osal_Memory_SEG 

DSP/BIOS segment-based allocation

Remarks:
This definition also has a short name alias of Memory_SEG.
ti_sdo_ce_osal_Memory_CONTIGPOOL 

Contiguous, pool-based allocation

Remarks:
This definition also has a short name alias of Memory_CONTIGPOOL.
ti_sdo_ce_osal_Memory_CONTIGHEAP 

Contiguous, heap-based allocation

Remarks:
This definition also has a short name alias of Memory_CONTIGHEAP.

Function Documentation

Ptr ti_sdo_ce_osal_Memory_alloc ( UInt  size,
ti_sdo_ce_osal_Memory_AllocParams params 
)

General memory allocation.

Parameters:
[in]sizeNumber of bytes to allocate.
[in]paramsParameters controlling the allocation.
Remarks:
This definition also has a short name alias of Memory_alloc.
Return values:
NULLThe memory request failed.
non-NULLThe pointer to a buffer containing the requested memory.
See also:
ti_sdo_ce_osal_Memory_free()
ti_sdo_ce_osal_Memory_contigAlloc()
Void ti_sdo_ce_osal_Memory_cacheInv ( Ptr  addr,
Int  sizeInBytes 
)

Invalidate a range of cache.

Parameters:
[in]addrAddress of the beginning of the buffer to invalidate.
[in]sizeInBytesSize of the buffer to invalidate.
Remarks:
In addition to application usage, this is often called by a skeleton implementor after it has received a shared memory buffer from another processor, and before it invokes an algorithm's interface which will operate on that shared memory buffer.
This definition also has a short name alias of Memory_cacheInv.
See also:
ti_sdo_ce_osal_Memory_cacheWb()
ti_sdo_ce_osal_Memory_cacheWbInv()
Void ti_sdo_ce_osal_Memory_cacheWb ( Ptr  addr,
Int  sizeInBytes 
)

Write back cache.

Parameters:
[in]addrAddress of the beginning of the buffer to writeback.
[in]sizeInBytesSize of the buffer to writeback.
Remarks:
This definition also has a short name alias of Memory_cacheWb.
See also:
ti_sdo_ce_osal_Memory_cacheInv()
ti_sdo_ce_osal_Memory_cacheWbInv()
Void ti_sdo_ce_osal_Memory_cacheWbInv ( Ptr  addr,
Int  sizeInBytes 
)

Write back and invalidate cache.

Parameters:
[in]addrAddress of the beginning of the buffer to writeback and invalidate.
[in]sizeInBytesSize of the buffer to writeback invalidate.
Remarks:
This definition also has a short name alias of Memory_cacheWbInv.
See also:
ti_sdo_ce_osal_Memory_cacheInv()
ti_sdo_ce_osal_Memory_cacheWb()
Void ti_sdo_ce_osal_Memory_cacheWbInvAll (  )

Write back and invalidate the entire cache. Not supported yet on all OS's.

Remarks:
This definition also has a short name alias of Memory_cacheWbInvAll.
See also:
ti_sdo_ce_osal_Memory_cacheInv()
ti_sdo_ce_osal_Memory_cacheWb()
ti_sdo_ce_osal_Memory_cacheWbInv()
Ptr ti_sdo_ce_osal_Memory_contigAlloc ( UInt  size,
UInt  align 
)

Allocate physically contiguous blocks of memory.

Deprecated:
This function has been superceded by ti_sdo_ce_osal_Memory_alloc() and will be removed in a future release. Users are recommended to modify their applications to use the new, more flexible ti_sdo_ce_osal_Memory_alloc() instead.
Parameters:
[in]sizeSize of the buffer to allocate.
[in]alignAlignment of the buffer; must be divisible by a power of two.
Precondition:
align must be divisible by a power of two.
Remarks:
This definition also has a short name alias of Memory_contigAlloc.
Return values:
non-NULLAddress of a physically contiguous buffer.
NULLUnable to obtain the requested buffer.
Remarks:
This is commonly called by an application wishing to obtain a physically contiguous buffer which it must share with another processor.
For portability reasons, applications commonly use this API even in environments which do not have virtual memory or an MMU (e.g. a single processor, DSP/BIOS based system). Doing so makes them portable to environments which do have to provide physically contiguous memory to remote processors.
See also:
ti_sdo_ce_osal_Memory_alloc()
ti_sdo_ce_osal_Memory_contigFree()
Bool ti_sdo_ce_osal_Memory_contigFree ( Ptr  addr,
UInt  size 
)

Free memory allocated by ti_sdo_ce_osal_Memory_contigAlloc()

Parameters:
[in]addrAddress of a buffer allocated by ti_sdo_ce_osal_Memory_contigAlloc()
[in]sizeSize of the buffer to free.
Remarks:
This definition also has a short name alias of Memory_contigFree.
Return values:
TRUEThe buffer was freed and the memory pointed to by addr is no longer valid.
FALSEThe buffer couldn't be freed.
Precondition:
addr must be a valid address returned by ti_sdo_ce_osal_Memory_contigAlloc()
size must be equivalent to the size passed in during the ti_sdo_ce_osal_Memory_contigAlloc() allocation.
See also:
ti_sdo_ce_osal_Memory_contigAlloc()
Bool ti_sdo_ce_osal_Memory_free ( Ptr  addr,
UInt  size,
ti_sdo_ce_osal_Memory_AllocParams params 
)

Free memory allocated with ti_sdo_ce_osal_Memory_alloc().

Parameters:
[in]addrAddress of a buffer allocated by ti_sdo_ce_osal_Memory_alloc().
[in]sizeSize of the buffer to free.
[in]paramsParameters controlling the free operation.
Remarks:
This definition also has a short name alias of Memory_free.
Return values:
TRUEThe buffer was freed and the memory pointed to by addr is no longer valid.
FALSEThe buffer couldn't be freed.
Precondition:
addr must be a valid address returned by ti_sdo_ce_osal_Memory_alloc().
size must be equivalent to the size passed in during the ti_sdo_ce_osal_Memory_alloc() allocation.
params must be equivalent to the params passed in during the ti_sdo_ce_osal_Memory_alloc() allocation.
See also:
ti_sdo_ce_osal_Memory_alloc()
Void ti_sdo_ce_osal_Memory_dumpKnownContigBufsList ( Void   )

Dumps the list of all translated/registered bufs.

Remarks:
The list is printed using the tracing infrastructure at trace level 5 to tracemask Memory_MODNAME.
There are several mechanisms to enable this trace mask, one would be to do the following from your application:
    Diags_setMask(Memory_MODNAME"+5");
See also:
ti_sdo_ce_osal_Memory_registerContigBuf()
ti_sdo_ce_osal_Memory_unregisterContigBuf()
UInt32 ti_sdo_ce_osal_Memory_getBufferPhysicalAddress ( Ptr  virtualAddress,
Int  sizeInBytes,
Bool *  isContiguous 
)

Converts application virtual address to a physical address.

This API also checks verifies that the buffer is really contiguous.

Parameters:
[in]virtualAddressAddress of a buffer.
[in]sizeInBytesSize of the buffer.
[out]isContiguousOptional flag indicating whether the buffer was physically contiguous or not.
Return values:
0Failure, the physical address could not be obtained.
non-zeroThe physical address of the buffer.
Remarks:
sizeInBytes must be non-zero.
isContiguous is an optional parameter, and can be NULL if the caller doesn't want the results of this check. If isContiguous is NULL but the buffer is not contiguous, error trace will be generated.
If a physically discontiguous buffer is provided in virtualAddress, zero will be returned. And if isContiguous is non-null, it will be set to FALSE.
This is typically called by a stub implementation to translate an application-side virtual address into a physical address usable by a remote skeleton and algorithm.
To enable portable code, this is safe to call on systems without virtual memory. In those cases, the returned physical buffer will be the same as the provided "virtual" buffer.
This definition also has a short name alias of Memory_getBufferPhysicalAddress.
See also:
ti_sdo_ce_osal_Memory_getBufferVirtualAddress()
Int ti_sdo_ce_osal_Memory_getHeapId ( String  name )

Get the heap heap ID corresponding to a heap name. This number will be between 0 and the value returned by ti_sdo_ce_osal_Memory_getNumHeaps(). The heap Id can be passed to ti_sdo_ce_osal_Memory_redefine() and ti_sdo_ce_osal_Memory_restoreHeap().

Remarks:
This is an unsupported, private function. There is no contract to provide compatibility between releases, and it may be deleted at any time.
Return values:
>=0 The heap number.
<0 No heap with the given name was found.
See also:
ti_sdo_ce_osal_Memory_getNumHeaps()
Int ti_sdo_ce_osal_Memory_getNumHeaps (  )

Get the number of memory heaps.

Remarks:
This is an unsupported, private function. There is no contract to provide compatibility between releases, and it may be deleted at any time.
Return values:
Thenumber of memroy heaps.
Ptr ti_sdo_ce_osal_Memory_getBufferVirtualAddress ( UInt32  physicalAddress,
Int  sizeInBytes 
)

Obtains the virtual address of a physically contiguous buffer.

Parameters:
[in]physicalAddressPhysical address of a buffer.
[in]sizeInBytesSize of the buffer.
Return values:
NULLFailure, the virtual address could not be obtained.
non-zeroThe virtual address of the buffer.
Remarks:
sizeInBytes must be non-zero.
If virtualAddress, was not acquired by ti_sdo_ce_osal_Memory_getBufferPhysicalAddress(), no attempt is made to map the physically contiguous buffer into the application's virtual memory space.
This is typically called by a stub implementation to translate a buffer provided by a remote skeleton and/or algorithm into an application-usable, virtual address.
On some homogenous multicore devices (e.g. C6472), this service translates a local address to a global address that's visible by a different processor.
To enable portable code, this is safe to call on systems without virtual memory. In those cases, the returned "virtual" buffer will be the same as the provided physical buffer.
This definition also has a short name alias of Memory_getBufferVirtualAddress.
See also:
ti_sdo_ce_osal_Memory_getBufferPhysicalAddress()
Void ti_sdo_ce_osal_Memory_registerContigBuf ( UInt32  virtualAddress,
UInt32  sizeInBytes,
UInt32  physicalAddress 
)

Register a physical buffer allocated without ti_sdo_ce_osal_Memory_contigAlloc()

Parameters:
[in]virtualAddressAddress of the buffer mapped into the process space
[in]sizeInBytesSize of the region
[in]physicalAddressPhysical address of the buffer
Remarks:
A cache of "app-address to codec-address" mappings (e.g. virtual to physical address mappings in DM644x devices) is internally maintained in some environments (e.g. Linux). This is used, for example, by Memory_getBufferPhysicalAddress() and Memory_getBufferVirtualAddress(). This lookup map is automatically updated when using Memory_contigAlloc() and Memory_contigFree(). However, if the user acquires buffers independently, it must use Memory_registerContigBuf() and Memory_unregisterContigBuf() to ensure the lookup map is current.
Individual sub-blocks of a buffer need not be registered; registering the entire buffer once will suffice.
This API is typically only required for environments with virtual memory (e.g. Linux-based systems).
See also:
ti_sdo_ce_osal_Memory_unregisterContigBuf()
ti_sdo_ce_osal_Memory_dumpKnownContigBufsList()
Void ti_sdo_ce_osal_Memory_unregisterContigBuf ( UInt32  virtualAddress,
UInt32  sizeInBytes 
)

Unregisters a physical buffer allocated without ti_sdo_ce_osal_Memory_contigAlloc().

Parameters:
[in]virtualAddressbeginning address of the buffer mapped into the process space
[in]sizeInBytessize of the region
Remarks:
This API must be used to unregister a buffer allocated outside of Memory_contigAlloc() if the buffer (or a portion of it) is passed on to VISA calls. Segments of the buffer need not be individually unregistered.
See also:
ti_sdo_ce_osal_Memory_registerContigBuf()
ti_sdo_ce_osal_Memory_dumpKnownContigBufsList()

Variable Documentation

Default parameters for ti_sdo_ce_osal_Memory_alloc() & ti_sdo_ce_osal_Memory_free()

Remarks:
This definition also has a short name alias of Memory_DEFAULTPARAMS.
ti_sdo_ce_osal_Memory_DEFAULTPARAMS will be used when NULL is passed in the ti_sdo_ce_osal_Memory_AllocParams parameter for ti_sdo_ce_osal_Memory_alloc() & ti_sdo_ce_osal_Memory_free(). When passing a non-NULL ti_sdo_ce_osal_Memory_AllocParams parameter, you should first copy ti_sdo_ce_osal_Memory_DEFAULTPARAMS to your structure and then modify individual elements as needed:
      Memory_AllocParams  myParams;

      myParams = Memory_DEFAULTPARAMS;
      myParams.type = Memory_CONTIGHEAP;
See also:
ti_sdo_ce_osal_Memory_alloc()
ti_sdo_ce_osal_Memory_free()
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Copyright 2012, Texas Instruments Incorporated