The introduced Heap-manager requires on administration of ≥64kB 2(3)bytes and up to 4GB 4(5)bytes overhead per entry (depends on linked with MEM_CleanUp).
Additional he can administer RAM and EE-PROM parallel and gives HW-indepenend tools for write accesses to the EE-PROM memory over the port.
User-Functions:
Memory-Manager: | |
MEM_Init | Initialization of the Heap-Manager |
MEM_Alloc | Allocation of storage |
MEM_Free | release allocated storage |
MEM_Resize | Size of allocated storage alters |
Heap_Write_EE | on allocated EEPROM-heap write |
Heap_Fill_EE | allocated EEPROM-heap fill |
optional | |
MEM_CleanUp | release all allocated storage-elements of a task |
Error-Codes:
Name | Decimal_Value | Description |
MEM_NO_ERR | 0 | no error |
MEM_WR_PTR | 120 | Pointer is not in the storage area or not allocated or no valid entry into this address |
MEM_OVF | 121 | memory pool fully |
MEM_ERR | 122 | error in the memory management |
allgemeines
MEM_Init
It initializes the heap-manager. If the EE-heap should be recognized as unformatted, so this is executed.
This function must be called before all other heap services at the system initialization once.
With utilization of the Linux-HOSTs, an existing heap-IMAGE is tried before the EE-formattest to load for the EE-simulation from a Linux-file.
Parameters
none |
Return Value
MEM_NO_ERR | initializes successfully |
MEM_ERR | Mistakes in the memory management |
MEM_INVALID | EE-IMAGE invalid (only with Linux-HOST) |
Example
MEM_Flush
Only with utilization of the Linux_HOST.
It saves the EE-heap as image into a Linux-file.
Parameters
none |
Return Value
MEM_NO_ERR | secured successfully |
... | ... |
Example
MEM_Alloc
Allocate the stated storage in the demanded memory type (RAM/EE) and returns the start address.
Parameters
size | size of array in bytes |
type | type of Memory (0=RAM / 1=EE) |
Return Value
If the returned address equally ZERO, so you get the following error-codes from MEM_GetErrNo().
MEM_OVF | memory full |
MEM_ERR | Mistakes in the memory management |
Example
MEM_Free
It releases the allocated storage again. The type of memory (RAM/EE) is determined on that occasion itself.
It becomes tried this freely storage area directly at a free storage behind it to the decontrol and if directly existing, at a free storage before it, to hang. (defragmentation)
Parameters
*ptr | pointer of array (from MEM_Alloc) |
Return Value
MEM_NO_ERR | memory released |
MEM_WR_PTR | Pointer is not in the storage area or not allocated or no valid entry into this address |
MEM_ERR | Mistakes in the memory management |
Example
MEM_CleanUp
If releases all allocated storage from the task with the priority prio again. The types of memory (RAM/EE) is determined on that occasion itself.
Parameters
prio | priority of task to free |
Return Value
MEM_NO_ERR | memory released |
OS_PRIO_INVALID | the priority is bigger OS_MAX_TASK |
OS_TASK_SUSP_PRIO | under this priority, no Task is registered |
MEM_ERR | Mistakes in the memory management |
Example
MEM_Resize
Resize the allocated storage and returns the new start address.
It will try on that occasion when increasing, a possible free storage directly behind this entry, and if this is not yet enough to use a possible free storage exactly before this entry. (defragmentation)
Only if this is not enough, a new area becomes allocated by means of MEM_Alloc and the old one released after taken place copy of data by means of MEM_Free
Parameters
*ptr | pointer of array (from MEM_Alloc) |
newsize | new size of array in bytes |
Return Value
If the returned address equally ZERO, so you get the following error-codes from MEM_GetErrNo().
MEM_OVF | memory full |
MEM_WR_PTR | Pointer is not in the storage area or not allocated or no valid entry into this address |
MEM_ERR | Mistakes in the memory management |
Example
EE-Heap Access
Heap_Write_EE
Write length bytes from *source to *dest into the EE-PROM under observation of the HW-spezifica.
Parameters
*source | source pointer (not in EE-PROM) |
*dest | destination pointer into EE-PROM |
length | bytes to write |
Return Value
MEM_NO_ERR | memory written |
MEM_WR_PTR | source-pointer shows into the EE-PROM |
MEM_ERR | Mistakes in the memory management |
Example
Heap_Fill_EE
Fills the area into the EE-PROM with value under observation of the HW-spezifica.
Parameters
*dest | destination pointer into EE-PROM |
length | bytes to fill |
value | byte to fill with it |
Return Value
MEM_NO_ERR | memory written |
MEM_WR_PTR | dest-pointer doesn't show into the EE-PROM |
MEM_ERR | Mistakes in the memory management |
Example