The HeapCallback module enables users to provide a custom heap
implementation by providing callback functions that will be invoked
by HeapCallback for the various heap management functions.
The user-supplied HeapCallback.initInstFxn is called during boot time to
initialize any HeapCallback objects that were created in the .cfg file.
The user-supplied HeapCallback.createInstFxn is called during runtime
for any calls to HeapCallback_create(). Both of these functions return
a context value (typically a pointer to an object managed by the
user-supplied heap code). This context value is passed to subsequent
user allocInstFxn, freeInstFxn, etc. functions.
HeapCallback_alloc(), HeapCallback_free() and HeapCallback_getStats()
call the user-supplied allocInstFxn, freeInstFxn and getStatsInstFxn
functions with the context value returned by initInstFxn or createInstFxn.
HeapCallback_delete() calls the user-supplied instDeleteFxn with the
context returned by the createInstFxn.
Configuration example: The following XDC configuration statements
creates a HeapCallback instance and plugs in the user defined functions.
typedef HeapCallback_AllocInstFxn |
|
Instance alloc callback function signature
typedef Ptr (*HeapCallback_AllocInstFxn)(UArg,SizeT,SizeT);
DETAILS
This function takes the context return from createInstFxn(), the
size to be allocated and the align value. The return value from
this function is a pointer to the allocated memory block.
typedef HeapCallback_CreateInstFxn |
|
Instance create callback function signature
typedef UArg (*HeapCallback_CreateInstFxn)(UArg);
DETAILS
HeapCallback.arg is passed as an argument to this function.
The return value from this function (context) will be passed as an
argument to the other instance functions.
typedef HeapCallback_DeleteInstFxn |
|
Instance delete callback function signature
typedef Void (*HeapCallback_DeleteInstFxn)(UArg);
DETAILS
The context returned from createInstFxn() is passed as an argument to
this function.
typedef HeapCallback_FreeInstFxn |
|
Instance free callback function signature
typedef Void (*HeapCallback_FreeInstFxn)(UArg,Ptr,SizeT);
DETAILS
This function takes the context returned by createInstFxn() and a
pointer to the buffer to be freed and the size to be freed.
typedef HeapCallback_GetStatsInstFxn |
|
Instance getStats callback function signature
typedef Void (*
HeapCallback_GetStatsInstFxn)(
UArg,
Memory_Stats*);
DETAILS
This function takes the context returned by createInstFxn() and a
pointer to a memory stats object.
typedef HeapCallback_InitInstFxn |
|
Instance init callback function signature
typedef UArg (*HeapCallback_InitInstFxn)(UArg);
DETAILS
`
HeapCallback.arg is passed as an argument to this function.
The return value from this function (context) will passed as an
argument to the other instance functions.
typedef HeapCallback_IsBlockingInstFxn |
|
Instance isblocking callback function signature
typedef Bool (*HeapCallback_IsBlockingInstFxn)(UArg);
DETAILS
The context return from createInstFxn() is passed as an argument to
this function. The return value is 'TRUE' or 'FALSE'.
config HeapCallback_allocInstFxn // module-wide |
|
User supplied instance alloc function
DETAILS
This function is called when the
HeapCallback.alloc is
called.
This parameter is configured with a default alloc function. The
default alloc function returns NULL.
config HeapCallback_createInstFxn // module-wide |
|
User supplied instance create function
DETAILS
This function is called when the
HeapCallback.create is
called.
This parameter is configured with a default create function.
The default create function returns 0.
config HeapCallback_deleteInstFxn // module-wide |
|
User supplied instance delete function
DETAILS
This function is called when the
HeapCallback.delete is
called.
This parameter is configured with a default delete function.
config HeapCallback_freeInstFxn // module-wide |
|
User supplied instance free function
DETAILS
This function is called when the
HeapCallback.free is
called.
This parameter is configured with a default free function.
config HeapCallback_getStatsInstFxn // module-wide |
|
User supplied getStat function
DETAILS
This function is called when the
HeapCallback.getStat is
called.
This parameter is configured with a default getStats function.
The default getStats function does not make any changes to stats
structure.
config HeapCallback_initInstFxn // module-wide |
|
User supplied init function
DETAILS
This function is called in Module startup for statically created
instances. The user-supplied function must not do any memory
allocations or call any module create functions (e.g.,
Semaphore_create()).
This parameter is configured with a default init function. The
default init function returns NULL.
config HeapCallback_isBlockingInstFxn // module-wide |
|
User supplied isBlocking function
DETAILS
This function is called when the
HeapCallback.isBlocking is
called.
This parameter is configured with a default isBlocking function. The
default isBlocking returns FALSE.
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool HeapCallback_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool HeapCallback_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 HeapCallback_Module_getMask();
// Returns the diagnostics mask for this module
Void HeapCallback_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types |
|
typedef struct HeapCallback_Object HeapCallback_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct HeapCallback_Struct HeapCallback_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
Instance Config Parameters |
|
typedef struct HeapCallback_Params {
// Instance config-params structure
// Common per-instance configs
UArg arg;
// User supplied argument for the user supplied create function
} HeapCallback_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
config HeapCallback_Params.arg // instance |
|
User supplied argument for the user supplied create function
DETAILS
This user supplied argument will be passed back as an argument to the
createInstFxn function. It can be used by the
HeapCallback.createInstFxn function at runtime to
differentiate between the multiple Heap instances configured in the
user config script.
The user can skip configuring this argument. In such a case, the
default value 0 will be passed back as an argument to the
createInstFxn function.
Runtime Instance Creation |
|
// Allocate and initialize a new instance object and return its handle
// 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)
Instance Deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
HeapCallback_alloc() // instance |
|
Allocates a block of memory from the heap
ARGUMENTS
handle
handle of a previously-created HeapCallback 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.
HeapCallback_free() // instance |
|
Free a block of memory back to the heap
ARGUMENTS
handle
handle of a previously-created HeapCallback 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.
HeapCallback_getContext() // instance |
|
Get the context returned from user supplied create function
ARGUMENTS
handle
handle of a previously-created HeapCallback instance object
HeapCallback_getStats() // instance |
|
Retrieve the statistics from the heap
ARGUMENTS
handle
handle of a previously-created HeapCallback 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.
HeapCallback_isBlocking() // instance |
|
Returns whether the heap may block during an alloc() or
free()
ARGUMENTS
handle
handle of a previously-created HeapCallback instance object
RETURNS
If the heap might block, TRUE is returned.
If the heap does not block, FALSE is returned.
Instance Convertors |
|
// unconditionally move one level up the inheritance hierarchy
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins |
|
Int HeapCallback_Object_count();
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object
config HeapCallback.allocInstFxn // module-wide |
|
User supplied instance alloc function
HeapCallback.allocInstFxn = Ptr(*)(UArg,SizeT,SizeT) '&ti_sysbios_heaps_HeapCallback_defaultAlloc';
DETAILS
This function is called when the
HeapCallback.alloc is
called.
This parameter is configured with a default alloc function. The
default alloc function returns NULL.
C SYNOPSIS
config HeapCallback.createInstFxn // module-wide |
|
User supplied instance create function
HeapCallback.createInstFxn = UArg(*)(UArg) '&ti_sysbios_heaps_HeapCallback_defaultCreate';
DETAILS
This function is called when the
HeapCallback.create is
called.
This parameter is configured with a default create function.
The default create function returns 0.
C SYNOPSIS
config HeapCallback.deleteInstFxn // module-wide |
|
User supplied instance delete function
HeapCallback.deleteInstFxn = Void(*)(UArg) '&ti_sysbios_heaps_HeapCallback_defaultDelete';
DETAILS
This function is called when the
HeapCallback.delete is
called.
This parameter is configured with a default delete function.
C SYNOPSIS
config HeapCallback.freeInstFxn // module-wide |
|
User supplied instance free function
HeapCallback.freeInstFxn = Void(*)(UArg,Ptr,SizeT) '&ti_sysbios_heaps_HeapCallback_defaultFree';
DETAILS
This function is called when the
HeapCallback.free is
called.
This parameter is configured with a default free function.
C SYNOPSIS
config HeapCallback.getStatsInstFxn // module-wide |
|
User supplied getStat function
HeapCallback.
getStatsInstFxn =
Void(*)(UArg,Memory.Stats*) '&ti_sysbios_heaps_HeapCallback_defaultGetStats';
DETAILS
This function is called when the
HeapCallback.getStat is
called.
This parameter is configured with a default getStats function.
The default getStats function does not make any changes to stats
structure.
C SYNOPSIS
config HeapCallback.initInstFxn // module-wide |
|
User supplied init function
HeapCallback.initInstFxn = UArg(*)(UArg) '&ti_sysbios_heaps_HeapCallback_defaultInit';
DETAILS
This function is called in Module startup for statically created
instances. The user-supplied function must not do any memory
allocations or call any module create functions (e.g.,
Semaphore_create()).
This parameter is configured with a default init function. The
default init function returns NULL.
C SYNOPSIS
config HeapCallback.isBlockingInstFxn // module-wide |
|
User supplied isBlocking function
HeapCallback.isBlockingInstFxn = Bool(*)(UArg) '&ti_sysbios_heaps_HeapCallback_defaultIsBlocking';
DETAILS
This function is called when the
HeapCallback.isBlocking is
called.
This parameter is configured with a default isBlocking function. The
default isBlocking returns FALSE.
C SYNOPSIS
metaonly config HeapCallback.common$ // module-wide |
|
Common module configuration parameters
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.
Instance Config Parameters |
|
var params = new HeapCallback.Params;
// Instance config-params object
params.arg = UArg 0;
// User supplied argument for the user supplied create function
config HeapCallback.Params.arg // instance |
|
User supplied argument for the user supplied create function
var params = new HeapCallback.Params;
...
params.arg = UArg 0;
DETAILS
This user supplied argument will be passed back as an argument to the
createInstFxn function. It can be used by the
HeapCallback.createInstFxn function at runtime to
differentiate between the multiple Heap instances configured in the
user config script.
The user can skip configuring this argument. In such a case, the
default value 0 will be passed back as an argument to the
createInstFxn function.
C SYNOPSIS
Static Instance Creation |
|
var params =
new HeapCallback.
Params;
// Allocate instance config-params
params.config = ...
// Assign individual configs
var inst = HeapCallback.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)