2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_SystemManager
19 /// \brief This file provides support for System Manager System Low Memory
22 ///////////////////////////////////////////////////////////////////////////////
24 #ifndef __SS_SYSTEM_MEMORY_MONITOR_H__ // NOLINT
25 #define __SS_SYSTEM_MEMORY_MONITOR_H__
27 #include <native_service/frameworkunified_types.h>
28 #include <system_service/resm.h>
29 #include <system_service/ss_system_timer.h>
32 #include "ss_sm_config.h"
35 typedef enum _ESMSysMemThreadCommandIds {
36 eSysMemThrdCmd_SYS_LOW_MEMORY = 0x744, ///< SM.CrashDetector --> SM
37 } ESMSysMemThreadCommandIds;
40 UI_32 FreeMemoryBytes;
41 UI_32 TotalMemoryBytes;
44 const UI_32 SS_SLM_MEM_MONITOR_TIMER_ID = 3000;
45 const UI_32 SS_SLM_SYSTEMMANAGERLOG_TIMER_ID = 3001;
46 const UI_32 SS_MEMORY_TIMER_CONFIG_MS = 1000;
47 const UI_32 SS_SYSTEMMANAGERLOG_TIMER_CONFIG_MS = 30000;
49 class CSysMemoryMonitor {
51 CSysMemoryMonitor(void);
53 virtual ~CSysMemoryMonitor(void);
55 EFrameworkunifiedStatus Initialize(HANDLE f_hApp);
56 EFrameworkunifiedStatus StopAndFreeObjects(HANDLE f_hApp);
58 const std::string GetThreadName(void);
59 void SetSLMConfigData(SLMConfigParameters &f_ConfigData); // NOLINT
62 EFrameworkunifiedStatus CPUMemThreadStart(HANDLE f_hThread);
63 EFrameworkunifiedStatus CPUMemThreadStop(HANDLE f_hThread);
64 EFrameworkunifiedStatus StopTimers(void);
65 EFrameworkunifiedStatus OnMemoryTimerExpiry(HANDLE f_hThread);
66 EFrameworkunifiedStatus OnSystemmanagerlogTimerExpiry(HANDLE f_hThread);
67 EFrameworkunifiedStatus OnAvailability(HANDLE f_hThread);
69 UI_32 GetSystemRamSize(void);
70 UI_32 BitReverse32(UI_32 f_val);
74 Timer m_memMonitorTimer;
75 Timer m_systemmanagerlogTimer;
76 SLMConfigParameters m_SLMConfig;
77 SI_32 m_SLMCheckCounter;
79 UI_32 m_NbrSamplesBeforeSystemmanagerlog;
80 SysMem m_sysMemInfoLast;
81 std::string m_memMonitorThreadName;
82 uint32_t m_resmSession;
85 #endif // __SS_SYSTEM_MEMORY_MONITOR_H__ // NOLINT