module ti.sdo.ipc.heaps.HeapMemMP

Multi-processor variable size buffer heap implementation

This module has a common header that can be found in the ti.ipc package. Application code should include the common header file (not the RTSC-generated one):
#include <ti/ipc/HeapMemMP.h>
The RTSC module must be used in the application's RTSC configuration file (.cfg) if runtime APIs will be used in the application:
HeapMemMP = xdc.useModule('ti.sdo.ipc.heaps.HeapMemMP');
Documentation for all runtime APIs, instance configuration parameters, error codes macros and type definitions available to the application integrator can be found in the Doxygen documenation for the IPC product. However, the documentation presented on this page should be referred to for information specific to the RTSC module, such as module configuration, Errors, and Asserts.
C synopsis target-domain sourced in ti/sdo/ipc/heaps/HeapMemMP.xdc
#include <ti/sdo/ipc/heaps/HeapMemMP.h>
Functions
Void
Void
Void
Void
Functions common to all IHeap modules
Ptr 
Void 
Void 
Bool 
Functions common to all target instances
Functions common to all target modules
Typedefs
typedef struct
typedef struct
typedef struct
typedef struct
Constants
extern const Assert_Id 
extern const Assert_Id 
extern const Assert_Id 
extern const Assert_Id 
extern const Error_Id 
extern const UInt 
 
 
struct HeapMemMP_ExtendedStats

Stats structure for the getExtendedStats API

C synopsis target-domain
typedef struct HeapMemMP_ExtendedStats {
    Ptr buf;
    SizeT size;
} HeapMemMP_ExtendedStats;
 
FIELDS
buf — Local address of the shared buffer This may be different from the original buf parameter due to alignment requirements.
size — Size of the shared buffer. This may be different from the original size parameter due to alignment requirements.
 
config HeapMemMP_A_align  // module-wide

Assert raised when the requested alignment is not a power of 2

C synopsis target-domain
extern const Assert_Id HeapMemMP_A_align;
 
 
config HeapMemMP_A_heapSize  // module-wide

Assert raised when the requested heap size is too small

C synopsis target-domain
extern const Assert_Id HeapMemMP_A_heapSize;
 
 
config HeapMemMP_A_invalidFree  // module-wide

Assert raised when the free detects that an invalid addr or size

C synopsis target-domain
extern const Assert_Id HeapMemMP_A_invalidFree;
 
DETAILS
This could arise when multiple frees are done on the same buffer or if corruption occurred.
This also could occur when an alloc is made with size N and the free for this buffer specifies size M where M > N. Note: not every case is detectable.
This assert can also be caused when passing an invalid addr to free or if the size is causing the end of the buffer to be out of the expected range.
 
config HeapMemMP_A_zeroBlock  // module-wide

Assert raised when a block of size 0 is requested

C synopsis target-domain
extern const Assert_Id HeapMemMP_A_zeroBlock;
 
 
config HeapMemMP_E_memory  // module-wide

Raised when requested size exceeds largest free block

C synopsis target-domain
extern const Error_Id HeapMemMP_E_memory;
 
 
config HeapMemMP_maxNameLen  // module-wide

Maximum length for heap names

C synopsis target-domain
extern const UInt HeapMemMP_maxNameLen;
 
Module-Wide Built-Ins

C synopsis target-domain
Types_ModuleId HeapMemMP_Module_id();
// Get this module's unique id
 
Bool HeapMemMP_Module_startupDone();
// Test if this module has completed startup
 
IHeap_Handle HeapMemMP_Module_heap();
// The heap from which this module allocates memory
 
Bool HeapMemMP_Module_hasMask();
// Test whether this module has a diagnostics mask
 
Bits16 HeapMemMP_Module_getMask();
// Returns the diagnostics mask for this module
 
Void HeapMemMP_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types

C synopsis target-domain
typedef struct HeapMemMP_Object HeapMemMP_Object;
// Opaque internal representation of an instance object
 
typedef HeapMemMP_Object *HeapMemMP_Handle;
// Client reference to an instance object
 
typedef struct HeapMemMP_Struct HeapMemMP_Struct;
// Opaque client structure large enough to hold an instance object
 
HeapMemMP_Handle HeapMemMP_handle(HeapMemMP_Struct *structP);
// Convert this instance structure pointer into an instance handle
 
HeapMemMP_Struct *HeapMemMP_struct(HeapMemMP_Handle handle);
// Convert this instance handle into an instance structure pointer
Instance Config Parameters

