📄 ram.st
字号:
#include <RTOS_Variables.h>
#include <RTOS_Header.h>
VAR_EXTERNAL
pEndMem : ^void;
pNextMem : ^void;
END_VAR
// This function serves as an interface to the RAM-class
// It has to be compiled with any project using the RTDB-object-loader.
// If this project doesn't use RAM-classes, this function will always
// return C_OK. Otherwise a static RAM-method is called to allocate memory
// for the retentive part of RAM-objects.
//
FUNCTION GLOBAL _GetRAM
VAR_OUTPUT
ret_code : ConfStates;
END_VAR
#ifdef LSL_TEST
// If You do not want to have additional checks and
// debug traces, just undefine the constant LSL_TEST
// in the global header file of this project.
// #pragma message ("Compiling a test version!")
#endif
IF _RtOSversion < 16#0500 THEN
// With old projects, no check is performed, malloc isn't used
// With new projects, a trace message is generated, malloc is used
#ifdef DONT_CHECK_OS_0500 // OS-version too old?
// Please download an OS with version greater or equal 5.00.
// With the currently used version You might face memory problems.
//
// The various OS-versions can be found in the LASAL installation
// directory (i.e. c:\program files\lasal\class\OS Versions).
// The new OS can be downloaded by selecting the menu item
// 'debug\extras\download OS'.
// Please make sure the downloaded OS version meets Your requirements
// (i.e. graphic/text mode, resolution, IPC/x386).
TRACE("OS-version too old. Doubleclick for more information!");
#endif // DONT_CHECK_OS_0500
END_IF;
ret_code := C_OK;
END_FUNCTION
#ifndef DONT_CHECK_OS_0500 // OS-version too old?
#ifdef MAX_MEMORY // only with new LASAL and Loader-Versions
#ifndef MAX_MEM
TYPE
#ifdef TARGET_IPC
#define USE_MEM 16#100000 // memory area used by the alloc-command
#elif TARGET_DIAS
#define USE_MEM 16#80000
#else // TARGET_ANY
#define USE_MEM 16#1E000
#endif
// keep space for ordinary variables
#define MAX_MEM (MAX_MEMORY-16#2000)
#if MAX_MEM < USE_MEM // can be defined in global.h
// in the project-directory
#undef USE_MEM
#define USE_MEM MAX_MEM // MAX_MEMORY is set when compiling
// during online operation
#pragma message ("===> Configuration Is Adjusted To Currently Used Target")
#pragma message (" max. Size of Data Segment: " MAX_MEMORY)
#endif // MAX_MEM
FreeMemory : ARRAY[0..USE_MEM-1] OF USINT;
END_TYPE
VAR_PRIVATE
aDummyBlock AT % M 1100 : ARRAY[0..16#125] OF USINT;
aMemBlock : FreeMemory;
END_VAR
// Initializes the pointers to start and end of the
// free memory block. When the project is compiled online
// MAX_MEMORY contains the maximum data size of the
// target system.
//
FUNCTION GLOBAL _alloc_init
pNextMem := #aMemBlock $ void;
pEndMem := #aMemBlock $ void + (sizeof(FreeMemory)-1);
END_FUNCTION
#define _ALLOC_INIT_IS_DEFINED_
#endif // !MAX_MEM
#endif // MAX_MEMORY
#endif // DONT_CHECK_OS_0500
#ifndef _ALLOC_INIT_IS_DEFINED_
FUNCTION GLOBAL _alloc_init
pNextMem :=
pEndMem := NIL; // this indicates, that malloc can be used
END_FUNCTION
#endif // _ALLOC_INIT_IS_DEFINED_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -