From 947c78887e791596d4a5ec2d1079f8b1a049628b Mon Sep 17 00:00:00 2001 From: takeshi_hoshina Date: Tue, 27 Oct 2020 11:16:21 +0900 Subject: basesystem 0.1 --- .../server/include/ss_system_memory_monitor.h | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 systemservice/system_manager/server/include/ss_system_memory_monitor.h (limited to 'systemservice/system_manager/server/include/ss_system_memory_monitor.h') diff --git a/systemservice/system_manager/server/include/ss_system_memory_monitor.h b/systemservice/system_manager/server/include/ss_system_memory_monitor.h new file mode 100644 index 00000000..50cf8574 --- /dev/null +++ b/systemservice/system_manager/server/include/ss_system_memory_monitor.h @@ -0,0 +1,85 @@ +/* + * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_SystemManager +/// \brief This file provides support for System Manager System Low Memory +/// detection. +/// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef __SS_SYSTEM_MEMORY_MONITOR_H__ // NOLINT +#define __SS_SYSTEM_MEMORY_MONITOR_H__ + +#include +#include +#include +#include +#include +#include "ss_sm_config.h" + + +typedef enum _ESMSysMemThreadCommandIds { + eSysMemThrdCmd_SYS_LOW_MEMORY = 0x744, ///< SM.CrashDetector --> SM +} ESMSysMemThreadCommandIds; + +struct SysMem { + UI_32 FreeMemoryBytes; + UI_32 TotalMemoryBytes; +}; + +const UI_32 SS_SLM_MEM_MONITOR_TIMER_ID = 3000; +const UI_32 SS_SLM_SYSTEMMANAGERLOG_TIMER_ID = 3001; +const UI_32 SS_MEMORY_TIMER_CONFIG_MS = 1000; +const UI_32 SS_SYSTEMMANAGERLOG_TIMER_CONFIG_MS = 30000; + +class CSysMemoryMonitor { + public: + CSysMemoryMonitor(void); + + virtual ~CSysMemoryMonitor(void); + + EFrameworkunifiedStatus Initialize(HANDLE f_hApp); + EFrameworkunifiedStatus StopAndFreeObjects(HANDLE f_hApp); + + const std::string GetThreadName(void); + void SetSLMConfigData(SLMConfigParameters &f_ConfigData); // NOLINT + + private: + EFrameworkunifiedStatus CPUMemThreadStart(HANDLE f_hThread); + EFrameworkunifiedStatus CPUMemThreadStop(HANDLE f_hThread); + EFrameworkunifiedStatus StopTimers(void); + EFrameworkunifiedStatus OnMemoryTimerExpiry(HANDLE f_hThread); + EFrameworkunifiedStatus OnSystemmanagerlogTimerExpiry(HANDLE f_hThread); + EFrameworkunifiedStatus OnAvailability(HANDLE f_hThread); + + UI_32 GetSystemRamSize(void); + UI_32 BitReverse32(UI_32 f_val); + + HANDLE m_hThread; + HANDLE m_hParentApp; + Timer m_memMonitorTimer; + Timer m_systemmanagerlogTimer; + SLMConfigParameters m_SLMConfig; + SI_32 m_SLMCheckCounter; + SI_32 m_siPriority; + UI_32 m_NbrSamplesBeforeSystemmanagerlog; + SysMem m_sysMemInfoLast; + std::string m_memMonitorThreadName; + uint32_t m_resmSession; +}; + +#endif // __SS_SYSTEM_MEMORY_MONITOR_H__ // NOLINT -- cgit 1.2.3-korg