C synopsis target-domain
typedef struct HeapMemMP_Params {
// Instance config-params structure
    IInstance_Params *instance;
    // Common per-instance configs
    GateMP_Handle gate;
    // GateMP used for critical region management of the shared memory
    String name;
    // Name of this instance
    UInt16 regionId;
    // Shared region ID
    SizeT sharedBufSize;
    // Size of sharedBuf
} HeapMemMP_Params;
 
Void HeapMemMP_Params_init(HeapMemMP_Params *params);
// Initialize this config-params structure with supplier-specified defaults before instance creation
 
config HeapMemMP_gate  // instance

GateMP used for critical region management of the shared memory

C synopsis target-domain
struct HeapMemMP_Params {
      ...
    GateMP_Handle gate;
 
DETAILS
Using the default value of NULL will result in use of the GateMP system gate for context protection.
 
config HeapMemMP_name  // instance

Name of this instance

C synopsis target-domain
struct HeapMemMP_Params {
      ...
    String name;
 
DETAILS
The name (if not NULL) must be unique among all HeapMemMP instances in the entire system. When creating a new heap, it is necessary to supply an instance name.
 
config HeapMemMP_regionId  // instance

Shared region ID

C synopsis target-domain
struct HeapMemMP_Params {
      ...
    UInt16 regionId;
 
DETAILS
The index corresponding to the shared region from which shared memory will be allocated.
 
config HeapMemMP_sharedBufSize  // instance

Size of sharedBuf

C synopsis target-domain
struct HeapMemMP_Params {
      ...
    SizeT sharedBufSize;
 
DETAILS
This is the size of the buffer to be used in the HeapMemMP instance. The actual buffer size in the created instance might actually be less than the value supplied in 'sharedBufSize' because of alignment constraints.
It is important to note that the total amount of shared memory required for a HeapMemMP instance will be greater than the size supplied here. Additional space will be consumed by shared instance attributes and alignment-related padding. Use the sharedMemReq or the sharedMemReqMeta call to determine the exact amount of shared memory required for an instance for a given sharedBufSize and cache settings.
Instance Creation

C synopsis target-domain
HeapMemMP_Handle HeapMemMP_create(const HeapMemMP_Params *params, Error_Block *eb);
// Allocate and initialize a new instance object and return its handle
 
Void HeapMemMP_construct(HeapMemMP_Struct *structP, const HeapMemMP_Params *params, Error_Block *eb);
// Initialize a new instance object inside the provided structure
ARGUMENTS
params — per-instance config params, or NULL to select default values (target-domain only)
eb — active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
See specific IHeap implementation for parameters used.
Instance Deletion

C synopsis target-domain
Void HeapMemMP_delete(HeapMemMP_Handle *handleP);
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
 
Void HeapMemMP_destruct(HeapMemMP_Struct *structP);
// Finalize the instance object inside the provided structure
 
HeapMemMP_alloc()  // instance

Allocates a block of memory from the heap

C synopsis target-domain
Ptr HeapMemMP_alloc(HeapMemMP_Handle handle, SizeT size, SizeT align, Error_Block *eb);
 
ARGUMENTS
handle — handle of a previously-created HeapMemMP instance object
size — size (in MADUs) of the block
align — alignment (in MADUs) of the block
eb — pointer to error block
DETAILS
This method returns a block of memory from the heap. It is called by the xdc.runtime.Memory.alloc() function.
RETURNS
Returns the address of the allocated memory.
 
HeapMemMP_free()  // instance

Free a block of memory back to the heap

C synopsis target-domain
Void HeapMemMP_free(HeapMemMP_Handle handle, Ptr block, SizeT size);
 
ARGUMENTS
handle — handle of a previously-created HeapMemMP instance object
block — non-NULL address of allocated block to free
size — size (in MADUs) of the block of memory to free
DETAILS
This method gives back a block of memory to a heap. It is called by the xdc.runtime.Memory.free() function.
 
HeapMemMP_getStats()  // instance

Retrieve the statistics from the heap

C synopsis target-domain
Void HeapMemMP_getStats(HeapMemMP_Handle handle, Memory_Stats *stats);
 
ARGUMENTS
handle — handle of a previously-created HeapMemMP instance object
stats — non-NULL pointer to an output buffer
DETAILS
The caller passes in a pointer to a xdc.runtime.Memory.Stats structure and getStats fills in this structure.
This function is called by the xdc.runtime.Memory.getStats() function.
The returned totalSize reflects the usable size of the buffer, not necessarily the size specified during create.
HEAPMEMMP
getStats() will lock the heap using the HeapMemMP Gate while it retrieves the HeapMemMP's statistics.
 
HeapMemMP_isBlocking()  // instance

Returns whether the heap may block during an alloc() or free()

C synopsis target-domain
Bool HeapMemMP_isBlocking(HeapMemMP_Handle handle);
 
ARGUMENTS
handle — handle of a previously-created HeapMemMP instance object
RETURNS
If the heap might block, TRUE is returned. If the heap does not block, FALSE is returned.
Instance Convertors

C synopsis target-domain
IHeap_Handle HeapMemMP_Handle_upCast(HeapMemMP_Handle handle);
// unconditionally move one level up the inheritance hierarchy
 
HeapMemMP_Handle HeapMemMP_Handle_downCast(IHeap_Handle handle);
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins

C synopsis target-domain
Int HeapMemMP_Object_count();
// The number of statically-created instance objects
 
HeapMemMP_Handle HeapMemMP_Object_get(HeapMemMP_Object *array, Int i);
// The handle of the i-th statically-created instance object (array == NULL)
 
HeapMemMP_Handle HeapMemMP_Object_first();
// The handle of the first dynamically-created instance object, or NULL
 
HeapMemMP_Handle HeapMemMP_Object_next(HeapMemMP_Handle handle);
// The handle of the next dynamically-created instance object, or NULL
 
IHeap_Handle HeapMemMP_Object_heap();
// The heap used to allocate dynamically-created instance objects
 
Types_Label *HeapMemMP_Handle_label(HeapMemMP_Handle handle, Types_Label *buf);
// The label associated with this instance object
 
String HeapMemMP_Handle_name(HeapMemMP_Handle handle);
// The name of this instance object
 
XDCscript usage meta-domain sourced in ti/sdo/ipc/heaps/HeapMemMP.xdc
var HeapMemMP = xdc.useModule('ti.sdo.ipc.heaps.HeapMemMP');
module-wide constants & types
        obj.buf = Ptr  ...
        obj.size = SizeT  ...
module-wide config parameters
        msg: "A_align: Requested align is not a power of 2"
    };
        msg: "A_heapSize: Requested heap size is too small"
    };
        msg: "A_invalidFree: Invalid free"
    };
        msg: "A_zeroBlock: Cannot allocate size 0"
    };
        msg: "E_memory: Out of memory: handle=0x%x, size=%u"
    };
 
per-instance config parameters
    var params = new HeapMemMP.Params// Instance config-params object;
        params.name// Name of this instance = String null;
        params.regionId// Shared region ID = UInt16 0;
        params.sharedBufSize// Size of sharedBuf = SizeT 0;
per-instance creation
    var inst = HeapMemMP.create// Create an instance-object(params);
 
 
struct HeapMemMP.ExtendedStats

Stats structure for the getExtendedStats API

XDCscript usage meta-domain
var obj = new HeapMemMP.ExtendedStats;
 
    obj.buf = Ptr  ...
    obj.size = SizeT  ...
 
FIELDS
buf — Local address of the shared buffer This may be different from the original buf parameter due to alignment requirements.
size — Size of the shared buffer. This may be different from the original size parameter due to alignment requirements.
C SYNOPSIS
 
config HeapMemMP.A_align  // module-wide

Assert raised when the requested alignment is not a power of 2

XDCscript usage meta-domain
HeapMemMP.A_align = Assert.Desc {
    msg: "A_align: Requested align is not a power of 2"
};
 
C SYNOPSIS
 
config HeapMemMP.A_heapSize  // module-wide

Assert raised when the requested heap size is too small

XDCscript usage meta-domain
HeapMemMP.A_heapSize = Assert.Desc {
    msg: "A_heapSize: Requested heap size is too small"
};
 
C SYNOPSIS
 
config HeapMemMP.A_invalidFree  // module-wide

Assert raised when the free detects that an invalid addr or size

XDCscript usage meta-domain
HeapMemMP.A_invalidFree = Assert.Desc {
    msg: "A_invalidFree: Invalid free"
};
 
DETAILS
This could arise when multiple frees are done on the same buffer or if corruption occurred.
This also could occur when an alloc is made with size N and the free for this buffer specifies size M where M > N. Note: not every case is detectable.
This assert can also be caused when passing an invalid addr to free or if the size is causing the end of the buffer to be out of the expected range.
C SYNOPSIS
 
