SysMem V3x E
SysMem V3x E
SysMem V3x E
CoDeSys V 3.x
SysMem.library
CONTENT
1 OVERVIEW 4
2 LIBRARY MODULES 5
2.1 SysMemAllocArea 5
2.2 SysMemAllocCode 5
2.3 SysMemAllocData 5
2.4 SysMemCmp 6
2.5 SysMemCpy 6
2.6 SysMemForceSwap 6
2.7 SysMemFreeArea 7
2.8 SysMemFreeCode 7
2.9 SysMemFreeData 7
2.10 SysMemIsValidPointer 8
2.11 SysMemMove 8
2.12 SysMemReallocData 8
2.13 SysMemSet 9
2.14 SysMemSwap 9
CHANGE HISTORY 10
libdoc_e.dot / V1.0
1 Overview
Note: It depends on the target system, which system libraries can be used in the application program.
This library conduces to memory management. Provided that the library functions are
supported by the target system they can be used to allocate or release memory, to define or
compare memory spaces, to copy the content of one memory to another or to swap. The
processing is synchronous.
SysMemAllocArea
SysMemAllocCode
SysMemAllocData
SysMemCmp
SysMemCpy
SysMemForceSwap
SysMemFreeArea
SysMemFreeCode
SysMemFreeData
SysMemIsValidPointer
SysMemMove
SysMemReallocData
SysMemSet
SysMemSwap
libdoc_e.dot / V1.0
2 Library Modules
2.1 SysMemAllocArea
This function dynamically allocates a memory area for an application. Therefor, the
component requesting memory has to be indicated as well as the required category and size
of memory.
The return of type POINTER TO BYTE is a pointer to the memory space reserved. In case of
the requested memory not being available, the NULL pointer will be returned. Therefore one
should always check the return even in case of small memory amount requested!
Input variable Data type Description
2.2 SysMemAllocCode
This function allocates memory space for code, wherein the code is executable. Therefore,
function SysMemAllocCode is mainly helpful for computer architectures that prevent the
default memory from executing of code. In addition to the memory size required one has to
indicate the component that is requesting memory.
The return of type POINTER TO BYTE is a pointer to the memory space reserved. In case of
the requested memory not being available, the NULL pointer will be returned. Therefore one
should always check the return even in case of small memory amount requested!
Input variable Data type Description
2.3 SysMemAllocData
This function dynamically allocates data memory for an application. Therefor, the component
requesting memory has to be indicated as well as the required category and size of memory.
The return of type POINTER TO BYTE is a pointer to the memory space reserved. In case of
the requested memory not being available, the NULL pointer will be returned. Therefore one
should always check the return even in case of small memory amount requested!
libdoc_e.dot / V1.0
pResult PONTER TO UDINT Pointer to error code; see document "Runtime Error
Codes"; (may be NULL)
2.4 SysMemCmp
By use of this function the content of two memory areas (buffer 1 and buffer 2) can be
compared.
The return of type DINT equals 0, if the content is identical. Otherwise, the function will return
a value unlike 0.
Input variable Data type Description
2.5 SysMemCpy
By use of this function a specified number of location is copied from one memory space to
another. In difference to SysMemMove (2.11) copying is only possible on non-cohesive
memory areas.
The return of type POINTER TO BYTE is a pointer to the address of the target memory.
Input variable Data type Description
2.6 SysMemForceSwap
This function serves to swap data within memory areas. It is mainly used to convert data from
Intel byte order to Motorola byte order or vice versa.
In difference to SysMemSwap (2.14) the function SysMemForceSwap does not care for the
target system used!
2.7 SysMemFreeArea
This function serves to release (deallocate) a memory area having been allocated by
SysMemAllocArea. Calling this function one has to indicate the name of the component
having requested this memory area originally as well as the pointer to the associated memory
address.
The return is an error code indicating success or failure of the operation (see document
"Runtime Error Codes").
Input variable Data type Description
2.8 SysMemFreeCode
This function serves to release (deallocate) a code memory area having been allocated by
SysMemAllocCode.
The return is an error code indicating success or failure of the operation (see document
"Runtime Error Codes").
Input variable Data type Description
2.9 SysMemFreeData
This function serves to release (deallocate) a data memory area having been allocated by
SysMemAllocData.
The return is an error code indicating success or failure of the operation (see document
"Runtime Error Codes").
Input variable Data type Description
2.10 SysMemIsValidPointer
This function checks if a pointer is assigned to a valid memory address.
The return is an error code indicating success or failure of the operation (see document
"Runtime Error Codes").
Input variable Data type Description
2.11 SysMemMove
This function serves to copy the content of one memory area (source) to another (target).
Calling this function one has to transmit to pointers pointing to the address of source and
target memory.
In difference to SysMemCpy (2.5) the memory spaces of source and target may belong to a
cohesive memory area and even overlap.
2.12 SysMemReallocData
By use of this function the size of a memory block can be modified (reallocation). Therefor a
pointer on the memory block to be reallocated is passed to the function. The content of the
memory block will not be modified.
If the requested memory size cannot made available at the same place (address) , the
function will allocate new memory space, copy the original content to the new memory and
release the old one.
The return is an error code indicating success or failure of the operation (see document
"Runtime Error Codes").
Input variable Data type Description
2.13 SysMemSet
By use of this function a memory space is initialized with a specified value.
The return is an error code indicating success or failure of the operation (see document
"Runtime Error Codes").
Input variable Data type Description
2.14 SysMemSwap
This function serves to swap data within memory areas. It is mainly used to convert data from
Intel byte order to Motorola byte order. Thereby portable libraries can be built.
Note: Swapping will only be executed on Motorola target systems (PPC), but not on Intel
target systems (ARM, MIPS, SH, x86). Otherwise see SysMemForceSwap (2.6).
0, if swapping is not necessary (i.e. the data already has Intel byte order).
a value >0 reflecting the number of bytes swapped. In particular: return 1, if buffer is
of type Motorola and function has been called with pbyBuffer =NULL
Input variable Data type Description
Change History
Version Description Date