//***************************************************************************** // (C) Automotive Lighting Reutlingen GmbH // Tuebinger Strasse 123, 72762 Reutlingen, Germany // // Automotive Lighting Reutlingen GmbH owns all the rights to this work. // This work shall not be copied, reproduced, used, modified, transferred // or its information shall not be disclosed without the prior written // authorization of Automotive Lighting Reutlingen GmbH. //***************************************************************************** //----------------------------------------------------------------------------- /// \file StatM.h /// /// \brief ECU statistic manager, including CPU load, stack usage... /// /// \author f24301c (walker.lv@marelli.com) /// /// \date 05.17.2023 //----------------------------------------------------------------------------- #ifndef STATM_2023_05_24_H #define STATM_2023_05_24_H //============================================================================= // Includes //============================================================================= #include "inc/StatM_Publish.h" //============================================================================= // internal data structure //============================================================================= #if (STATM_MEASURE_CPU_LOAD == STD_ON) typedef struct { uint32 startFlag; // set the flag to start CPU load measurement uint32 idleCounter; // idle counter during measurement, 2us per count TIMER endTime; // GPT timestamp of end of test, current + CPULOAD_TEST_PEROID_US, intermediate variable uint8 runningFlag; // CPU load measurement in progress flag uint8 reserved0; // padding uint16 nonIdleLoad; // holds result CPU load measurement, in 0,1%, // including system time, task time, interrupt/exception time(no exception should happen) uint16 duration; // define cpu load measurement duration, in millisecond uint16 reserved1; // padding } StatM_Statistic_CpuLoad; #endif #if (STATM_PFLSH_INTEGRITY_CHECK == STD_ON) #include #define HASH_START_ADDR (0x80080100u) #define HASH_LENGHT (0x0026FF00u) typedef struct { uint16 hashReady; // flag of digest availability uint16 integrityFlag; // flag after integrity check uint32 hashStartAddr; // begin address of pFlash to be check uint32 hashLength; // size of data to be check uint8 digest[SHA256_DIGEST_LENGTH]; // HASH Digest uint32 duration; // HASH execution time in [microsecond] } StatM_Statistic_Pflash_Intact; #endif // end of STATM_PFLSH_INTEGRITY_CHECK #if (OS_CFG_STACKMEASUREMENT == STD_ON) // stack statistic typedef enum { StatM_Stack_Type_Core = 0, StatM_Stack_Type_ISR = 1, StatM_Stack_Type_TASK = 2, StatM_Stack_Type_INVALID = 0xFFu, } StatM_Stack_Type; typedef struct { StatM_Stack_Type type; uint8 parameter; // parameter to Os_GetxxxStackUsage, based on type const uint32 StartAddress; // static config const uint32 StatckSize; // size in byte const uint32 EndAddress; uint32 UsedSize; // runtime dynamic float UsedPercentage; } StatM_Statistic_Stack; #endif typedef struct { uint32 systemUptime; // system up time in second #if (STATM_MEASURE_CPU_LOAD == STD_ON) StatM_Statistic_CpuLoad cpuLoad; #endif #if (OS_CFG_STACKMEASUREMENT == STD_ON) StatM_Statistic_Stack* stacks; // stack usage, include kernel, task stack // NOTENOTE: last member->StartAddress is 0 // this mark the end of the effective element of the array #endif #if (STATM_PFLSH_INTEGRITY_CHECK == STD_ON) StatM_Statistic_Pflash_Intact pFlashIntegrity; // HASH2-256 #endif } StatM_Stat_System_Interal; //============================================================================= // macros //============================================================================= #define SMU_ALARM_TEST STD_OFF //============================================================================= // local global functions //============================================================================= extern void StatM_SmuInit(void); #if (STATM_MEASURE_CPU_LOAD == STD_ON) extern void StatM_IdleLoop2us(void); // export for Os Idle task #endif #if (SMU_ALARM_TEST == STD_ON) extern void Smu_Trigger_SW_Alarm(const uint8 AlarmNum); #endif //============================================================================= // Start declaration or definitions of functions //============================================================================= #endif // STATM_2023_05_24_H