config HeapMemMP.A_zeroBlock  // module-wide

Assert raised when a block of size 0 is requested

XDCscript usage meta-domain
HeapMemMP.A_zeroBlock = Assert.Desc {
    msg: "A_zeroBlock: Cannot allocate size 0"
};
 
C SYNOPSIS
 
config HeapMemMP.E_memory  // module-wide

Raised when requested size exceeds largest free block

XDCscript usage meta-domain
HeapMemMP.E_memory = Error.Desc {
    msg: "E_memory: Out of memory: handle=0x%x, size=%u"
};
 
C SYNOPSIS
 
config HeapMemMP.maxNameLen  // module-wide

Maximum length for heap names

XDCscript usage meta-domain
HeapMemMP.maxNameLen = UInt 32;
 
C SYNOPSIS
 
metaonly config HeapMemMP.common$  // module-wide

Common module configuration parameters

XDCscript usage meta-domain
HeapMemMP.common$ = Types.Common$ undefined;
 
DETAILS
All modules have this configuration parameter. Its name contains the '$' character to ensure it does not conflict with configuration parameters declared by the module. This allows new configuration parameters to be added in the future without any chance of breaking existing modules.
 
metaonly config HeapMemMP.maxRuntimeEntries  // module-wide

Maximum runtime entries

XDCscript usage meta-domain
HeapMemMP.maxRuntimeEntries = UInt NameServer.ALLOWGROWTH;
 
DETAILS
Maximum number of HeapMemMP's that can be dynamically created and added to the NameServer.
To minimize the amount of runtime allocation, this parameter allows the pre-allocation of memory for the HeapMemMP's NameServer table. The default is to allow growth (i.e. memory allocation when creating a new instance).
 
metaonly config HeapMemMP.tableSection  // module-wide

Section name is used to place the names table

XDCscript usage meta-domain
HeapMemMP.tableSection = String null;
 
DETAILS
The default value of NULL implies that no explicit placement is performed.
Instance Config Parameters

XDCscript usage meta-domain
var params = new HeapMemMP.Params;
// Instance config-params object
    params.gate = GateMP.Handle null;
    // GateMP used for critical region management of the shared memory
    params.name = String null;
    // Name of this instance
    params.regionId = UInt16 0;
    // Shared region ID
    params.sharedBufSize = SizeT 0;
    // Size of sharedBuf
 
config HeapMemMP.gate  // instance

GateMP used for critical region management of the shared memory

XDCscript usage meta-domain
var params = new HeapMemMP.Params;
  ...
params.gate = GateMP.Handle null;
 
DETAILS
Using the default value of NULL will result in use of the GateMP system gate for context protection.
C SYNOPSIS
 
config HeapMemMP.name  // instance

Name of this instance

XDCscript usage meta-domain
var params = new HeapMemMP.Params;
  ...
params.name = String null;
 
DETAILS
The name (if not NULL) must be unique among all HeapMemMP instances in the entire system. When creating a new heap, it is necessary to supply an instance name.
C SYNOPSIS
 
config HeapMemMP.regionId  // instance

Shared region ID

XDCscript usage meta-domain
var params = new HeapMemMP.Params;
  ...
params.regionId = UInt16 0;
 
DETAILS
The index corresponding to the shared region from which shared memory will be allocated.
C SYNOPSIS
 
config HeapMemMP.sharedBufSize  // instance

Size of sharedBuf

XDCscript usage meta-domain
var params = new HeapMemMP.Params;
  ...
params.sharedBufSize = SizeT 0;
 
DETAILS
This is the size of the buffer to be used in the HeapMemMP instance. The actual buffer size in the created instance might actually be less than the value supplied in 'sharedBufSize' because of alignment constraints.
It is important to note that the total amount of shared memory required for a HeapMemMP instance will be greater than the size supplied here. Additional space will be consumed by shared instance attributes and alignment-related padding. Use the sharedMemReq or the sharedMemReqMeta call to determine the exact amount of shared memory required for an instance for a given sharedBufSize and cache settings.
C SYNOPSIS
Instance Creation

XDCscript usage meta-domain
var params = new HeapMemMP.Params;
// Allocate instance config-params
params.config =   ...
// Assign individual configs
 
var inst = HeapMemMP.create(params);
// Create an instance-object
ARGUMENTS
params — per-instance config params, or NULL to select default values (target-domain only)
eb — active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
See specific IHeap implementation for parameters used.
generated on Sat, 11 Feb 2012 00:38:01 GMT