summaryrefslogtreecommitdiffstats
path: root/systemservice
diff options
context:
space:
mode:
authorRiku Nomoto <riku_nomoto@mail.toyota.co.jp>2020-11-19 12:45:32 +0900
committerRiku Nomoto <riku_nomoto@mail.toyota.co.jp>2020-11-19 12:45:32 +0900
commit8e0e00d21146a84c18f9cf9409e187b4fb0248aa (patch)
treeef791689dad216ac61091a1d1bd3b928d563aba6 /systemservice
parent18df6e21c6743a137e2760c52ca89d0789e90417 (diff)
Init basesystem source codes.
Signed-off-by: Riku Nomoto <riku_nomoto@mail.toyota.co.jp> Change-Id: I55aa2f1406ce7f751ae14140b613b53b68995528
Diffstat (limited to 'systemservice')
-rwxr-xr-xsystemservice/config/LICENSE177
-rwxr-xr-xsystemservice/config/Makefile.client19
-rwxr-xr-xsystemservice/config/library/Makefile19
-rwxr-xr-xsystemservice/config/library/system_manager_config/Makefile21
-rwxr-xr-xsystemservice/config/library/system_manager_config/include/system_service/ss_access_if_private.h80
-rwxr-xr-xsystemservice/config/library/system_manager_config/include/system_service/ss_package.h65
-rwxr-xr-xsystemservice/config/library/system_manager_config/include/system_service/ss_system_manager_conf.h145
-rwxr-xr-xsystemservice/config/library/system_manager_config/include/system_service/system_manager_config.h26
-rwxr-xr-xsystemservice/config/library/system_manager_config/last2order/Makefile71
-rwxr-xr-xsystemservice/config/library/system_manager_config/last2order/sm_last2order.cfobin0 -> 8 bytes
-rwxr-xr-xsystemservice/config/library/system_manager_config/last2order/tool/mklast2ordertbl.pl107
-rwxr-xr-xsystemservice/config/library/system_manager_config/order/Makefile64
-rwxr-xr-xsystemservice/config/library/system_manager_config/order/launch_order_body.xml0
-rwxr-xr-xsystemservice/config/library/system_manager_config/order/launch_order_main.xml23
-rwxr-xr-xsystemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl171
-rwxr-xr-xsystemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg3
-rwxr-xr-xsystemservice/config/library/system_manager_config/order/system_launcher_main.xml36
-rwxr-xr-xsystemservice/config/library/system_manager_config/src/Makefile45
-rwxr-xr-xsystemservice/config/library/system_manager_config/src/libsssmcfg.ver30
-rwxr-xr-xsystemservice/config/library/system_manager_config/src/ss_system_manager_conf.cpp489
-rwxr-xr-xsystemservice/config/library/system_manager_config/xml/Makefile53
-rwxr-xr-xsystemservice/config/library/system_manager_config/xml/launch_cfg2xml.sh69
-rwxr-xr-xsystemservice/config/library/system_manager_config/xml/launch_xml2cfg.sh116
-rwxr-xr-xsystemservice/config/library/system_manager_config/xml/sm_launch_agl.cfg7
-rwxr-xr-xsystemservice/config/library/system_manager_config/xml/sm_launch_agl.xml35
-rwxr-xr-xsystemservice/interface_unified/LICENSE177
-rwxr-xr-xsystemservice/interface_unified/Makefile.client33
-rwxr-xr-xsystemservice/interface_unified/library/Makefile127
-rwxr-xr-xsystemservice/interface_unified/library/include/ss_devicedetection_service_if_interfaceunifiedlog.h86
-rwxr-xr-xsystemservice/interface_unified/library/include/ss_last_to_order_local.h41
-rwxr-xr-xsystemservice/interface_unified/library/include/ss_logger_service_if_interfaceunifiedlog.h86
-rwxr-xr-xsystemservice/interface_unified/library/include/ss_power_if_interfaceunifiedlog.h85
-rwxr-xr-xsystemservice/interface_unified/library/include/ss_system_if_interfaceunifiedlog.h89
-rwxr-xr-xsystemservice/interface_unified/library/include/ss_system_timer_local.h44
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/interface_unified.h100
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/interfaceunified_system_application.h219
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/interfaceunified_system_types.h165
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_boot_map.h25
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_client_names.h77
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service.h640
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service_ifc.h1118
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service_local.h37
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service_notifications.h58
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol.h143
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol_local.h69
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types.h186
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types_local.h44
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_error_event_common.h111
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_error_event_common_local.h63
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_error_message.h40
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_heartbeat_if.h165
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_heartbeat_notifications.h46
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_heartbeat_service_protocol.h72
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_last_to_order.h58
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_logger_service.h255
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_logger_service_ifc.h1865
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_logger_service_local.h94
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_logger_service_notifications.h47
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_logger_service_protocol.h146
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_logger_store_logs.h81
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_power_service.h535
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_power_service_if.h606
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_power_service_local.h66
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_power_service_notifications.h48
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_power_service_notifications_local.h67
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_power_service_protocol.h201
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_services.h63
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_sm_client_if.h1064
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_sm_client_if_local.h66
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_sm_thread_names.h45
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_sm_thread_names_local.h46
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_string_maps.h680
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_sys_boot_area_map.h39
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_if.h119
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_manager_if.h335
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_manager_if_local.h40
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_manager_notifications.h49
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_manager_notifications_local.h51
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_manager_protocol.h329
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_manager_protocol_local.h45
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_process.h1118
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_timer.h670
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_system_types.h36
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_templates.h303
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_test_clients.h31
-rwxr-xr-xsystemservice/interface_unified/library/include/system_service/ss_version.h33
-rwxr-xr-xsystemservice/interface_unified/library/src/libSS_SystemIfUnified.ver78
-rwxr-xr-xsystemservice/interface_unified/library/src/makefile_PosixBasedOS001180
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_devicedetection_service_ifc.cpp673
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_framework_if.cpp55
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_heartbeat_client.cpp156
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_last_to_order.cpp186
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_logger_service_ifc.cpp781
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_power_client.cpp254
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_pwrsvc_if.cpp343
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_sm_client.cpp1509
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_string_maps.cpp462
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_system_process.cpp1147
-rwxr-xr-xsystemservice/interface_unified/library/src/ss_system_timer.cpp228
-rwxr-xr-xsystemservice/interface_unified/scfg/gpf_ss_cpu_mon_config.cfg14
-rwxr-xr-xsystemservice/interface_unified/scfg/gpf_ss_ps_config.cfg20
-rwxr-xr-xsystemservice/interface_unified/scfg/gpf_ss_showmem.cfg6
-rwxr-xr-xsystemservice/interface_unified/scfg/ss_cpu_high_load_monitor.cfg85
-rwxr-xr-xsystemservice/interface_unified/scfg/ss_logger.cfg133
-rwxr-xr-xsystemservice/interface_unified/scfg/system_launch_flashloader.cfg8
-rwxr-xr-xsystemservice/interface_unified/scfg_pram/gpf_ss_sm_config_data.cfg26
-rwxr-xr-xsystemservice/logger_service/LICENSE177
-rwxr-xr-xsystemservice/logger_service/Makefile.server19
-rwxr-xr-xsystemservice/logger_service/server/Makefile28
-rwxr-xr-xsystemservice/logger_service/server/SS_LoggerService.conf_bin4
-rwxr-xr-xsystemservice/logger_service/server/include/loggerservicedebug_loggerservicelog.h81
-rwxr-xr-xsystemservice/logger_service/server/include/loggerservicedebug_thread_if.h319
-rwxr-xr-xsystemservice/logger_service/server/include/loggerservicedebug_writer_Evntworker.h211
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/reader/mem_reader.h51
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/reader/queue_reader.h49
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/reader/reader.h52
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/reader_writer.h77
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/reader_writer_cfg.h35
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/writer/cached_file_writer.h45
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/writer/file_writer.h51
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/writer/udp_file_writer.h54
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/writer/udp_writer.h63
-rwxr-xr-xsystemservice/logger_service/server/include/readerWriter/writer/writer.h56
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_cfg.h185
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_common.h115
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_device_detection.h66
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_error_event.h156
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_error_event_archive.h77
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_error_event_can_evt_reply.h48
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_error_event_cfg.h135
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_error_event_storage.h82
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_fs_directory.h108
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_popups.h51
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_reader_writer_control.h49
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_scrshot.h30
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_service_callbacks.h96
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_types.h52
-rwxr-xr-xsystemservice/logger_service/server/include/ss_logger_util.h127
-rwxr-xr-xsystemservice/logger_service/server/lib/Makefile62
-rwxr-xr-xsystemservice/logger_service/server/lib/ss_logger_store_logs.cpp2233
-rwxr-xr-xsystemservice/logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h96
-rwxr-xr-xsystemservice/logger_service/server/realtimeUsbLog/Makefile22
-rwxr-xr-xsystemservice/logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin4
-rwxr-xr-xsystemservice/logger_service/server/realtimeUsbLog/src/Makefile74
-rwxr-xr-xsystemservice/logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp103
-rwxr-xr-xsystemservice/logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp722
-rwxr-xr-xsystemservice/logger_service/server/realtimeUsbLog/work/Makefile23
-rwxr-xr-xsystemservice/logger_service/server/realtimeUsbLog/work_debug/Makefile19
-rwxr-xr-xsystemservice/logger_service/server/screenShot/Makefile52
-rwxr-xr-xsystemservice/logger_service/server/screenShot/ss_logger_scrshot.cpp89
-rwxr-xr-xsystemservice/logger_service/server/src/cached_file_writer.cpp79
-rwxr-xr-xsystemservice/logger_service/server/src/file_writer.cpp122
-rwxr-xr-xsystemservice/logger_service/server/src/loggerservice_application.cpp952
-rwxr-xr-xsystemservice/logger_service/server/src/loggerservice_main.cpp59
-rwxr-xr-xsystemservice/logger_service/server/src/loggerservicedebug_child_thread.cpp134
-rwxr-xr-xsystemservice/logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp1362
-rwxr-xr-xsystemservice/logger_service/server/src/mem_reader.cpp125
-rwxr-xr-xsystemservice/logger_service/server/src/mod_version.c49
-rwxr-xr-xsystemservice/logger_service/server/src/queue_reader.cpp101
-rwxr-xr-xsystemservice/logger_service/server/src/reader.cpp86
-rwxr-xr-xsystemservice/logger_service/server/src/reader_writer.cpp282
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_cfg.cpp754
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_device_detection.cpp209
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_error_event.cpp1047
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_error_event_archive.cpp413
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp147
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_error_event_cfg.cpp335
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_error_event_responses.cpp625
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_error_event_storage.cpp628
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_fs_directory.cpp236
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_popups.cpp176
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_reader_writer_control.cpp151
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_server_callbacks.cpp900
-rwxr-xr-xsystemservice/logger_service/server/src/ss_logger_util.cpp1273
-rwxr-xr-xsystemservice/logger_service/server/src/testapps/fopen0
-rwxr-xr-xsystemservice/logger_service/server/src/testapps/testapps.log0
-rwxr-xr-xsystemservice/logger_service/server/src/testapps/testapps.tar.gz0
-rwxr-xr-xsystemservice/logger_service/server/src/udp_file_writer.cpp161
-rwxr-xr-xsystemservice/logger_service/server/src/udp_writer.cpp295
-rwxr-xr-xsystemservice/logger_service/server/src/writer.cpp86
-rwxr-xr-xsystemservice/logger_service/server/work/Makefile126
-rwxr-xr-xsystemservice/power_service/LICENSE177
-rwxr-xr-xsystemservice/power_service/Makefile.server19
-rwxr-xr-xsystemservice/power_service/server/Makefile51
-rwxr-xr-xsystemservice/power_service/server/include/ss_power.h318
-rwxr-xr-xsystemservice/power_service/server/include/ss_power_config.h147
-rwxr-xr-xsystemservice/power_service/server/include/ss_power_powerservicelog.h85
-rwxr-xr-xsystemservice/power_service/server/include/ss_power_session.h70
-rwxr-xr-xsystemservice/power_service/server/include/ss_power_state_hysteresis.h74
-rwxr-xr-xsystemservice/power_service/server/include/ss_power_state_machine.h414
-rwxr-xr-xsystemservice/power_service/server/src/powerservice_application.cpp236
-rwxr-xr-xsystemservice/power_service/server/src/powerservice_main.cpp70
-rwxr-xr-xsystemservice/power_service/server/src/ss_power.cpp1672
-rwxr-xr-xsystemservice/power_service/server/src/ss_power_config.cpp188
-rwxr-xr-xsystemservice/power_service/server/src/ss_power_session.cpp276
-rwxr-xr-xsystemservice/power_service/server/src/ss_power_state_machine.cpp924
-rwxr-xr-xsystemservice/power_service/server/src/ss_pwr_test_client_handlers.cpp204
-rwxr-xr-xsystemservice/power_service/server/src/ss_supervisor_handlers.cpp498
-rwxr-xr-xsystemservice/power_service/server/src/ss_system_handlers.cpp52
-rwxr-xr-xsystemservice/resource_manager/LICENSE177
-rwxr-xr-xsystemservice/resource_manager/Makefile.client21
-rwxr-xr-xsystemservice/resource_manager/Makefile.server23
-rwxr-xr-xsystemservice/resource_manager/client/Makefile58
-rwxr-xr-xsystemservice/resource_manager/client/RESMGR.api12
-rwxr-xr-xsystemservice/resource_manager/client/include/resmgr_api_resourcemanagerlog.h78
-rwxr-xr-xsystemservice/resource_manager/client/libresm.ver28
-rwxr-xr-xsystemservice/resource_manager/client/src/#resmgr_api_lib.c#142
-rwxr-xr-xsystemservice/resource_manager/client/src/resmgr_api_lib.c142
-rwxr-xr-xsystemservice/resource_manager/drop_caches/Makefile38
-rwxr-xr-xsystemservice/resource_manager/drop_caches/src/drop_caches.cpp183
-rwxr-xr-xsystemservice/resource_manager/server/Makefile55
-rwxr-xr-xsystemservice/resource_manager/server/include/proc_watch.h25
-rwxr-xr-xsystemservice/resource_manager/server/include/resm_cfg.h132
-rwxr-xr-xsystemservice/resource_manager/server/include/resm_internal.h40
-rwxr-xr-xsystemservice/resource_manager/server/include/ss_resm_resourcemanagerlog.h82
-rwxr-xr-xsystemservice/resource_manager/server/include/system_service/resm.h325
-rwxr-xr-xsystemservice/resource_manager/server/include/system_service/resm_type.h85
-rwxr-xr-xsystemservice/resource_manager/server/include/system_service/resource_manager.h43
-rwxr-xr-xsystemservice/resource_manager/server/src/cpuload_custom.cpp512
-rwxr-xr-xsystemservice/resource_manager/server/src/proc_watch.cpp285
-rwxr-xr-xsystemservice/resource_manager/server/src/resm.cpp2667
-rwxr-xr-xsystemservice/resource_manager/server/src/resourcemanager_application.cpp155
-rwxr-xr-xsystemservice/rom_access_library/LICENSE177
-rwxr-xr-xsystemservice/rom_access_library/Makefile.client19
-rwxr-xr-xsystemservice/rom_access_library/library/Makefile19
-rwxr-xr-xsystemservice/rom_access_library/library/include/rom_access_library_nor.h43
-rwxr-xr-xsystemservice/rom_access_library/library/include/rom_access_library_rom.h45
-rwxr-xr-xsystemservice/rom_access_library/library/include/ss_rom_access_define.h38
-rwxr-xr-xsystemservice/rom_access_library/library/include/ss_rom_access_if_romaccesslibrarylog.h89
-rwxr-xr-xsystemservice/rom_access_library/library/include/ss_sm_checksum.h34
-rwxr-xr-xsystemservice/rom_access_library/library/include/system_service/nor_backup.h212
-rwxr-xr-xsystemservice/rom_access_library/library/include/system_service/rom_access_library.h47
-rwxr-xr-xsystemservice/rom_access_library/library/include/system_service/ss_sm_boot_access.h362
-rwxr-xr-xsystemservice/rom_access_library/library/include/system_service/ss_sm_ram_access.h235
-rwxr-xr-xsystemservice/rom_access_library/library/include/system_service/ss_sm_rom_access.h1010
-rwxr-xr-xsystemservice/rom_access_library/library/nor/Makefile46
-rwxr-xr-xsystemservice/rom_access_library/library/nor/libBlkDev_API.ver30
-rwxr-xr-xsystemservice/rom_access_library/library/nor/libssaccess.ver30
-rwxr-xr-xsystemservice/rom_access_library/library/nor/src/nor_backup.c807
-rwxr-xr-xsystemservice/rom_access_library/library/rom/Makefile62
-rwxr-xr-xsystemservice/rom_access_library/library/rom/src/ss_sm_boot_access.cpp122
-rwxr-xr-xsystemservice/rom_access_library/library/rom/src/ss_sm_checksum.cpp37
-rwxr-xr-xsystemservice/rom_access_library/library/rom/src/ss_sm_ram_access.cpp215
-rwxr-xr-xsystemservice/rom_access_library/library/rom/src/ss_sm_rom_access.cpp969
-rwxr-xr-xsystemservice/system_manager/LICENSE177
-rwxr-xr-xsystemservice/system_manager/Makefile.server19
-rwxr-xr-xsystemservice/system_manager/server/Makefile118
-rwxr-xr-xsystemservice/system_manager/server/PhaseInfo.txt2
-rwxr-xr-xsystemservice/system_manager/server/include/crashdetector/ss_crashdetector.h46
-rwxr-xr-xsystemservice/system_manager/server/include/heartbeat/ss_hb_if.h67
-rwxr-xr-xsystemservice/system_manager/server/include/heartbeat/ss_hb_session.h91
-rwxr-xr-xsystemservice/system_manager/server/include/heartbeat/ss_hb_thread.h206
-rwxr-xr-xsystemservice/system_manager/server/include/processlauncher/ProcessLauncher.h58
-rwxr-xr-xsystemservice/system_manager/server/include/processlauncher/ProcessLauncher_if.h30
-rwxr-xr-xsystemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher.h111
-rwxr-xr-xsystemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher_protocol.h62
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_config.h543
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_default_paths.h42
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_dynamic_launch_table.h72
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_dynamic_launcher.h111
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_launch_configuration.h191
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_signals.h32
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_systemmanagerlog.h91
-rwxr-xr-xsystemservice/system_manager/server/include/ss_sm_version.h39
-rwxr-xr-xsystemservice/system_manager/server/include/ss_system_manager.h760
-rwxr-xr-xsystemservice/system_manager/server/include/ss_system_manager_callbacks.h29
-rwxr-xr-xsystemservice/system_manager/server/include/ss_system_memory_monitor.h85
-rwxr-xr-xsystemservice/system_manager/server/include/ss_system_thread_info.h45
-rwxr-xr-xsystemservice/system_manager/server/include/system_launcher_cfg_format.h66
-rwxr-xr-xsystemservice/system_manager/server/sm_launch__CWORD84_.xml116
-rwxr-xr-xsystemservice/system_manager/server/src/heartbeat/ss_hb_if.cpp201
-rwxr-xr-xsystemservice/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp184
-rwxr-xr-xsystemservice/system_manager/server/src/heartbeat/ss_hb_session.cpp415
-rwxr-xr-xsystemservice/system_manager/server/src/heartbeat/ss_hb_thread.cpp355
-rwxr-xr-xsystemservice/system_manager/server/src/processlauncher/ProcessLauncher.cpp317
-rwxr-xr-xsystemservice/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp126
-rwxr-xr-xsystemservice/system_manager/server/src/ss_sm_config.cpp1528
-rwxr-xr-xsystemservice/system_manager/server/src/ss_sm_dynamic_launcher.cpp221
-rwxr-xr-xsystemservice/system_manager/server/src/ss_sm_version.cpp79
-rwxr-xr-xsystemservice/system_manager/server/src/ss_system_manager.cpp3655
-rwxr-xr-xsystemservice/system_manager/server/src/ss_system_manager_callbacks.cpp3411
-rwxr-xr-xsystemservice/system_manager/server/src/ss_system_manager_error_event.cpp945
-rwxr-xr-xsystemservice/system_manager/server/src/ss_system_manager_error_event_responses.cpp1007
-rwxr-xr-xsystemservice/system_manager/server/src/ss_system_manager_error_event_triggers.cpp1093
-rwxr-xr-xsystemservice/system_manager/server/src/ss_system_memory_monitor.cpp362
-rwxr-xr-xsystemservice/system_manager/server/src/systemmanager_application.cpp237
-rwxr-xr-xsystemservice/system_manager/server/src/systemmanager_main.cpp120
-rwxr-xr-xsystemservice/system_manager/server/version.txt2
-rwxr-xr-xsystemservice/system_service.mk44
-rwxr-xr-xsystemservice/task_manager/LICENSE177
-rwxr-xr-xsystemservice/task_manager/Makefile.client21
-rwxr-xr-xsystemservice/task_manager/Makefile.server21
-rwxr-xr-xsystemservice/task_manager/client/Makefile26
-rwxr-xr-xsystemservice/task_manager/client/libprimary/Makefile37
-rwxr-xr-xsystemservice/task_manager/client/libprimary/include/pri_main.h48
-rwxr-xr-xsystemservice/task_manager/client/libprimary/libprimary.ver22
-rwxr-xr-xsystemservice/task_manager/client/libprimary/src/pri_api.cpp224
-rwxr-xr-xsystemservice/task_manager/client/libprimary/src/pri_main.cpp873
-rwxr-xr-xsystemservice/task_manager/client/libtskm/Makefile35
-rwxr-xr-xsystemservice/task_manager/client/libtskm/TSKM.api9
-rwxr-xr-xsystemservice/task_manager/client/libtskm/libtskm.ver21
-rwxr-xr-xsystemservice/task_manager/client/libtskm/src/tskm_api_lib.cpp90
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/Makefile93
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/conf/agl_thread.h1377
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/conf/tskm_launch.xml106
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown.xml11
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown_vup.xml6
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup.xml8
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup_vup.xml5
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/include/system_service/task_manager_libtskmcfg.h40
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/include/system_service/tskm_svcid.h59
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/include/system_service/tskm_xml_data.h173
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/libtskmcfg.ver21
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/src/parsexml.c879
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/src/tskm_xml_data.cpp138
-rwxr-xr-xsystemservice/task_manager/client/libtskmcfg/tskm_cfg.xml83
-rwxr-xr-xsystemservice/task_manager/client/ss_data_init/Makefile43
-rwxr-xr-xsystemservice/task_manager/client/ss_data_init/include/libss_data_init_taskmanagerlog.h78
-rwxr-xr-xsystemservice/task_manager/client/ss_data_init/include/system_service/task_manager_libss_data_init.h39
-rwxr-xr-xsystemservice/task_manager/client/ss_data_init/include/system_service/tskm_data_init.h121
-rwxr-xr-xsystemservice/task_manager/client/ss_data_init/include/tskm_data_init_local.h25
-rwxr-xr-xsystemservice/task_manager/client/ss_data_init/mkdatainit.sh45
-rwxr-xr-xsystemservice/task_manager/client/ss_data_init/tskm_data_init.cpp.in66
-rwxr-xr-xsystemservice/task_manager/include-share/tskm_gstep.h54
-rwxr-xr-xsystemservice/task_manager/include-share/tskm_type_local.h52
-rwxr-xr-xsystemservice/task_manager/include-share/tskm_util.h32
-rwxr-xr-xsystemservice/task_manager/server/Makefile67
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/INI_API.h25
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/INI_API.hpp738
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/Primary_common.h148
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/sysup.h41
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/sysup_from.h41
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/task_manager.h54
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/tskm.h413
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/tskm_local_type.h287
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/tskm_svc.h904
-rwxr-xr-xsystemservice/task_manager/server/include/system_service/tskm_type.h123
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_comm.h59
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_debug.h208
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_main.h71
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_port_pf.h46
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_port_subsys.h42
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_shutdown.h27
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_state.h36
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_wakeup.h26
-rwxr-xr-xsystemservice/task_manager/server/include/tskm_watch.h25
-rwxr-xr-xsystemservice/task_manager/server/src/pri_main.cpp840
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_api.cpp268
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_comm.cpp402
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_debug.cpp286
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_main.cpp727
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_port_pf.cpp884
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_port_subsys.cpp297
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_shutdown.cpp242
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_state.cpp452
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_svc.cpp970
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_wakeup.cpp201
-rwxr-xr-xsystemservice/task_manager/server/src/tskm_watch.cpp101
-rwxr-xr-xsystemservice/version_library/LICENSE177
-rwxr-xr-xsystemservice/version_library/Makefile.client19
-rwxr-xr-xsystemservice/version_library/library/Makefile37
-rwxr-xr-xsystemservice/version_library/library/include/system_service/ss_ver.h338
-rwxr-xr-xsystemservice/version_library/library/include/system_service/version_library.h40
-rwxr-xr-xsystemservice/version_library/library/src/ss_ver.cc309
364 files changed, 86824 insertions, 0 deletions
diff --git a/systemservice/config/LICENSE b/systemservice/config/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/config/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/config/Makefile.client b/systemservice/config/Makefile.client
new file mode 100755
index 0000000..0a186c5
--- /dev/null
+++ b/systemservice/config/Makefile.client
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-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.
+#
+
+SUBDIRS := library
+
+include ../system_service.mk
diff --git a/systemservice/config/library/Makefile b/systemservice/config/library/Makefile
new file mode 100755
index 0000000..f326127
--- /dev/null
+++ b/systemservice/config/library/Makefile
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-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.
+#
+
+SUBDIRS := system_manager_config
+
+include ../../system_service.mk
diff --git a/systemservice/config/library/system_manager_config/Makefile b/systemservice/config/library/system_manager_config/Makefile
new file mode 100755
index 0000000..fbb09d7
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/Makefile
@@ -0,0 +1,21 @@
+#
+# @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.
+#
+
+
+SUBDIRS := src
+
+include ../../../system_service.mk
+
diff --git a/systemservice/config/library/system_manager_config/include/system_service/ss_access_if_private.h b/systemservice/config/library/system_manager_config/include/system_service/ss_access_if_private.h
new file mode 100755
index 0000000..1753bf0
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/include/system_service/ss_access_if_private.h
@@ -0,0 +1,80 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_access_if_private.h
+ * @brief \~english This file contains declaration of structures RAM_AccessPrivate and ROM_AccessPrivate
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup config
+ * @ingroup system_service
+ * @{
+ */
+#ifndef CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_ACCESS_IF_PRIVATE_H_
+#define CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_ACCESS_IF_PRIVATE_H_
+
+#include <system_service/ss_sm_rom_access.h>
+#include <system_service/ss_sm_ram_access.h>
+
+// Should be design the data so that the default value is 0.
+
+// Product private area for DRAM BACKUP
+
+/**
+ * @struct RAM_AccessPrivate
+ * @brief \~english RAM Access Private data define
+ */
+typedef struct {
+ union {
+ //! \~english _CWORD80_ error define
+ struct {
+ /*
+ * Note.
+ * This feature needs to be defined depending on the product specification by the vendor.
+ */
+ };
+ //! \~english RAM product private max
+ uint8_t max[RAM_PRODUCT_PRIVATE_MAX];
+ };
+} RAM_AccessPrivate;
+
+/**
+ * @struct ROM_AccessPrivate
+ * @brief \~english ROM Access Private data define
+ */
+typedef struct {
+ union {
+ // Since data is accessed with 32 bit width at the low level, data must be allocated using 32 bits algin
+ struct {
+ /*
+ * Note.
+ * This feature needs to be defined depending on the product specification by the vendor.
+ */
+ };
+ //! \~english ROM product private max
+ uint8_t max[ROM_PRODUCT_PRIVATE_MAX];
+ };
+} ROM_AccessPrivate;
+
+#endif // CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_ACCESS_IF_PRIVATE_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/config/library/system_manager_config/include/system_service/ss_package.h b/systemservice/config/library/system_manager_config/include/system_service/ss_package.h
new file mode 100755
index 0000000..788fd2c
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/include/system_service/ss_package.h
@@ -0,0 +1,65 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_package.h
+ * @brief \~english This file contains declaration of common package values
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_PACKAGE_H_
+#define CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_PACKAGE_H_
+
+// _CWORD71_ package name list
+#define SS_PKG_MAIN_EMMC "MAIN_EMMC" // define MAIN_EMMC for main_emmc
+#define SS_PKG_MAIN_PRODUCT_SI "MAIN_PRODUCT_SI" // define MAIN_PRODUCT_SI for main_product_si
+#define SS_PKG_TARGETBOARD "TARGETBOARD" // define TARGETBOARD for target boar
+#define SS_PKG_MAIN_LPF_SI "MAIN_LPF_SI" // define MAIN_LPF_SI for main_lpf_si
+
+#define SS_PKG_NAVI_GPS _Pragma ("GCC warning \"'SS_NAVI_GPS' macro is deprecated\"") "NAVI_GPS"
+#define SS_PKG_SERIES_INFO _Pragma ("GCC warning \"'SS_PKG_SERIES_INFO' macro is deprecated\"") "SERIES_INFO"
+
+#define MSG_PSM_REBOOT_NOTIFY 0x11 // define ps_psmshadow reboot notice id
+
+// AGL reserved version list.
+#define SS_PKG_DIAG_CPU_INFO_001 "DIAG_CPU_INFO_001"
+#define SS_PKG_DIAG_CPU_INFO_002 "DIAG_CPU_INFO_002"
+#define SS_PKG_DIAG_CPU_INFO_003 "DIAG_CPU_INFO_003"
+#define SS_PKG_DIAG_CPU_INFO_004 "DIAG_CPU_INFO_004"
+#define SS_PKG_DIAG_CPU_INFO_005 "DIAG_CPU_INFO_005"
+#define SS_PKG_DIAG_CPU_INFO_006 "DIAG_CPU_INFO_006"
+#define SS_PKG_DIAG_CPU_INFO_007 "DIAG_CPU_INFO_007"
+#define SS_PKG_DIAG_CPU_INFO_008 "DIAG_CPU_INFO_008"
+#define SS_PKG_DIAG_CPU_INFO_009 "DIAG_CPU_INFO_009"
+#define SS_PKG_DIAG_CPU_INFO_010 "DIAG_CPU_INFO_010"
+#define SS_PKG_DIAG_CPU_INFO_011 "DIAG_CPU_INFO_011"
+#define SS_PKG_DIAG_CPU_INFO_012 "DIAG_CPU_INFO_012"
+#define SS_PKG_DIAG_CPU_INFO_013 "DIAG_CPU_INFO_013"
+#define SS_PKG_DIAG_CPU_INFO_014 "DIAG_CPU_INFO_014"
+#define SS_PKG_DIAG_CPU_INFO_015 "DIAG_CPU_INFO_015"
+
+#endif // CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_PACKAGE_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/config/library/system_manager_config/include/system_service/ss_system_manager_conf.h b/systemservice/config/library/system_manager_config/include/system_service/ss_system_manager_conf.h
new file mode 100755
index 0000000..5354da8
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/include/system_service/ss_system_manager_conf.h
@@ -0,0 +1,145 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_system_manager_conf.h
+ * @brief \~english This file contains declaration of structures T_SS_SM_INIT_HOOK_IN_PARAM, T_SS_SM_INIT_HOOK_OUT_PARAM and api initial Hook
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup config
+ * @ingroup system_service
+ * @{
+ */
+#ifndef CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_SYSTEM_MANAGER_CONF_H_
+#define CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_SYSTEM_MANAGER_CONF_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <vector>
+#include <string>
+
+/**
+ * @struct T_SS_SM_INIT_HOOK
+ * @brief \~english Version up mode, Callback function
+ */
+typedef struct T_SS_SM_INIT_HOOK {
+ //! \~english Version up mode
+ BOOL bIsVupMode;
+ //! \~english Call back function
+ EFrameworkunifiedStatus (*cbRebootNoticeFunc)(HANDLE hApp);
+
+ T_SS_SM_INIT_HOOK()
+ : bIsVupMode(FALSE),
+ cbRebootNoticeFunc(NULL) {
+ }
+} T_SS_SM_INIT_HOOK_IN_PARAM;
+
+
+/**
+ * @struct T_SS_SM_INIT_HOOK_OUT_PARAM
+ * @brief \~english Not in OOM Killer's service object, Group Relaunch service.
+ */
+typedef struct {
+ std::vector<std::string> protectedSvcs;
+ //! \~english Not in OOM Killer's service object.
+ std::vector<std::string> groupRelaunchSvcs;
+ //! \~english Group Relaunch service.
+} T_SS_SM_INIT_HOOK_OUT_PARAM;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup ss_sm_initHook
+/// \~english @par Summary
+///
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE Application
+/// \~english @param [in] inPrm
+/// T_SS_SM_INIT_HOOK_IN_PARAM -
+/// \~english @param [in] outPrm
+/// T_SS_SM_INIT_HOOK_OUT_PARAM -
+/// \~english @par
+/// T_SS_SM_INIT_HOOK_IN_PARAM struct
+/// \~english @code
+/// typedef struct T_SS_SM_INIT_HOOK {
+/// BOOL bIsVupMode; /* version up model */
+/// EFrameworkunifiedStatus (*cbRebootNoticeFunc)(HANDLE hApp); /* call back function */
+/// T_SS_SM_INIT_HOOK()
+/// : bIsVupMode(FALSE),
+/// cbRebootNoticeFunc(NULL) {
+/// } /* constructor */
+/// } T_SS_SM_INIT_HOOK_IN_PARAM;
+/// @endcode
+/// \~english @par
+/// T_SS_SM_INIT_HOOK_IN_PARAM struct
+/// \~english @code
+/// typedef struct {
+/// std::vector<std::string> protectedSvcs; /* OOM Killer's protected service */
+/// std::vector<std::string> groupRelaunchSvcs; /* group relunch service */
+/// } T_SS_SM_INIT_HOOK_OUT_PARAM;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - None
+/// \~english @par Change of the internal state
+/// - save inPrm->cbRebootNoticeFunc to s_confCtx.cbRebootNoticeFunc.
+/// \~english @par Causes of failures
+/// -
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a transmission type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Transmission for the file descriptor of System Manager message for the session is invalid. \n
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the transmission of \n
+/// the System Manager message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmission buffer of the System Manager message for the session is invalid. \n
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session. \n
+/// [eFrameworkunifiedStatusFail]
+/// - Transmission of System Manager message for the session fails to shared memory access. \n
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// get env val from application,and write these to Launch Config file.
+/// \~english @par
+/// eFrameworkunifiedStatus:Result
+/// - eFrameworkunifiedStatusOK:Success
+/// - Except eFrameworkunifiedStatusOK:Fail
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus ss_sm_initHook(HANDLE hApp, const T_SS_SM_INIT_HOOK_IN_PARAM *inPrm,
+ T_SS_SM_INIT_HOOK_OUT_PARAM *outPrm);
+
+#endif // CONFIG_LIBRARY_SYSTEM_MANAGER_CONFIG_INCLUDE_SYSTEM_SERVICE_SS_SYSTEM_MANAGER_CONF_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/config/library/system_manager_config/include/system_service/system_manager_config.h b/systemservice/config/library/system_manager_config/include/system_service/system_manager_config.h
new file mode 100755
index 0000000..2f44f98
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/include/system_service/system_manager_config.h
@@ -0,0 +1,26 @@
+/*
+ * @copyright Copyright (c) 2017-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.
+ */
+/**
+ * @file
+ */
+#ifndef SYSTEMSERVICE_SYSTEMMANAGERCONFIG_H_ // NOLINT(build/header_guard)
+#define SYSTEMSERVICE_SYSTEMMANAGERCONFIG_H_ // NOLINT(build/header_guard)
+
+#include <system_service/ss_access_if_private.h>
+#include <system_service/ss_package.h>
+#include <system_service/ss_system_manager_conf.h>
+
+#endif // SYSTEMSERVICE_SYSTEMMANAGERCONFIG_H_
diff --git a/systemservice/config/library/system_manager_config/last2order/Makefile b/systemservice/config/library/system_manager_config/last2order/Makefile
new file mode 100755
index 0000000..f38ee77
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/last2order/Makefile
@@ -0,0 +1,71 @@
+#
+# @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.
+#
+
+# ==== Customization ================
+#Directory path located XMLs for conversion
+CONFXML_DIR_PATH ?= $(SDKTARGETSYSROOT)/usr/agl/conf/sm_last2order
+
+#path to order file
+ORDER_DEF_PATH ?= $(SDKTARGETSYSROOT)/usr/agl/include/agl_wakeup_order.h
+
+#path to be installed CFO file
+CONF_INSTALL_DIR ?= $(SDKTARGETSYSROOT)/usr/agl/conf/systemmanager
+
+# ==================================
+
+HOST_CPP = cpp
+MKL_LAST2ORDER = mklast2ordertbl.pl
+
+#path located last2order tools
+TOOLPATH = ./tool
+
+VPATH = $(CONFXML_DIR_PATH) $(TOOLPATH)
+
+XMLFILES = $(shell cd $(CONFXML_DIR_PATH); ls *.xml)
+XMLTMPFILES = $(XMLFILES:%.xml=%.xml.pped)
+CFOFILES = $(XMLFILES:%.xml=%.cfo)
+
+_all:$(CFOFILES)
+
+install:install-pre install-cfo
+
+install-pre:
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/sm_last2order;\
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/systemmanager sm_last2order.cfo
+
+install-cfo:_all
+ set -e ;\
+ install -d -m 775 $(CONF_INSTALL_DIR) ;\
+ for cfofile in $(CFOFILES); do \
+ install -m 644 -t $(CONF_INSTALL_DIR) $$cfofile; \
+ done
+
+%.cfo:%.xml.pped $(MKL_LAST2ORDER)
+ ln -fs $(TOOLPATH)/$(MKL_LAST2ORDER)
+ ./$(MKL_LAST2ORDER) $< $@
+
+%.xml.pped:%.xml
+ $(HOST_CPP) -P -include $(ORDER_DEF_PATH) $< > $@
+
+clean:clean_local
+clean-sub:clean_local
+
+clean_local:
+ rm -f *.cfo *.pped *.pl
+
+.PHONY:install-cfo _all
+
+include ../../../../system_service.mk
diff --git a/systemservice/config/library/system_manager_config/last2order/sm_last2order.cfo b/systemservice/config/library/system_manager_config/last2order/sm_last2order.cfo
new file mode 100755
index 0000000..2463eec
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/last2order/sm_last2order.cfo
Binary files differ
diff --git a/systemservice/config/library/system_manager_config/last2order/tool/mklast2ordertbl.pl b/systemservice/config/library/system_manager_config/last2order/tool/mklast2ordertbl.pl
new file mode 100755
index 0000000..9b7dcab
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/last2order/tool/mklast2ordertbl.pl
@@ -0,0 +1,107 @@
+#!/usr/bin/perl
+use strict;
+
+use XML::XPath;
+
+my $LOCAL_XML = "./last2order.xml.tmp";
+my $LOCAL_DTD = "./last2order.dtd";
+
+my $DTD = <<'EODTD';
+<!ELEMENT last2order_tbl (last2order*) >
+
+<!ELEMENT last2order EMPTY>
+<!ATTLIST last2order
+ front_video CDATA "EMPTY"
+ front_sub_video CDATA "EMPTY"
+ front_audio CDATA "EMPTY"
+ rear_video CDATA "EMPTY"
+ rear_audio CDATA "EMPTY"
+ ordername CDATA #REQUIRED
+>
+EODTD
+
+sub usage(){
+ print STDERR "USAGE:$0 *.xml *.cfo\n";
+}
+
+#==== MAIN ====
+my $ret=system("which xmllint > /dev/null");
+if($ret != 0){
+ die("xmllint is not installed \n");
+}
+
+if(2 != @ARGV){
+ usage();
+ exit 1;
+}
+
+my $inXmlFile= $ARGV[0];
+my $outCfgXmlFile= $ARGV[1];
+
+
+#ARG CHECK
+if(! -e $inXmlFile){
+ die("$inXmlFile not found");
+}
+
+
+system("cp $inXmlFile $LOCAL_XML");
+
+open FOUT,'>',$LOCAL_DTD or die("can't open $LOCAL_DTD");
+print FOUT $DTD;
+close FOUT;
+
+$ret=system("xmllint --noout --valid $LOCAL_XML ");
+if($ret != 0){
+ die("$inXmlFile is NOT VAILD");
+}
+
+my $xml = XML::XPath->new(filename=>$LOCAL_XML);
+
+my $last2order_tbl = $xml->find('/last2order_tbl/last2order');
+
+my @nodelist = $last2order_tbl->get_nodelist;
+my $numOfElement = @nodelist;
+
+printf("num of element :$numOfElement\n");
+
+my $writeValue;
+open FOUT,'+>',$outCfgXmlFile or die("can't open $outCfgXmlFile");
+binmode(FOUT);
+
+$writeValue = pack("A4","CTOO"); print FOUT $writeValue;
+$writeValue = pack("L",$numOfElement); print FOUT $writeValue;
+
+foreach my $last2order( @nodelist ) {
+ $writeValue = $last2order->findvalue('@front_video');
+ printf("FV:$writeValue ");
+ $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
+
+ $writeValue = $last2order->findvalue('@front_sub_video');
+ printf("FSV:$writeValue ");
+ $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
+
+ $writeValue = $last2order->findvalue('@front_audio');
+ printf("FA:$writeValue ");
+ $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
+
+ $writeValue = $last2order->findvalue('@rear_video');
+ printf("RV:$writeValue ");
+ $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
+
+ $writeValue = $last2order->findvalue('@rear_audio');
+ printf("RA:$writeValue ");
+ $writeValue = pack("a128",$writeValue); print FOUT $writeValue;
+
+ $writeValue = $last2order->findvalue('@ordername');
+ printf("ON:$writeValue ");
+ $writeValue = pack("a64",$writeValue); print FOUT $writeValue;
+
+ printf("\n");
+}
+
+close(FOUT);
+
+system("rm $LOCAL_XML $LOCAL_DTD");
+
+
diff --git a/systemservice/config/library/system_manager_config/order/Makefile b/systemservice/config/library/system_manager_config/order/Makefile
new file mode 100755
index 0000000..38af0ee
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/Makefile
@@ -0,0 +1,64 @@
+#
+# @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.
+#
+
+#HOST TOOLS
+HOST_CPP = cpp
+HOST_ORDER_XML2CFG = ./launch_order_xml2cfg.pl
+
+CONF_DIR = $(SDKTARGETSYSROOT)/usr/agl/conf
+CONF_WON_H = $(SDKTARGETSYSROOT)/usr/agl/include/agl_wakeup_order.h
+
+LAUNCH_XMLFILES = $(shell cd $(CONF_DIR)/sm_launch; ls *.xml)
+ORDER_XMLFILES = $(LAUNCH_XMLFILES:%.xml=%.order)
+ORDER_CFGFILES = $(ORDER_XMLFILES:%.order=%.order.cfg)
+
+INST_CONFDIR = $(SDKTARGETSYSROOT)/usr/agl/conf/systemmanager
+
+CLEAN_FILES = launch_order_body.xml $(ORDER_CFGFILES)
+
+VPATH = $(CONF_DIR)/sm_launch
+VPATH += ../xml
+
+install:install-pre install-cfg
+
+install-pre:
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/sm_launch system_launcher_main.xml
+
+install-cfg:$(ORDER_CFGFILES)
+ set -e ;\
+ install -d -m 775 $(INST_CONFDIR) ;\
+ for cfgfile in $(ORDER_CFGFILES);do \
+ install -m 644 -t $(INST_CONFDIR) $$cfgfile;\
+ done ;\
+
+#Create CFG file
+%.order.cfg:%.order %.cfg
+ echo $@
+ set -e; \
+ $(HOST_CPP) $(CPPFLAGS) -P -include $(CONF_WON_H) $< > launch_in.order; \
+ $(HOST_ORDER_XML2CFG) launch_in.order $(filter %.cfg,$+) > $@ ; \
+ rm -fr launch_in.order;
+
+%.order:
+ echo $@
+ set -e; \
+ if [ ! -e $@ ] ; then \
+ touch $@ ; \
+ fi
+
+PHONY:install-cfg
+
+include ../../../../system_service.mk
diff --git a/systemservice/config/library/system_manager_config/order/launch_order_body.xml b/systemservice/config/library/system_manager_config/order/launch_order_body.xml
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/launch_order_body.xml
diff --git a/systemservice/config/library/system_manager_config/order/launch_order_main.xml b/systemservice/config/library/system_manager_config/order/launch_order_main.xml
new file mode 100755
index 0000000..ee22646
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/launch_order_main.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" ?>
+
+<!DOCTYPE launch_order [
+ <!ELEMENT launch_order (order*) >
+
+ <!ELEMENT order (group+) >
+ <!ATTLIST order
+ oname ID #REQUIRED
+ fixed_group CDATA "NULL"
+ >
+
+ <!ELEMENT group EMPTY >
+ <!ATTLIST group
+ gname CDATA #REQUIRED
+ waittime CDATA "0"
+ >
+
+ <!ENTITY launch_order_body SYSTEM "launch_order_body.xml">
+]>
+
+<launch_order>
+ &launch_order_body;
+</launch_order>
diff --git a/systemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl b/systemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl
new file mode 100755
index 0000000..1060107
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl
@@ -0,0 +1,171 @@
+#!/usr/bin/perl -w
+use strict;
+
+use XML::XPath;
+use File::Copy;
+
+my $main_file="launch_order_main.xml";
+my $body_file="launch_order_body.xml";
+
+
+sub usage(){
+ print STDERR "USAGE:$0 *.order *.cfg\n"
+}
+
+
+
+
+#=== MAIN ===
+my $ret=system("which xmllint > /dev/null");
+if($ret != 0){
+ print STDERR "It need xmllint. Please install it.\n";
+ exit 1;
+}
+
+if(2 != @ARGV){
+ usage();
+ exit 1;
+}
+
+my $infile=$ARGV[0];
+my $launchfile=$ARGV[1];
+
+
+#ARG CHECK
+if($infile !~ /.+\.order$/){
+ print STDERR "$infile is not *.order\n";
+ exit 1;
+}elsif(! -e $infile){
+ print "$infile not found\n";
+ usage();
+ exit 1;
+}
+
+if($launchfile !~ /.+\.cfg$/){
+ print STDERR "$launchfile is not *.cfg\n";
+ exit 1;
+}elsif(! -e $launchfile){
+ print "$launchfile not found\n";
+ usage();
+ exit 1;
+}
+
+
+system("cp -f $infile $body_file");
+
+#check xml vaild
+$ret=system("xmllint --noout --valid $main_file");
+if($ret != 0){
+ print STDERR "XML is Invalid. \n";
+ exit 1;
+}
+
+my $date=`LANG=en date`;
+print "# This file is created from $infile and $launchfile\n";
+print "# created date : $date\n";
+
+my %gnamemap;
+my %gidmap;
+
+open(FIN,"<$launchfile") or die("error :$!");
+while (my $line = <FIN>){
+ if($line =~ /^Launch/){
+ $line =~ s/^[^|]+=//g;
+ my @args = split(/\|/,$line);
+ $gnamemap{$args[0]}=$args[1];
+ $gidmap{$args[1]}=$args[0];
+ }
+}
+close(FIN);
+
+foreach my $key (sort{$a <=> $b} keys(%gidmap)){
+ print "#$key:$gidmap{$key}\n";
+}
+
+
+my $xml = XML::XPath->new(filename=>$main_file);
+
+my $orders = $xml->find('/launch_order/order');
+foreach my $order ($orders->get_nodelist) {
+ my $groups = $order->find('./group');
+
+ my $oname=$order->findvalue('@oname');
+ my $fixed_group=$order->findvalue('@fixed_group');
+
+ print "[$oname]\n";
+ print "order=";
+
+ my %l_gidmap = %gidmap;
+ my $sep="";
+ #fix groups
+ if($fixed_group ne "NULL"){
+ if(! exists $gnamemap{$fixed_group}){
+ die("$fixed_group not found");
+ }
+ foreach my $gid (sort{$a <=> $b} keys(%l_gidmap)){
+ print "$sep$gid";
+ $sep="|";
+ my $str=$l_gidmap{$gid};
+ delete $l_gidmap{$gid};
+ if($str eq $fixed_group){
+ last;
+ }
+ }
+ }
+
+ # re-order group via *.order
+ my %waitow;
+ foreach my $group ($groups->get_nodelist) {
+ my $gname=$group->findvalue('@gname');
+ my $waittime=XML::XPath::Number::value($group->findvalue('@waittime'));
+
+ my $gid=$gnamemap{$gname};
+
+ if(! exists $gnamemap{$gname}){
+ die("$oname:$gname is not defined");
+ }
+
+ if(! exists $l_gidmap{$gid}){
+ die("$oname:$gname is multiple defined");
+ }
+
+ print "$sep$gid";
+ $sep="|";
+ delete $l_gidmap{$gid};
+
+ if($waittime > 0){
+ $waitow{$gname} = $waittime;
+ }
+ }
+
+# Output waittime configuration
+
+ #out rest groups
+ foreach my $gid (sort{$a <=> $b} keys(%l_gidmap)){
+ print "$sep$gid";
+ $sep="|";
+ }
+
+ print "\n";
+ if(keys(%waitow) > 0 ){
+ print "owlist=";
+ $sep="";
+ foreach my $owgroup ( keys(%waitow)) {
+ print "${sep}oww_${owgroup}";
+ $sep="|";
+ }
+ print "\n";
+
+ foreach my $owgroup ( keys(%waitow)) {
+ print "oww_${owgroup}=$waitow{$owgroup}\n";
+ }
+
+
+ }
+ print "\n";
+}
+
+
+
+
+
diff --git a/systemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg b/systemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg
new file mode 100755
index 0000000..dc49cd7
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg
@@ -0,0 +1,3 @@
+# This file is created from launch_in.order and system_launcher_main.cfg
+# created date : Tue Aug 29 13:45:54 JST 2017
+
diff --git a/systemservice/config/library/system_manager_config/order/system_launcher_main.xml b/systemservice/config/library/system_manager_config/order/system_launcher_main.xml
new file mode 100755
index 0000000..2dd97d9
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/system_launcher_main.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" ?>
+
+<!DOCTYPE system_launcher [
+ <!ELEMENT system_launcher (group+) >
+
+ <!ELEMENT group (launch+) >
+ <!ATTLIST group
+ name CDATA #REQUIRED
+ wait_time CDATA #REQUIRED
+ trigger (True|False) #REQUIRED
+ >
+
+ <!ELEMENT launch EMPTY >
+ <!ATTLIST launch
+ name CDATA #REQUIRED
+ path CDATA #REQUIRED
+ priority CDATA #REQUIRED
+ critical CDATA #REQUIRED
+ retry_cnt CDATA #REQUIRED
+ arguments CDATA #REQUIRED
+ logging_mask CDATA "NULL"
+ restart (me|NULL) #REQUIRED
+ is_start_required (True|False) #REQUIRED
+ shutdown_critical CDATA #REQUIRED
+ shutdown_wait_time CDATA #REQUIRED
+ fast_shutdown_wait_time CDATA #REQUIRED
+ user_name CDATA #REQUIRED
+ env_cond CDATA #IMPLIED
+ >
+
+ <!ENTITY system_launcher_body SYSTEM "system_launcher_body.xml">
+]>
+
+<system_launcher>
+ &system_launcher_body;
+</system_launcher>
diff --git a/systemservice/config/library/system_manager_config/src/Makefile b/systemservice/config/library/system_manager_config/src/Makefile
new file mode 100755
index 0000000..9fbc9cc
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/src/Makefile
@@ -0,0 +1,45 @@
+#
+# @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.
+#
+
+#HOST TOOLS
+INST_SHLIBS = libsssmcfg
+
+VPATH = ./ ../include/$(COMPONENT_NAME)
+
+INST_HEADERS = ss_system_manager_conf.h
+INST_HEADERS += ss_package.h
+INST_HEADERS += ss_access_if_private.h
+INST_HEADERS += system_manager_config.h
+
+libsssmcfg_SRCS = ss_system_manager_conf.cpp
+
+
+
+CPPFLAGS += -I../include
+
+LDFLAGS += -Wl,--no-as-needed
+
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lSS_RomAccessIf
+LDLIBS += -Wl,-Bdynamic -lssver
+
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lvp
+
+DUMMY_SHLIB += libSS_RomAccessIf.so
+DUMMY_SHLIB += libSS_SystemIfUnified.so
+
+include ../../../../system_service.mk
diff --git a/systemservice/config/library/system_manager_config/src/libsssmcfg.ver b/systemservice/config/library/system_manager_config/src/libsssmcfg.ver
new file mode 100755
index 0000000..4d61996
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/src/libsssmcfg.ver
@@ -0,0 +1,30 @@
+/*
+ * @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.
+ */
+
+#
+# libsssmcfg version script
+#
+{
+ global:
+ ### .text section ###
+ extern "C++" {
+ ss_sm_initHook*;
+ ss_sm_avilavbilityHook*;
+ };
+ local:
+ *;
+};
+
diff --git a/systemservice/config/library/system_manager_config/src/ss_system_manager_conf.cpp b/systemservice/config/library/system_manager_config/src/ss_system_manager_conf.cpp
new file mode 100755
index 0000000..16ec02a
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/src/ss_system_manager_conf.cpp
@@ -0,0 +1,489 @@
+/*
+ * @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.
+ */
+
+#include <fstream>
+#include <string.h>
+#include <agl_thread.h>
+#include <other_service/VP_GetEnv.h>
+
+#include <system_service/ss_templates.h>
+#include <system_service/ss_sm_ram_access.h>
+#include <system_service/ss_ver.h>
+
+#include "system_service/ss_package.h"
+#include "system_service/ss_access_if_private.h"
+#include "system_service/ss_system_manager_conf.h"
+
+#ifndef ZONE_WARN
+#define ZONE_WARN ZONEMASK(30)
+#endif
+#ifndef ZONE_INFO
+#define ZONE_INFO ZONEMASK(29)
+#endif
+
+/* Environment variable name */
+const CHAR LaunchConfigFileNameEnvVariable[] = "APPS_CONFIG_FILENAME";
+const CHAR AreaTypeEnvVariable[] = "VEHICLEPARAMETERLIBRARY_AREA";
+const CHAR BrandTypeEnvVariable[] = "VEHICLEPARAMETERLIBRARY_BRAND";
+const CHAR GradeEnvVariable[] = "VP_VEHICLEPARAMETERLIBRARY_grade";
+
+/* Environment variable value */
+const CHAR EnvValueYes[] = "y";
+const CHAR EnvValueNo[] = "n";
+
+const CHAR EnvValueAvailable[] = "available";
+const CHAR EnvValueUnavailable[] = "unavailable";
+
+/*
+ * Note.
+ * Define areas, brands, and grades by the vendor.
+ * For example, an area is a destination of a product.
+ * Examples of areas : JP(Japan), EU, etc.
+ */
+const CHAR EnvValueArea1[] = "Area1";
+const CHAR EnvValueArea2[] = "Area2";
+const CHAR EnvValueArea3[] = "Area3";
+const CHAR EnvValueArea4[] = "Area4";
+const CHAR EnvValueBrand1[] = "Brand1";
+const CHAR EnvValueBrand2[] = "Brand2";
+const CHAR EnvValueGrade1[] = "Grade1";
+const CHAR EnvValueGrade2[] = "Grade2";
+const CHAR EnvValueGrade3[] = "Grade3";
+
+/* Package information */
+const CHAR PkgInfoGen2[] = "Gen2";
+
+
+typedef struct T_SS_SM_CONF_CTX {
+ EFrameworkunifiedStatus (*cbRebootNoticeFunc)(HANDLE hApp);
+ T_SS_SM_CONF_CTX()
+ : cbRebootNoticeFunc(NULL) {
+ }
+} T_SS_SM_CONF_CTX_INFO;
+
+static T_SS_SM_CONF_CTX_INFO s_confCtx;
+
+/***********************************************************************
+ * registProtectSvcs
+ ***********************************************************************/
+static void registProtectSvcs(std::vector<std::string> & protectedSvcs) {
+ protectedSvcs.push_back(MN_NS_SHAREDMEM);
+ protectedSvcs.push_back(MN_NS_NPPSERVICE);
+ protectedSvcs.push_back(MN_NS_BACKUPMGR);
+ protectedSvcs.push_back(MN_SS_LOGGERSRV);
+ protectedSvcs.push_back(MN_COMMUNICATION);
+ protectedSvcs.push_back(MN_PS_PSMSHADOW);
+ protectedSvcs.push_back(MN_SS_POWERSERVICE);
+}
+
+/***********************************************************************
+ * registGroupRelaunchSvcs
+ ***********************************************************************/
+static void registGroupRelaunchSvcs(
+ std::vector<std::string> & groupRelaunchSvcs) {
+ groupRelaunchSvcs.push_back(MN_ENFORMSERVICE);
+ groupRelaunchSvcs.push_back(MN_NAVIPROXY);
+ groupRelaunchSvcs.push_back(MN_AWBPROXY);
+ groupRelaunchSvcs.push_back(MN_TFFPROXY);
+ groupRelaunchSvcs.push_back(MN_AWNPRIMARY);
+ groupRelaunchSvcs.push_back(MN_AWMPRIMARY);
+ groupRelaunchSvcs.push_back(MN_AWBPRIMARY);
+ groupRelaunchSvcs.push_back(MN_AWTPRIMARY);
+}
+
+/***********************************************************************
+ * setEvnVariableForLaunchConfigFile
+ ***********************************************************************/
+static EFrameworkunifiedStatus setEvnVariableForLaunchConfigFile(std::string f_sEnvFile,
+ std::string f_sEnvBrand,
+ std::string f_sEnvGrade,
+ BOOL f_bIsVup) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ const CHAR VupLaunchConfigFileName[] = "sm_launch_vup.cfg";
+ const CHAR LaunchConfigFileName1[] = "sm_launch.cfg";
+ const CHAR LaunchConfigFileName2[] = "sm_launch.cfg";
+
+ // If an environment variable is set, that value is used, so set only when it is not set
+ if (f_sEnvFile.empty()) {
+ const CHAR *l_pLaunchConfigFile = NULL;
+
+ if (f_bIsVup) {
+ l_pLaunchConfigFile = VupLaunchConfigFileName;
+ } else {
+ // Change the file read by Brand and Grade
+ if ((f_sEnvBrand == EnvValueBrand2) && (f_sEnvGrade != EnvValueGrade1)) {
+ l_pLaunchConfigFile = LaunchConfigFileName1;
+ } else {
+ l_pLaunchConfigFile = LaunchConfigFileName2;
+ }
+
+ std::string cnfPath = "/usr/agl/conf/BS/ss/system_manager/rwdata/";
+ cnfPath += l_pLaunchConfigFile;
+ if (access(cnfPath.c_str(), F_OK) != 0) {
+ l_pLaunchConfigFile = LaunchConfigFileName1;
+ }
+ }
+
+ if (0 != setenv(LaunchConfigFileNameEnvVariable, l_pLaunchConfigFile, 1)) {
+ SS_ASERT_ERRNO(0);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ return l_eStatus;
+}
+
+/***********************************************************************
+ * setEvnVariableForLaunchCus
+ ***********************************************************************/
+static EFrameworkunifiedStatus setEvnVariableForLaunchCus(std::string f_sEnvArea) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ const CHAR LaunchCusEnvVariable[] = "SM_CONF_LAUNCH_CUS";
+
+ const CHAR *l_pSetValue =
+ (EnvValueArea1 == f_sEnvArea || EnvValueArea2 == f_sEnvArea) ?
+ EnvValueYes : EnvValueNo;
+
+ if (0 != setenv(LaunchCusEnvVariable, l_pSetValue, 1)) {
+ SS_ASERT_ERRNO(0);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+/***********************************************************************
+ * setEvnVariableForLaunchTFF
+ ***********************************************************************/
+static EFrameworkunifiedStatus setEvnVariableForLaunchTFF(std::string f_sEnvArea) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ const CHAR LaunchTFFEnvVariable[] = "SM_CONF_LAUNCH_TFF";
+
+ const CHAR *l_pSetValue = EnvValueNo;
+
+ BOOL l_bArea1 = (f_sEnvArea == EnvValueArea1) ? TRUE : FALSE;
+ BOOL l_bArea2 = (f_sEnvArea == EnvValueArea2) ? TRUE : FALSE;
+
+ if (l_bArea1 || l_bArea2) {
+ l_pSetValue = EnvValueYes;
+ } else {
+ l_pSetValue = EnvValueNo;
+ }
+
+ if (0 != setenv(LaunchTFFEnvVariable, l_pSetValue, 1)) {
+ SS_ASERT_ERRNO(0);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+/***********************************************************************
+ * getEnvValiavleWithDefault
+ ***********************************************************************/
+static std::string getEnvValiavleWithDefault(const CHAR *f_pEnvName,
+ const CHAR *f_pDefault) {
+ std::string l_sReturnValue;
+ char buf[VP_MAX_LENGTH];
+
+ VP_GetEnv(f_pEnvName, buf);
+ if (buf[0] == '\0') {
+ l_sReturnValue = (NULL != f_pDefault) ? f_pDefault : "";
+ } else {
+ l_sReturnValue = buf;
+ }
+ return l_sReturnValue;
+}
+
+
+/***********************************************************************
+ * getPkgInfoWithDefault
+ ***********************************************************************/
+static std::string
+getPkgInfoWithDefault(const CHAR *f_pPkgName, const CHAR *f_pDefault){
+ std::string l_sReturnValue = (NULL != f_pDefault) ? f_pDefault : "";
+
+ try {
+ SSVER_PkgInfo pkgInfo = {0};
+ CSSVer cVersion;
+
+ if(!cVersion.empty()){
+ EFrameworkunifiedStatus ret = cVersion.getPkgInfo(f_pPkgName, &pkgInfo);
+ if((ret == eFrameworkunifiedStatusOK) && ('\0' != pkgInfo.version[0])){
+ l_sReturnValue = pkgInfo.version;
+ }
+ }
+ } catch(EFrameworkunifiedStatus ee){
+ SS_ASERT(0);
+ }
+
+ return l_sReturnValue;
+}
+
+/***********************************************************************
+ * setEvnVariableForPkgSeriesInfo
+ ***********************************************************************/
+static EFrameworkunifiedStatus
+setEvnVariableForPkgSeriesInfo(std::string f_sPkgSeriesInfo){
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ const CHAR PkgSeriesEnvVariable[] = "SM_CONF_PKG_SERIES";
+
+ if (f_sPkgSeriesInfo.empty()) {
+ SS_ASERT(0);
+ }
+
+ if (0 != setenv(PkgSeriesEnvVariable, f_sPkgSeriesInfo.c_str(), 1)) {
+ SS_ASERT_ERRNO(0);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+/***********************************************************************
+ * setVersionInfo subfunction(version,date settings)
+ ***********************************************************************/
+static EFrameworkunifiedStatus setVerInfo_version_date(const char* VerPath) {
+ EFrameworkunifiedStatus configRet = eFrameworkunifiedStatusOK;
+ CSSVer ver;
+ SSVER_PkgInfo pkgInfo;
+
+ bzero(&pkgInfo, sizeof(pkgInfo));
+ std::string line;
+ std::ifstream verFin(VerPath);
+ if (verFin) {
+ if (std::getline(verFin, line)) {
+ snprintf(pkgInfo.version, sizeof(pkgInfo.version), "%s",
+ line.c_str());
+ }
+
+ if (std::getline(verFin, line)) {
+ snprintf(pkgInfo.date, sizeof(pkgInfo.date), "%s", line.c_str());
+ }
+
+ configRet = ver.setPkgInfo(SS_PKG_MAIN_LPF_SI, pkgInfo);
+ SS_ASERT(configRet == eFrameworkunifiedStatusOK);
+ } else {
+ SS_ASERT_ERRNO(0);
+ }
+ return configRet;
+}
+
+/***********************************************************************
+ * Set version information
+ ***********************************************************************/
+static EFrameworkunifiedStatus setVersionInfo(void) {
+ EFrameworkunifiedStatus configRet = eFrameworkunifiedStatusOK;
+
+ try {
+ CSSVer ver;
+ SSVER_PkgInfo pkgInfo;
+ const char targetEnv[] = "TARGET_BOARD";
+
+ // HARDWARE
+ snprintf(pkgInfo.version, sizeof(pkgInfo.version), "%s",
+ getEnvValiavleWithDefault(targetEnv, NULL).c_str());
+ pkgInfo.date[0] = '\0';
+ configRet = ver.setPkgInfo(SS_PKG_TARGETBOARD, pkgInfo);
+ SS_ASERT(configRet == eFrameworkunifiedStatusOK);
+
+ // Set PRODUCT version information
+ const char prdVersion[] = "/usr/agl/share/BS/ss/system_manager/rodata/version.txt";
+ {
+ std::string line;
+ std::ifstream prdFin(prdVersion);
+ if (prdFin) {
+ bzero(&pkgInfo, sizeof(pkgInfo));
+ if (std::getline(prdFin, line)) {
+ snprintf(pkgInfo.version, sizeof(pkgInfo.version), "%s",
+ line.c_str());
+ }
+ configRet = ver.setPkgInfo(SS_PKG_MAIN_EMMC, pkgInfo);
+ SS_ASERT(configRet == eFrameworkunifiedStatusOK);
+
+ bzero(&pkgInfo, sizeof(pkgInfo));
+ if (std::getline(prdFin, line)) {
+ snprintf(pkgInfo.version, sizeof(pkgInfo.version), "%s",
+ line.c_str());
+ }
+ configRet = ver.setPkgInfo(SS_PKG_MAIN_PRODUCT_SI, pkgInfo);
+ SS_ASERT(configRet == eFrameworkunifiedStatusOK);
+ } else {
+ SS_ASERT_ERRNO(0);
+ }
+ }
+
+ // PHASE_INFO
+ const char phaseVersion[] = "/usr/agl/share/BS/ss/system_manager/rodata/PhaseInfo.txt";
+ {
+ configRet = setVerInfo_version_date(phaseVersion);
+ }
+
+ } catch (EFrameworkunifiedStatus ee) {
+ SS_ASERT(0);
+ configRet = ee;
+ }
+ return configRet;
+}
+
+// If _CWORD83_ common header is added, replace with century definition
+#define NTFY_PSMShadowService_Availability MN_PS_PSMSHADOW"/Availability"
+
+EFrameworkunifiedStatus cbPsmNotificationFunc(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (MSG_PSM_REBOOT_NOTIFY != FrameworkunifiedGetMsgProtocol(hApp)) {
+ SS_ASERT(0);
+ goto ERROR;
+ }
+
+ if (NULL != s_confCtx.cbRebootNoticeFunc) {
+ l_eStatus = s_confCtx.cbRebootNoticeFunc(hApp);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ SS_ASERT(0);
+ goto ERROR;
+ }
+ } else {
+ SS_ASERT(0);
+ goto ERROR;
+ }
+
+ERROR:
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus cbServiceNotificationFunc(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ PCSTR l_availabilityName;
+ BOOL l_serviceAvailability;
+
+ l_availabilityName = FrameworkunifiedGetLastNotification(hApp);
+ if (l_availabilityName == NULL) {
+ SS_ASERT(0);
+ goto ERROR;
+ }
+ l_serviceAvailability = FrameworkunifiedIsServiceAvailable(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s : %s", l_availabilityName,
+ l_serviceAvailability ? "TRUE" : "FALSE");
+
+ // Since it is necessary to guarantee SYNC of RAMD at _CWORD71_
+ // within 200msec after receiving reboot notice from SYS mcu,
+ // do UMOUNT RAMD immediately after receiving reboot notice by SystemManager.
+ if ((strcmp(NTFY_PSMShadowService_Availability, l_availabilityName) == 0)
+ && (l_serviceAvailability)) {
+ l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, FRAMEWORKUNIFIED_ANY_SOURCE,
+ MSG_PSM_REBOOT_NOTIFY,
+ cbPsmNotificationFunc);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ SS_ASERT(0);
+ goto ERROR;
+ }
+ }
+
+ERROR:
+ return l_eStatus;
+}
+
+/***********************************************************************
+ * ss_sm_initHook
+ ***********************************************************************/
+EFrameworkunifiedStatus ss_sm_initHook(HANDLE hApp, const T_SS_SM_INIT_HOOK_IN_PARAM *inPrm,
+ T_SS_SM_INIT_HOOK_OUT_PARAM *outPrm) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_sEnvFile;
+ std::string l_sEnvArea;
+ std::string l_sEnvBrand;
+ std::string l_sEnvGrade;
+
+ std::string l_sPkgSeriesInfo;
+
+ // Register non-recoverable services for OOM Killer
+ registProtectSvcs(outPrm->protectedSvcs);
+
+ // Register services for Group Relaunch
+ registGroupRelaunchSvcs(outPrm->groupRelaunchSvcs);
+
+ if (NULL == inPrm->cbRebootNoticeFunc) {
+ SS_ASERT(0);
+ } else {
+ s_confCtx.cbRebootNoticeFunc = inPrm->cbRebootNoticeFunc;
+ }
+
+ /** Set Version information **/
+ if (eFrameworkunifiedStatusOK != setVersionInfo()) {
+ SS_ASERT(0);
+ }
+
+ /** Get environment variable **/
+
+ // APPS_CONFIG_FILENAME (not set by default)
+ l_sEnvFile = getEnvValiavleWithDefault(LaunchConfigFileNameEnvVariable, NULL);
+
+ // VEHICLEPARAMETERLIBRARY_AREA
+ l_sEnvArea = getEnvValiavleWithDefault(AreaTypeEnvVariable, EnvValueArea1);
+
+ // VEHICLEPARAMETERLIBRARY_BRAND
+ l_sEnvBrand = getEnvValiavleWithDefault(BrandTypeEnvVariable, NULL);
+
+ // VEHICLEPARAMETERLIBRARY_grade
+ l_sEnvGrade = getEnvValiavleWithDefault(GradeEnvVariable, NULL);
+
+
+ /** Get Package information **/
+
+ // SERIES_INFO
+ l_sPkgSeriesInfo = getPkgInfoWithDefault(SS_PKG_SERIES_INFO, NULL);
+
+
+ /** Set environment variable **/
+ // APPS_CONFIG_FILENAME
+ if (eFrameworkunifiedStatusOK
+ != setEvnVariableForLaunchConfigFile(l_sEnvFile, l_sEnvBrand,
+ l_sEnvGrade, inPrm->bIsVupMode)) {
+ SS_ASERT(0);
+ }
+
+ // SM_CONF_PKG_SERIES
+ if (eFrameworkunifiedStatusOK != setEvnVariableForPkgSeriesInfo(l_sPkgSeriesInfo)) {
+ SS_ASERT(0);
+ }
+
+
+ // SM_CONF_LAUNCH_CUS
+ if (eFrameworkunifiedStatusOK != setEvnVariableForLaunchCus(l_sEnvArea)) {
+ SS_ASERT(0);
+ }
+
+ // SM_CONF_LAUNCH_TFF
+ if (eFrameworkunifiedStatusOK
+ != setEvnVariableForLaunchTFF(l_sEnvArea)) {
+ SS_ASERT(0);
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(
+ hApp, NTFY_PSMShadowService_Availability, cbServiceNotificationFunc))) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error: FrameworkunifiedSubscribeNotificationWithCallback(" "hApp, %s) errored: %d/'%s'",
+ NTFY_PSMShadowService_Availability, l_eStatus, GetStr(l_eStatus).c_str());
+ }
+
+ return l_eStatus;
+}
+
diff --git a/systemservice/config/library/system_manager_config/xml/Makefile b/systemservice/config/library/system_manager_config/xml/Makefile
new file mode 100755
index 0000000..e11288c
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/xml/Makefile
@@ -0,0 +1,53 @@
+#
+# @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.
+#
+
+#HOST TOOLS
+HOST_CPP = cpp
+HOST_LAUNCH_XML2CFG = ./launch_xml2cfg.sh
+
+CONF_DIR = $(SDKTARGETSYSROOT)/usr/agl/conf
+CONF_THREAD_H = $(SDKTARGETSYSROOT)/usr/agl/include/agl_thread.h
+
+LAUNCH_XMLFILES = $(shell cd $(CONF_DIR)/sm_launch; ls *.xml)
+LAUNCH_CFGFILES = $(LAUNCH_XMLFILES:%.xml=%.cfg)
+
+INST_CONFDIR = $(SDKTARGETSYSROOT)/usr/agl/conf/systemmanager
+
+CLEAN_FILES = system_launcher_body.xml $(LAUNCH_CFGFILES)
+
+VPATH = $(CONF_DIR)/sm_launch
+
+install:install-pre install-cfg
+
+install-pre:
+ install -d -m 775 $(DESTDIR)/usr/agl/conf;\
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/sm_launch;\
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/systemmanager;\
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/sm_launch sm_launch_agl.xml
+
+install-cfg:$(LAUNCH_CFGFILES)
+ set -e ;\
+ install -d -m 775 $(INST_CONFDIR) ;\
+ for cfgfile in $(LAUNCH_CFGFILES);do \
+ install -m 644 -t $(INST_CONFDIR) $$cfgfile;\
+ done ;\
+
+#Create CFG file
+# %.cfg:%.xml # defined in agl.mk
+
+PHONY:install-cfg
+
+include ../../../../system_service.mk
diff --git a/systemservice/config/library/system_manager_config/xml/launch_cfg2xml.sh b/systemservice/config/library/system_manager_config/xml/launch_cfg2xml.sh
new file mode 100755
index 0000000..57b6ee2
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/xml/launch_cfg2xml.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+#
+# Copyright (c) 2019-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.
+#
+
+export infile=$1
+export g_group=1
+
+if ! [[ "$infile" =~ .+\.cfg ]] ;then
+ echo "$infile is not *.cfg"
+ exit 1
+elif ! [ -e $infile ];then
+ echo "$infile not found"
+ exit 1
+fi
+
+#GROUP extraction
+cat ${infile} | while read line
+do
+ if ! [[ "${line}" =~ ^[#\[] ]]; then #Remove first #[
+ echo $line | sed 's/Launch[0-9]\+=//g' | cut -d '|' -f1-4
+ fi
+done | uniq | while read line
+do
+ echo "<!-- group_id=$g_group -->"
+ echo "<group name=\"`echo $line | cut -d '|' -f1`\" wait_time=\"`echo $line | cut -d '|' -f3`\" trigger=\"`echo $line | cut -d '|' -f4`\" >"
+
+ cat ${infile} | while read line
+ do
+ if ! [[ "${line}" =~ ^[#\[] ]]; then #Remove first #[
+ l_group=`echo $line | sed 's/Launch[0-9]\+=//g' | cut -d '|' -f2`
+
+ #Extract only LAUNCH applicable to g_group
+ if [ ${l_group} = ${g_group} ]; then
+ echo $line | sed 's/Launch[0-9]\+=//g' | cut -d '|' -f5-
+ fi
+ fi
+ done | while read line
+ do
+ echo " <launch "
+ echo " name=\"`echo $line | cut -d '|' -f1`\" path=\"`echo $line | cut -d '|' -f2`\" priority=\"`echo $line | cut -d '|' -f3`\""
+ echo " critical=\"`echo $line | cut -d '|' -f4`\" retry_cnt=\"`echo $line | cut -d '|' -f5`\" arguments=\"`echo $line | cut -d '|' -f6`\""
+ echo " logging_mask=\"`echo $line | cut -d '|' -f7`\" restart=\"`echo $line | cut -d '|' -f8`\" is_start_required=\"`echo $line | cut -d '|' -f9`\""
+ echo " shutdown_critical=\"`echo $line | cut -d '|' -f10`\" shutdown_wait_time=\"`echo $line | cut -d '|' -f11`\" fast_shutdown_wait_time=\"`echo $line | cut -d '|' -f12`\""
+ echo " user_name=\"`echo $line | cut -d '|' -f13`\""
+ echo " />"
+ done
+
+ echo "</group>"
+
+ g_group=$(($g_group + 1))
+done
+
+
+
+
diff --git a/systemservice/config/library/system_manager_config/xml/launch_xml2cfg.sh b/systemservice/config/library/system_manager_config/xml/launch_xml2cfg.sh
new file mode 100755
index 0000000..20fa097
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/xml/launch_xml2cfg.sh
@@ -0,0 +1,116 @@
+#!/bin/bash
+
+#
+# Copyright (c) 2019-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.
+#
+
+#xpath is slow, so use sed as much as possible
+
+infile=$1
+
+main_file=system_launcher_main.xml
+body_file=system_launcher_body.xml
+
+
+#check xmllint is exist
+if ! which xmllint > /dev/null ; then
+ echo "It need xmllint. Please install it."
+ exit 1;
+fi
+
+#check xpath is exist
+if ! which xpath > /dev/null ; then
+ echo "It need xpath Please install it."
+ exit 1;
+fi
+
+#arg check
+if ! [[ "$infile" =~ .+\.xml ]] ;then
+ echo "$infile is not *.xml"
+ exit 1
+elif ! [ -e $infile ];then
+ echo "$infile not found"
+ exit 1
+fi
+
+cp -f $infile $body_file
+
+#check xml vaild
+if ! xmllint --noout --valid $main_file ;then
+ echo "XML is Invalid. "
+ exit 1;
+fi
+
+#Read into memory after shaping with xpath
+xmem=`xpath -q -e /system_launcher $main_file`
+
+echo "# This file is created from $infile."
+echo "# created date : `LANG=en date`"
+echo "[ModulesLaunchConfig]"
+
+#GROUP LOOP
+group_num=`echo $xmem | xpath -e /system_launcher/group 2>&1 | grep Found | cut -d ' ' -f2`
+
+l_idx=1
+cur_group=1
+until [ $cur_group -gt $group_num ];
+do
+ #LAUNCH LOOP
+ group_text=`echo $xmem | xpath -q -e /system_launcher/group[$cur_group]` #group full XML text
+ group_attr=`echo $group_text | sed 's/\(<group[^>]\+>\)\(.*\)/\1/g'`
+
+ g_name=`echo $group_attr | sed 's/\(.* name="\)\([^"]*\)\(.*\)/\2/g'`
+ g_wait_time=`echo $group_attr | sed 's/\(.* wait_time="\)\([^"]*\)\(.*\)/\2/g'`
+ g_trigger=`echo $group_attr | sed 's/\(.* trigger="\)\([^"]*\)\(.*\)/\2/g'`
+
+# echo $g_name $g_wait_time $g_trigger
+ l_launch_num=`echo $xmem | xpath -e /system_launcher/group[$cur_group]/launch 2>&1 | grep Found | cut -d ' ' -f2`
+
+ cur_launch=1;
+ until [ $cur_launch -gt $l_launch_num ]; do
+ launch_text=`echo $xmem | xpath -q -e /system_launcher/group[$cur_group]/launch[$cur_launch]`
+
+ l_attr="Launch${l_idx}=$g_name|$cur_group|$g_wait_time|$g_trigger"
+ l_attr+="|"`echo $launch_text | sed 's/\(.* name="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* path="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* priority="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* critical="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* retry_cnt="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* arguments="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* logging_mask="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* restart="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* is_start_required="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* shutdown_critical="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* shutdown_wait_time="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* fast_shutdown_wait_time="\)\([^"]*\)\(.*\)/\2/g'`
+ l_attr+="|"`echo $launch_text | sed 's/\(.* user_name="\)\([^"]*\)\(.*\)/\2/g'`
+ if echo "$launch_text" | grep -sq 'env_cond=' ; then
+ l_attr+="|"`echo $launch_text | sed 's/\(.* env_cond="\)\([^"]*\)\(.*\)/\2/g'`
+ else
+ l_attr+="|"
+ fi
+
+ echo $l_attr
+
+ cur_launch=$(($cur_launch+1))
+ l_idx=$(($l_idx+1))
+ done
+
+ cur_group=$(($cur_group+1))
+done
+
+
+
+
diff --git a/systemservice/config/library/system_manager_config/xml/sm_launch_agl.cfg b/systemservice/config/library/system_manager_config/xml/sm_launch_agl.cfg
new file mode 100755
index 0000000..876ab41
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/xml/sm_launch_agl.cfg
@@ -0,0 +1,7 @@
+# This file is created from sm_launch_agl.xml.tmp.
+# created date : Tue Aug 29 13:31:32 JST 2017
+[ModulesLaunchConfig]
+Launch1=CoreModules|1|0|False|NS_NPPService|/usr/agl/bin/NS_NPPService|25|True|0|-a SS_SysManager -r output=0x2|NULL|NULL|False|True|20|1000||
+Launch2=CoreModules|1|0|False|NS_BackupMgr|/usr/agl/bin/NS_BackupMgr|25|True|0|-l console|NULL|NULL|True|True|15|1000||
+Launch3=SS_Logger|2|0|False|SS_DevDetectSrv|/tmp/SS_DeviceDetectionService|20|True|0|-l console|NULL|NULL|True|False|1|1000||
+Launch4=SS_Logger|2|0|False|SS_LoggerSrv|/usr/agl/bin/SS_LoggerService|0|True|0|-l console -p thrd=pdg.LogQueReader:30,thrd=pdg.TransmitQueReader:30,thrd=pdg.DumpQueReader:11,thrd=pdg.PerformanceQueReader:11,thrd=pdg.LogQueWriter:30,thrd=pdg.TransmitQueWriter:30,thrd=pdg.EvntLogQue:8,thrd=pdg.UdpQueWriter:10|NULL|NULL|True|True|10|1000||
diff --git a/systemservice/config/library/system_manager_config/xml/sm_launch_agl.xml b/systemservice/config/library/system_manager_config/xml/sm_launch_agl.xml
new file mode 100755
index 0000000..a433be3
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/xml/sm_launch_agl.xml
@@ -0,0 +1,35 @@
+<!-- group_id=1 -->
+<group name="CoreModules" wait_time="0" trigger="False" >
+ <launch
+ name="NS_NPPService" path="/usr/agl/bin/NS_NPPService" priority="25"
+ critical="True" retry_cnt="0" arguments="-a SS_SysManager -r output=0x2"
+ logging_mask="NULL" restart="NULL" is_start_required="False"
+ shutdown_critical="True" shutdown_wait_time="20" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+ <launch
+ name="NS_BackupMgr" path="/usr/agl/bin/NS_BackupMgr" priority="25"
+ critical="True" retry_cnt="0" arguments="-l console"
+ logging_mask="NULL" restart="NULL" is_start_required="True"
+ shutdown_critical="True" shutdown_wait_time="15" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+</group>
+<!-- group_id=2 -->
+<group name="SS_Logger" wait_time="0" trigger="False" >
+ <launch
+ name="SS_DevDetectSrv" path="/tmp/SS_DeviceDetectionService" priority="20"
+ critical="True" retry_cnt="0" arguments="-l console"
+ logging_mask="NULL" restart="NULL" is_start_required="True"
+ shutdown_critical="False" shutdown_wait_time="1" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+ <launch
+ name="SS_LoggerSrv" path="/usr/agl/bin/SS_LoggerService" priority="0"
+ critical="True" retry_cnt="0" arguments="-l console -p thrd=pdg.LogQueReader:30,thrd=pdg.TransmitQueReader:30,thrd=pdg.DumpQueReader:11,thrd=pdg.PerformanceQueReader:11,thrd=pdg.LogQueWriter:30,thrd=pdg.TransmitQueWriter:30,thrd=pdg.EvntLogQue:8,thrd=pdg.UdpQueWriter:10"
+ logging_mask="NULL" restart="NULL" is_start_required="True"
+ shutdown_critical="True" shutdown_wait_time="10" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+</group>
+
diff --git a/systemservice/interface_unified/LICENSE b/systemservice/interface_unified/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/interface_unified/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/interface_unified/Makefile.client b/systemservice/interface_unified/Makefile.client
new file mode 100755
index 0000000..de16e15
--- /dev/null
+++ b/systemservice/interface_unified/Makefile.client
@@ -0,0 +1,33 @@
+#
+# @copyright Copyright (c) 2017-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.
+#
+
+SUBDIRS := library
+
+install:install_cfg install_cfg_pram
+
+install_cfg_pram:
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/BS/ss/system_manager/rwdata
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/BS/ss/system_manager/rwdata scfg_pram/gpf_ss_sm_config_data.cfg
+
+install_cfg:
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/BS/ss/power_service/rodata
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/BS/ss/power_service/rodata scfg/gpf_ss_ps_config.cfg
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/BS/ss/logger_service/rodata
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/BS/ss/logger_service/rodata scfg/ss_logger.cfg
+
+include ../system_service.mk
+
+.PHONY:install_cfg install_cfg_pram
diff --git a/systemservice/interface_unified/library/Makefile b/systemservice/interface_unified/library/Makefile
new file mode 100755
index 0000000..e784550
--- /dev/null
+++ b/systemservice/interface_unified/library/Makefile
@@ -0,0 +1,127 @@
+#
+# @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.
+#
+
+# installed shared library(.so)
+INST_SHLIBS := libSS_SystemIfUnified
+
+# compiled sources
+libSS_SystemIfUnified_SRCS := ss_framework_if.cpp \
+ ss_heartbeat_client.cpp \
+ ss_sm_client.cpp \
+ ss_string_maps.cpp \
+ ss_system_process.cpp \
+ ss_system_timer.cpp \
+ ss_last_to_order.cpp
+libSS_SystemIfUnified_SRCS += ss_devicedetection_service_ifc.cpp
+libSS_SystemIfUnified_SRCS += ss_logger_service_ifc.cpp
+libSS_SystemIfUnified_SRCS += ss_power_client.cpp \
+ ss_pwrsvc_if.cpp
+
+# additional source path
+VPATH += ./src
+VPATH += ./include/$(COMPONENT_NAME)
+
+# installed headers
+INST_HEADERS = interface_unified.h
+INST_HEADERS += interfaceunified_system_application.h \
+ interfaceunified_system_types.h \
+ ss_client_names.h \
+ ss_devicedetection_service.h \
+ ss_devicedetection_service_ifc.h \
+ ss_devicedetection_service_notifications.h \
+ ss_devicedetection_service_protocol.h \
+ ss_devicedetection_service_types.h \
+ ss_error_event_common.h \
+ ss_error_message.h \
+ ss_heartbeat_if.h \
+ ss_heartbeat_notifications.h \
+ ss_heartbeat_service_protocol.h \
+ ss_logger_service.h \
+ ss_logger_service_ifc.h \
+ ss_logger_service_notifications.h \
+ ss_logger_service_protocol.h \
+ ss_power_service_if.h \
+ ss_power_service_notifications.h \
+ ss_power_service_protocol.h \
+ ss_power_service.h \
+ ss_services.h \
+ ss_sm_client_if.h \
+ ss_sys_boot_area_map.h \
+ ss_sm_thread_names.h \
+ ss_string_maps.h \
+ ss_system_if.h \
+ ss_system_manager_if.h \
+ ss_system_manager_notifications.h \
+ ss_system_manager_protocol.h \
+ ss_system_process.h \
+ ss_system_timer.h \
+ ss_system_types.h \
+ ss_boot_map.h \
+ ss_templates.h \
+ ss_test_clients.h \
+ ss_version.h \
+ ss_last_to_order.h
+INST_HEADERS += ss_logger_store_logs.h
+INST_HEADERS += ss_devicedetection_service_local.h \
+ ss_devicedetection_service_protocol_local.h \
+ ss_devicedetection_service_types_local.h \
+ ss_error_event_common_local.h \
+ ss_sm_client_if_local.h \
+ ss_sm_thread_names_local.h \
+ ss_system_manager_if_local.h \
+ ss_system_manager_notifications_local.h \
+ ss_system_manager_protocol_local.h \
+ ss_logger_service_local.h \
+ ss_power_service_local.h \
+ ss_power_service_notifications_local.h
+
+
+
+# additional include path
+CPPFLAGS += -I./include/
+CPPFLAGS += -I../../rom_access_library/library/include/
+
+# additional compile option
+CPPFLAGS += -DLINUX -fdata-sections -ffunction-sections
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+
+CPPFLAGS_ss_devicedetection_service_ifc.os = -fno-exceptions
+CPPFLAGS_ss_logger_service_ifc.os = -fno-exceptions
+CPPFLAGS_ss_system_timer.os = -fno-exceptions
+CPPFLAGS_ss_string_maps.os = -fno-exceptions
+CPPFLAGS_ss_client_session.os = -fno-exceptions
+CPPFLAGS_ss_framework_if.os = -fno-exceptions
+CPPFLAGS_ss_ss_heartbeat_client.os = -fno-exceptions
+CPPFLAGS_ss_parameter.os = -fno-exceptions
+CPPFLAGS_ss_parameter_map.os = -fno-exceptions
+CPPFLAGS_ss_str_stream.os = -fno-exceptions
+CPPFLAGS_ss_system_config_reader.os = -fno-exceptions
+CPPFLAGS_ss_system_shared_memory.os = -fno-exceptions
+CPPFLAGS_ss_plm_if.os = -fno-exceptions
+CPPFLAGS_ss_power_client.os = -fno-exceptions
+CPPFLAGS_ss_pwrsvc_if.os = -fno-exceptions
+
+LDFLAGS += -Wl,--no-as-needed
+
+# linked libraries
+LDLIBS += -Wl,-Bdynamic
+LDLIBS += -Wl,-Bdynamic
+LDLIBS += -Wl,-Bdynamic -lstdc++
+
+LDFLAGS += -g -Wl,--gc-sections -shared
+
+
+include ../../system_service.mk
diff --git a/systemservice/interface_unified/library/include/ss_devicedetection_service_if_interfaceunifiedlog.h b/systemservice/interface_unified/library/include/ss_devicedetection_service_if_interfaceunifiedlog.h
new file mode 100755
index 0000000..62f32b9
--- /dev/null
+++ b/systemservice/interface_unified/library/include/ss_devicedetection_service_if_interfaceunifiedlog.h
@@ -0,0 +1,86 @@
+/*
+ * @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_SystemServices_DeviceDetection
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ */
+#ifndef INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_DEVICEDETECTION_SERVICE_IF_INTERFACEUNIFIEDLOG_H_
+#define INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_DEVICEDETECTION_SERVICE_IF_INTERFACEUNIFIEDLOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR
+#endif // FRAMEWORKUNIFIEDLOGAPPZONES
+
+extern const CHAR AppName[];
+#endif // INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_DEVICEDETECTION_SERVICE_IF_INTERFACEUNIFIEDLOG_H_
diff --git a/systemservice/interface_unified/library/include/ss_last_to_order_local.h b/systemservice/interface_unified/library/include/ss_last_to_order_local.h
new file mode 100755
index 0000000..889a733
--- /dev/null
+++ b/systemservice/interface_unified/library/include/ss_last_to_order_local.h
@@ -0,0 +1,41 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_last_to_order_local.h
+ * @brief \~english This file contains declaration of SS_LAST_TO_ORDER_CONF_PATH
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_LAST_TO_ORDER_LOCAL_H_
+#define INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_LAST_TO_ORDER_LOCAL_H_
+
+#include <string>
+
+#define SS_LAST_TO_ORDER_CONF_PATH "/usr/agl/conf/BS/ss/system_manager/rodata/sm_last2order.cfo"
+
+#endif // INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_LAST_TO_ORDER_LOCAL_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/ss_logger_service_if_interfaceunifiedlog.h b/systemservice/interface_unified/library/include/ss_logger_service_if_interfaceunifiedlog.h
new file mode 100755
index 0000000..8989bf6
--- /dev/null
+++ b/systemservice/interface_unified/library/include/ss_logger_service_if_interfaceunifiedlog.h
@@ -0,0 +1,86 @@
+/*
+ * @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_SystemServices_Logger
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ */
+#ifndef INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_LOGGER_SERVICE_IF_INTERFACEUNIFIEDLOG_H_
+#define INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_LOGGER_SERVICE_IF_INTERFACEUNIFIEDLOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR
+#endif
+
+extern const CHAR AppName[];
+#endif // INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_LOGGER_SERVICE_IF_INTERFACEUNIFIEDLOG_H_
diff --git a/systemservice/interface_unified/library/include/ss_power_if_interfaceunifiedlog.h b/systemservice/interface_unified/library/include/ss_power_if_interfaceunifiedlog.h
new file mode 100755
index 0000000..d198030
--- /dev/null
+++ b/systemservice/interface_unified/library/include/ss_power_if_interfaceunifiedlog.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_PowerServiceIf
+/// \brief This file supports 002 application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_POWER_IF_INTERFACEUNIFIEDLOG_H_
+#define INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_POWER_IF_INTERFACEUNIFIEDLOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT, LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR, ZONE_WARN
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern const CHAR AppName[];
+#endif // INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_POWER_IF_INTERFACEUNIFIEDLOG_H_
diff --git a/systemservice/interface_unified/library/include/ss_system_if_interfaceunifiedlog.h b/systemservice/interface_unified/library/include/ss_system_if_interfaceunifiedlog.h
new file mode 100755
index 0000000..81ef016
--- /dev/null
+++ b/systemservice/interface_unified/library/include/ss_system_if_interfaceunifiedlog.h
@@ -0,0 +1,89 @@
+/*
+ * @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_SystemManagerIf
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ */
+#ifndef INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_SYSTEM_IF_INTERFACEUNIFIEDLOG_H_
+#define INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_SYSTEM_IF_INTERFACEUNIFIEDLOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR, ZONE_WARN
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern const CHAR AppName[];
+
+#endif // INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_SYSTEM_IF_INTERFACEUNIFIEDLOG_H_
diff --git a/systemservice/interface_unified/library/include/ss_system_timer_local.h b/systemservice/interface_unified/library/include/ss_system_timer_local.h
new file mode 100755
index 0000000..d694bdd
--- /dev/null
+++ b/systemservice/interface_unified/library/include/ss_system_timer_local.h
@@ -0,0 +1,44 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_system_timer_local.h
+ * @brief \~english This file supports a generic timer abstraction.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_SYSTEM_TIMER_LOCAL_H_
+#define INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_SYSTEM_TIMER_LOCAL_H_
+
+enum {
+ NS_PER_MS = 1000000,
+ DEFAULT_TIMERID = 1000,
+ DEFAULT_NTIMERS = 10,
+};
+
+#endif // INTERFACE_UNIFIED_LIBRARY_INCLUDE_SS_SYSTEM_TIMER_LOCAL_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/interface_unified.h b/systemservice/interface_unified/library/include/system_service/interface_unified.h
new file mode 100755
index 0000000..a25423a
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/interface_unified.h
@@ -0,0 +1,100 @@
+//
+// @copyright Copyright (c) 2017-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.
+//
+/**
+ * @file interface_unified.h
+ * @brief \~english include all interface_unified head files
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+// include guard
+#ifndef SYSTEMSERVICE_INTERFACEUNIFIED_H_ // NOLINT(build/header_guard)
+#define SYSTEMSERVICE_INTERFACEUNIFIED_H_
+
+#include "system_service/interfaceunified_system_application.h"
+#include "system_service/interfaceunified_system_types.h"
+#include "system_service/ss_boot_map.h"
+#include "system_service/ss_client_names.h"
+#include "system_service/ss_devicedetection_service.h"
+#include "system_service/ss_devicedetection_service_ifc.h"
+#include "system_service/ss_devicedetection_service_notifications.h"
+#include "system_service/ss_devicedetection_service_protocol.h"
+#include "system_service/ss_devicedetection_service_types.h"
+#include "system_service/ss_error_event_common.h"
+#include "system_service/ss_error_message.h"
+#include "system_service/ss_heartbeat_if.h"
+#include "system_service/ss_heartbeat_notifications.h"
+#include "system_service/ss_heartbeat_service_protocol.h"
+#include "system_service/ss_last_to_order.h"
+#include "system_service/ss_logger_service.h"
+#include "system_service/ss_logger_service_ifc.h"
+#include "system_service/ss_logger_service_notifications.h"
+#include "system_service/ss_logger_service_protocol.h"
+#include "system_service/ss_services.h"
+#include "system_service/ss_sm_client_if.h"
+#include "system_service/ss_sm_thread_names.h"
+#include "system_service/ss_string_maps.h"
+#include "system_service/ss_sys_boot_area_map.h"
+#include "system_service/ss_system_if.h"
+#include "system_service/ss_system_manager_if.h"
+#include "system_service/ss_system_manager_notifications.h"
+#include "system_service/ss_system_manager_protocol.h"
+#include "system_service/ss_system_process.h"
+#include "system_service/ss_system_timer.h"
+#include "system_service/ss_system_types.h"
+#include "system_service/ss_templates.h"
+#include "system_service/ss_test_clients.h"
+#include "system_service/ss_version.h"
+
+// reference from logger_store_logs
+#include "system_service/ss_logger_store_logs.h"
+
+// files with local
+// reference from device_detection_service
+#include "system_service/ss_devicedetection_service_local.h"
+#include "system_service/ss_devicedetection_service_protocol_local.h"
+#include "system_service/ss_devicedetection_service_types_local.h"
+// reference from system_manager
+#include "system_service/ss_error_event_common_local.h"
+#include "system_service/ss_sm_client_if_local.h"
+#include "system_service/ss_sm_thread_names_local.h"
+#include "system_service/ss_system_manager_if_local.h"
+#include "system_service/ss_system_manager_notifications_local.h"
+
+#include "system_service/ss_system_manager_protocol_local.h"
+// reference from logger_service
+#include "system_service/ss_logger_service_local.h"
+
+// reference from power_service
+#include "system_service/ss_power_service_if.h"
+#include "system_service/ss_power_service_notifications.h"
+#include "system_service/ss_power_service_protocol.h"
+#include "system_service/ss_power_service.h"
+#include "system_service/ss_power_service_local.h"
+#include "system_service/ss_power_service_notifications_local.h"
+
+#endif // SYSTEMSERVICE_INTERFACEUNIFIED_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/interfaceunified_system_application.h b/systemservice/interface_unified/library/include/system_service/interfaceunified_system_application.h
new file mode 100755
index 0000000..fe5224e
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/interfaceunified_system_application.h
@@ -0,0 +1,219 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file interfaceunified_system_application.h
+ * @brief This file supports the System Manager AGL framework client
+ * interface.
+ */
+
+#ifndef INTERFACEUNIFIED_SYSTEM_APPLICATION_H_ // NOLINT (build/header_guard)
+#define INTERFACEUNIFIED_SYSTEM_APPLICATION_H_
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#include <native_service/frameworkunified_types.h>
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup InterfaceunifiedSystemConnectToPowerSerivce
+ /// \~english @par Summary
+ /// Subscribe and attach call backs to notifications, to PowerSerivce!
+ /// \~english @param [in] hApp
+ /// HANDLE - App handle
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - Pointer (pNtfyHandler) is NULL to the structure of the Notification Handler specified in the argument.
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount) 0. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount) has exceeded
+ /// the maximum number of Notification.[eFrameworkunifiedStatusFail]
+ /// - The acquisition of the buffer for storing a plurality of information of
+ /// Notification Handler specified by the argument has failed. [eFrameworkunifiedStatusInvldParam]
+ /// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+ /// [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Message queue name of HANDLE specified in the argument (hApp)
+ /// is not appropriate(The name is NULL, more than 20byte) [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to the NPP Service.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message
+ /// for the NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for the NPP Service.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// Subscribe and attach call backs to notifications, to PowerSerivce! \n
+ /// if callback has not subscribe,resubscribe! \n
+ /// if callback has been subscribed,initialize!
+ /// \~english @see FrameworkunifiedGetAppName FrameworkunifiedSubscribeNotificationsWithCallback
+ ////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus InterfaceunifiedSystemConnectToPowerSerivce(HANDLE hApp);
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup InterfaceunifiedSystemConnectToPowerSerivce
+ /// \~english @par Summary
+ /// Called from framework for every app to start connection to HeartBeat
+ /// \~english @param [in] hApp
+ /// HANDLE - App handle, Handle to message queue of HeartBeat Service.
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - Pointer (pNtfyHandler) is NULL to the structure of the Notification Handler specified
+ /// in the argument. [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount) 0. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount) has exceeded
+ /// the maximum number of Notification. [eFrameworkunifiedStatusFail]
+ /// - The acquisition of the buffer for storing a plurality of information of
+ /// Notification Handler specified by the argument has failed. [eFrameworkunifiedStatusInvldParam]
+ /// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+ /// [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Message queue name of HANDLE specified in the argument (hApp)
+ /// is not appropriate(The name is NULL, more than 20byte) [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+ // [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to the NPP Service.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of
+ /// the session message for the NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to the NPP Service.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to the NPP Service.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message
+ /// for the NPP Service. [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// Called from framework for every app to start connection to HeartBeat \n
+ /// if app has not connection,reconnection! \n
+ /// if app has been connectioned,initialize it!
+ /// \~english @see FrameworkunifiedGetAppName FrameworkunifiedAttachCallbacksToDispatcher
+ ////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus InterfaceunifiedSystemConnectToHeartBeatService(HANDLE hApp);
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup InterfaceunifiedSystemConnectToPowerSerivce
+ /// \~english @par Summary
+ /// Subscribe and attach callbacks to System Manager Service!
+ /// \~english @param [in] hApp
+ /// HANDLE - App handle.
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - Pointer (pNtfyHandler) is NULL to the structure of
+ /// the Notification Handler specified in the argument. [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount) 0. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount)
+ /// has exceeded the maximum number of Notification. [eFrameworkunifiedStatusFail]
+ /// - The acquisition of the buffer for storing a plurality of information of
+ /// Notification Handler specified by the argument has failed. [eFrameworkunifiedStatusInvldParam]
+ /// - Can not be acquired memory in the acquisition of the buffer of
+ /// the message for transmission (malloc). [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument message queue HANDLE in (hApp)
+ /// is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - Message queue name of HANDLE specified in the argument (hApp)
+ /// is not appropriate(The name is NULL, more than 20byte) [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue type of HANDLE specified in the argument (hApp)
+ /// is not a transmission. [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to the NPP Service.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of
+ /// the session message for the NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for
+ /// the NPP Service. [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// Subscribe and attach callbacks to System Manager Service! \n
+ /// if app has not Subscribed,resubscribe!
+ /// \~english @see FrameworkunifiedGetAppName SystemManagerOpenSender
+ ////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus InterfaceunifiedSystemConnectToSystemManagerService(HANDLE hApp);
+
+/** @}*/
+/** @}*/
+/** @}*/
+
+
+#endif /* INTERFACEUNIFIED_SYSTEM_APPLICATION_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/interfaceunified_system_types.h b/systemservice/interface_unified/library/include/system_service/interfaceunified_system_types.h
new file mode 100755
index 0000000..d3d3abd
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/interfaceunified_system_types.h
@@ -0,0 +1,165 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file interfaceunified_system_types.h
+ * @brief \~english This file supports the System Manager audio source types.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef INTERFACEUNIFIED_SYSTEM_TYPES_H_ // NOLINT (build/header_guard)
+#define INTERFACEUNIFIED_SYSTEM_TYPES_H_
+
+
+typedef enum _SS_Sources {
+ SS_SOURCE_NA = 0,
+ SS_SOURCE_FM = 1, //## To be integrated into SS_SOURCE_AMFM for _CWORD71_
+ SS_SOURCE_AM = 2, //## To be integrated into SS_SOURCE_AMFM for _CWORD71_
+
+ SS_SOURCE_CD = 3, // For Audio CDs
+ SS_SOURCE_AUX = 4,
+
+ SS_SOURCE_PHONE = 5, // Will be deprecated soon, use specific Incoming or Outgoing call.
+ SS_SOURCE_TA = 6, // ## To be integrated into SS_SOURCE_AMFM for _CWORD71_
+ SS_SOURCE_CHIMES = 7,
+ SS_SOURCE_NAVI = 8,
+
+ SS_SOURCE_MSC = 9, ///< Any mass storage device (USB-MSC, SD, HDD etc.,)
+ SS_SOURCE_MTP = 10, ///< _CWORD104_, MTP protocol devices(like _CWORD28_ over USB)
+
+ SS_SOURCE__CWORD57_ = 11, // ## To be integrated into SS_SOURCE_USB and SS_SOURCE_USB2 for _CWORD71_
+
+ SS_SOURCE__CWORD73__APP = 12, ///< _CWORD73_ based audio application (_CWORD74_ over BT/USB) - _CWORD22_, _CWORD13_ etc.,
+ SS_SOURCE__CWORD73__VIDEO_MODE = 13, ///< _CWORD73_ Video Mode (_CWORD57_ playback)
+
+ SS_SOURCE_STREAMING = 14, ///< Streaming over Wi-fi
+ SS_SOURCE_BT_AUDIO = 15, ///< Bluetooth Audio
+ SS_SOURCE_BT_SPP = 16, ///< Bluetooth SPP based audio application (_CWORD28_/BB etc.,)
+
+ SS_SOURCE_SPEECH = 17, ///< Speech audio playback
+
+ SS_SOURCE_USB = SS_SOURCE_MSC, ///< will be deprecated soon
+
+ SS_SOURCE__CWORD59_ = 18,
+ SS_SOURCE_ADRM = 19,
+ SS_SOURCE__CWORD60_ = 20,
+ SS_SOURCE_ADRA = 21,
+
+
+ SS_SOURCE_INCOMING_CALL = SS_SOURCE_PHONE,
+
+ SS_SOURCE_PRIVATE_MODE_CALL = 24,
+
+ SS_SOURCE_HANDSFREE_SPEAKING = 25,
+
+ SS_SOURCE_FM_DAB = 29,
+ SS_SOURCE_SD_CARD = 30,
+ SS_SOURCE_SDARS = 31,
+ SS_SOURCE_BROWSER_ENT = 32,
+ SS_SOURCE_ML_ENT = 33,
+ SS_SOURCE_ML_INFO = 34,
+
+ SS_SOURCE_DATA_CD = 35, // For Data CDs
+
+ SS_SOURCE_TAS = 40, // TA on same frequency
+
+ SS_SOURCE_DTV = 41,
+ SS_SOURCE_DVD = 42,
+ SS_SOURCE_BD = 43,
+ SS_SOURCE_DELIVERY_APP = 44,
+ SS_SOURCE_ENTUNE_ENT = 45,
+ SS_SOURCE_HDD_AUDIO = 46,
+ SS_SOURCE_JOYFUL_TALK = 47,
+ SS_SOURCE_CLEARANCE_SONAR = 48, // Not used, To be deleted
+ SS_SOURCE_DSRC = 49,
+ SS_SOURCE_ENTUNE_INFO = 50, // Not used, To be deleted
+ SS_SOURCE_HELPNET = 51,
+ SS_SOURCE_OTV = 52,
+ SS_SOURCE_MIRACAST = 53,
+ SS_SOURCE_RSE = 54,
+ SS_SOURCE_INSIDER = 55,
+ SS_SOURCE_MAIL = 56,
+ SS_SOURCE_MAIL_RINGTONE = 57,
+ SS_SOURCE_BD_REAR = 58,
+ SS_SOURCE_HDMI_REAR = 59,
+ SS_SOURCE_SD_CARD_REAR = 60,
+ SS_SOURCE_MIRACAST_REAR = 61,
+ SS_SOURCE_USB_REAR = 62, // Not used, To be deleted
+ SS_SOURCE_DLNA_REAR = 63,
+ SS_SOURCE_BROWSER_INFO = 64,
+ SS_SOURCE_DSRC_ENT = 65,
+ SS_SOURCE_RECDATA_PLAY = 66,
+// add Source ##
+ SS_SOURCE_AMFM = SS_SOURCE_FM,
+ SS_SOURCE_DLNA = 67,
+ SS_SOURCE_USB2 = 68,
+// add interrupt audio source ##
+ SS_SOURCE_VDSP = 69,
+ SS_SOURCE_NAVI_VR = 70,
+ SS_SOURCE_STARTUPBGM = 71,
+ SS_SOURCE_STARTUPBGM_INIT = 72,
+ SS_SOURCE_MAIL_INFO = 73,
+
+ SS_SOURCE_DIAG = 74,
+ SS_SOURCE_MAYDAY = 75,
+ SS_SOURCE_DCM = 76,
+ SS_SOURCE_SD_VIDEO = 77,
+
+ SS_SOURCE_DELIVERY_APP_INFO = 78,
+
+ SS_SOURCE__CWORD27__INFO = 86,
+
+ // Declaration of special sources starting from 100
+ SS_SOURCE_POWER_OFF = 100 // Being used by Mode
+}SS_SOURCE, *PSS_SOURCE;
+
+
+typedef enum _SS_Zones {
+ SS_ZONE_NA = 0,
+ SS_ZONE_DRIVER = 1, ///< Zero/Driver zone
+ SS_ZONE_REAR1,
+ SS_ZONE_REAR2,
+ SS_ZONE_REAR3,
+ SS_ZONE_ALL
+}SS_ZONE, *PSS_ZONE;
+
+
+typedef enum E_AUDIO_PORT {
+ SS_AUDIO_INPUT_PORT_1 = 0x01, ///< Enum representing MCASP2
+ SS_AUDIO_INPUT_PORT_2 = 0x02, ///< Enum representing MCBSP
+ SS_AUDIO_INPUT_PORT_3 = 0x03, ///< Enum representing MCASP3
+ SS_AUDIO_INPUT_PORT_4 = 0x04, ///< Enum representing MCASP3
+ SS_AUDIO_INPUT_PORT_5 = 0x05 ///< Enum representing other port
+}SS_AUDIO_INPUT_PORT, *PSS_AUDIO_INPUT_PORT;
+
+typedef enum _SS_Device_Context {
+ SINGLE_CONTEXT = 0,
+ MULTI_CONTEXT = 1
+}SS_DEVICE_CONTEXT, *PSS_DEVICE_CONTEXT;
+
+#endif /* INTERFACEUNIFIED_SYSTEM_TYPES_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_boot_map.h b/systemservice/interface_unified/library/include/system_service/ss_boot_map.h
new file mode 100755
index 0000000..364d5ed
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_boot_map.h
@@ -0,0 +1,25 @@
+/*
+ * @copyright Copyright (c) 2019-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.
+ */
+/**
+ * @file
+ */
+#ifndef _SS_BOOT_MAP_H_ // NOLINT (build/header_guard)
+#define _SS_BOOT_MAP_H_
+
+#include <system_service/ss_sm_boot_access.h>
+
+#endif //_SS_BOOT_MAP_H_ // NOLINT (build/header_guard)
+
diff --git a/systemservice/interface_unified/library/include/system_service/ss_client_names.h b/systemservice/interface_unified/library/include/system_service/ss_client_names.h
new file mode 100755
index 0000000..23604a1
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_client_names.h
@@ -0,0 +1,77 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_client_names.h
+ * @brief This file supports contains the queue names of the client
+ * services that System Services needs to know about.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_CLIENT_NAMES_H_ // NOLINT (build/header_guard)
+#define SS_CLIENT_NAMES_H_
+
+#define SERVICE__CWORD69_ "_CWORD69_"
+#define SERVICE_AS_AUDIO "AS_AudioService"
+#define SERVICE_AS_MODE "AS_ModeService"
+#define SERVICE_BR_BROWSER "BR_BrowserService"
+#define SERVICE_CAN_SHADOW "VS_CANShadow"
+#define SERVICE__CWORD51__BT "_CWORD51__BT"
+#define SERVICE__CWORD51__DR "_CWORD51__DR"
+#define SERVICE_DAB "RS_Master_Tuner"
+#define SERVICE_HMI "HMI"
+#define SERVICE_HMI__CWORD46_ "HMI__CWORD46_Service"
+#define SERVICE_HMI__CWORD77_ "HMI__CWORD77_Service"
+#define SERVICE_IPC_MP_SHADOW "PS_IPC_MP_Shadow"
+#define SERVICE_KEY_HANDLER "PS_KeyHandler"
+#define SERVICE_MM_ICD "MM_ICDService"
+#define SERVICE_MM_MEDIA "MM_MediaService"
+#define SERVICE_MM__CWORD21_ "MM__CWORD21_Service"
+#define SERVICE_NAV "NAV_NavigationService"
+#define SERVICE_NAV_LOC "NAV_LocationService"
+#define SERVICE_NS_NPP "NS_NPPService"
+#define SERVICE_NS_SHARED_MEM "NS_SharedMem"
+#define SERVICE_NW_BT "NW_BluetoothService"
+#define SERVICE_NW_CONNECTION "NW_ConnectionService"
+#define SERVICE_NW_MESSAGING "NW_MessagingService"
+#define SERVICE_NW_PHONE "NW_PhoneService"
+#define SERVICE_NW_PHONE_BOOK "NW_PhoneBookService"
+#define SERVICE_PSM_SHADOW "PS_PSMShadow"
+#define SERVICE_PS_IPC "PS_IPC"
+#define SERVICE_PS_SWDL_SHADOW "PS_SoftwareUpdateShadow"
+#define SERVICE_SDARS "RS_XSDARSService"
+#define SERVICE_TUNER "RS_Radio"
+#define SERVICE_VS__CWORD85_ "VS__CWORD85_Service"
+#define SERVICE_VS_DIAG "VS_DiagService"
+#define SERVICE_VS_DIAG_DISP "DiagDispatcherService"
+#define SERVICE_VS_RVC "VS_RVCService"
+#define SERVICE_VS_VEHICLE "VS_VehicleService"
+
+#endif /* SS_CLIENT_NAMES_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service.h
new file mode 100755
index 0000000..134ab1f
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service.h
@@ -0,0 +1,640 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_devicedetection_service.h
+ * @brief This file supports the Device Detection service.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup device_detection_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef _SS_DEVICEDETECTION_SERVER_H_ // NOLINT (build/header_guard)
+#define _SS_DEVICEDETECTION_SERVER_H_
+
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "system_service/ss_devicedetection_service_types.h"
+
+/**
+ * \~english The max size of the file path.
+ */
+#define FILEPATH_SIZE (256)
+
+/**
+ * \~english The max size of URL.
+ */
+#define URL_SIZE (256)
+
+/**
+ * \~english The max size of the device name.
+ */
+#define SS_DEV_DEVICE_NAME_SIZE (64)
+
+/**
+ * \~english The max size of the name.
+ */
+#define SS_DEV_NAME_SIZE (256)
+
+
+/**
+ * \~english Structure for FuseDAV info.
+ */
+typedef struct _FuseDAVInfo {
+ /**
+ * \~english FuseDAV server address
+ */
+ int8_t url[URL_SIZE]; // FuseDAV server address
+}SS_FuseDAVInfo;
+
+/**
+ * \~english Structure for USB device info.
+ */
+typedef struct _UsbInfo {
+ /**
+ * \~english Bus Number
+ */
+ uint8_t bus_no; // Bus Number
+ /**
+ * \~english Device Number
+ */
+ uint8_t dev_no; // Device Number
+ /**
+ * \~english Vendor ID
+ */
+ uint16_t idVendor; // Vendor ID
+ /**
+ * \~english Product ID
+ */
+ uint16_t idProduct; // Product ID
+ /**
+ * \~english reserved area
+ */
+ uint8_t reserved[2];
+ /**
+ * \~english Manufacturer Name
+ */
+ CHAR manufacturerName[SS_DEV_NAME_SIZE]; // Manufacturer Name
+ /**
+ * \~english Product Name
+ */
+ CHAR productName[SS_DEV_NAME_SIZE]; // Product Name
+ /**
+ * \~english Serial Number
+ */
+ CHAR serial_no[SS_DEV_NAME_SIZE]; // Serial Number
+ /**
+ * \~english Device file path
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Device file path
+}SS_UsbInfo;
+
+/**
+ * \~english CID(Card Identification Register Data)of SD/MMC card
+ */
+typedef struct _CID {
+ /**
+ * \~english Manufacturer ID
+ */
+ uint8_t manufacturerID; /* Manufacturer ID */
+ /**
+ * \~english Application ID
+ */
+ uint16_t applicationID; /* Application ID */
+ /**
+ * \~english Product Revision (PRV)
+ */
+ uint8_t revision; /* Product Revision (PRV) */
+ /**
+ * \~english Product Serial Number (PSN)
+ */
+ uint32_t serialNumber; /* Product Serial Number (PSN) */
+ /**
+ * \~english Product Name (PNM)
+ */
+ uint8_t productName[6]; /* Product Name (PNM) */
+ /**
+ * \~english Reserved area
+ */
+ uint8_t reserve[2]; /* Reserve */
+ /**
+ * \~english Manufacture date (MDT)
+ */
+ uint16_t manufactureDate; /* Manufacture date (MDT) */
+}SS_CID;
+
+// CSD(Card Specification Register Data)of SD/MMC card
+/**
+ * \~english CSD(Card Specification Register Data)of SD/MMC card
+ */
+typedef struct _CSD {
+ /**
+ * \~english CSD structure
+ */
+ uint8_t csd_structure; /* CSD structure */
+ /**
+ * \~english data read access-time-1
+ */
+ uint8_t taac; /* data read access-time-1 */
+ /**
+ * \~english data read access-time-2 in CLK cycles (NSAC*100)
+ */
+ uint8_t nsac; /* data read access-time-2 in CLK cycles (NSAC*100) */
+ /**
+ * \~english max. data transfer rate
+ */
+ uint8_t tran_speed; /* max. data transfer rate */
+ /**
+ * \~english card command classes
+ */
+ uint16_t ccc; /* card command classes */
+ /**
+ * \~english max. read data block length
+ */
+ uint8_t read_bl_len; /* max. read data block length */
+ /**
+ * \~english partial blocks for read allowed
+ */
+ uint8_t read_bl_partial; /* partial blocks for read allowed */
+ /**
+ * \~english write block misalignment
+ */
+ uint8_t write_blk_misalign; /* write block misalignment */
+ /**
+ * \~english read block misalignment
+ */
+ uint8_t read_blk_misalign; /* read block misalignment */
+ /**
+ * \~english DSR implemented
+ */
+ uint8_t dsr_imp; /* DSR implemented */
+ /**
+ * \~english Reserve area 1
+ */
+ uint8_t reserve1; /* Reserve 1 */
+ /**
+ * \~english device size
+ */
+ uint32_t c_size; /* device size */
+ /**
+ * \~english max. read current -VDD min
+ */
+ uint8_t vdd_r_curr_min; /* max. read current @VDD min */
+ /**
+ * \~english max. read current -VDD max
+ */
+ uint8_t vdd_r_curr_max; /* max. read current @VDD max */
+ /**
+ * \~english max. write current -VDD min
+ */
+ uint8_t vdd_w_curr_min; /* max. write current @VDD min */
+ /**
+ * \~english max. write current -VDD max
+ */
+ uint8_t vdd_w_curr_max; /* max. write current @VDD max */
+ /**
+ * \~english device size multiplier
+ */
+ uint8_t c_size_mult; /* device size multiplier */
+ /**
+ * \~english erase single block enable
+ */
+ uint8_t erase_blk_en; /* erase single block enable */
+ /**
+ * \~english erase sector size
+ */
+ uint8_t sector_size; /* erase sector size */
+ /**
+ * \~english write protect group size
+ */
+ uint8_t wp_grp_size; /* write protect group size */
+ /**
+ * \~english write protect group enable
+ */
+ uint8_t wp_grp_enable; /* write protect group enable */
+ /**
+ * \~english write speed factor
+ */
+ uint8_t r2w_factor; /* write speed factor */
+ /**
+ * \~english max. write data block length
+ */
+ uint8_t write_bl_len; /* max. write data block length */
+ /**
+ * \~english partial blocks for write allowed
+ */
+ uint8_t write_bl_partial; /* partial blocks for write allowed */
+ /**
+ * \~english File format group
+ */
+ uint8_t file_format_grp; /* File format group */
+ /**
+ * \~english copy flag
+ */
+ uint8_t copy; /* copy flag */
+ /**
+ * \~english permanent write protection
+ */
+ uint8_t perm_write_protect; /* permanent write protection */
+ /**
+ * \~english temporary write protection
+ */
+ uint8_t tmp_write_protect; /* temporary write protection */
+ /**
+ * \~english File format
+ */
+ uint8_t file_format; /* File format */
+ /**
+ * \~english Reserve area 2
+ */
+ uint8_t reserve2[3]; /* Reserve 2 */
+} SS_CSD;
+
+// Structure for SD device info.
+/**
+ * \~english Structure for SD device info.
+ */
+typedef struct _SdInfo {
+ /**
+ * \~english CID
+ */
+ SS_CID cid; // CID
+ /**
+ * \~english CSD
+ */
+ SS_CSD csd; // CSD
+ /**
+ * \~english Device file path
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Device file path
+ /**
+ * \~english Current Partion No
+ */
+ int32_t part_num; // Current Partion No
+ /**
+ * \~english Number of partions
+ */
+ int32_t nparts; // Number of partions
+}SS_SdInfo;
+
+// Structure for DISC info.
+/**
+ * \~english Structure for DISC info.
+ */
+typedef struct _DiscInfo {
+ /**
+ * \~english Device file path
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Device file path
+ /**
+ * \~english Disc Type(eCD, eDVD, eBD)
+ */
+ EDISC_TYPE disc_type; // Disc Type(eCD, eDVD, eBD)
+}SS_DiscInfo;
+
+// Structure that is available when SS_DEV_ANY_USB_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_ANY_USB_EV is published.
+ */
+typedef struct _UsbDeviceInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+}SS_UsbDeviceInfo;
+
+// Structure for device info.
+/**
+ * \~english Structure for device info.
+ */
+typedef union _DeviceInfo {
+ /**
+ * \~english usb device info
+ */
+ SS_UsbInfo usb_info; // usb device info
+ /**
+ * \~english sd info
+ */
+ SS_SdInfo sd_info; // sd info
+ /**
+ * \~english disc info
+ */
+ SS_DiscInfo disc_info; // disc info
+ /**
+ * \~english fusedav info
+ */
+ SS_FuseDAVInfo fusedav_info; // fusedav info
+}SS_DeviceInfo;
+
+// Structure for volume label infomation.
+/**
+ * \~english Structure for volume label infomation.
+ */
+typedef struct _VolumeInfo {
+ /**
+ * \~english volume label's availability
+ */
+ BOOL volume_label_availability; // volume label's availability
+ /**
+ * \~english volume label
+ */
+ CHAR volume_label[SS_DEV_NAME_SIZE]; // volume label
+}SS_VolumeInfo;
+
+// Structure that is available when SS_DEV_DETECT*_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT*_EV is published.
+ */
+typedef struct _MediaDetectInfo {
+ /**
+ * \~english Deive type(eUSB,eSD...)
+ */
+ EDEVICE_TYPE dev_type; // Deive type(eUSB,eSD...)
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english Device Infomation
+ */
+ SS_DeviceInfo dev_info; // Device Infomation
+ /**
+ * \~english Mount path
+ */
+ CHAR deviceMountpath[FILEPATH_SIZE]; // Mount path
+ /**
+ * \~english Do Not Used.(This member is for compatibility)
+ */
+ CHAR filepathName[FILEPATH_SIZE]; // Do Not Used.(This menber is for compatibility)
+ /**
+ * \~english FuseDav:TRUE, Not FuseDav:FALSE
+ */
+ BOOL bIsFuseDav;
+ /**
+ * \~english result of mount NORMAL:SS_DEV_OK, ERR:SS_DEV_ERR_MOUNT
+ */
+ SS_DEV_ERROR err_code; // result of mount NORMAL:SS_DEV_OK, ERR:SS_DEV_ERR_MOUNT
+ /**
+ * \~english volume infomation (USB mass storage only support)
+ */
+ SS_VolumeInfo volume_info; // volume infomation (USB mass storage only support)
+}SS_MediaDetectInfo, *PSS_MediaDetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB_NCM_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB_NCM_EV is published.
+ */
+typedef struct _NcmDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+ /**
+ * \~english Network Name
+ */
+ int8_t networkName[SS_DEV_DEVICE_NAME_SIZE]; // Network Name
+}SS_NcmDetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB__CWORD57__EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB__CWORD57__EV is published.
+ */
+typedef struct __CWORD57_DetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+}SS__CWORD57_DetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB_ACM_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB_ACM_EV is published.
+ */
+typedef struct _AcmDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+ /**
+ * \~english ACM device file
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // ACM device file
+}SS_AcmDetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB_DEV_MNG_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB_DEV_MNG_EV is published.
+ */
+typedef struct _DevMngDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+ /**
+ * \~english Device Manager device file
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Device Manager device file
+}SS_DevMngDetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB_DEV_VEHICLE_CTRL_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB_DEV_VEHICLE_CTRL_EV is published.
+ */
+typedef struct _VehicleCtrlDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+ /**
+ * \~english Vehicle control device file
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Vehicle control device file
+}SS_VehicleCtrlDetectInfo;
+
+// Structure for audio detect info.
+/**
+ * \~english Structure for audio detect info.
+ */
+typedef struct _AudioDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable;
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info;
+ /**
+ * \~english Audio control device file
+ */
+ int8_t audio_ctrl[FILEPATH_SIZE];
+ /**
+ * \~english Audio Playback device file
+ */
+ int8_t audio_play[FILEPATH_SIZE];
+ /**
+ * \~english Audio Capture device file
+ */
+ int8_t audio_capture[FILEPATH_SIZE];
+}SS_AudioDetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB_DSRC_APP_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB_DSRC_APP_EV is published.
+ */
+typedef struct _DsrcAppDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+ /**
+ * \~english Dsrc Application device file
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Dsrc Application device file
+}SS_DsrcAppDetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB_DSRC_CTRL_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB_DSRC_CTRL_EV is published.
+ */
+typedef struct _DsrcCtrlDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+ /**
+ * \~english Dsrc Control device file
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Dsrc Control device file
+}SS_DsrcCtrlDetectInfo;
+
+// Structure that is available when SS_DEV_DETECT_USB_IR_VICS_DATA_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_USB_IR_VICS_DATA_EV is published.
+ */
+typedef struct _IrVicsDataDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+ /**
+ * \~english USB Infomation
+ */
+ SS_UsbInfo usb_info; // USB Infomation
+ /**
+ * \~english Ir Vics Data device file
+ */
+ int8_t deviceFile[FILEPATH_SIZE]; // Ir Vics Data device file
+}SS_IrVicsDataDetectInfo;
+
+/**
+ * \~english USB overcurrent error info.
+ */
+typedef struct _UsbOverCurrentErrInfo {
+ /**
+ * \~english error port no
+ */
+ uint8_t portNo; // error port no
+} SS_UsbOverCurrentErrInfo;
+
+// Structure that is available when SS_DEV_INFO_USB_NOTIFY_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_INFO_USB_NOTIFY_EV is published.
+ */
+typedef struct _UsbNotifyInfo {
+ /**
+ * \~english notify code
+ */
+ SS_NOTIFY_CODE nofity_code; // notify code
+ /**
+ * \~english USB device information's availability
+ */
+ BOOL usb_info_availability; // USB device information's availability
+ /**
+ * \~english USB device information
+ */
+ SS_UsbInfo usb_info; // USB device information
+} SS_UsbNotifyInfo;
+
+// Structure that is available when SS_DEV_DETECT_ANY_USB__CWORD57__ROLE_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_DETECT_ANY_USB__CWORD57__ROLE_EV is published.
+ */
+typedef struct __CWORD57_RoleDetectInfo {
+ /**
+ * \~english Insert:TURE, Remove:FALSE
+ */
+ BOOL bIsDeviceAvailable; // Insert:TURE, Remove:FALSE
+} SS__CWORD57_RoleDetectInfo;
+
+// Structure that is available when SS_DEV_INFO_SD_FORMAT_COMP_EV is published.
+/**
+ * \~english Structure that is available when SS_DEV_INFO_SD_FORMAT_COMP_EV is published.
+ */
+typedef struct _SDFormatInfo {
+ /**
+ * \~english Result of SD Format.
+ */
+ SS_DEV_ERROR result; // Result of SD Format.
+} SS_SDFormatInfo;
+
+#endif /* _SS_DEVICEDETECTION_SERVER_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/ // end of device_detection_service
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_ifc.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_ifc.h
new file mode 100755
index 0000000..1ad7e67
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_ifc.h
@@ -0,0 +1,1118 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_devicedetection_service_ifc.h
+ * @brief This file supports the Device Detection service interface.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup device_detection_service
+ * @ingroup system_service
+ * @{
+ */
+/** @addtogroup device_manager
+ * @ingroup device_detection_service
+ * @{
+ */
+
+#ifndef SS_DEVICE_DETECTION_SERVICE_IFC_H_ // NOLINT (build/header_guard)
+#define SS_DEVICE_DETECTION_SERVICE_IFC_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include "system_service/ss_devicedetection_service_protocol.h"
+
+// CID(Card Identification Register Data)of SD/MMC card
+typedef struct T_cid {
+ UI_8 mid; // Manufacture ID
+ UI_8 oid[3]; // OEM/Application ID
+ UI_8 pnm[6]; // Product name
+ UI_8 prv; // Product revision
+ UI_32 psn; // Product serial number
+ UI_16 mdt; // Manufacture date code
+ UI_8 cr7cs; // CRC7 Check sum
+} Tcid;
+
+/**
+ * @class DeviceDetectionServiceIf
+ * \~english @brief Device detection
+ * \~english @par Brief Introduction
+ * Class to provide the device detection function
+ *
+ */
+class DeviceDetectionServiceIf {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DeviceDetectionServiceIf
+ /// \~english @par Summary
+ /// Constructor of DeviceDetectionServiceIf class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To generate a DeviceDetectionServiceIf class. \n
+ /// Member variables (m_hApp, m_hService, m_hSession) to be NULL initialization. \n
+ /// After the constructor, be sure to call Initialize method.
+ /// \~english @see ~DeviceDetectionServiceIf, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ DeviceDetectionServiceIf();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~DeviceDetectionServiceIf
+ /// \~english @par Summary
+ /// Destructor of DeviceDetectionServiceIf class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To delete a DeviceDetectionServiceIf class. \n
+ /// Session is the case still open, to close the session.\n
+ /// Service is the case still open, to close the service.
+ /// Member variables (m_hApp, m_hService, m_hSession) to be NULL initialization.
+ /// \~english @see DeviceDetectionServiceIf
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~DeviceDetectionServiceIf();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Initialize
+ /// \~english @par Summary
+ /// API to initialize the DeviceDetectionServiceIf class.
+ /// \~english @param [in] hApp
+ /// HANDLE - HANDLE for Application
+ /// \~english @retval TRUE Success
+ /// \~english @retval FALSE Failure
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// Conditions for return FALSE is as follows.
+ /// - NULL handle specified in the argument
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Application to use the services of device_detection_service is, after generating a \n
+ /// DeviceDetectionServiceIf class, which is a method to be executed first. \n
+ /// Member variable(m_hApp) of DeviceDetectionServiceIf class initialized with hApp \n
+ /// that has been specified by the argument.
+ /// \~english @see DeviceDetectionServiceIf
+ ////////////////////////////////////////////////////////////////////////////////////
+ BOOL Initialize(HANDLE hApp);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NotifyOnDeviceDetectionAvailability
+ /// \~english @par Summary
+ /// API to set the Callback function for Availability notification of Device Detection Service.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Pointer to function callback for Device Detection Service Availability Notification
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Can not get the App/Thread name from HANDLE in the class member variables (m_hApp).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - The acquisition of the buffer that stores the Callback information specified in the argument failed.
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+ /// [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hApp). [eFrameworkunifiedStatusInvldParam]
+ /// - Message queue HANDLE in HANDLE (m_hApp) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - It is not appropriate message queue name of HANDLE (m_hApp) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hApp) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_DeviceDetectionService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Pub-Sub
+ /// \~english @par Detail
+ /// Which is a method to register a Callback function for the initialization of the \n
+ /// device_detection_service receives the timing at which the start (open) is possible \n
+ /// of completed service.\n
+ /// (Native Service of API: Use the FrameworkunifiedSubscribeNotificationsWithCallback, to register \n
+ /// a Callback function for Availability notification of Device Detection Service.)
+ /// \~english @see DetachDeviceDetectionAvailabilityCb
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotifyOnDeviceDetectionAvailability(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NotifyOnOpenSessionAck
+ /// \~english @par Summary
+ /// API to set the Callback function for OpenSessionRequest response from the Device Detection Service.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Callback function pointer for receiving the response of OpenSessionRequest
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// To register the Callback function for receiving a response of completion of OpenSessionRequest to
+ /// Dispatcher. \n
+ /// (Native Service of API: Use the FrameworkunifiedAttachCallbackToDispatcher, to register a Callback function for receiving
+ /// \n
+ /// a response of completion of OpenSessionRequest to Dispatcher.) \n
+ /// On successful session establishment, the client can register for device information.
+ /// \~english @see DetachOpenSessionAckCb
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotifyOnOpenSessionAck(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NotifyOnCloseSessionAck
+ /// \~english @par Summary
+ /// API to set the Callback function for CloseSessionRequest response from the Device Detection Service.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Callback function pointer for receiving the response of CloseSessionRequest
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// To register the Callback function for receiving a response of completion of CloseSessionRequest to
+ /// Dispatcher. \n
+ /// (Native Service of API: Use the FrameworkunifiedAttachCallbackToDispatcher, to register a Callback function for receiving
+ /// \n
+ /// a response of completion of CloseSessionRequest to Dispatcher.) \n
+ /// \~english @see DetachCloseSessionAckCb
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotifyOnCloseSessionAck(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup OpenSessionRequest
+ /// \~english @par Summary
+ /// API to perform the generation of the service/session of Device Detection Service
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Service of Device Detection Service is not Availability state. [eFrameworkunifiedStatusFail]
+ /// - Service of Device Detection Service can not be opened (can not start). [eFrameworkunifiedStatusFail]
+ /// - SS_DeviceDetectionService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Pub-Sub
+ /// \~english @par Detail
+ /// And generate the service of device_detection_service, which is a method for generating a session.\n
+ /// (To send the command of PROTOCOL_OPEN_SESSION_REQ to device_detection_service.)\n
+ /// If you already service has been created, once to close the service.
+ /// \~english @see CloseSessionRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OpenSessionRequest();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DecodeOpenSessionResponse
+ /// \~english @par Summary
+ /// API to perform the generation of the service/session of Device Detection Service
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Incorrect PROTOCOL_OPEN_SESSION_ACK message length of Device Detection Service. [eFrameworkunifiedStatusFail]
+ /// - PROTOCOL_OPEN_SESSION_ACK message of Device Detection Service can not be acquired. [eFrameworkunifiedStatusFail]
+ /// - Can not session generation of message transmission to Device Detection Service. [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Get the session initiation response message(PROTOCOL_OPEN_SESSION_ACK) of Device Detection \n
+ /// Service, and get the session ID from the message. \n
+ /// Acquired session ID, (after opening the message transmission queue) created after a session \n
+ /// of message transmission, hold as the session information in the session HANDLE (m_hSession).\n
+ /// of the class member variable.
+ /// \~english @see OpenSessionRequest, CloseSessionRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DecodeOpenSessionResponse();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RegisterForDeviceDetectionEvent
+ /// \~english @par Summary
+ /// API to register a Callback function for receiving the timing of when an event occurs in the device.
+ /// \~english @param [in] f_eDevDetectEvent
+ /// SS_DeviceDetectionServerEvents - Event type (USB/SD/...etc event)
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Pointer to a callback function that corresponds to the event
+ /// \~english @param [in] pfilepath
+ /// PCSTR - Pointer to the file path name(Non-support:Be NULL)
+ /// \~english @par
+ /// Event type (enum values of SS_DeviceDetectionServerEvents)
+ /// - SS_DEV_DETECT_ANY_USB_EV : Notify the insertion and mount path of USB MassStorage class(USB
+ /// mass storage is subject)
+ /// - SS_DEV_DETECT_ANY_SD_EV : Notify the insertion and mount path of SD card
+ /// - SS_DEV_INFO_ANY_USB_EV : Notify the USB device insertion and removal detection(All USB
+ /// devices are subject)
+ /// - SS_DEV_DETECT_ANY_DISC_EV : Notify the insertion of DISC(BD, DVD, CD) and mount path of block
+ /// devices
+ /// - SS_DEV_DETECT_ANY_USB_NCM_EV : Notify the insertion and network IF name of the USB NCM class
+ /// device(for MirrorLink)
+ /// - SS_DEV_DETECT_ANY_USB__CWORD57__EV : Notify the insertion and removal and the device file name of the
+ /// _CWORD57_ device(Rather than the _CWORD57_ only class, the device is subject)
+ /// - SS_DEV_DETECT_ANY_USB_ACM_EV : Notify the insertion and removal and device file name of the USB
+ /// ACM class device(for DCM device)
+ /// - SS_DEV_DETECT_ANY_USB_DEV_MNG_EV : Notify the insertion and removal and device file name of the USB
+ /// DeviceManagementModel class(for DCM device)
+ /// - SS_DEV_DETECT_ANY_USB_VEHICLE_CTRL_EV : Notify the insertion and removal and device file name of the USB
+ /// Vehicle Control class(for DCM device)
+ /// - SS_DEV_DETECT_ANY_USB_DSRC_APP_EV : Notify the insertion and removal and device file name of the USB
+ /// DSRC Application class(for DSRC device)
+ /// - SS_DEV_DETECT_ANY_USB_DSRC_CTRL_EV : Notify the insertion and removal and device file name of the USB
+ /// DSRC Control class(for DSRC device)
+ /// - SS_DEV_DETECT_ANY_USB_IR_VICS_DATA_EV : Notify the insertion and removal and device file name of the USB
+ /// IR-VICS Data class(for DSRC device)
+ /// - SS_DEV_ERR_USB_OVER_CURRENT_EV : Notify the overcurrent detection error of USB
+ /// - SS_DEV_DETECT_ANY_USB_MTP_EV : Notify the insertion and mount path of USB MTP class device
+ /// - SS_DEV_INFO_ANY_USB_NOTIFY_EV : Notify the connection of non-compliant USB device
+ /// - SS_DEV_DETECT_ANY_USB__CWORD57__ROLE_EV : Notify the insertion and removal of the _CWORD57_ device after
+ /// RoleSW(Rather than the _CWORD57_ only class, the device is subject)
+ /// - SS_DEV_INFO_SD_FORMAT_COMP_EV : Notify the SD format results
+ /// - SS_DEV_DETECT_ANY_USB_DCM_NCM_EV : Notify the insertion and removal and network IF name of the USB
+ /// NCM class device(for DCM)
+ /// - SS_DEV_INFO_ANY_USB_DVDP_EV : Notify the insertion and removal of the DVD-P device
+ /// \~english @par
+ /// For SS_DEV_INFO_ANY_USB_NOTIFY_EV, it is also notified in the event the following conditions.
+ /// - When the enumeration failed.
+ /// - When it detects the current excess of the USB device connected to the bus power HUB.
+ /// - When it is detected that the number of the USB device has exceeded the number of support.
+ /// - When it is detected that the HUB is connected beyond the HUB number that supports.
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE in the class member variables (m_hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_DeviceDetectionService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_DeviceDetectionService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_DeviceDetectionService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_DeviceDetectionService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Pub-Sub x Pub-Sub
+ /// \~english @par Detail
+ /// Which is a method to register a callback function for receiving the timing of the \n
+ /// occurrence of an event in the device. \n
+ /// \~english @see UnRegisterForDeviceDetectionEvent
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RegisterForDeviceDetectionEvent(
+ SS_DeviceDetectionServerEvents f_eDevDetectEvent, CbFuncPtr f_pCallBackFn,
+ PCSTR pfilepath = NULL);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup UnRegisterForDeviceDetectionEvent
+ /// \~english @par Summary
+ /// API to release a Callback function that corresponds to the event notification from the device
+ /// \~english @param [in] f_eDevDetectEvent
+ /// SS_DeviceDetectionServerEvents - Event notification type (USB/SD/...etc event)
+ /// \~english @par
+ /// Releasable event notification type (enum values of SS_DeviceDetectionServerEvents)
+ /// - SS_DEV_DETECT_ANY_USB_EV : Notify the insertion and mount path of USB MassStorage class(USB
+ /// mass storage is subject)
+ /// - SS_DEV_DETECT_ANY_SD_EV : Notify the insertion and mount path of SD card
+ /// - SS_DEV_INFO_ANY_USB_EV : Notify the USB device insertion and removal detection(All USB
+ /// devices are subject)
+ /// - SS_DEV_DETECT_ANY_DISC_EV : Notify the insertion of DISC(BD, DVD, CD) and mount path of block
+ /// devices
+ /// - SS_DEV_DETECT_ANY_USB_NCM_EV : Notify the insertion and network IF name of the USB NCM class
+ /// device(for MirrorLink)
+ /// - SS_DEV_DETECT_ANY_USB__CWORD57__EV : Notify the insertion and removal and the device file name of the
+ /// _CWORD57_ device(Rather than the _CWORD57_ only class, the device is subject)
+ /// - SS_DEV_DETECT_ANY_USB_ACM_EV : Notify the insertion and removal and device file name of the USB
+ /// ACM class device(for DCM device)
+ /// - SS_DEV_DETECT_ANY_USB_DEV_MNG_EV : Notify the insertion and removal and device file name of the USB
+ /// DeviceManagementModel class(for DCM device)
+ /// - SS_DEV_DETECT_ANY_USB_VEHICLE_CTRL_EV : Notify the insertion and removal and device file name of the USB
+ /// Vehicle Control class(for DCM device)
+ /// - SS_DEV_DETECT_ANY_USB_DSRC_APP_EV : Notify the insertion and removal and device file name of the USB
+ /// DSRC Application class(for DSRC device)
+ /// - SS_DEV_DETECT_ANY_USB_DSRC_CTRL_EV : Notify the insertion and removal and device file name of the USB
+ /// DSRC Control class(for DSRC device)
+ /// - SS_DEV_DETECT_ANY_USB_IR_VICS_DATA_EV : Notify the insertion and removal and device file name of the USB
+ /// IR-VICS Data class(for DSRC device)
+ /// - SS_DEV_ERR_USB_OVER_CURRENT_EV : Notify the overcurrent detection error of USB
+ /// - SS_DEV_DETECT_ANY_USB_MTP_EV : Notify the insertion and mount path of USB MTP class device
+ /// - SS_DEV_INFO_ANY_USB_NOTIFY_EV : Notify the connection of non-compliant USB device
+ /// - SS_DEV_DETECT_ANY_USB__CWORD57__ROLE_EV : Notify the insertion and removal of the _CWORD57_ device after
+ /// RoleSW(Rather than the _CWORD57_ only class, the device is subject)
+ /// - SS_DEV_INFO_SD_FORMAT_COMP_EV : Notify the SD format results
+ /// - SS_DEV_DETECT_FILEPATHNAME_EV : Notify the specified file access in pfilepath
+ /// - SS_DEV_DETECT_ANY_USB_DCM_NCM_EV : Notify the insertion and removal and network IF name of the USB
+ /// NCM class device(for DCM)
+ /// - SS_DEV_INFO_ANY_USB_DVDP_EV : Notify the insertion and removal of the DVD-P device
+ /// \~english @par
+ /// For SS_DEV_INFO_ANY_USB_NOTIFY_EV, it is also notified in the event the following conditions.
+ /// - When the enumeration failed.
+ /// - When it detects the current excess of the USB device connected to the bus power HUB.
+ /// - When it is detected that the number of the USB device has exceeded the number of support.
+ /// - When it is detected that the HUB is connected beyond the HUB number that supports.
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE in the class member variables (m_hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldParam]
+ /// - The service can not be determined from the HANDLE in the class member variables (m_hApp). [eFrameworkunifiedStatusFail]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_DeviceDetectionService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_DeviceDetectionService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_DeviceDetectionService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_DeviceDetectionService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Pub-Sub x Pub-Sub
+ /// \~english @par Detail
+ /// Which is a method to release a callback function for receiving the timing of the \n
+ /// occurrence of an event in the device. \n
+ /// \~english @see RegisterForDeviceDetectionEvent
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UnRegisterForDeviceDetectionEvent(
+ SS_DeviceDetectionServerEvents f_eDevDetectEvent);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CloseSessionRequest
+ /// \~english @par Summary
+ /// API to perform the destruction of services/session of Device Detection Service
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - SS_DeviceDetectionService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Method
+ /// \~english @par Detail
+ /// And destruct the service of device_detection_service, which is a method for destructing a session.\n
+ /// (To send the command of PROTOCOL_CLOSE_SESSION_REQ to device_detection_service.)\n
+ /// \~english @see OpenSessionRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CloseSessionRequest();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DetachDeviceDetectionAvailabilityCb
+ /// \~english @par Summary
+ /// API to release the Callback function for Availability notification of Device Detection Service.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// - The call-back function for Availability notification has been registered.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Can not get the App/Thread name from HANDLE in the class member variables (m_hApp).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+ /// [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hApp). [eFrameworkunifiedStatusInvldParam]
+ /// - Message queue HANDLE in HANDLE (m_hApp) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - It is not appropriate message queue name of HANDLE (m_hApp) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hApp) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Callback function for Availability notification is not registered. [eFrameworkunifiedStatusFail]
+ /// - Session message queue is full to SS_DeviceDetectionService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Is a method for releasing a Callback function registered to receive the timing \n
+ /// initialization is completed device_detection_service
+ /// (Native Service of API: Use the FrameworkunifiedUnsubscribeNotificationWithCallback, to release \n
+ /// a Callback function for Availability notification of Device Detection Service.)
+ /// \~english @see NotifyOnDeviceDetectionAvailability
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DetachDeviceDetectionAvailabilityCb();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DetachOpenSessionAckCb
+ /// \~english @par Summary
+ /// API to release the Callback function for OpenSessionRequest response from the Device Detection Service.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Not Callback function information of the release target is present. [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// To cancel the Callback function for receiving a response of completion of OpenSessionRequest from
+ /// Dispatcher. \n
+ /// (Native Service of API: Use the FrameworkunifiedDetachCallbackFromDispatcher, to cancel a Callback function for receiving
+ /// \n
+ /// a response of completion of OpenSessionRequest from Dispatcher.) \n
+ /// \~english @see NotifyOnOpenSessionAck
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DetachOpenSessionAckCb();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DetachCloseSessionAckCb
+ /// \~english @par Summary
+ /// API to release the Callback function for CloseSessionRequest response from the Device Detection Service.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Not Callback function information of the release target is present. [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// To cancel the Callback function for receiving a response of completion of CloseSessionRequest from
+ /// Dispatcher. \n
+ /// (Native Service of API: Use the FrameworkunifiedDetachCallbackFromDispatcher, to cancel a Callback function for receiving
+ /// \n
+ /// a response of completion of CloseSessionRequest from Dispatcher.) \n
+ /// \~english @see NotifyOnCloseSessionAck
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DetachCloseSessionAckCb();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup MountSD
+ /// \~english @par Summary
+ /// API to mount the specified SD partition
+ /// \~english @param [in] part_num
+ /// uint8_t - Partition number of SD card(From 0 to 3)
+ /// \~english @param [out] already_mounted
+ /// BOOL* - Mount existence result
+ /// \~english @par
+ /// - TRUE : Already mount
+ /// - FALSE : Mount request is accepted. Wait for mount notification.
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusAccessError Access error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - SD card partition number (part_num) exceeds the 3 specified by the argument. [eFrameworkunifiedStatusInvldParam]
+ /// - Can not have access to the device file for the SD. [eFrameworkunifiedStatusAccessError]
+ /// - HANDLE (m_hSession) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hSession).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) in the message queue name is NULL.
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE in HANDLE (m_hSession) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldHandle]
+ /// - It is not appropriate message queue name of HANDLE (m_hSession) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hSession) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_DeviceDetectionService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method only
+ /// \~english @par Detail
+ /// The API is a method used to mount the specified partition (area).\n
+ /// The target device is an SD card.
+ /// Service(Thread) to call this method is not limited. Therefore, \n
+ /// to be utilized as a mismatch does not occur between the service \n
+ /// to use the SD card. \n
+ /// SD card in the specified partition, already returned eFrameworkunifiedStatusOK \n
+ /// if mount existence results (already_mounted) in the TRUE that is mounted.\n
+ /// If it is not already mounted mount existence results (already_mounted) \n
+ /// and to FALSE, then carry out the SD of the mount request to Device \n
+ /// Detection Service.
+ /// \~english @see UmountSD, RegisterForDeviceDetectionEvent
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus MountSD(uint8_t part_num, BOOL *already_mounted);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup UmountSD
+ /// \~english @par Summary
+ /// API to mount the specified SD partition
+ /// \~english @param [in] part_num
+ /// uint8_t - Partition number of SD card(From 0 to 3)
+ /// \~english @param [out] already_umounted
+ /// BOOL* - Mount existence result
+ /// \~english @par
+ /// - TRUE : Already umount
+ /// - FALSE : Umount request is accepted. Wait for umount notification.
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusAccessError Access error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - SD card partition number (part_num) exceeds the 3 specified by the argument. [eFrameworkunifiedStatusInvldParam]
+ /// - Can not have access to the device file for the SD. [eFrameworkunifiedStatusAccessError]
+ /// - HANDLE (m_hSession) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hSession).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) in the message queue name is NULL.
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE in HANDLE (m_hSession) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldHandle]
+ /// - It is not appropriate message queue name of HANDLE (m_hSession) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hSession) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_DeviceDetectionService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method only
+ /// \~english @par Detail
+ /// The API is a method used to mount the specified partition (area).\n
+ /// The target device is an SD card.
+ /// Service(Thread) to call this method is not limited. Therefore, \n
+ /// to be utilized as a mismatch does not occur between the service \n
+ /// to use the SD card. \n
+ /// SD card in the specified partition, already returned eFrameworkunifiedStatusOK \n
+ /// if unmount existence results (already_unmounted) in the TRUE that is unmounted.
+ /// If it is not already unmounted unmount existence results (already_unmounted) \n
+ /// and to FALSE, then carry out the SD of the unmount request to Device \n
+ /// Detection Service. \n
+ /// That all of the services specifically, to call this API after the close \n
+ /// completion of the directory and file of the SD card. \n
+ /// Also, do not call this API in a state in which a directory on the SD card \n
+ /// in the current directory. (At SD drive processing threads in SS_DeviceDetectionService, \n
+ /// umount fails, error of SS_DEV_ERR_BUSY is returned as an asynchronous notification \n
+ /// events.)
+ /// \~english @see MountSD, RegisterForDeviceDetectionEvent
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UmountSD(uint8_t part_num, BOOL *already_umounted);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup UsbVBusReset
+ /// \~english @par Summary
+ /// API to reset the VBUS of the specified USB port
+ /// \~english @param [in] port
+ /// uint8_t - USB port number
+ /// \~english @param [in] inteval
+ /// uint8_t - interval (interval * 100 [msec])
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// - Checking USB port number should be done before calling this API.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Environment variable (TARGET_BOARD) is not defined. [eFrameworkunifiedStatusFail]
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Name of the target board in the environment variable (TARGET_BOARD) is not correct. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE (m_hSession) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hSession).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) in the message queue name is NULL.
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE in HANDLE (m_hSession) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldHandle]
+ /// - It is not appropriate message queue name of HANDLE (m_hSession) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hSession) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_DeviceDetectionService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget only
+ /// \~english @par Detail
+ /// The API is a method for resetting the VBUS of the specified USB port.\n
+ /// Environment variable (TARGET_BOARD) is defined in the configure options \n
+ /// specified at the time of build. \n
+ /// (Example. TARGET_BOARD:_CWORD71__CWORD91__e2_na_t__CWORD84_2__CWORD71_) \n
+ /// Before reset USB port for DCM, the device files(dcm_acm, dcm_vc, dcm_wdm) \n
+ /// related to DCM-related must be closed. \n
+ /// *) Device file may not be created correctly when the process of Disconnect/Connect \n
+ /// without closing to work.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UsbVBusReset(int8_t port);
+ EFrameworkunifiedStatus UsbVBusReset(int8_t port, uint8_t interval);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RoleSwStateNotify
+ /// \~english @par Summary
+ /// API to notify RoleSW state
+ /// \~english @param [in] state
+ /// SS_DEV_ROLE_SW_STATE - RoleSW state
+ /// \~english @par
+ /// enum variable SS_DEV_ROLE_SW_STATE
+ /// - SS_DEV_ROLE_SW_START : Start
+ /// - SS_DEV_ROLE_SW_BEGIN_END : Beginning of End
+ /// - SS_DEV_ROLE_SW_END : End
+ /// - SS_DEV_ROLE_SW_RESTART : Restart
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusInvldQName Invalid Message Queue Name
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusBadConnection It can not be a socket connection
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hSession) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - It failed to open the message queue for messages received from SS_DeviceDetectionService. [eFrameworkunifiedStatusFail]
+ /// - It failed to buffer acquisition for messages received from SS_DeviceDetectionService(malloc failure).
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to create a sequence ID of the message to be sent to the SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hSession).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) in the message queue name is NULL.
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE name in the HANDLE (m_hSession) in the class member variables is NULL.
+ /// [eFrameworkunifiedStatusInvldQName]
+ /// - Message queue HANDLE name in the HANDLE (hService) in the class member variables exceeds 20byte.
+ /// [eFrameworkunifiedStatusInvldQName]
+ /// - Message queue HANDLE in HANDLE (m_hSession) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldHandle]
+ /// - It is not appropriate message queue name of HANDLE (m_hSession) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hSession) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_DeviceDetectionService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid send and receive file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the send and receive of the session message
+ /// for SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the send and receive buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the send and receive of a session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for send and receive of the session message for
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrOther]
+ /// - It failed to connect to the socket for the response message to be received from SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to wait control of the response message received from SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - Interruption by the system call (signal) has occurred in wait in the response message received from
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusFail]
+ /// - After the failure at the time of the response message received from SS_DeviceDetectionService, it failed
+ /// to re-connection of the Socket. [eFrameworkunifiedStatusBadConnection]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync x Method
+ /// \~english @par Detail
+ /// By executing this API, Device Detection Service recognizes the state \n
+ /// has been switched from the USB Host due to RoleSW to USB Function. \n
+ /// The initial state of Detection is a state(SS_DEV_ROLE_SW_END:End state) \n
+ /// that has not been RoleSW. \n
+ /// (It is a state that accepts a SS_DEV_ROLE_SW_START:Start.)
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RoleSwStateNotify(SS_DEV_ROLE_SW_STATE state);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FormatSD
+ /// \~english @par Summary
+ /// API to Format SD
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusAccessError Access error occurred
+ /// \~english @retval eFrameworkunifiedStatusBadConnection It can not be a socket connection
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_DeviceDetectionService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) \n
+ /// has been done, and Availability of Device Detection Service is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Can not have access to the device file for the SD. [eFrameworkunifiedStatusAccessError]
+ /// - HANDLE (m_hSession) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hSession).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) in the message queue name is NULL.
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE in HANDLE (m_hSession) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldHandle]
+ /// - It is not appropriate message queue name of HANDLE (m_hSession) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hSession) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_DeviceDetectionService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_DeviceDetectionService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_DeviceDetectionService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Detail
+ /// The SD card inserted into the _CWORD84_ side in this API is formatted in compliance with the SD standard.\n
+ /// A result of format implementation is notified by SS_DEV_INFO_SD_FORMAT_COMP_EV events.\n
+ /// String pickled notification content and the result is as follows.\n
+ /// - SS_DEV_OK : Format success \n
+ /// - SS_DEV_ERR_BUSY : For unmount unexecuted, format failure \n
+ /// - SS_DEV_ERR : Format fails for any other factors
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Method
+ /// \~english @par
+ /// This API is able to call after the SD card umount completion and the device file close of \n
+ /// SD card is complete.\n
+ /// If the SD card umount of has not been completed, SS_DEV_ERR_BUSY is notified.\n
+ /// If the device file of the SD card has not been close, although it is the format becomes \n
+ /// the operation completed, there can be no assurance of the operation.
+ /// \~english @see MountSD, UmountSD, RegisterForDeviceDetectionEvent
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FormatSD(void);
+
+ private:
+ HANDLE OpenService();
+ UI_8 Crc7Checksum(UI_8 *data, UI_8 sz);
+ HANDLE m_hApp;
+ HANDLE m_hService;
+ HANDLE m_hSession;
+ BOOL CheckDetectEvent(SS_DeviceDetectionServerEvents f_eDevDetectEvent);
+};
+
+#endif /* SS_DEVICE_DETECTION_SERVICE_IFC_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/ // end of device_manager
+/** @}*/ // end of device_detection_service
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_local.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_local.h
new file mode 100755
index 0000000..c85e6b3
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_local.h
@@ -0,0 +1,37 @@
+/*
+ * @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.
+ */
+/**
+ * @file
+ * @brief This is local header file of Device Detection service.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SystemServicesIf
+/// \brief This file supports the Device Detection service.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _SS_DEVICEDETECTION_SERVER_LOCAL_H_ // NOLINT (build/header_guard)
+#define _SS_DEVICEDETECTION_SERVER_LOCAL_H_
+
+
+// Structure for SS_DEV_REMOUNT_PARTITION
+typedef struct _RemountPatitionInfo {
+ unsigned long mountflags; // NOLINT (runtime/int)
+ CHAR deviceMountpath[FILEPATH_SIZE]; // Mount path
+} SS_RemountPatitionInfo;
+
+#endif /* _SS_DEVICEDETECTION_SERVER_LOCAL_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_notifications.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_notifications.h
new file mode 100755
index 0000000..7de03b9
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_notifications.h
@@ -0,0 +1,58 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_devicedetection_service_notifications.h
+ * @brief This file supports the Device Detection service.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup device_detection_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SS_DEVICE_DETECTION_SERVICE_NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+#define SS_DEVICE_DETECTION_SERVICE_NOTIFICATIONS_H_
+
+#include "system_service/ss_services.h"
+
+/**
+ * \~english SS_DeviceDetection service availability notification.
+ */
+#define NTFY_SS_Device_Detection_Service_Availability SS_DEV_DETECT_SRV"/Availability"
+
+/**
+ * \~english SS_DeviceDetection service USB error notification.
+ */
+#define NTFY_SS_Device_Detection_USB_Error SS_DEV_DETECT_SRV"/USBError"
+
+/**
+ * \~english SS_DeviceDetection service MMCSD error notification.
+ */
+#define NTFY_SS_Device_Detection_MMCSD_Error SS_DEV_DETECT_SRV"/MMCSDError"
+
+#endif /* SS_DEVICE_DETECTION_SERVICE_NOTIFICATIONS_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/ // end of device_detection_service
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol.h
new file mode 100755
index 0000000..cb54ee5
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol.h
@@ -0,0 +1,143 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_devicedetection_service_protocol.h
+ * @brief This file supports the Device Detection service.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup device_detection_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef _SS_DEVICEDETECTION_SERVICE_PROTOCOL_H_ // NOLINT (build/header_guard)
+#define _SS_DEVICEDETECTION_SERVICE_PROTOCOL_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include "system_service/ss_devicedetection_service.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \~english Event type (USB/SD/...etc event)
+ */
+typedef enum _DeviceDetectionServerEvents {
+ /**
+ * \~english Notify whenever a USB MassStorage device is connected/removed
+ */
+ SS_DEV_DETECT_ANY_USB_EV = 121,
+ /**
+ * \~english Notify whenever a SD device is connected/removed
+ */
+ SS_DEV_DETECT_ANY_SD_EV = 122,
+ /**
+ * \~english Notify all events for all devices
+ */
+ SS_DEV_DETECT_FILEPATHNAME_EV = 123,
+ /**
+ * \~english Notify whenever a Navi Emmc device is connected/removed
+ */
+ SS_DEV_DETECT_ANY_EMMC_NAV_EV = 124,
+ /**
+ * \~english Notify whenever a USB device is connected/removed
+ */
+ SS_DEV_INFO_ANY_USB_EV = 125,
+ /**
+ * \~english Notify whenever a DISC(block) device is connected/removed
+ */
+ SS_DEV_DETECT_ANY_DISC_EV = 126,
+ /**
+ * \~english Notify whenever a USB NCM device is connected/removed
+ */
+ SS_DEV_DETECT_ANY_USB_NCM_EV = 127,
+ /**
+ * \~english Notify whenever a USB _CWORD57_ device is connected/removed
+ */
+ SS_DEV_DETECT_ANY_USB__CWORD57__EV = 128,
+ /**
+ * \~english Notify whenever a USB ACM device is connected/removed (for DCM)
+ */
+ SS_DEV_DETECT_ANY_USB_ACM_EV = 129,
+ /**
+ * \~english Notify whenever a USB Device Management device is connected/removed (for DCM)
+ */
+ SS_DEV_DETECT_ANY_USB_DEV_MNG_EV = 130,
+ /**
+ * \~english Notify whenever a USB Vics Control device is connected/removed (for DCM)
+ */
+ SS_DEV_DETECT_ANY_USB_VEHICLE_CTRL_EV = 131,
+ /**
+ * \~english Notify whenever a USB DSRC Application device is connected/removed (for DSRC)
+ */
+ SS_DEV_DETECT_ANY_USB_DSRC_APP_EV = 132,
+ /**
+ * \~english Notify whenever a USB DSRC Control device is connected/removed (for DSRC)
+ */
+ SS_DEV_DETECT_ANY_USB_DSRC_CTRL_EV = 133,
+ /**
+ * \~english Notify whenever a USB IR Vics Data device is connected/removed (for DSRC)
+ */
+ SS_DEV_DETECT_ANY_USB_IR_VICS_DATA_EV = 134,
+ /**
+ * \~english Notify whenever USB Over Current is Detected
+ */
+ SS_DEV_ERR_USB_OVER_CURRENT_EV = 135,
+ /**
+ * \~english Notify whenever USB MTP Device is Detected
+ */
+ SS_DEV_DETECT_ANY_USB_MTP_EV = 136,
+ /**
+ * \~english Notify whenever USB Authentication Error Notify
+ */
+ SS_DEV_INFO_ANY_USB_NOTIFY_EV = 137,
+ /**
+ * \~english Notify whenever a USB _CWORD57_ device is connected/removed after RoleSW.
+ */
+ SS_DEV_DETECT_ANY_USB__CWORD57__ROLE_EV = 138,
+ /**
+ * \~english Notify whenever SD is formated.
+ */
+ SS_DEV_INFO_SD_FORMAT_COMP_EV = 139,
+ /**
+ * \~english Notify whenever a USB NCM device is connected/removed (for DCM)
+ */
+ SS_DEV_DETECT_ANY_USB_DCM_NCM_EV = 140,
+ /**
+ * \~english Notify whenever a DVD-P device is connected/removed
+ */
+ SS_DEV_INFO_ANY_USB_DVDP_EV = 141,
+} SS_DeviceDetectionServerEvents;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SS_DEVICEDETECTION_SERVICE_PROTOCOL_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/ // end of device_detection_service
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol_local.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol_local.h
new file mode 100755
index 0000000..4b7be37
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_protocol_local.h
@@ -0,0 +1,69 @@
+/*
+ * @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_SystemServicesIf
+/// \brief This file supports the Device Detection service.
+///
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ */
+#ifndef _SS_DEVICEDETECTION_SERVICE_PROTOCOL_LOCAL_H_ // NOLINT (build/header_guard)
+#define _SS_DEVICEDETECTION_SERVICE_PROTOCOL_LOCAL_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum _DeviceDetectionServerProtocol {
+ SS_DEV_DETECT_GET_APP_INFO = 0x10, /// client to service: not really needed
+ SS_DEV_DETECT_RETURN_APP_INFO = 0x11, /// service to client: not really needed
+ SS_UDEV_DEV_DETECT_INFO = 0x12, /// UDEV to service: device detect info sent to service
+ SS_UDEV_DEV_DETECT_FILEPATHNAME_INFO = 0x13, /// File pathname info cmd
+ SS_REGISTER_FILEPATHNAME = 0x14, /// Register file pathname cmd
+ SS_BSP_DEV_DETECT_ERR_INFO = 0x15, /// BSP / MCD device insert/removal/mount error report.
+ SS_REGISTER_DETECT_EVENT = 0x16, /// Register DeviceDetection Event
+ SS_UDEV_DEV_DEVICE_INFO = 0x17, /// UDEV to service: device info sent to service
+ SS_UDEV_DEV_DETECT_NCM_INFO = 0x18, /// UDEV to service: detect ncm sent to service
+ SS_UDEV_DEV_DETECT__CWORD57__INFO = 0x19, /// UDEV to service: detect _CWORD57_ sent to service
+ SS_UDEV_DEV_DETECT_ACM_INFO = 0x1a, /// UDEV to service: detect ACM sent to service
+ SS_UDEV_DEV_DETECT_MNG_INFO = 0x1b, /// UDEV to service: detect DeviceManagementModel sent to service
+ SS_UDEV_DEV_DETECT_VEHICLE_CTRL_INFO = 0x1c, /// UDEV to service: detect Vehicle Control sent to service
+ SS_UDEV_DEV_DETECT_DSRCCTL_INFO = 0x1d, /// UDEV to service: detect DSRC Application sent to service
+ SS_UDEV_DEV_DETECT_DSRCAPP_INFO = 0x1e, /// UDEV to service: detect DSRC Control sent to service
+ SS_UDEV_DEV_DETECT_IRVICS_DATA_INFO = 0x1f, /// UDEV to service: detect IR-VICS Data sent to service
+ SS_DETECT_USB_OVC_ERR = 0x20, /// USB Monitor OVC to service: detect OverCurrent Error
+ SS_UDEV_DEV_DETECT_MTP_INFO = 0x21, /// UDEV to service: detect MTP Device
+ SS_DEV_MOUNT_SD = 0x22, /// client to service: mount SD partion
+ SS_DEV_UMOUNT_SD = 0x23, /// client to service: umount SD partion
+ SS_DEV_REMOUNT_PARTITION = 0x24, /// client to service: Remount partion
+ SS_UNREGISTER_DETECT_EVENT = 0x25, /// UnRegister DeviceDetection event
+ SS_USB_VBUS_RESET = 0x26, /// client to service: USB Vbus Reset
+ SS_UDEV_USB_AUTHENTICATION_ERR_INFO = 0x27, /// USB Monitor to service: USB Authentication Error Notify
+ SS_UDEV_DEV_DETECT_USB_FUNC_INFO = 0x28, /// USB Monitor to service: detect USB Func to service
+ SS_DEV_ROLE_SW_STATE_NOTIFY = 0x29, /// client to service: notify RoleSw state
+ SS_DEV_FORMAT_SD = 0x2a, /// client to service: Format SD
+ SS_INFO_FORMAT_SD = 0x2b, /// SDDRV to service: Infomation Format SD result
+}SS_DeviceDetectionServerProtocol;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SS_DEVICEDETECTION_SERVICE_PROTOCOL_LOCAL_H_ */ // NOLINT (build/header_guard)
+
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types.h
new file mode 100755
index 0000000..c5ab1c3
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types.h
@@ -0,0 +1,186 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_devicedetection_service_types.h
+ * @brief This file supports the Device Detection service.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup device_detection_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SS_DEVDETECT_TYPES_H_ // NOLINT (build/header_guard)
+#define SS_DEVDETECT_TYPES_H_
+
+/**
+ * \~english Deive type(eUSB,eSD...)
+ */
+typedef enum _DeviceType {
+ /**
+ * \~english USB
+ */
+ eUSB,
+ /**
+ * \~english SD
+ */
+ eSD,
+ /**
+ * \~english EMMC
+ */
+ eMMC,
+ /**
+ * \~english DISC
+ */
+ eDISC,
+ /**
+ * \~english MTP
+ */
+ eMTP
+} EDEVICE_TYPE;
+
+/**
+ * \~english Action result
+ */
+typedef enum _SsDevError {
+ /**
+ * \~english success
+ */
+ SS_DEV_OK,
+ /**
+ * \~english error
+ */
+ SS_DEV_ERR,
+ /**
+ * \~english mount error
+ */
+ SS_DEV_ERR_MOUNT,
+ /**
+ * \~english device busy
+ */
+ SS_DEV_ERR_BUSY,
+} SS_DEV_ERROR;
+
+/**
+ * \~english USB port
+ */
+typedef enum _USBPort {
+ /**
+ * \~english USB0(IF-BOX)
+ */
+ SS_DEV_USB_PORT0, // IF-BOX
+ /**
+ * \~english USB1(DCM)
+ */
+ SS_DEV_USB_PORT1, // DCM
+ /**
+ * \~english USB2(DSRC/ETC)
+ */
+ SS_DEV_USB_PORT2, // DSRC/ETC
+ /**
+ * \~english USB3(External deck)
+ */
+ SS_DEV_USB_PORT3, // External DECK
+ /**
+ * \~english USB4(Drive recorder)
+ */
+ SS_DEV_USB_PORT4, // Supplies drive recorder
+ /**
+ * \~english USB number max.
+ */
+ SS_DEV_USB_MAX // MAX
+} SS_DEV_USBPORT;
+
+/**
+ * \~english notify code
+ */
+typedef enum SsNotifyCode {
+ /**
+ * \~english Unsupport USB device
+ */
+ SS_DEV_UNSUPPORT_USB, // Un support USB device
+ /**
+ * \~english The connected device has no response.
+ */
+ SS_DEV_NON_RESPONSE_USB, // Enemuration Error
+ /**
+ * \~english It detects a USB device of current excess that has been connected to the bus power HUB.
+ */
+ SS_DEV_HIGH_POWER_USB, // It detects a USB device of current excess that
+ // has been connected to the bus power HUB.
+ /**
+ * \~english Over support USB(3 or more units)
+ */
+ SS_DEV_OVER_SUPPORT_USB, // Over support USB(3 or more units)
+ /**
+ * \~english Over number of USB HUB(2 or more units)
+ */
+ SS_DEV_OVER_NUM_USB_HUB, // Over number of USB HUB(2 or more units)
+} SS_NOTIFY_CODE;
+
+/**
+ * \~english RoleSw state
+ */
+typedef enum _SsDevRoleSwState {
+ /**
+ * \~english start
+ */
+ SS_DEV_ROLE_SW_START,
+ /**
+ * \~english begin end
+ */
+ SS_DEV_ROLE_SW_BEGIN_END,
+ /**
+ * \~english end
+ */
+ SS_DEV_ROLE_SW_END,
+ /**
+ * \~english restart
+ */
+ SS_DEV_ROLE_SW_RESTART,
+} SS_DEV_ROLE_SW_STATE;
+
+/**
+ * \~english Disc Type(eCD, eDVD, eBD)
+ */
+typedef enum _DiscType {
+ /**
+ * \~english CD
+ */
+ eCD,
+ /**
+ * \~english DVD
+ */
+ eDVD,
+ /**
+ * \~english BD
+ */
+ eBD,
+} EDISC_TYPE;
+
+#endif /* SS_DEVDETECT_TYPES_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/ // end of device_detection_service
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types_local.h b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types_local.h
new file mode 100755
index 0000000..dafd4d4
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_devicedetection_service_types_local.h
@@ -0,0 +1,44 @@
+/*
+ * @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_SystemServicesIf
+/// \brief This file supports the Device Detection service.
+///
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ */
+#ifndef SS_DEVDETECT_TYPES_LOCAL_H_ // NOLINT (build/header_guard)
+#define SS_DEVDETECT_TYPES_LOCAL_H_
+
+/**
+ * \~english Service state.
+ */
+typedef enum _ServiceStatus {
+ eInit, //!< \~english Initialize.
+ ePre, //!< \~english In-vehicle.
+ eBackground, //!< \~english Background boot.
+ eStart, //!< \~english Normal boot.
+ eStop, //!< \~english Stop.
+} ESERVICESTATUS;
+
+typedef enum _USBMount {
+ SS_DEV_RO, // Read Only
+ SS_DEV_RW // Read/Write
+} SS_DEV_USB_REMOUNT;
+
+#endif /* SS_DEVDETECT_TYPES_LOCAL_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_error_event_common.h b/systemservice/interface_unified/library/include/system_service/ss_error_event_common.h
new file mode 100755
index 0000000..ce7677f
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_error_event_common.h
@@ -0,0 +1,111 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_error_event_common.h
+ * @brief This file supports SM logging.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef __SS_ERROR_EVENT_COMMON_H__ // NOLINT (build/header_guard)
+#define __SS_ERROR_EVENT_COMMON_H__
+
+#include <native_service/frameworkunified_types.h> // added for test build
+
+
+// Do not change enumeration order.
+// HMI hard codes error event square
+// colors based on expected enum order.
+enum EErrorEventType {
+ eErrorEventTypeProcessCrash = 0,
+ eErrorEventTypeHeartBeatFailure,
+ eErrorEventTypeSystemLowMemory,
+ eErrorEventTypeReserved1, // Formerly SS_SM_EVENT_ERROR_HIGH_CPU_LOAD, now HMI enum place holder.
+ eErrorEventTypeUserInvokedUserForceReset,
+ eErrorEventTypeReserved2,
+ eErrorEventTypeReserved3,
+ eErrorEventTypeUserInvokedCollectAllLogs,
+ eErrorEventTypeBootMicroReset,
+ eErrorEventTypeProcessExit,
+ eErrorEventTypeUserInvokedCollectScreenShot,
+ eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs,
+ eErrorEventTypeEelExport,
+ eErrorEventTypeInterfaceunifiedEmmcLogs,
+ eErrorEventTypeDiagEvent,
+ eErrorEventTypeCanEvent,
+ eErrorEventTypeDtcEvent,
+ eErrorEventTypeModConnFailed,
+ eErrorEventTypeStartRespFailed,
+ eErrorEventTypeUserInvokedCollectDevLogs,
+ eErrorEventTypeModuleInvokedResetRequest,
+ eErrorEventTypeModuleInvokedCollectDebugLogs,
+ eErrorEventTypeUserInvokedClearLogs,
+ eErrorEventTypeUserInvokedCollectNaviLog,
+ eErrorEventTypeGroupRelaunch,
+ eErrorEventTypeMaxValue
+};
+
+/* Value range of EArtifactId must be defined within 32, */
+/* because of it's definition is used by 4byte bitmask. */
+enum EArtifactId {
+ eArtifactIdInterfaceunifiedDebugLog = 0,
+ eArtifactIdTransmitLog,
+ eArtifactIdPerformanceLog,
+ eArtifactIdBootMicroLog,
+ eArtifactIdSystemDataCsv,
+ eArtifactIdShowMemTxt, // << ID 5
+ eArtifactIdProcessCore,
+ eArtifactIdDebugDumpLog,
+ eArtifactIdKernelLog,
+ eArtifactIdDRInitialLog,
+ eArtifactIdDRLocationLog, // << ID 10
+ eArtifactIdCpuHighLoadMonteCarloLogs,
+ eArtifactIdMetaCoreLogs,
+ eArtifactIdCmsLogs,
+ eArtifactIDInternalDTC,
+ eArtifactIdComDebugLog, // << ID 15
+ eArtifactIdKernelBootLog,
+ eArtifactIdPstoreLog,
+ eArtifactIdClearAllLog,
+ eArtifactIdNaviLog,
+ eArtifactIdScreenShot, // These three Log entries have to remain
+ eArtifactIdDebugFolder2Content, // at the end of the list
+ eArtifactIdDebugFolderContent,
+ eArtifactIdMaxValue // << 23
+};
+
+struct ARTIFACT_RESPONSE {
+ EArtifactId ArtifactId;
+ CHAR FilePathAndName[MAX_PATH_LENGTH];
+};
+
+
+#endif /* __SS_ERROR_EVENT_COMMON_H___ */ // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_error_event_common_local.h b/systemservice/interface_unified/library/include/system_service/ss_error_event_common_local.h
new file mode 100755
index 0000000..47da0d3
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_error_event_common_local.h
@@ -0,0 +1,63 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_error_event_common_local.h
+ * @brief This file supports SM logging.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef __SS_ERROR_EVENT_COMMON_LOCAL_H__ // NOLINT (build/header_guard)
+#define __SS_ERROR_EVENT_COMMON_LOCAL_H__
+
+#define SS_ERROR_EVENT_START_REQ_TO_SEC (5)
+#define SS_ERROR_EVENT_DEBUG_DUMP_RSPN_TO_SEC (1)
+#define SS_ERROR_EVENT_BOOT_MICRO_LOG_RESPONSE_TO_SEC (2)
+#define SS_ERROR_EVENT_CORE_FILE_POLL_TO_MS (100)
+
+// Do not change enumeration order.
+// HMI hard codes error event square
+// colors based on expected enum order.
+enum EErrorEventPrio { /* Higher number = higher priority. */
+ eErrorEventPrioDiagLogRequest = 8,
+ eErrorEventPrioUserInvokedCollectAllLogs = 7,
+ eErrorEventPrioUserInvokedCollectScreenShot = 6,
+ eErrorEventPrioUserInvokedCollectInterfaceunifiedLogs = 5,
+ eErrorEventPrioModuleInvokedCollectDebugLogs = 4,
+ eErrorEventPrioUserInvokedUserForceReset = 3,
+ eErrorEventPrioEelStorageFilePresent = 2,
+ eErrorEventPrioEmmcLogsFilePresent = 1,
+ eErrorEventPrioDefault = 0
+};
+
+
+#endif /* __SS_ERROR_EVENT_COMMON_LOCAL_H__ */ // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
+
diff --git a/systemservice/interface_unified/library/include/system_service/ss_error_message.h b/systemservice/interface_unified/library/include/system_service/ss_error_message.h
new file mode 100755
index 0000000..e810d7b
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_error_message.h
@@ -0,0 +1,40 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_error_message.h
+ * @brief \~english This file contains declaration of system error message
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef _SS_ERROR_MESSAGE_H_ // NOLINT (build/header_guard)
+#define _SS_ERROR_MESSAGE_H_
+
+#define SS_ERROR_MSG_USB_DISCON "UsbDisconnected"
+#define SS_ERROR_MSG__CWORD84__ABNORMAL_SHUTDOWN "_CWORD84_AbnormalShutdown"
+
+#endif // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_heartbeat_if.h b/systemservice/interface_unified/library/include/system_service/ss_heartbeat_if.h
new file mode 100755
index 0000000..e5a94e5
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_heartbeat_if.h
@@ -0,0 +1,165 @@
+/**
+ * @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.
+ */
+
+/**
+ * @file ss_heartbeat_if.h
+ * @brief \~english This file supports the System Manager Heartbeat Service.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_HEARTBEAT_IF_H_ // NOLINT (build/header_guard)
+#define SS_HEARTBEAT_IF_H_
+
+#include <string>
+
+typedef struct {
+ BOOL fAvailable;
+ HANDLE hService;
+ std::string szServiceName;
+}THeartBeatSession;
+
+
+class CHeartBeatServiceIf {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Constructor of CHeartBeatServiceIf class.
+ /// \~english @param [in] avail
+ /// BOOL avail - default value of HBSession available
+ /// \~english @param [in] service
+ /// HANDLE service - set default value of Service handle
+ /// \~english @param [in] name
+ /// PSTR name - set application name used by client
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// Constructor of CHeartBeatServiceIf class. \n
+ /// variables (g_tHeartBeatSession) to be initialization.
+ /// \~english @see ~CHeartBeatServiceIf
+ ////////////////////////////////////////////////////////////////////////////////////
+ CHeartBeatServiceIf(BOOL avail, HANDLE service, PCSTR name);
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Destructor of CHeartBeatServiceIf class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To delete a CHeartBeatServiceIf class. \n
+ /// pHeartBeatServiceIf is not NULL, to delete it.\n
+ /// \~english @see CHeartBeatServiceIf
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CHeartBeatServiceIf();
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Subscribe hApp to message queue of the HeartBeat client application.
+ /// \~english @param [in] f_hApp
+ /// HANDLE - Handle to message queue of the HeartBeat client application.
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - Pointer (pNtfyHandler) is NULL to the structure of the Notification Handler specified in the argument.
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount) 0. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - Notification Handler number specified in the argument (uiHandlerCount) has exceeded the maximum number of
+ /// Notification. [eFrameworkunifiedStatusFail]
+ /// - The acquisition of the buffer for storing a plurality of information of Notification Handler specified by
+ /// the argument has failed. [eFrameworkunifiedStatusInvldParam]
+ /// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+ /// [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more
+ /// than 20byte) [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to the NPP Service.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// the NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for the NPP Service.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// Subscribe hApp to message queue of the HeartBeat client application. \n
+ /// if service hApp is NULL and hApp is not be Subscribed,return eFrameworkunifiedStatusNullPointer.\n
+ /// if service hApp is Subscribe to Heartbeat Serivceand hApp is not NULL,then subscribe hApp to message
+ /// queue of the HeartBeat client application.
+ /// \~english @see FrameworkunifiedGetAppName FrameworkunifiedSubscribeNotificationsWithCallback
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnHeartBeatRequest(HANDLE hApp);
+
+ private:
+ THeartBeatSession g_tHeartBeatSession;
+
+
+ friend EFrameworkunifiedStatus DBG_CloseHeatBeat(HANDLE hApp);
+};
+
+#endif /* SS_HEARTBEAT_IF_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_heartbeat_notifications.h b/systemservice/interface_unified/library/include/system_service/ss_heartbeat_notifications.h
new file mode 100755
index 0000000..8b25fe1
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_heartbeat_notifications.h
@@ -0,0 +1,46 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_heartbeat_notifications.h
+ * @brief This file supports the System Manager Heartbeat Service.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_manager
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SS_HEARTBEAT_NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+#define SS_HEARTBEAT_NOTIFICATIONS_H_
+
+#include "system_service/ss_services.h"
+
+/// Indicates if HeartBeat is available or unavailable
+#define NTFY_HeartBeatAvailability SERVICE_HEARTBEAT"/Availability"
+
+#endif /* SS_HEARTBEAT_NOTIFICATIONS_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_heartbeat_service_protocol.h b/systemservice/interface_unified/library/include/system_service/ss_heartbeat_service_protocol.h
new file mode 100755
index 0000000..6d31d04
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_heartbeat_service_protocol.h
@@ -0,0 +1,72 @@
+/*
+ * @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.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// Handle HeartBeat Module Start and Stop notifications.
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ss_heartbeat_service_protocol.h
+ * @brief API Header for HeartBeat messages used by senders and receivers.
+ *
+ * Declares the external Protocol messages to the HeartBeat.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_manager
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SS_HEARTBEAT_SERVICE_PROTOCOL_H_ // NOLINT (build/header_guard)
+#define SS_HEARTBEAT_SERVICE_PROTOCOL_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+
+/// \brief HeatBeat Protocol Command
+/// heartbeat service protocol --> define all protocol messages in and out of heart beat thread
+/// that are pertinent to the functionality offered by heart beat thread.
+typedef enum T_SMHBProtocolMessages {
+ // Diagnostic Protocol
+ SS_HEARTBEAT_PRINT_CONNECTIONS = 0x32, ///< client to hb thread
+ SS_HEARTBEAT_PRINT_STACK = 0x33, ///< client to hb thread
+ SS_HEARTBEAT_PERIODIC_STATUS_REQ = 0xD0, ///< sysmgr to hb thread
+ SS_HEARTBEAT_PERIODIC_RESP = 0xD1, ///< hb thread to sysmgr
+ SS_HEARTBEAT_START = 0xD2, ///< sysmgr to hb thread
+ SS_HEARTBEAT_STOP = 0xD3, ///< sysmgr to hb thread
+ SS_HEARTBEAT_DELETE_MODULE_ENTRY = 0xD5, ///< sysmgr to hb thread
+ SS_HEARTBEAT_MSG_CATEGORY_REPORT = 0xD6, ///< report message
+ SS_HEARTBEAT_ERROR_DETECTED = 0xD8, ///< hb thread to sysmgr
+ SS_HEARTBEAT_APPEND_MODULE_ENTRY = 0xD9, ///< sysmgr to hb thread
+ SS_HEARTBEAT_AVAIL_CHECK_REQ = 0xDA, ///< sysmgr to hb thread
+ SS_HEARTBEAT_AVAIL_CHECK_RESP = 0xDB, ///< sysmgr to hb thread
+ SS_HEARTBEAT_RESPONSE = 0xE0, ///< client to hb thread
+ SS_HEARTBEAT_REQUEST = 0xE1 ///< hb thread to client
+}EHBProtocolMessages;
+
+#endif /* SS_HEARTBEAT_SERVICE_PROTOCOL_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_last_to_order.h b/systemservice/interface_unified/library/include/system_service/ss_last_to_order.h
new file mode 100755
index 0000000..5a3b8b0
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_last_to_order.h
@@ -0,0 +1,58 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_last_to_order.h
+ * @brief \~english This file contains declaration of enum SS_CONT_CATEGORY_t and api convert lastinfo to order
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef _SS_CONTID_TO_ORDER_H_ // NOLINT (build/header_guard)
+#define _SS_CONTID_TO_ORDER_H_
+
+#include <stdint.h>
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include <string>
+
+typedef enum {
+ SS_CCAT_F_VIDEO,
+ SS_CCAT_F_SUB_VIDEO,
+ SS_CCAT_F_AUDIO,
+ SS_CCAT_R_VIDEO,
+ SS_CCAT_R_AUDIO,
+ SS_CCAT_MAX,
+}SS_CONT_CATEGORY_t;
+
+typedef std::string SS_CONTENT_NAME_t;
+
+typedef std::map<SS_CONT_CATEGORY_t, SS_CONTENT_NAME_t> SS_LAST_INFO_t;
+
+EFrameworkunifiedStatus SS_ConvLastInfoToOrder(SS_LAST_INFO_t &curLastMode, std::string &order, const char* p_cfgPath = NULL); //NOLINT (runtime/references)
+
+
+#endif // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_logger_service.h b/systemservice/interface_unified/library/include/system_service/ss_logger_service.h
new file mode 100755
index 0000000..67ecb08
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_logger_service.h
@@ -0,0 +1,255 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_logger_service.h
+ * @brief \~english This file supports the the Logger Service.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_LOGGER_SERVICE_H_ // NOLINT (build/header_guard)
+#define SS_LOGGER_SERVICE_H_
+
+
+#include <native_service/frameworkunified_types.h>
+
+#define MAX_STATISTICAL_BUFFER 240
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Shared Memory names
+///////////////////////////////////////////////////////////////////////////////
+#define SHMEM_DRLOCATIONLOG "/DRLocationLog"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Shared Memory names
+///////////////////////////////////////////////////////////////////////////////
+#define SHMEM_DRINITIALLOG "/DRInitialLog"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief VIN numbers
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _TVINnumber {
+ static const UI_8 VIN_LEN = 18;
+ CHAR VINstr[VIN_LEN];
+} STVIN_NUMBER;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief CAN Diagnostic status data
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _TInterfaceunifiedCANMileageInfo {
+ UI_8 DidA_ExtTest_Pres;
+ UI_8 EngRun_Stat;
+ UI_8 Odo_MSB_H;
+ UI_8 Odo_MSB_L;
+ UI_8 Odo_LSB_H;
+ UI_8 Odo_LSB_L;
+ UI_8 PN14_SupBat_Volt;
+} STLOGGER_CANDIAGSTAT;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief CAN current date and time
+///////////////////////////////////////////////////////////////////////////////
+/**
+* @struct __CWORD62_DateAndTime
+* @brief \~english CAN current date and time
+*/
+typedef struct __CWORD62_DateAndTime {
+ UI_8 DateTime_Stat; /*!< \~english Date time status*/
+ UI_8 DateTimeDay; /*!< \~english Date*/
+ UI_8 DateTimeHour; /*!< \~english Hour*/
+ UI_8 DateTimeMinute; /*!< \~english Minute*/
+ UI_8 DateTimeMonth; /*!< \~english Month*/
+ UI_8 DateTimeSecond; /*!< \~english Second*/
+ UI_8 DateTimeYear; /*!< \~english Year*/
+ UI_8 TimeFormat; /*!< \~english Format*/
+}STCanCurrentDateTime;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Logger Device Type
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _ELoggerDeviceTypes {
+ eDevUSB1,
+ eDevUSB2,
+ eDevSD,
+ eTotalDevicesTypes,
+ eInvalid_DevType
+}EDEV_TYPE;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Logger State
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _ELoggerState {
+ eDeactivate,
+ eActivate,
+ eInvalid_LoggerState
+}ELOGGER_STAT;
+
+typedef enum _ELoggerErrorCodes {
+ eSelectedDeviceNotFound = 0x0001,
+ eWriteToDeviceFailed = 0x0002,
+ eScreenCaptureFailed = 0x0003,
+ eScreenCaptureSaveTimeExpired = 0x0004,
+ eScreenCaptureStoreTimeExpired = 0x0005,
+ eNoLogToStore = 0x0006,
+}ELOGGERERR_CODES;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Screen Capture Event data
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _TInterfaceunifiedScreenCaptureEvt {
+ static const UI_16 STR_BUFF_LEN = 64;
+ BOOL fSucessful;
+ UI_32 uiSceenShotId;
+ CHAR strNameAndLocation[STR_BUFF_LEN];
+ UI_32 uiFaultReasonCode;
+}STScreenCaptureEvt;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief USB source number to store event logs.
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _EEventLoggerUSBDeviceNumber {
+ USB0 = 0,
+ USB1 = 1,
+ SD = 2
+}EEvtLogUSBDevNumber;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief USB source number to store emergency error logs.
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _EDevNumber {
+ eEEL_USB1 = 1,
+ eEEL_USB2 = 2,
+ eEEL_SD = 3
+}EDevNumber;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Counter group ID.
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _ECounterGroupID {
+ STARTUP_SHUTDOWN_COUNTER_GROUP = 0x01,
+ APP_USAGE_COUNTER_GROUP,
+ F_BLK_STABILITY_COUNTER_GROUP,
+ MAX_COUNTER_GROUP
+}EStatCounterGroupID;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Statistical counter.
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _SStatisticalCounter {
+ UI_16 u16StartupCounterLength; ///< No of Counter from startup phase
+ UI_16 u16NormalCounterLength; ///< No of Counter from Normal phase
+ UI_16 u16ShutDownCounterLength; ///< No of Counter from Shut down phase
+ UI_8 StatisticalCountBuffer[MAX_STATISTICAL_BUFFER]; ///< Counter values for startup,normal and shutsown phases
+}SStatisticalCounter;
+
+typedef enum _EEventLoggerSuccessCode {
+ COPY_EVT_USB_SUCCESS = 0x20,
+ CLEAR_EVENT_LOG_SUCCESS = 0x21,
+ STATISTICAL_COUNTER_READ_SUCCESS = 0x22
+}EEvtLoggerSuccessCode;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Event Logger error code
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _EEventLoggerErrorCode {
+ USB_DEVICE_NOT_AVAILABLE = 0x10,
+ USB_DEVICE_WRITE_ERROR = 0x11,
+ CLEAR_EVENT_LOG_FAILED = 0x12,
+ STATISTICAL_COUNTER_READ_FAILED = 0x13,
+ NO_ERROR_INFO = 0x14
+}EEvtLoggerErrorCode;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Emergency Log error code
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _EEmergencyLogErrorCode {
+ eDEVICE_NOT_AVAILABLE = 0x10,
+ eDEVICE_WRITE_ERROR = 0x11,
+ eNO_ERROR_INFO = 0x12
+}EELL_ErrorCode;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Event logger common information
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _SEventLoggerCommonInfo {
+ UI_8 BodyCAN_Stat:4;
+ UI_8 HeadUnitCAN_Stat:4;
+ UI_8 HMIInteraction:4;
+ UI_8 IGN_Status:4;
+ UI_8 FOT_Temp:2;
+ UI_8 SystemVoltage:6;
+}STEventLoggerCommonInfo;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Event logger resets counter information
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _SEventLoggerResetInfo {
+ UI_8 _CWORD56__ResetInfo;
+ UI_8 _CWORD102__ResetInfo;
+}STEventLoggerResetInfo;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Event logger _CWORD56_ events information
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _SEventLoggerEventInfo {
+ UI_8 NumberOfEvents;
+ UI_8 EventGroup;
+ UI_8 EventIdentifier;
+ UI_8 EventData[4];
+}STEventLoggerEventInfo;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Event logger CAN events information
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _SEventCANLoggerEventInfo {
+ BOOL success;
+ BOOL valid;
+ UI_32 triggerNumber;
+ STCanCurrentDateTime dateAndTime;
+}STEventCANLoggerEventInfo;
+
+#endif /* SS_LOGGER_SERVICE_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+
diff --git a/systemservice/interface_unified/library/include/system_service/ss_logger_service_ifc.h b/systemservice/interface_unified/library/include/system_service/ss_logger_service_ifc.h
new file mode 100755
index 0000000..2646c73
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_logger_service_ifc.h
@@ -0,0 +1,1865 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_logger_service_ifc.h
+ * @brief \~english This file supports the the Logger Service.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup logger_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SS_LOGGER_SERVICE_IFC_H_ // NOLINT (build/header_guard)
+#define SS_LOGGER_SERVICE_IFC_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include "system_service/ss_logger_service.h"
+#include "system_service/ss_logger_service_protocol.h"
+
+/**
+ * @class LoggerServiceIf
+ * \~english @brief logger_service
+ * \~english @par Brief Introduction
+ * Class to provide LoggerServiceIf
+ *
+ */
+class LoggerServiceIf {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerServiceIf
+ /// \~english @par Summary
+ /// Constructor of LoggerServiceIf class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To generate a LoggerServiceIf class, and initialize member variables(m_hApp, m_hService, m_hSession) to be
+ /// NULL. \n
+ /// After the constructor, be sure to call the Initialize.
+ /// \~english @see ~LoggerServiceIf, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ LoggerServiceIf();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~LoggerServiceIf
+ /// \~english @par Summary
+ /// Destructor of LoggerServiceIf class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To generate a LoggerServiceIf class. \n
+ /// If the service and the session is started (open) state, causing the end (closed).
+ /// \~english @see LoggerServiceIf
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~LoggerServiceIf();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Initialize
+ /// \~english @par Summary
+ /// API to initialize the LoggerServiceIf class.
+ /// \~english @param [in] hApp
+ /// HANDLE - HANDLE for Application
+ /// \~english @retval TRUE Success
+ /// \~english @retval FALSE Failure
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLE(hApp) specified in the argument is NULL. [FALSE]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Application to use the services of SS_LoggerService is, after generating a LoggerServiceIf class, which is a
+ /// method to be executed first. \n
+ /// Member variable(m_hApp) of LoggerServiceIf class initialized with hApp that has been specified by the
+ /// argument.
+ /// \~english @see LoggerServiceIf
+ ////////////////////////////////////////////////////////////////////////////////////
+ BOOL Initialize(HANDLE hApp);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NotifyOnLoggerServiceAvailability
+ /// \~english @par Summary
+ /// API to set the Callback function for Availability notification of SS_LoggerService.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Pointer to function callback for SS_LoggerService Availability Notification
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Can not get the App/Thread name from HANDLE in the class member variables (m_hApp).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - The acquisition of the buffer that stores the Callback information specified in the argument failed.
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+ /// [eFrameworkunifiedStatusFail]
+ /// - Message queue HANDLE is NULL in the HANDLE of the class member variables (m_hApp). [eFrameworkunifiedStatusInvldParam]
+ /// - Message queue HANDLE in HANDLE (m_hApp) of the class member variables are not appropriate(which is
+ /// invalid). [eFrameworkunifiedStatusInvldParam]
+ /// - It is not appropriate message queue name of HANDLE (m_hApp) in the class member variables(The name is
+ /// NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of HANDLE (m_hApp) in the class member variables.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_LoggerService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_LoggerService. [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_LoggerService. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Pub-Sub x Pub-Sub
+ /// \~english @par Detail
+ /// Which is a method to register a Callback function for the initialization of the SS_LoggerService receives
+ /// the timing at which the start (open) is possible of completed service.\n
+ /// (Using API:FrameworkunifiedSubscribeNotificationsWithCallback of Native Service, to register a Callback function for
+ /// Availability notification of SS_LoggerService.)
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotifyOnLoggerServiceAvailability(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NotifyOnOpenSessionAck
+ /// \~english @par Summary
+ /// API to set the Callback function for OpenSessionRequest response from SS_LoggerService.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Callback function pointer for receiving the response of OpenSessionRequest
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// To register the Callback function for receiving a response of completion of OpenSessionRequest to
+ /// Dispatcher. \n
+ /// (Using API:FrameworkunifiedAttachCallbackToDispatcher of Native Service, to register a Callback function for receiving a
+ /// response of completion of OpenSessionRequest to Dispatcher.)
+ /// \~english @see NotifyOnCloseSessionAck
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotifyOnOpenSessionAck(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NotifyOnCloseSessionAck
+ /// \~english @par Summary
+ /// API to set the Callback function for CloseSessionRequest response from SS_LoggerService.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Callback function pointer for receiving the response of OpenSessionRequest
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// To register the Callback function for receiving a response of completion of CloseSessionRequest to
+ /// Dispatcher. \n
+ /// (Using API:FrameworkunifiedAttachCallbackToDispatcher of Native Service, to register a Callback function for receiving a
+ /// response of completion of CloseSessionRequest to Dispatcher.) \n
+ /// \~english @see NotifyOnOpenSessionAck
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotifyOnCloseSessionAck(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup OpenSessionRequest
+ /// \~english @par Summary
+ /// API to generate service/session of SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Availability of SS_LoggerService is TRUE.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// - Use the NotifyOnOpenSessionAck(), that you register a callback function for receiving a completion
+ /// response of OpenSessionRequest to Dispatcher
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - SS_LoggerService is not Availability state. [eFrameworkunifiedStatusFail]
+ /// - SS_LoggerService can not be opened (can not start). [eFrameworkunifiedStatusFail]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Fire and Forget
+ /// \~english @par Detail
+ /// Which is a method for generating service/session of SS_LoggerService.\n
+ /// (To send the command of PROTOCOL_OPEN_SESSION_REQ to SS_LoggerService.)\n
+ /// If you already service has been created, once to close the service, and to re-open.
+ /// \~english @see CloseSessionRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OpenSessionRequest();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DecodeOpenSessionResponse
+ /// \~english @par Summary
+ /// API to hold the session ID in SS_LoggerServiceIf class
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Incorrect PROTOCOL_OPEN_SESSION_ACK message length of SS_LoggerService. [eFrameworkunifiedStatusFail]
+ /// - PROTOCOL_OPEN_SESSION_ACK message of SS_LoggerService can not be acquired. [eFrameworkunifiedStatusFail]
+ /// - Can not session generation of message transmission to SS_LoggerService. [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Get the session initiation response message(PROTOCOL_OPEN_SESSION_ACK) of SS_LoggerService, and get the
+ /// session ID from the message. \n
+ /// Acquired session ID, (after opening the message transmission queue) created after a session of message
+ /// transmission, hold as the session information in the session HANDLE(m_hSession) of the class member
+ /// variable.
+ /// \~english @see OpenSessionRequest, CloseSessionRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DecodeOpenSessionResponse();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CloseSessionRequest
+ /// \~english @par Summary
+ /// API to discard service/session of SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// - Use the NotifyOnCloseSessionAck(), that you register a callback function for receiving a completion
+ /// response of CloseSessionRequest to Dispatcher
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Pub-Sub x Pub-Sub
+ /// \~english @par Detail
+ /// which is a method for discarding service/session of SS_LoggerService.\n
+ /// (To send the command of PROTOCOL_CLOSE_SESSION_REQ to SS_LoggerService.)
+ /// \~english @see OpenSessionRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CloseSessionRequest();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RegisterForLoggerEvent
+ /// \~english @par Summary
+ /// API to register a Callback function for SS_LoggerService.
+ /// \~english @param [in] f_eLoggerEvent
+ /// SS_LoggerServerEvents - Event type
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Pointer to a callback function that corresponds to the event
+ /// \~english @par
+ /// SS_LoggerServerEvents enum value
+ /// \~english @code
+ /// typedef enum _LoggerServerEvents
+ /// {
+ /// SS_LOGGER_SCREENCAPTURE_EVT = 0xA0, /* Event notification of the Screen Capture */
+ /// SS_LOGGER_ERRORINFO_EVT, /* Event notification of error log information */
+ /// SS_LOGGER_LOGINFO_EVT, /* Event notification of log information */
+ /// SS_LOGGER_LOGSTARTED_EVT /* Event notification at the time of log start */
+ /// }SS_LoggerServerEvents;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Which is a method to register a callback function for receiving the timing of the occurrence of an event in
+ /// the SS_LoggerService to the Dispatcher. \n
+ /// (To send the command of PROTOCOL_REGISTER_EVENTS to SS_LoggerService.)
+ /// \~english @see UnRegisterForLoggerEvent
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RegisterForLoggerEvent(SS_LoggerServerEvents f_eLoggerEvent, CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup UnRegisterForLoggerEvent
+ /// \~english @par Summary
+ /// API to cancel a Callback function for SS_LoggerService.
+ /// \~english @param [in] f_eLoggerEvent
+ /// SS_LoggerServerEvents - Event type
+ /// \~english @par
+ /// SS_LoggerServerEvents enum value
+ /// \~english @code
+ /// typedef enum _LoggerServerEvents
+ /// {
+ /// SS_LOGGER_SCREENCAPTURE_EVT = 0xA0, /* Event notification of the Screen Capture */
+ /// SS_LOGGER_ERRORINFO_EVT, /* Event notification of error log information */
+ /// SS_LOGGER_LOGINFO_EVT, /* Event notification of log information */
+ /// SS_LOGGER_LOGSTARTED_EVT /* Event notification at the time of log start */
+ /// }SS_LoggerServerEvents;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Which is a method to cancel a callback function for receiving the timing of the occurrence of an event in
+ /// the SS_LoggerService. \n
+ /// \~english @see RegisterForLoggerEvent
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UnRegisterForLoggerEvent(SS_LoggerServerEvents f_eLoggerEvent);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SendDiagStat
+ /// \~english @par Summary
+ /// API to send CAN Diagnostic status data(it has mileage information) to SS_LoggerService.
+ /// \~english @param [in] pCanDiagStat_t
+ /// STLOGGER_CANDIAGSTAT - Pointer to structure of CAN Diagnostic state data
+ /// \~english @par
+ /// STLOGGER_CANDIAGSTAT Structure
+ /// \~english @code
+ /// typedef struct _TInterfaceunifiedCANMileageInfo
+ /// {
+ /// UI_8 DidA_ExtTest_Pres; /* For extended test(unused) */
+ /// UI_8 EngRun_Stat; /* Engine run state(unused) */
+ /// UI_8 Odo_MSB_H; /* Mileage information(MSB:High) */
+ /// UI_8 Odo_MSB_L; /* Mileage information(MSB:Low) */
+ /// UI_8 Odo_LSB_H; /* Mileage information(LSB:High) */
+ /// UI_8 Odo_LSB_L; /* Mileage information(LSB:Low) */
+ /// UI_8 PN14_SupBat_Volt; /* Battery voltage(unused) */
+ /// }STLOGGER_CANDIAGSTAT;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// Which is a method to send the mileage information in the CAN diagnostic state data to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_MILEAGE_DATA to SS_LoggerService. \n
+ /// SS_LoggerService uses the log write thread, to output a log of the mileage information.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SendDiagStat(STLOGGER_CANDIAGSTAT *pCanDiagStat_t);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_CANGetCurrentDateAndTime
+ /// \~english @par Summary
+ /// API to send the current date and time of the CAN to SS_LoggerService.
+ /// \~english @param [in] stDateAndTime
+ /// STCanCurrentDateTime - Structure of CAN current date and time
+ /// \~english @par
+ /// STCanCurrentDateTime Structure
+ /// \~english @code
+ /// typedef struct __CWORD62_DateAndTime
+ /// {
+ /// UI_8 DateTime_Stat; /* Date and Time State */
+ /// UI_8 DateTimeDay; /* Day */
+ /// UI_8 DateTimeHour; /* Hour */
+ /// UI_8 DateTimeMinute; /* Minute */
+ /// UI_8 DateTimeMonth; /* Month */
+ /// UI_8 DateTimeSecond; /* Second */
+ /// UI_8 DateTimeYear; /* Year */
+ /// UI_8 TimeFormat; /* Time display format */
+ /// }STCanCurrentDateTime;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// Which is a method to send current date and time of the CAN to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_SET_DATETIME to SS_LoggerService.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_CANGetCurrentDateAndTime(STCanCurrentDateTime stDateAndTime);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_CANSetVIN
+ /// \~english @par Summary
+ /// API to send the Vehicle Identification Number(VIN) to SS_LoggerService.
+ /// \~english @param [in] stVinNumber
+ /// STVIN_NUMBER& - Structure of Vehicle Identification Number(VIN)
+ /// \~english @par
+ /// STVIN_NUMBER Structure
+ /// \~english @code
+ /// typedef struct _TVINnumber
+ /// {
+ /// static const UI_8 VIN_LEN = 18;
+ /// CHAR VINstr[VIN_LEN]; /* Vehicle Identification Number(VIN) */
+ /// }STVIN_NUMBER;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// Which is a method to send the Vehicle Identification Number(VIN) to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_SET_VIN to Logger Service. \n
+ /// SS_LoggerService uses the log write thread, to output a log of the Vehicle Identification Number(VIN).
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_CANSetVIN(STVIN_NUMBER& stVinNumber); // NOLINT (runtime/references)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_SetLoggerParams
+ /// \~english @par Summary
+ /// API to send the logging propriety information of the selected device to SS_LoggerService.
+ /// \~english @param [in] eLoggerStatus
+ /// ELOGGER_STAT - Logging propriety information
+ /// \~english @param [in] eDevType
+ /// EDEV_TYPE - Device type
+ /// \~english @par
+ /// ELOGGER_STAT enum value
+ /// \~english @code
+ /// typedef enum _ELoggerState
+ /// {
+ /// eDeactivate, /* Logging impossible(Deativate) */
+ /// eActivate, /* Logging possible(Activate) */
+ /// eInvalid_LoggerState /* Invalid logging state */
+ /// }ELOGGER_STAT;
+ /// @endcode
+ /// \~english @par
+ /// EDEV_TYPE enum value
+ /// \~english @code
+ /// typedef enum _ELoggerDeviceTypes
+ /// {
+ /// eDevUSB1, /* USB1 */
+ /// eDevUSB2, /* USB2 */
+ /// eDevSD, /* SD */
+ /// eTotalDevicesTypes, /* Total device types */
+ /// eInvalid_DevType /* Invalid device type */
+ /// }EDEV_TYPE;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// Which is a method to send the logging propriety information of the selected device to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_SET_PARAMS to SS_LoggerService. \n
+ /// SS_LoggerService is based on the logging propriety information of the transmission selection device, and
+ /// update as a member variable of the class.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_SetLoggerParams(ELOGGER_STAT eLoggerStatus, EDEV_TYPE eDevType);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_UDPLogging
+ /// \~english @par Summary
+ /// API to send the logging propriety information of UDP to SS_LoggerService.
+ /// \~english @param [in] eLoggerStatus
+ /// ELOGGER_STAT - Logging propriety information
+ /// \~english @par
+ /// ELOGGER_STAT enum value
+ /// \~english @code
+ /// typedef enum _ELoggerState
+ /// {
+ /// eDeactivate, /* Logging impossible(Deativate) */
+ /// eActivate, /* Logging possible(Activate) */
+ /// eInvalid_LoggerState /* Invalid logging state */
+ /// }ELOGGER_STAT;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// Which is a method to send the logging propriety information of UDP to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_UDP_LOGGING to SS_LoggerService. \n
+ /// SS_LoggerService is based on the logging propriety information of the transmission UDP, and update as a
+ /// member variable of the class.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_UDPLogging(ELOGGER_STAT eLoggerStatus);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_ScreenCaptureEventACK
+ /// \~english @par Summary
+ /// API to send the event response of screen capture to SS_LoggerService.
+ /// \~english @param [in] stScreenCaptureInfo
+ /// STScreenCaptureEvt - Structure of event data of screen capture
+ /// \~english @par
+ /// STScreenCaptureEvt Structure
+ /// \~english @code
+ /// typedef struct _TInterfaceunifiedScreenCaptureEvt
+ /// {
+ /// static const UI_16 STR_BUFF_LEN = 64;
+ /// BOOL fSucessful; /* Success propriety flag */
+ /// UI_32 uiSceenShotId; /* Screen capture ID */
+ /// CHAR strNameAndLocation[STR_BUFF_LEN]; /* Screen capture save file name */
+ /// UI_32 uiFaultReasonCode; /* Failure reason code */
+ /// }STScreenCaptureEvt;
+ /// @endcode
+ /// \~english @par
+ /// uiFaultReasonCode : Failure reason code (plm::screen_shot::status List)
+ /// - ok : Success
+ /// - invalid_window_handle : Invalid window handle
+ /// - invalid_context_handle : Invalid context handle
+ /// - display_count_error : Display count error
+ /// - rgb_display_not_found : RGB display not found
+ /// - create_pixmap_error : Create error of PIXMAP
+ /// - usage_pixmap_property_error : Usage error of PIXMAP property
+ /// - format_pixmap_property_error : Format error of PIXMAP property
+ /// - buffer_pixmap_property_error : Buffer error of PIXMAP property
+ /// - create_pixmap_buffer_error : Create error of PIXMAP buffer
+ /// - render_pixmap_property_error : Render error of PIXMAP property
+ /// - pointer_pixmap_property_error : Pointer error of PIXMAP property
+ /// - stride_pixmap_property_error : Stride error of PIXMAP property
+ /// - window_read_error : Window read error
+ /// - write_bitmap_file_error : Writing error of bitmap files
+ /// - window_post_error : Window post error
+ /// - window_property_error : Window property error
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// As the data in the event the response of the screen capture to SS_LoggerService, which is a method for
+ /// transmitting the information of the screen capture ID and screen capture save file name.\n
+ /// Send a message in the command ID of SS_LOGGER_SCREENCAPTURE_EVT_ACK to SS_LoggerService. \n
+ /// This API is an API for screen capture in PLM(Physical Layer Management) function support. In PLM
+ /// non-support, to prohibit the use.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_ScreenCaptureEventACK(STScreenCaptureEvt stScreenCaptureInfo);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_EventLoggingCommonInfo
+ /// \~english @par Summary
+ /// API to send the event information of the common log in SS_LoggerService.
+ /// \~english @param [in] stEventCommonInfo
+ /// STEventLoggerCommonInfo - Event information structure of the common log
+ /// \~english @par
+ /// STEventLoggerCommonInfo Structure
+ /// \~english @code
+ /// typedef struct _SEventLoggerCommonInfo
+ /// {
+ /// UI_8 BodyCAN_Stat:4; /* CAN state of the body */
+ /// UI_8 HeadUnitCAN_Stat:4; /* CAN state of the Head Unit */
+ /// UI_8 HMIInteraction:4; /* HMI Interaction */
+ /// UI_8 IGN_Status:4; /* Ignition state */
+ /// UI_8 FOT_Temp:2; /* Field Operation Tests Temporary */
+ /// UI_8 SystemVoltage:6; /* System Voltage */
+ /// }STEventLoggerCommonInfo;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// It is a method to send the event information of the common log to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_EVENT_COMMONINFO to SS_LoggerService. \n
+ /// Using the log write thread, SS_LoggerService outputs the following log information.
+ /// - CAN state of the body
+ /// - CAN state of the Head Unit
+ /// - HMI Interaction
+ /// - Ignition state
+ /// - System Voltage
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_EventLoggingCommonInfo(STEventLoggerCommonInfo stEventCommonInfo);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_EventLoggingEventInfo
+ /// \~english @par Summary
+ /// API to send the event information of the _CWORD56_ log to SS_LoggerService.
+ /// \~english @param [in] stEventInfo
+ /// STEventLoggerEventInfo - Event information structure of _CWORD56_ log
+ /// \~english @par
+ /// STEventLoggerEventInfo Structure
+ /// \~english @code
+ /// typedef struct _SEventLoggerCommonInfo
+ /// {
+ /// UI_8 NumberOfEvents; /* Event count */
+ /// UI_8 EventGroup; /* Event group */
+ /// UI_8 EventIdentifier; /* Event identifier */
+ /// UI_8 EventData[4]; /* Event data */
+ /// }STEventLoggerEventInfo;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// It is a method to send the event information of _CWORD56_ log to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER__CWORD56__EVENT_INFO to SS_LoggerService.\n
+ /// Using the log write thread, SS_LoggerService outputs the following log information.
+ /// - Event count
+ /// - Event group
+ /// - Event identifier
+ /// - Event data
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_EventLoggingEventInfo(STEventLoggerEventInfo stEventInfo);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_EventLoggingResetInfo
+ /// \~english @par Summary
+ /// API to send the event information of _CWORD56_ reset count to SS_LoggerService.
+ /// \~english @param [in] stResetInfo
+ /// STEventLoggerResetInfo - Event information structure of _CWORD56_ reset counter
+ /// \~english @par
+ /// STEventLoggerResetInfo Structure
+ /// \~english @code
+ /// typedef struct _SEventLoggerResetInfo
+ /// {
+ /// UI_8 _CWORD56__ResetInfo; /* Reset counter information of _CWORD56_ */
+ /// UI_8 _CWORD102__ResetInfo; /* Reset counter information of _CWORD102_ */
+ /// }STEventLoggerResetInfo;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// It is a method to send the event information of _CWORD56_ reset counter to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER__CWORD56__RESET_INFO to SS_LoggerService. \n
+ /// Using the log write thread, SS_LoggerService outputs the following log information.
+ /// - Reset counter information of _CWORD56_
+ /// - Reset counter information of _CWORD102_
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_EventLoggingResetInfo(STEventLoggerResetInfo stResetInfo);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_PersistEventLogOnActiveDTC
+ /// \~english @par Summary
+ /// API to persist the event log on the DTC to SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// Which is a method to send a message of the order to immediately persist the event log on the DTC(Diagnostic
+ /// Trouble Code) to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_DIAGDTC_ACTIVE to SS_LoggerService.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_PersistEventLogOnActiveDTC(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_Shutdown_Complete
+ /// \~english @par Summary
+ /// API to send a shutdown completion message to SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// Which is a method to send a shutdown completion message to SS_LoggerService.\n
+ /// Send a message in the command ID of SS_LOGGER_SHUTDOWN_COMPLETE to SS_LoggerService.\n
+ /// SS_LoggerService stops the thread for the log writing, and the Availability of self-service is set to FALSE,
+ /// to disable the service.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_Shutdown_Complete(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StoreEventLogsToUSB
+ /// \~english @par Summary
+ /// API to request an event log output to USB/SD to SS_LoggerService.
+ /// \~english @param [in] eUSBDevNumber
+ /// EEvtLogUSBDevNumber - Event Log output destination USB/SD device number
+ /// \~english @par
+ /// EEvtLogUSBDevNumber enum value
+ /// \~english @code
+ /// typedef enum _EEventLoggerUSBDeviceNumber
+ /// {
+ /// USB0=0, /* USB0 */
+ /// USB1=1, /* USB1 */
+ /// SD=2 /* SD */
+ /// }EEvtLogUSBDevNumber;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Fire and Forget
+ /// \~english @par Detail
+ /// Which is a method to request the event log output to USB/SD to SS_LoggerService.\n
+ /// To send a message in the command ID of SS_LOGGERCOPYEVENTUSB against SS_LoggerService. \n
+ /// Using the event log writing thread, SS_LoggerService output the event log to the specified device (USB/SD).
+ /// \n
+ /// As a result of the event output, the message is notified to the caller of the API in the command ID below.
+ /// - Success: SS_LOGGERCOPYEVENTUSB_SUCCESS_RESP
+ /// - Failure: SS_LOGGERCOPYEVENTUSB_ERROR_RESP
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus StoreEventLogsToUSB(EEvtLogUSBDevNumber eUSBDevNumber);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StoreEmergencyErrorLogsToUSB
+ /// \~english @par Summary
+ /// API to request the emergency error log output to USB/SD to SS_LoggerService.
+ /// \~english @param [in] eDevNumber
+ /// EDevNumber - Emergency error log output destination USB/SD device number
+ /// \~english @par
+ /// EDevNumber value of enum
+ /// \~english @code
+ /// typedef enum _EDevNumber
+ /// {
+ /// eEEL_USB1=1, /* USB0 */
+ /// eEEL_USB2=2, /* USB1 */
+ /// eEEL_SD=3 /* SD */
+ /// }EDevNumber ;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// Which is a method to request the emergency error log output to USB/SD to SS_LoggerService.\n
+ /// To send a message in the command ID of SS_LOGGERCOPYEMERGENCYLOGS against SS_LoggerService. \n
+ /// Using the diagnostic log output function of System Manager, SS_LoggerService output the emergency error log
+ /// to the specified device(USB/SD). \n
+ /// As a result of the clearing process of the event log, the message is notified to the caller of the API in the
+ /// command ID below.
+ /// - Success: SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP
+ /// - Failure: SS_LOGGERCOPYEMERGENCYLOGS_ERROR_RESP
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus StoreEmergencyErrorLogsToUSB(EDevNumber eDevNumber);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StartCANLogging
+ /// \~english @par Summary
+ /// API to request the start of CAN logging to SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// Which is a method to request the start of CAN logging against SS_LoggerService. \n
+ /// This function is called by CAN to trigger Logging to USB. \n
+ /// Progress is published by notifications eSSLoggerCANEventStart, eSSLoggerCANEventError and
+ /// eSSLoggerCANEventFinished. \n
+ /// To send a message in the command ID of eSSLoggerCANProtocolIDCANTrigger against SS_LoggerService. \n
+ /// SS_LoggerService requests the logging start of CAN to the System Manager.
+ /// \~english @see RegisterLoggingStartNotification, RegisterLoggingFinishNotification
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus StartCANLogging(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RegisterLoggingStartNotification
+ /// \~english @par Summary
+ /// API to set a callback function for CAN logging start notification.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Callback function pointer for CAN logging start notification
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hSession) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Handle name of the session message queue is NULL to SS_LoggerService. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE of the session message to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE of the session message to SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - It is not appropriate message queue name of the session message to SS_LoggerService(The name is NULL, more
+ /// than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_LoggerService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_LoggerService. [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_LoggerService. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Pub-Sub x Pub-Sub
+ /// \~english @par Detail
+ /// Use the StartCANLogging, after the request of the start of the CAN logging operation, which is a method to
+ /// register a callback function to receive a notification of the start of the logging operation.\n
+ /// (Using API:FrameworkunifiedSubscribeToSessionEventWithCallback of Native Service, to register a Callback function for CAN
+ /// logging start notification.) \n
+ /// SS_LoggerService publish the logging start of CAN in the notification of eSSLoggerCANEventStart to
+ /// Subscribers.
+ /// \~english @see StartCANLogging, RegisterLoggingFinishNotification
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RegisterLoggingStartNotification(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RegisterLoggingFinishNotification
+ /// \~english @par Summary
+ /// API to set a callback function for CAN logging finish notification.
+ /// \~english @param [in] f_pCallBackFn
+ /// CbFuncPtr - Callback function pointer for CAN logging finish notification
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc.) has been
+ /// done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hApp) is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Callback function pointer specified by the argument is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - HANDLE (m_hApp) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE (m_hSession) in the class member variables are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Handle name of the session message queue is NULL to SS_LoggerService. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE of the session message to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message queue HANDLE of the session message to SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - It is not appropriate message queue name of the session message to SS_LoggerService(The name is NULL, more
+ /// than 20byte). [eFrameworkunifiedStatusInvldHandle]
+ /// - Is not a transmission type message queue type of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldHndlType]
+ /// - Session message queue is full to SS_LoggerService. [eFrameworkunifiedStatusMsgQFull]
+ /// - It is invalid transmission file descriptor of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - Incorrect size of the transmit buffer of the session message to SS_LoggerService. [eFrameworkunifiedStatusInvldBufSize]
+ /// - Any errors occur during the transmission of a session message to SS_LoggerService. [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message for SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Pub-Sub x Pub-Sub
+ /// \~english @par Detail
+ /// Which is a method to register a callback function to receive a notification of the finish of the logging
+ /// operation.\n
+ /// (Using API:FrameworkunifiedSubscribeToSessionEventWithCallback of Native Service, to register a Callback function for CAN
+ /// logging finish notification.) \n
+ /// SS_LoggerService publish the logging finish of CAN in the notification of eSSLoggerCANEventFinished to
+ /// Subscribers.
+ /// \~english @see StartCANLogging, RegisterLoggingStartNotification
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RegisterLoggingFinishNotification(CbFuncPtr f_pCallBackFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StartDTCLoggingToEmmc
+ /// \~english @par Summary
+ /// API to request the start of CAN logging to SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// Which is a method to request the start of CAN logging to SS_LoggerService. \n
+ /// This function is called by CAN at the time of the trigger of the error that occurred in the DTC. \n
+ /// Progress is published by notifications eSSLoggerCANEventStart, eSSLoggerCANEventError and
+ /// eSSLoggerCANEventFinished. \n
+ /// To send a message in the command ID of eSSLoggerCANProtocolIDDTCTrigger against SS_LoggerService. \n
+ /// SS_LoggerService sends a message in the command ID of eThrdCmdImmPersistEvtLog against the event log writing
+ /// thread. \n
+ /// Event log writing thread will immediately start with respect to the event log for Persistent.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus StartDTCLoggingToEmmc(UI_32 f_dtc);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ClearEventLogs
+ /// \~english @par Summary
+ /// API to request to clear the event log to SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Pub-Sub
+ /// \~english @par Detail
+ /// Which is a method to request to clear the event log to SS_LoggerService. \n
+ /// To send a message in the command ID of SS_LOGGERCLEAREVENT against SS_LoggerService. \n
+ /// SS_LoggerService sends a message in the command ID of eThrdCmdClearEvntLogs against the event log writing
+ /// thread. \n
+ /// Event log write thread, delete all the event logs that are queued in the log write waiting. \n
+ /// As a result of the clearing process of the event log, the message is notified to the caller of the API in the
+ /// command ID below.
+ /// - Success: SS_LOGGERCLEAREVENT_SUCCESS_RESP
+ /// - Failure: SS_LOGGERCLEAREVENT_ERROR_RESP
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ClearEventLogs(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ReadStatisticalCounter
+ /// \~english @par Summary
+ /// API to request a statistics counter reading of the event log to SS_LoggerService.
+ /// \~english @param [in] eCounterGroup
+ /// EStatCounterGroupID - Group ID of the statistics counter
+ /// \~english @par
+ /// EStatCounterGroupID enum value
+ /// \~english @code
+ /// typedef enum _ECounterGroupID
+ /// {
+ /// STARTUP_SHUTDOWN_COUNTER_GROUP =0x01, /* Statistics counter group for StartUp/Shutdown */
+ /// APP_USAGE_COUNTER_GROUP, /* Statistics counter group for application usage */
+ /// F_BLK_STABILITY_COUNTER_GROUP, /* Do not use : Statistics counter for flash access */
+ /// MAX_COUNTER_GROUP /* Max value of statistics counter group */
+ /// }EStatCounterGroupID ;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Fire and Forget
+ /// \~english @par Detail
+ /// Against SS_LoggerService, which is a method that requires a reading of the statistics counter corresponding
+ /// to the statistics counter groups in the event log. \n
+ /// To send a message in the command ID of SS_LOGGER_READ_STATL_COUNTER against SS_LoggerService. \n
+ /// SS_LoggerService sends a message in the command ID of eThrdCmdStatisticalCounter against the event log
+ /// writing thread. \n
+ /// Event log write thread read the statistics counter corresponding to the statistics counter groups in the
+ /// event log. \n
+ /// As a result of the clearing process of the event log, the message is notified to the caller of the API in the
+ /// command ID below.
+ /// - Success: SS_LOGGER_READ_STATL_COUNTER_SUCCESS_RESP
+ /// - Failure: SS_LOGGER_READ_STATL_COUNTER_ERROR_RESP
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ReadStatisticalCounter(EStatCounterGroupID eCounterGroup);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ResetStatisticalCounter
+ /// \~english @par Summary
+ /// API to request the reset of statistics counters of the event log to SS_LoggerService.
+ /// \~english @param [in] eCounterGroup
+ /// EStatCounterGroupID - Group ID of the statistics counter
+ /// \~english @par
+ /// EStatCounterGroupID enum value
+ /// \~english @code
+ /// typedef enum _ECounterGroupID
+ /// {
+ /// STARTUP_SHUTDOWN_COUNTER_GROUP =0x01, /* Statistics counter group for StartUp/Shutdown */
+ /// APP_USAGE_COUNTER_GROUP, /* Statistics counter group for application usage */
+ /// F_BLK_STABILITY_COUNTER_GROUP, /* Do not use : Statistics counter for flash access */
+ /// MAX_COUNTER_GROUP /* Max value of statistics counter group */
+ /// }EStatCounterGroupID ;
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hSession) is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Fire and Forget
+ /// \~english @par Detail
+ /// Against SS_LoggerService, which is a method to reset the statistics counters corresponding to the statistics
+ /// counter groups in the event log. \n
+ /// To send a message in the command ID of SS_LOGGER_READ_STATL_COUNTER against SS_LoggerService. \n
+ /// SS_LoggerService sends a message in the command ID of eThrdCmdStatisticalCounter against the event log
+ /// writing thread. \n
+ /// Event log write thread reset the statistics counter corresponding to the statistics counter groups in the
+ /// event log. \n
+ /// As a result of the clearing process of the event log, the message is notified to the caller of the API in the
+ /// command ID below.
+ /// - Success: SS_LOGGER_RESET_STATL_COUNTER_SUCCESS_RESP
+ /// - Failure: SS_LOGGER_RESET_STATL_COUNTER_ERROR_RESP
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ResetStatisticalCounter(EStatCounterGroupID eCounterGroup);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_SetDiagID
+ /// \~english @par Summary
+ /// API to send the diagnosis ID to SS_LoggerService.
+ /// \~english @param [in] f_u16DiagID
+ /// UI_16 - Diagnosis ID
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Fire and Forget x Sync
+ /// \~english @par Detail
+ /// It is a method to send the diagnosis ID to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_SET_DIAGID to SS_LoggerService. \n
+ /// SS_LoggerService sets the diagnosis ID as a part of the suffix name of the event log storage file name.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_SetDiagID(UI_16 f_u16DiagID);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LoggerIf_UploadEventLog
+ /// \~english @par Summary
+ /// API to request the upload of the event log to SS_LoggerService.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+ /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+ /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+ /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+ /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+ /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+ /// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+ /// \~english @par Preconditions
+ /// - SS_LoggerService process has been started.
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop) has been
+ /// done, and Availability of SS_LoggerService is TRUE.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - HANDLES in the class member variables (m_hService/m_hSession) is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - HANDLE in the class member variables (m_hSession) is not appropriate. (which is invalid)
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// - SS_LoggerService message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+ /// - Message Queue HANDLE for the session for SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Message Queue HANDLE for the session for SS_LoggerService are not appropriate(which is invalid).
+ /// [eFrameworkunifiedStatusInvldHandle]
+ /// - Session message queue name to SS_LoggerService is NULL. [eFrameworkunifiedStatusInvldHandle]
+ /// - Is invalid transmission file descriptor of the session message to SS_LoggerService. [eFrameworkunifiedStatusErrNoEBADF]
+ /// - Interruption by the system call (signal) has occurred during the transmission of the session message to
+ /// SS_LoggerService. [eFrameworkunifiedStatusErrNoEINTR]
+ /// - It is an incorrect size of the transmit buffer of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusInvldBufSize]
+ /// - Some sort of error has occurred at the time of transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusFail]
+ /// - It failed to shared memory access for transmission of the session message to SS_LoggerService.
+ /// [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method x Fire and Forget
+ /// \~english @par Detail
+ /// Which is a method to request the upload of the event log to SS_LoggerService. \n
+ /// Send a message in the command ID of SS_LOGGER_UPLOAD_EVENTLOG to SS_LoggerService. \n
+ /// SS_LoggerService sends a message in the command ID of eThrdCmdUploadEventLog against the event log writing
+ /// thread. \n
+ /// Event log write thread upload the event log in the interior of the buffer. \n
+ /// Upload a result, the message is notified in the command ID of SS_LOGGER_UPLOAD_EVENTLOG_RES to the caller of
+ /// the API.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus LoggerIf_UploadEventLog();
+
+ private:
+ HANDLE OpenService();
+ EFrameworkunifiedStatus SendMessage(UI_32 f_cmdID, UI_32 f_size, void* f_pData);
+
+ HANDLE m_hApp;
+ HANDLE m_hService;
+ HANDLE m_hSession;
+};
+
+#endif /* SS_LOGGER_SERVICE_IFC_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/ // end of logger_service
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_logger_service_local.h b/systemservice/interface_unified/library/include/system_service/ss_logger_service_local.h
new file mode 100755
index 0000000..0261f2e
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_logger_service_local.h
@@ -0,0 +1,94 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_logger_service_local.h
+ * @brief \~english This file supports the the Logger Service.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup logger_service
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_LOGGER_SERVICE_LOCAL_H_ // NOLINT (build/header_guard)
+#define SS_LOGGER_SERVICE_LOCAL_H_
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Screen Capture Event data
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _TInterfaceunifiedSetLoggerParams {
+ ELOGGER_STAT Logger_State;
+ EDEV_TYPE Device_Type;
+}STLoggerSetParams;
+
+typedef struct _TInterfaceunifiedSetLoggerAllParams {
+ ELOGGER_STAT Logger_State;
+ EDEV_TYPE Device_Type;
+ ELOGGER_STAT Logger_UDPState;
+ UI_32 Log_FolderCnt;
+}STLoggerSetAllParams;
+
+typedef struct _TErrorLogger_FolderInfo {
+ static const UI_16 STR_BUFF_LEN = 64;
+ CHAR FoldernameAndLogname[STR_BUFF_LEN];
+ CHAR StorageTarget[STR_BUFF_LEN];
+}STLoggerFolderInfo;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Event logger resets counter information
+///////////////////////////////////////////////////////////////////////////////
+typedef union _uEvtLoggerCommonInfo {
+ STEventLoggerCommonInfo u_stEvtLoggerCommonInfo;
+ UI_8 CommonData[4];
+}UEvtLoggerCommonInfo;
+
+#pragma pack(1)
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Logger Event information
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _stLogEventss_ {
+ UI_32 ts;
+ UI_8 grp_ID;
+ UI_8 event_id;
+ UI_8 data[4];
+}st_LogEvent_ss;
+#pragma pack(0)
+
+/// Macros definition for the Event Logs
+#define MAX_EVT_RECORDS 20000
+#define MAX_EVENTLOG_SIZE 10*MAX_EVT_RECORDS ///< Max size for event logging
+
+typedef struct _TInterfaceunifiedEventLogPersistBuffer {
+ static const UI_16 EVT_BUFMAXSIZE = MAX_EVT_RECORDS;
+ st_LogEvent_ss EvtLog_Buffer[EVT_BUFMAXSIZE];
+ UI_16 Current_Log_Size;
+}STEventLogPersistBuffer;
+
+#endif /* SS_LOGGER_SERVICE_LOCAL_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+
+
diff --git a/systemservice/interface_unified/library/include/system_service/ss_logger_service_notifications.h b/systemservice/interface_unified/library/include/system_service/ss_logger_service_notifications.h
new file mode 100755
index 0000000..7a5fc3d
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_logger_service_notifications.h
@@ -0,0 +1,47 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_logger_service_notifications.h
+ * @brief \~english This file supports the the Logger Service.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup logger_service
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_LOGGER_SERVICE_NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+#define SS_LOGGER_SERVICE_NOTIFICATIONS_H_
+
+#include "system_service/ss_services.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Logger Service Availability Notification
+///////////////////////////////////////////////////////////////////////////////
+#define NTFY_SS_LoggerService_Availability SERVICE_LOGGER"/Availability"
+
+#endif /* SS_LOGGER_SERVICE_NOTIFICATIONS_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+
diff --git a/systemservice/interface_unified/library/include/system_service/ss_logger_service_protocol.h b/systemservice/interface_unified/library/include/system_service/ss_logger_service_protocol.h
new file mode 100755
index 0000000..36c602c
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_logger_service_protocol.h
@@ -0,0 +1,146 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_logger_service_protocol.h
+ * @brief \~english This file supports the the Logger Service.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef _SS_LOGGER_SERVICE_PROTOCOL_H_ // NOLINT (build/header_guard)
+#define _SS_LOGGER_SERVICE_PROTOCOL_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Logger service event IDs
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _LoggerServiceProtocol {
+ SS_LOGGER_MILEAGE_DATA = 0x60,
+ SS_LOGGER_SET_PARAMS,
+ SS_LOGGER_STORE_SCREENCAPTURE_AND_LOG, // CLR+1+3
+ SS_LOGGER_STORE_SCREENCAPTURE, // CLR+1+2
+ SS_LOGGER_STORE_LOG, // ONHOOK+7+9
+ SS_LOGGER_SCREENCAPTURE_EVT_ACK, // Screen shot response (filename)
+ SS_LOGGER_EVENT_COMMONINFO,
+ SS_LOGGER__CWORD56__EVENT_INFO,
+ SS_LOGGER__CWORD56__RESET_INFO,
+ SS_LOGGER_SET_DATETIME,
+ SS_LOGGER_SET_VIN,
+ SS_LOGGER_UDP_LOGGING,
+ SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ,
+ SS_LOGGER_ERROR_EVENT_ARTIFACT_RESP,
+ SS_LOGGER_SHUTDOWN_COMPLETE,
+ SS_LOGGER_DIAGDTC_ACTIVE,
+ SS_LOGGER_SET_DIAGID,
+ // Timer protocol IDs
+ SS_LOGGER_ERROR_EVENT_TIMER_ID_LOGGING_START_RSPN,
+ SS_LOGGER_ERROR_EVENT_TIMER_ID_ARTIFACT_RESPONSE,
+ SS_LOGGER_ERROR_EVENT_TIMER_ID_SCREEN_CAPTURE_RSPN,
+}SS_LoggerServiceProtocol;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Logger service event IDs
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _SS_LOGGERSERVICEPROTOCOL {
+ SS_LOGGERCOPYEVENTUSB = 0x80, // HMI to Dispatcher
+ SS_LOGGERCOPYEVENTUSB_SUCCESS_RESP,
+ SS_LOGGERCOPYEVENTUSB_ERROR_RESP,
+ SS_LOGGERCOPYEMERGENCYLOGS,
+ SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP,
+ SS_LOGGERCOPYEMERGENCYLOGS_ERROR_RESP,
+ SS_LOGGERCLEAREVENT, // HMI to Dispatcher
+ SS_LOGGERCLEAREVENT_SUCCESS_RESP,
+ SS_LOGGERCLEAREVENT_ERROR_RESP,
+ SS_LOGGER_READ_STATL_COUNTER,
+ SS_LOGGER_READ_STATL_COUNTER_SUCCESS_RESP,
+ SS_LOGGER_READ_STATL_COUNTER_ERROR_RESP,
+ SS_LOGGER_RESET_STATL_COUNTER,
+ SS_LOGGER_RESET_STATL_COUNTER_SUCCESS_RESP,
+ SS_LOGGER_RESET_STATL_COUNTER_ERROR_RESP,
+ SS_LOGGER_ENG_READ_NUMOFEVENTS,
+ SS_LOGGER_ENG_READ_NUMOFEVENTS_RESP,
+ SS_LOGGER_ENG_READ_STATISTICAL_COUNTERS,
+ SS_LOGGER_ENG_READ_STATISTICAL_COUNTERS_RESP,
+ SS_LOGGER_UPLOAD_EVENTLOG,
+ SS_LOGGER_UPLOAD_EVENTLOG_RESP
+}SS_loggerserviceprotocol;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+/// \brief Private events for the following categories of devices
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _LoggerServerEvents {
+ SS_LOGGER_SCREENCAPTURE_EVT = 0xA0, // Screen shot request from PLM.
+ SS_LOGGER_ERRORINFO_EVT,
+ SS_LOGGER_LOGINFO_EVT,
+ SS_LOGGER_LOGSTARTED_EVT
+}SS_LoggerServerEvents;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \brief eSSLoggerCANProtocolID
+///
+/// \note These IDs depict the possible events coming from CAN to logger_service
+///
+/////////////////////////////////////////////////////////////////////////////////////
+enum eSSLoggerCANProtocolID {
+ eSSLoggerCANProtocolIDCANTrigger = 0x10000000, /// Start logging to USB
+ eSSLoggerCANProtocolIDDTCTrigger /// Start logging of DTC to emmc
+};
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \brief eSSLoggerCANEvent
+///
+/// \note Events that are published to CAN for HK and CAN logging. Data structures
+/// attached to the single events can be found in below table
+/// | EventId | Return type |
+/// | :------------------------ | :------------------------ |
+/// | eSSLoggerCANEventStart | None |
+/// | eSSLoggerCANEventError | STEventCANLoggerEventInfo |
+/// | eSSLoggerCANEventFinished | STEventCANLoggerEventInfo |
+///
+/////////////////////////////////////////////////////////////////////////////////////
+enum eSSLoggerCANEvent {
+ eSSLoggerCANEventStart = 0x10001000, /// Logging has started for HK and CAN events
+ eSSLoggerCANEventError, /// Logging has aborted with an error
+ eSSLoggerCANEventFinished /// Logging has finished succesfully
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SS_DEVICEDETECTION_SERVICE_PROTOCOL_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_logger_store_logs.h b/systemservice/interface_unified/library/include/system_service/ss_logger_store_logs.h
new file mode 100755
index 0000000..7c68fd9
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_logger_store_logs.h
@@ -0,0 +1,81 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_logger_store_logs.h
+ * @brief This file supports the logger service interface for SystemManager.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_LOGGER_STORE_LOGS_H_ // NOLINT (build/header_guard)
+#define SS_LOGGER_STORE_LOGS_H_
+
+#include <native_service/frameworkunified_types.h>
+#include "system_service/interfaceunified_system_types.h"
+
+#include <string>
+#include <vector>
+
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+#define SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG "/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG"
+
+typedef enum {
+ SS_STORELOGS_INTERFACEUNIFIEDLOG = 0,
+ SS_STORELOGS_ILLEGAL,
+ SS_STORELOGS_ACCOFFON,
+
+ SS_STORELOGS_SYS_ILLEGAL,
+ SS_STORELOGS_ACCOFFON_PRESS,
+
+ SS_STORELOGS_MAX
+} SS_STORELOGS_OPE_TYPE;
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup logger_service
+///
+/// \brief SSLoggerSrvIfWriteDebugLogs
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SS_LoggerStoreLogs(SS_STORELOGS_OPE_TYPE type);
+
+EFrameworkunifiedStatus SS_LoggerStoreLogs_deleteOldLogAbnrm(const std::string& log_path, std::vector<std::string>& l_vector,
+ const std::string& f_archive_destination, SI_32 max_num,
+ UI_32 abnrm_total);
+
+EFrameworkunifiedStatus StartRtUsbLogThread(HANDLE hApp);
+EFrameworkunifiedStatus StopRtUsbLogThread(HANDLE hApp);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif /* SS_LOGGER_STORE_LOGS_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_power_service.h b/systemservice/interface_unified/library/include/system_service/ss_power_service.h
new file mode 100755
index 0000000..15ba033
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_power_service.h
@@ -0,0 +1,535 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_power_service.h
+ * @brief \~english This file supports the Power Service interface.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup power_service
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_POWER_SERVICE_H_ // NOLINT (build/header_guard)
+#define SS_POWER_SERVICE_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include "system_service/ss_system_types.h"
+
+
+
+typedef enum _PwLevelTypes {
+ epspltUNKNOWN,
+ epspltWAKEUP = 0x99,
+ epspltNORMAL,
+ epspltSHUTDOWN,
+ epspltEMERGENCY,
+} PowerSrvLevelType, EPWR_LEVEL_TYPE;
+
+
+typedef enum {
+ epsstUNKNOWN,
+ epsstBASIC,
+ epsstSUPERVISOR,
+ epsstSYSTEM,
+} PowerSrvSessionType, EPWR_SESSION_TYPE;
+
+
+typedef enum {
+ epscnINVALID = 0xFF,
+ epscnCANWAKEUP = 0x07, //< All modules up with Display Off and Audio Muted
+ epscnCANSLEEP = 0x08, //< Communication and all modules shut down
+} ePowerSrvCANStates, EPWR_CAN_STATE_TYPE;
+
+
+
+// Not in use for PastModel003*1. Can be used for Platform
+typedef enum {
+ epswlINVALID = 0xFF,
+ epswlFULLRUN = 0x0A, //< Normal ignition on and full wakeup
+ epswlLOCALWAKEUP = 0x0B, //< Only certain modules are up.
+} ePowerSrvWakeupLevels, EPWR_WAKEUP_LEVEL_TYPE;
+
+typedef EPWR_WAKEUP_LEVEL_TYPE * PEPWR_WAKEUP_LEVEL_TYPE;
+
+typedef enum {
+ epswsINVALID = 0xFF,
+ epswsPWRON = 0x00, //< Enable Display and Audio
+ epswsPWROFF = 0x01, //< Disable Audio and HMI
+} ePowerSrvPowerStates, EPWR_POWER_STATE_TYPE;
+
+
+typedef enum {
+ epsvsINVALID = 0xFF,
+ epsvsNORMAL = 0x20,
+ epsvsLVI1 = 0x22,
+ epsvsLVI2 = 0x24,
+} ePowerSrvVoltageStates, EPWR_VOLTAGE_STATE_TYPE;
+
+typedef EPWR_VOLTAGE_STATE_TYPE * PEPWR_VOLTAGE_STATE_TYPE;
+
+typedef enum {
+ epscsINVALID = 0xFF,
+ epscsENTRY = 0xA0,
+ epscsEXIT = 0xA2,
+} ePowerSrvCrankStates, EPWR_CRANK_STATE_TYPE;
+
+
+//******************************************************************************
+// Startup Reason / EPWR_WAKEUP_FACTOR_TYPE typedefs *
+// *
+/**
+ * \~english
+ */
+typedef enum {
+ epswfINVALID = 0xFF, //!< \~english
+ epswfTESTACC = 0x00, //!< \~english
+ epswfON_KEY = 0x01, //!< \~english
+ epswfIGN_ACC = 0x02, //!< \~english
+ epswfDR_OPEN_CLOSE = 0x03, //!< \~english
+ epswfDX_ACTIVATION = 0x04, //!< \~english
+ epswfPASS_ACTIVATION = 0x05, //!< \~english
+ epswfSPVACTIVATION = 0x06, //!< \~english
+ epswfUSER_DATA_RESET = 0x07 //!< \~english
+//
+// Carry-over enums from CCR
+//
+// epswfPWRBUTTONON = 0x0C,
+// epswfIGNON = 0x0D,
+// epswfDISCEJECT = 0x0F,
+// epswfSHOWTIME = 0x11,
+// epswfPHONECALL = 0x12,
+//
+// End of Carry-over enums from CCR
+//
+} ePowerSrvWakeupFactors, EPWR_WAKEUP_FACTOR_TYPE;
+typedef EPWR_WAKEUP_FACTOR_TYPE * PEPWR_WAKEUP_FACTOR_TYPE;
+// *
+// End of Startup Reason / EPWR_WAKEUP_FACTOR_TYPE *
+//******************************************************************************
+
+//****************************************************************************
+// Shutdown Popup Protocol enums & typedefs *
+// *
+typedef enum { // *
+ epsspPowerSave1 = 0x00, // *
+ epsspPowerSave2 = 0x01, // *
+ epsspPowerSave3 = 0x02, // *
+ epsspPowerSaveClr = 0x03, // *
+ epsspLowVoltage1 = 0x04, // *
+ epsspLowVoltage2 = 0x05, // *
+ epsspLowVoltage3 = 0x06, // *
+ epsspLowVoltageClr = 0x07, // *
+ epsspBattCouplingSW1 = 0x08, // *
+ epsspBattCouplingSW2 = 0x09, // *
+ epsspBattCouplingSW3 = 0x0A, // *
+ epsspBattCouplingSWClr = 0x0B, // *
+ epsspAbnormalTemp_1st = 0x0C, // *
+ epsspAbnormalTemp_Clr = 0x0D, // *
+ epsspLimpHome_1st = 0x0E, // *
+ epsspLimpHome_2nd = 0x0F, // *
+ epsspLimpHome_3rd = 0x10, // *
+ epsspLimpHome_Clr = 0x11, // *
+ epsspProdMd_1st = 0x12, // *
+ epsspProdMd_Clr = 0x13, // *
+ epsspTransMd_1st = 0x14, // *
+ epsspTransMd_Clr = 0x15, // *
+ epsspAllClr = 0xFF // *
+} ePwrServiceShutdownPopupType, EPWR_SHUTDOWN_POPUP_TYPE; // *
+ // *
+// *
+// End of Shutdown Condition Protocol enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// CPMShowPowerPopup Protocol enums & typedefs *
+// *
+typedef enum { // *
+ epssppNormal = 0x00, // *
+ epssppCritical = 0x01, // *
+ epssppAppCritical = 0x02, // *
+ epssppAllClr = 0xFF // *
+} ePwrServicePowerPopupType, EPWR_POWER_POPUP_TYPE; // *
+ // *
+// *
+// End of CPMShowPowerPopup Protocol enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// Limp Home Cutoff Protocol enums & typedefs *
+// *
+typedef enum { // *
+ epslhcINVALID = 0xFF, // *
+ epslhcDISABLED = 0x00, // *
+ epslhcENABLED = 0x01 // *
+} ePwrServiceLHCType, EPWR_LHC_TYPE; // *
+ // *
+// *
+// End of Limp Home Cutoff Protocol enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// Production Mode Protocol enums & typedefs *
+// *
+typedef enum { // *
+ epspmINVALID = 0xFF, // *
+ epspmDISABLED = 0x00, // *
+ epspmENABLED = 0x01 // *
+} ePwrServiceProdModeType, EPWR_PROD_MODE_TYPE; // *
+ // *
+// *
+// End of Production Mode Protocol enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// Transport Mode Protocol enums & typedefs *
+// *
+typedef enum { // *
+ epstmINVALID = 0xFF, // *
+ epstmDISABLED = 0x00, // *
+ epstmENABLED = 0x01 // *
+} ePwrServiceTransportModeType, EPWR_TRANSPORT_MODE_TYPE; // *
+ // *
+// *
+// End of Transport Mode Protocol enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// Last User Mode, User Mode , User Mode Change Reason Protocol enums & *
+// typedefs *
+// *
+/**
+ * \~english
+ */
+typedef enum {
+ epsumINVALID = 0xFF, //!< \~english
+ epsumOFF = 0x00, //!< \~english
+ epsumON = 0x01 //!< \~english
+} ePwrServiceUserModeType, EPWR_USER_MODE_TYPE;
+
+/**
+ * \~english State transition reason.
+ */
+typedef enum {
+ epsumcrNOT_AVAILABLE = 0x00, //!< \~english Not available.
+ epsumcrON_KEY = 0x01, //!< \~english
+ epsumcrPARKING_B, //!< \~english Parking(+B) Power state transition.
+ epsumcrPRE_BA, //!< \~english Pre-boot(+BA) Power state transition.
+ epsumcrNORMAL, //!< \~english Normal-boot Power state transition.
+ epsumcrBACKGROUND_BA, //!< \~english Background-boot(+BA) Power state transition.
+} ePwrServiceUserModeChangeReasonType, EPWR_USER_MODE_CHANGE_REASON_TYPE;
+ // *
+// *
+// End of Last User Mode, User Mode Protocol enums & typedefs *
+//****************************************************************************
+
+/**
+ * \~english
+ */
+typedef struct _upinfo {
+ EPWR_WAKEUP_LEVEL_TYPE level; //!< \~english
+ EPWR_WAKEUP_FACTOR_TYPE factor; //!< \~english
+ EPWR_USER_MODE_CHANGE_REASON_TYPE userModeChangeReason; //!< \~english State transition reason.
+} upInfo;
+
+/**
+ * \~english
+ */
+typedef struct _wakeinfo {
+ EPWR_POWER_STATE_TYPE powerupType; //!< \~english
+ upInfo up; //!< \~english
+} wakeInfo;
+
+//****************************************************************************
+// System Mode Info enums & typedefs *
+// *
+typedef enum { // *
+ epssinfINVALID = 0xFF, // *
+ epssinfNORMAL = 0x00, // *
+ epssinfPROGRAMMING = 0x08, // *
+}ePowerSrvSystemModeInfo, EPWR_SYSTEM_MODE_INFO; // *
+ // *
+typedef enum { // *
+ epssusfINVALID = 0xFF, // *
+ epssusSYSTEM_SERVICES_STARTED = 0x00, // *
+ epssusALL_SERVICES_LAUNCHED = 0x01 // *
+}ePowerSrvStartupStageType, EPWR_STARTUP_STAGE_TYPE; // *
+ // *
+typedef struct _SystemModeInfo { // *
+ EPWR_USER_MODE_TYPE lastUserMode; // NOTE: Don't use this. just only remained for backward compatibility.
+ EPWR_LHC_TYPE limpHomeCutoff; // *
+ EPWR_PROD_MODE_TYPE productionMode; // *
+ EPWR_TRANSPORT_MODE_TYPE transportMode; // *
+ EPWR_SYSTEM_MODE_INFO systemMode; // *
+ EPWR_STARTUP_STAGE_TYPE startupStage; // *
+} SystemModeInfo; // *
+// *
+// End of System Mode Info enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// Startup Confirmation enums & typedefs *
+// *
+typedef enum { // *
+ eps_CWORD56_bmINVALID = 0xFF, // *
+ eps_CWORD56_bmAPPLICATION_MODE = 0x00, // *
+ eps_CWORD56_bmPROGRAMMING_MODE = 0x08 // *
+} EPWR_SC__CWORD56__BOOT_MODE_TYPE; // *
+ // *
+typedef enum { // *
+ epsstINVALID = 0xFF, // *
+ epsstWARMSTART = 0x00, // *
+ epsstCOLDSTART = 0x01 // *
+} EPWR_SC_WAKEUP_TYPE; // *
+ // *
+typedef enum { // *
+ epsscrtINVALID = 0xFF, // *
+ epsscrtNOT_REQUIRED = 0x00, // *
+ epsscrtREQUIRED = 0x01 // *
+} EPWR_SC_COLD_START_REQ_TYPE; // *
+ // *
+typedef enum { // *
+ epsssINVALID = 0xFF, // *
+ epsssUNLOCK = 0x00, // *
+ epsssLOCK = 0x01 // *
+} EPWR_SC_SECURITY_STATUS; // *
+ // *
+typedef struct { // *
+ EPWR_SC__CWORD56__BOOT_MODE_TYPE _CWORD56_BootMode; // *
+ EPWR_SC_WAKEUP_TYPE wakeupType; // *
+ EPWR_SC_COLD_START_REQ_TYPE coldStartRequest; // *
+ EPWR_SC_SECURITY_STATUS securityStatus; // *
+ UI_32 HWVersion; // *
+ UI_32 matchedHardwareType; // *
+ UI_32 softwareType; // *
+ UI_32 imageType; // *
+ UI_32 majorVersion; // *
+ UI_32 minorVersion; // *
+ UI_32 SWVersionYear; // *
+ UI_32 SWVersionWeek; // *
+ UI_32 SWVersionPatchLevel; // *
+} StartupConfirmationMsgStrut, EPWR_SC_MSG_STRUCT; // *
+// *
+// End of Startup Confirmation enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// Power Request Message enums & typedefs *
+// *
+/**
+ * _CWORD102_ Startup Information
+ */
+typedef enum {
+ epsprm_CWORD102_siINVALID = 0xFF, //!< \~english
+ epsprm_CWORD102_si_CWORD102__STARTUP_NORMAL = 0x00, //!< Normal Startup
+ epsprm_CWORD102_si_CWORD102__STARTUP_AFTER_RESET = 0x01 //!< Startup after Irregular Reset
+}ePowerSrv_CWORD102_StartupInfoType, EPWR__CWORD102__STARTUP_INFO_TYPE;
+/**
+ * Opening Type
+ */
+typedef enum {
+ epsprmotINVALID = 0xFF, //!< \~english
+ epsprmotTIMING_TYPE_1 = 0x00, //!< CI/DI Show timing type1
+ epsprmotTIMING_TYPE_2 = 0x01 //!< CI/DI Show timing type2
+} ePowerSrvPwrReqMsgCIDIOpeningType, EPWR_OPENING_TYPE;
+/**
+ * Manual Reset Information
+ */
+typedef enum {
+ epsprmriINVALID = 0xFF, //!< \~english
+ epsprmriNORMAL = 0x00, //!< \~english
+ epsprmriWAKEUP_AFTER_RESET = 0x01 //!< \~english
+} ePowerSrvPwrManResetInfoType, EPWR_MAN_RESET_INFO_TYPE;
+/**
+ * Last System Retention Request
+ */
+typedef enum {
+ epsprlsrrINVALID = 0xFF, //!< \~english
+ epsprlsrrLAST_SYSTEM_OFF = 0x00, //!< \~english
+ epsprlsrrLAST_SYSTEM_ON = 0x01 //!< \~english
+} ePowerSrvTypeLastSysRetReq, EPWR_LAST_SYS_RET_REQ_TYPE;
+
+// *
+typedef struct { // *
+ EPWR__CWORD102__STARTUP_INFO_TYPE startupType; // *
+ EPWR_OPENING_TYPE openingType; // *
+ EPWR_WAKEUP_FACTOR_TYPE startupReason; // *
+ EPWR_USER_MODE_TYPE lastUserMode; // *
+ EPWR_MAN_RESET_INFO_TYPE manResetInfo; // *
+ EPWR_LAST_SYS_RET_REQ_TYPE lastSystemRetentionReq; // *
+ EPWR_USER_MODE_TYPE userMode; // *
+} PowerRequestMsgStrut, EPWR_POWER_REQUEST_MSG_STRUCT; // *
+
+/**
+ * \~english structure for power request message
+ */
+typedef struct {
+ EPWR__CWORD102__STARTUP_INFO_TYPE startupType; //!< \~english
+ EPWR_OPENING_TYPE openingType; //!< \~english
+ EPWR_WAKEUP_FACTOR_TYPE startupReason; //!< \~english
+ EPWR_USER_MODE_TYPE lastUserMode; //!< \~english
+ EPWR_MAN_RESET_INFO_TYPE manResetInfo; //!< \~english
+ EPWR_LAST_SYS_RET_REQ_TYPE lastSystemRetentionReq; //!< \~english
+ EPWR_USER_MODE_TYPE userMode; //!< \~english
+ EPWR_USER_MODE_CHANGE_REASON_TYPE userModeChangeReason; //!< \~english State transition reason.
+} PowerRequestMsgStrutWithUMCR, EPWR_POWER_REQUEST_MSG_STRUCT_WITH_UMCR;
+// *
+// End of Power Request Message enums & typedefs *
+//****************************************************************************
+
+
+
+//****************************************************************************
+// Shutdown Request Message enums & typedefs *
+// *
+// ONS *
+// *
+typedef enum { // *
+ epssdmonsINVALID = 0xFF, // *
+ epssdmonsNO_ONS = 0x00, // *
+ epssdmonsONS = 0x01 // *
+} ePowerSrvONSType, EPWR_ONS_TYPE; // *
+// *
+// Shutdown Trigger *
+// *
+typedef enum { // *
+ epssdmsdtINVALID = 0xFF, // *
+ epssdmsdtTESTACC_OFF = 0x00, // *
+ epssdmsdtON_KEY = 0x01, // *
+ epssdmsdtIGN_LOCK = 0x02, // *
+ epssdmsdtPWR_SAVE = 0x03, // *
+ epssdmsdtTMP_STARTUP = 0x04, // *
+ epssdmsdtDIAG_DEACTIVATION = 0x05, // *
+ epssdmsdtABNORMAL_VOLTAGE = 0x06, // *
+ epssdmsdtABNORMAL_TEMP = 0x07, // *
+ epssdmsdtBATTERYCUTOFF = 0x08, // *
+ epssdmsdtLIMPHOME = 0x09, // *
+ epssdmsdtHU_CAN_ERROR = 0x0A, // *
+ epssdmsdtBODY_CAN_ERROR = 0x0B, // *
+ epssdmsdtTRANSPORT_MODE = 0x0C, // *
+ epssdmsdtPRODUCTION_MODE = 0x0D, // *
+ epssdmsdtIGN_OFF = 0x0E, // *
+ epssdmsdtGENERIC_ERROR_RESET = 0x0F, // *
+ epssdmsdtFATAL_ERROR_RESET = 0x10, // *
+ epssdmsdtUSER_DATA_RESET = 0x11, // *
+ epssdmsdtFACTORY_DATA_RESET = 0x12, // *
+ epssdmsdtFAST_SLEEP_MODE = 0x13, // *
+ epssdmsdtNORMAL_RESET = 0x14, // *
+ epssdmsdtPROGUPDATE_RESET = 0x15, // cannot use this
+ // *
+ // Note to self: Make sure to update all enum-to-enum and *
+ // enum-to-string maps when changing these enums ! *
+} ePowerSrvPwrShutdownTriggerType, EPWR_SHUTDOWN_TRIGGER_TYPE; // *
+// *
+typedef struct { // *
+ EPWR_ONS_TYPE ONS_Type; // *
+ EPWR_SHUTDOWN_TRIGGER_TYPE shutdownTrigger; // *
+ EPWR_USER_MODE_TYPE lastUserMode; // *
+ EPWR_TRANSPORT_MODE_TYPE transportMode; // *
+ EPWR_PROD_MODE_TYPE productionMode; // *
+ EPWR_LHC_TYPE limpHomeCutoffRequest; // *
+} ShutdownRequestMsgStrut, EPWR_SHUTDOWN_REQUEST_MSG_STRUCT; // *
+// *
+// End of Shutdown Request Message enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// HeartBeat enums & typedefs *
+// *
+// HeartBeat Request Message *
+typedef struct { // *
+ UI_8 IntervalSec; // *
+} EPWR_HB_REQ_MSG_STRUCT; // *
+// *
+// HeartBeat Response Message *
+// Zero byte data message returned. *
+// End of HeartBeat enums & typedefs *
+//****************************************************************************
+
+//****************************************************************************
+// CPU Reset Reason enums & typedefs *
+typedef enum { // *
+ epsCpuResetReasonGeneric = 0 // *
+ , epsCpuResetReasonFatalError // *
+ , epsCpuResetReasonUserDataReset // *
+ , epsCpuResetReasonFactoryDataReset // *
+ , epsCpuResetReasonUserForceReset // *
+ , epsCpuResetReasonShipmentModeReset // *
+ , epsCpuResetReasonHeadUnitReset // *
+ , epsCpuResetReasonNormalReset // *
+ , epsCpuResetReasonProgupdateReset // cannot use this
+} epsCpuResetReason; // *
+//
+typedef struct {
+#define PWR_RESET_MSG_STR_SIZE 32
+ epsCpuResetReason resetReason; // *
+ CHAR messageStr[PWR_RESET_MSG_STR_SIZE]; // *
+} SS_Pwr_CpuResetMsgStruct;
+// *
+// End of CPU Reset Reason enums & typedefs *
+//****************************************************************************
+
+typedef struct {
+ union _data {
+ wakeInfo wake;
+
+ struct _crank {
+ EPWR_CRANK_STATE_TYPE state;
+ }crank;
+
+ struct _voltage {
+ EPWR_VOLTAGE_STATE_TYPE state;
+ }voltage;
+
+ struct _ws_complete {
+ EPWR_WAKEUP_LEVEL_TYPE level;
+ EPWR_WAKEUP_FACTOR_TYPE factor;
+ }wk_shdwn_complete;
+
+ struct _commwake {
+ EPWR_CAN_STATE_TYPE state;
+ }commwake;
+
+ struct _UserMode {
+ EPWR_USER_MODE_TYPE mode;
+ } user_mode;
+
+ struct _ShutdownPopup {
+ EPWR_SHUTDOWN_POPUP_TYPE shutdownPopupEvent;
+ } shutdownPopup;
+
+ struct _PowerPopup {
+ EPWR_POWER_POPUP_TYPE powerPopupEvent;
+ } powerPopup;
+
+ StartupConfirmationMsgStrut startupConfirmationMsg;
+ PowerRequestMsgStrutWithUMCR powerRequestMsg;
+ ShutdownRequestMsgStrut shutdownRequestMsg;
+ }data;
+} Pwr_ServiceSetInterface;
+
+#endif /* SS_POWER_SERVICE_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/ // end of power_service
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_power_service_if.h b/systemservice/interface_unified/library/include/system_service/ss_power_service_if.h
new file mode 100755
index 0000000..d0ace60
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_power_service_if.h
@@ -0,0 +1,606 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_power_service_if.h
+ * @brief \~english This file supports the Power Service client interface.
+ */
+/**
+ * @file
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup power_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_IF_H_ // NOLINT (build/header_guard)
+#define POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_IF_H_
+
+#include "system_service/ss_power_service.h"
+#include "system_service/ss_power_service_protocol.h"
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup OpenPowerService
+/// \~english @par Summary
+/// Obtain a handle for using the PowerService.
+/// \~english @param [in] f_hApp
+/// HANDLE - Application handle
+/// \~english @retval Handle Success
+/// \~english @retval NULL Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// - The API creates a communication resource between
+/// the user service and the PowerService
+/// and returns a handle for using the PowerService.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE OpenPowerService(HANDLE f_hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup ClosePowerService
+/// \~english @par Summary
+/// Free a handle for using PowerService.
+/// \~english @param [in] f_hApp
+/// HANDLE - Application handle
+/// \~english @param [in] f_hService
+/// HANDLE - PowerService handle
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail
+/// - The API terminates the communication resource between
+/// the user service and the PowerServiceand frees the given handle. \n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus ClosePowerService(HANDLE f_hApp, HANDLE f_hService);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceOpenSessionRequest
+/// \~english @par Summary
+/// Make the PowerService available.
+/// \~english @param [in] f_hService
+/// HANDLE - PowerService handle
+/// \~english @param [in] f_eSessionType
+/// EPWR_SESSION_TYPE - Session type
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget x Method
+/// \~english @par Detail
+/// - The API opens a session between the user service
+/// and the PowerService and makes the PowerService available. \n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceOpenSessionRequest(HANDLE f_hService,
+ EPWR_SESSION_TYPE f_eSessionType);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceCloseSessionRequest
+/// \~english @par Summary
+/// End using the PowerService.
+/// \~english @param [in] f_hService
+/// HANDLE - PowerService handle
+/// \~english @param [in] f_hSession
+/// HANDLE - Session type
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget x Method
+/// \~english @par Detail
+/// - The API closes the session between the user service
+/// and the PowerService and terminatesthe PowerSerivce use. \n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceCloseSessionRequest(HANDLE f_hService, HANDLE f_hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceDecodeOpenSessionResponse
+/// \~english @par Summary
+/// Obtain a handle for OpenSessionRequest response message.
+/// \~english @param [in] f_hApp
+/// HANDLE - Application handle
+/// \~english @param [in] f_hSession
+/// HANDLE& - Address of storing session handle
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL Pointer
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// - The API obtains a handle for OpenSessionRequest
+/// response message using the given application handle.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceDecodeOpenSessionResponse(HANDLE f_hApp,
+ HANDLE& f_hSession); // NOLINT (runtime/references)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSetVoltageState
+/// \~english @par Summary
+/// Set power supply state.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @param [in] f_eVoltage_state
+/// EPWR_VOLTAGE_STATE_TYPE - Power supply status value
+/// \~english @par
+/// - Power supply status value
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epsvsINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epsvsNORMAL</td><td>0x20</td></tr>
+/// <tr><td>epsvsLVI1</td><td>0x22</td></tr>
+/// <tr><td>epsvsLVI2</td><td>0x24</td></tr>
+/// </table>
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method only
+/// \~english @par Detail
+/// - The API sets power supply state to the PowerService. \n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSetVoltageState(HANDLE f_hSession,
+ EPWR_VOLTAGE_STATE_TYPE f_eVoltage_state);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSetCrankState
+/// \~english @par Summary
+/// Set crank state.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @param [in] f_eCrank_state
+/// EPWR_CRANK_STATE_TYPE - Crank state value
+/// \~english @par
+/// - Crank state value
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epscsINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epscsENTRY</td><td>0xA0</td></tr>
+/// <tr><td>epscsEXIT</td><td>0xA2</td></tr>
+/// </table>
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget only
+/// \~english @par Detail
+/// - The API sets crank state to the PowerService.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSetCrankState(HANDLE f_hSession,
+ EPWR_CRANK_STATE_TYPE f_eCrank_state);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSystemModeInfoRequest
+/// \~english @par Summary
+/// Request to obtain the system mode information.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method x Method
+/// \~english @par Detail
+/// - The API requests the PowerService to obtain
+/// the system mode information.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSystemModeInfoRequest(HANDLE f_hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSendInitCompReport
+/// \~english @par Summary
+/// Send an initialize complete response.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forgeat x Fire and Forget
+/// \~english @par Detail
+/// - The API sends an initialize complete response to the PowerService.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSendInitCompReport(HANDLE f_hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSendSetShutdownPopupRequest
+/// \~english @par Summary
+/// Obtain shutdown state.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @param [in] f_eShutdownPopup
+/// EPWR_SHUTDOWN_POPUP_TYPE - Shutdown state
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method only
+/// \~english @par Detail
+/// - The API obtains the shutdown state from the PowerService. \n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSendSetShutdownPopupRequest(HANDLE f_hSession,
+ EPWR_SHUTDOWN_POPUP_TYPE f_eShutdownPopup);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSendStartupConfirmationMsgRequest
+/// \~english @par Summary
+/// Send startup confirmation request.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @param [in] f_eState
+/// EPWR_SC_MSG_STRUCT
+/// - Address of the structure for startup confirmation request message
+/// \~english @par
+/// - Structure for startup confirmation request message
+/// \~english @code
+/// typedef struct {
+/// EPWR_SC__CWORD56__BOOT_MODE_TYPE _CWORD56_BootMode;
+/// EPWR_SC_WAKEUP_TYPE wakeupType;
+/// EPWR_SC_COLD_START_REQ_TYPE coldStartRequest;
+/// EPWR_SC_SECURITY_STATUS securityStatus;
+/// UI_32 HWVersion;
+/// UI_32 matchedHardwareType;
+/// UI_32 softwareType;
+/// UI_32 imageType;
+/// UI_32 majorVersion;
+/// UI_32 minorVersion;
+/// UI_32 SWVersionYear;
+/// UI_32 SWVersionWeek;
+/// UI_32 SWVersionPatchLevel;
+/// } StartupConfirmationMsgStrut, EPWR_SC_MSG_STRUCT;
+/// @endcode\n
+/// \n
+/// - EPWR_SC__CWORD56__BOOT_MODE_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>eps_CWORD56_bmINVALID</td><td>0xFF</td></tr>
+/// <tr><td>eps_CWORD56_bmAPPLICATION_MODE</td><td>0x00</td></tr>
+/// <tr><td>eps_CWORD56_bmPROGRAMMING_MODE</td><td>0x08</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_SC_WAKEUP_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epsstINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epsstWARMSTART</td><td>0x00</td></tr>
+/// <tr><td>epsstCOLDSTART</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_SC_COLD_START_REQ_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epsscrtINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epsscrtNOT_REQUIRED</td><td>0x00</td></tr>
+/// <tr><td>epsscrtREQUIRED</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_SC_SECURITY_STATUS
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epsssINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epsssUNLOCK</td><td>0x00</td></tr>
+/// <tr><td>epsssLOCK</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget x Fire and Forget
+/// \~english @par Detail
+/// - The API sends a startup confirmation request to the PowerService.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSendStartupConfirmationMsgRequest(HANDLE f_hSession
+ , EPWR_SC_MSG_STRUCT f_eState);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSendPowerRequest
+/// \~english @par Brief
+/// Send power request.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @param [in] f_eState
+/// \ref PowerRequestMsgStrutWithUMCR "EPWR_POWER_REQUEST_MSG_STRUCT_WITH_UMCR&" - Address of the structure for power request message
+/// \~english @par
+/// \n
+/// Of the eight elements of the \ref PowerRequestMsgStrutWithUMCR "EPWR_POWER_REQUEST_MSG_STRUCT_WITH_UMCR" structure, five elements set fixed values.\n
+/// startupType = \ref epsprm_CWORD102_si_CWORD102__STARTUP_NORMAL\n
+/// openingType = \ref epsprmotTIMING_TYPE_1\n
+/// lastUserMode = \ref epsumON\n
+/// manResetInfo = \ref epsprmriNORMAL\n
+/// lastSystemRetentionReq = \ref epsprlsrrLAST_SYSTEM_OFF\n
+/// \n
+/// For the following, set different values at system startup and shutdown.\n
+/// (Element name) = (Startup settings or Shutdown settings)\n
+/// startupReason = (\ref epswfIGN_ACC or \ref epswfINVALID)\n
+/// userMode = (\ref epsumON or \ref epsumOFF)\n
+/// \n
+/// For the following, set different values at power state transition.\n
+/// <table>
+/// <tr bgcolor="black"><th>Element name</th><th>Power state</th><th>Value</th></tr>
+/// <tr><td rowspan=7>userModeChangeReason</td><tr><td>Not Available</td><td>\ref epsumcrNOT_AVAILABLE</td></tr>
+/// <tr><td> </td><td>\ref epsumcrON_KEY</td></tr>
+/// <tr><td>Parking(+B)</td><td>\ref epsumcrPARKING_B</td></tr>
+/// <tr><td>Pre-boot(+BA)</td> <td>\ref epsumcrPRE_BA</td></tr>
+/// <tr><td>Normal-boot</td> <td>\ref epsumcrNORMAL</td></tr>
+/// <tr><td>Background-boot(+BA)</td> <td>\ref epsumcrBACKGROUND_BA</td></tr>
+/// </table>
+/// \n
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// - When the session handle (f_hSession) specified by the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - The process fails for some reason. [eFrameworkunifiedStatusFail]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method only
+/// \~english @par Detail
+/// - The API send a power request to the PowerService.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSendPowerRequest(HANDLE f_hSession,
+ EPWR_POWER_REQUEST_MSG_STRUCT_WITH_UMCR& f_eState);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSendShutdownRequest
+/// \~english @par Summary
+/// Send shutdown request.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @param [in] f_eState
+/// EPWR_SHUTDOWN_REQUEST_MSG_STRUCT&
+/// - Address of the structure for shutdown request message
+/// \~english @par
+/// - Structure for shutdown request message
+/// \~english @code
+/// typedef struct {
+/// EPWR_ONS_TYPE ONS_Type;
+/// EPWR_SHUTDOWN_TRIGGER_TYPE shutdownTrigger;
+/// EPWR_USER_MODE_TYPE lastUserMode;
+/// EPWR_TRANSPORT_MODE_TYPE transportMode;
+/// EPWR_PROD_MODE_TYPE productionMode;
+/// EPWR_LHC_TYPE limpHomeCutoffRequest;
+/// } ShutdownRequestMsgStrut, EPWR_SHUTDOWN_REQUEST_MSG_STRUCT
+/// @endcode\n
+/// \n
+/// - EPWR_ONS_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epssdmonsINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epssdmonsNO_ONS</td><td>0x00</td></tr>
+/// <tr><td>epssdmonsONS</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_SHUTDOWN_TRIGGER_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epssdmsdtINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epssdmsdtTESTACC_OFF</td><td>0x00</td></tr>
+/// <tr><td>epssdmsdtON_KEY</td><td>0x01</td></tr>
+/// <tr><td>epssdmsdtIGN_LOCK</td><td>0x02</td></tr>
+/// <tr><td>epssdmsdtPWR_SAVE</td><td>0x03</td></tr>
+/// <tr><td>epssdmsdtTMP_STARTUP</td><td>0x04</td></tr>
+/// <tr><td>epssdmsdtDIAG_DEACTIVATION</td><td>0x05</td></tr>
+/// <tr><td>epssdmsdtABNORMAL_VOLTAGE</td><td>0x06</td></tr>
+/// <tr><td>epssdmsdtABNORMAL_TEMP</td><td>0x07</td></tr>
+/// <tr><td>epssdmsdtBATTERYCUTOFF</td><td>0x08</td></tr>
+/// <tr><td>epssdmsdtLIMPHOME</td><td>0x09</td></tr>
+/// <tr><td>epssdmsdtHU_CAN_ERROR</td><td>0x0A</td></tr>
+/// <tr><td>epssdmsdtBODY_CAN_ERROR</td><td>0x0B</td></tr>
+/// <tr><td>epssdmsdtTRANSPORT_MODE</td><td>0x0C</td></tr>
+/// <tr><td>epssdmsdtPRODUCTION_MODE</td><td>0x0D</td></tr>
+/// <tr><td>epssdmsdtIGN_OFF</td><td>0x0E</td></tr>
+/// <tr><td>epssdmsdtGENERIC_ERROR_RESET</td><td>0x0F</td></tr>
+/// <tr><td>epssdmsdtFATAL_ERROR_RESET</td><td>0x10</td></tr>
+/// <tr><td>epssdmsdtUSER_DATA_RESET</td><td>0x11</td></tr>
+/// <tr><td>epssdmsdtFACTORY_DATA_RESET</td><td>0x12</td></tr>
+/// <tr><td>epssdmsdtFAST_SLEEP_MODE</td><td>0x13</td></tr>
+/// <tr><td>epssdmsdtNORMAL_RESET</td><td>0x14</td></tr>
+/// <tr><td>epssdmsdtPROGUPDATE_RESET</td><td>0x15</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_USER_MODE_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epsumINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epsumOFF</td><td>0x00</td></tr>
+/// <tr><td>epsumON</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_TRANSPORT_MODE_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epstmINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epstmDISABLED</td><td>0x00</td></tr>
+/// <tr><td>epstmENABLED</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_PROD_MODE_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epspmINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epspmDISABLED</td><td>0x00</td></tr>
+/// <tr><td>epspmENABLED</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// - EPWR_LHC_TYPE
+/// <table>
+/// <tr bgcolor="black"><th>Name</th><th>Value</th></tr>
+/// <tr><td>epslhcINVALID</td><td>0xFF</td></tr>
+/// <tr><td>epslhcDISABLED</td><td>0x00</td></tr>
+/// <tr><td>epslhcENABLED</td><td>0x01</td></tr>
+/// </table>\n
+/// \n
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method x Method
+/// \~english @par Detail
+/// - The API sends shutdown request to the PowerService.\n
+/// \n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSendShutdownRequest(
+ HANDLE f_hSession
+ , EPWR_SHUTDOWN_REQUEST_MSG_STRUCT &f_eState); // NOLINT (runtime/references)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup PwrServiceSendHeartBeatRequest
+/// \~english @par Summary
+/// Send a request for HeartBeat monitoring start.
+/// \~english @param [in] f_hSession
+/// HANDLE - Session handle
+/// \~english @param [in] f_eHbReqMsg
+/// EPWR_HB_REQ_MSG_STRUCT*
+/// - Address of the structure for HeartBeat monitoring start request message
+/// \~english @par
+/// - Structure for HeartBeat monitoring start request message
+/// \~english @code
+/// typedef struct {
+/// UI_8 IntervalSec;
+/// } EPWR_HB_REQ_MSG_STRUCT;
+/// @endcode\n
+/// \n
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusFail Failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method x Method
+/// \~english @par Detail
+/// - The API sends HeartBeat monitoring start\n
+/// request to the PowerService\n
+/// - Include ss_power_service_ifc.h
+/// - Library libSS_PowerServiceIf.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PwrServiceSendHeartBeatRequest(
+ HANDLE f_hSession,
+ EPWR_HB_REQ_MSG_STRUCT *f_eHbReqMsg);
+
+#endif // POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_IF_H_ // NOLINT (build/header_guard)
+
+/** @}*/ // end of PowerService
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_power_service_local.h b/systemservice/interface_unified/library/include/system_service/ss_power_service_local.h
new file mode 100755
index 0000000..51a284a
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_power_service_local.h
@@ -0,0 +1,66 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_power_service_local.h
+ * @brief \~english This file supports the Power Service interface.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_POWER_SERVICE_LOCAL_H_ // NOLINT (build/header_guard)
+#define SS_POWER_SERVICE_LOCAL_H_
+
+
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include "system_service/ss_system_types.h"
+
+
+
+
+
+const UI_32 MaxTestCaseName = 128;
+const UI_32 MaxRespMsg = 2048;
+
+typedef enum _PwLVIStatus {
+ ePwSrvLVI_Status_InActive,
+ ePwSrvLVI_Status_Active
+} PowerSrvLVIStatus, EPWER_LVI_STATUS;
+
+typedef struct _PwCompleteAck {
+ UI_16 unSessionId;
+ CHAR szServiceName[MAX_QUEUE_NAME_SIZE];
+} StartCompleteAck;
+
+typedef struct _SS_PSCurrentState {
+ CHAR testCaseId[MaxTestCaseName];
+ CHAR printRespmsg[MaxRespMsg];
+}SS_PSCurrentState;
+
+
+#endif /* SS_POWER_SERVICE_LOCAL_H_ */ // NOLINT (build/header_guard)
+/** @}*/ // end of power_service
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_power_service_notifications.h b/systemservice/interface_unified/library/include/system_service/ss_power_service_notifications.h
new file mode 100755
index 0000000..b25172d
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_power_service_notifications.h
@@ -0,0 +1,48 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_power_service_notifications.h
+ * @brief \~english This file supports the Power Service interface.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup power_service
+ * @ingroup system_service
+ * @{
+ */
+#ifndef POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+#define POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_NOTIFICATIONS_H_
+
+#include "system_service/ss_services.h"
+
+
+
+
+/// Indicated if Power Service is available or not portion of this message is BOOL
+#define szNTFY_PowerAvailability SERVICE_POWER"/Availability"
+
+/// @}
+
+#endif // POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+/** @}*/ // end of power_service
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_power_service_notifications_local.h b/systemservice/interface_unified/library/include/system_service/ss_power_service_notifications_local.h
new file mode 100755
index 0000000..a06c030
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_power_service_notifications_local.h
@@ -0,0 +1,67 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_power_service_notifications_local.h
+ * @brief \~english This file supports the Power Service interface.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_POWER_SERVICE_NOTIFICATIONS_LOCAL_H_ // NOLINT (build/header_guard)
+#define SS_POWER_SERVICE_NOTIFICATIONS_LOCAL_H_
+
+#include "system_service/ss_services.h"
+
+
+/// \addtogroup system_manager
+/// @{
+
+/// Depreciated !!
+#define szNTFY_PowerLVI1 SERVICE_POWER"/LVI1"
+/// Depreciated !!
+#define szNTFY_PowerLVI2 SERVICE_POWER"/LVI2"
+/// Indicates the current power level state
+#define szNTFY_PowerLevel SERVICE_POWER"/Level"
+
+/// Notification that Power Service publishes for subscribers ( ie, HMI ) to
+/// display a popup indicating the type of shutdown condition.
+/// 1. Power Save
+/// 2. BatteryCut
+/// 3. Low Voltage
+#define szNTFY_ShutdownPopup SERVICE_POWER"/ShutdownPopup"
+
+/// Notification that Power Service publishes for subscribers ( ie, HMI ) to
+/// display a popup indicating the type of CPMShowPowerPopup.
+/// 1. Normal
+/// 2. Critical
+/// 3. Application Critical
+#define szNTFY_PowerPopup SERVICE_POWER"/PowerPopup"
+
+/// @}
+
+#endif /* SS_POWER_SERVICE_NOTIFICATIONS_LOCAL_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_power_service_protocol.h b/systemservice/interface_unified/library/include/system_service/ss_power_service_protocol.h
new file mode 100755
index 0000000..92860e8
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_power_service_protocol.h
@@ -0,0 +1,201 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_power_service_protocol.h
+ * @brief \~english This file supports the Power Service interface.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_PROTOCOL_H_ // NOLINT (build/header_guard)
+#define POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_PROTOCOL_H_
+
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include "system_service/ss_power_service.h"
+
+/// \ingroup PSM_Local
+/**
+ * power service protocol --> define all protocol messages in and out of power that are pertinent to the functionality offered by power.
+ */
+typedef enum _SS_PowerServiceProtocol {
+ // Diagnostic Protocol
+ SS_POWER_PRINT_CONNECTIONS = 0x32, //!< client to service
+ SS_POWER_PRINT_STACK = 0x33, //!< client to service
+
+ SS_POWER_WAKEUP_COMPLETE = 0x41, //!< service to client // used by power state machine
+ SS_POWER_SHUTDOWN_COMPLETE = 0x42, //!< service to client // used by power state machine
+ SS_POWER_VOLTAGE_STATE = 0x43, //!< client to service
+ SS_POWER_LVI2_SHUTDOWN_COMPLETE = 0x44, //!< service to client
+ SS_POWER_CRANK_STATE = 0x45, //!< client to service
+
+
+ // System Manager commands
+ SS_POWER_WAKEUP_MODULES_CMPL_RSPN = 0x51, //!< service to shadow
+ SS_POWER_SYSTEM_LAUNCH_COMPLETE = 0x56, //!< client to service
+
+
+ // SSM Service commands
+ SS_POWER_STATE_CHANGE_REQ = 0x40, //!< client to service : send wakeup to System Manager
+ SS_POWER_STATE_CHANGE_RESP = 0x46, //!< \~english Response to request of power state transition to power_supply_manager_shadow.
+
+ SS_POWER_COMM_WAKEUP = 0x58, //!< client to service : Power On expected
+
+ SS_POWER_SHUTDOWN_REQ = 0x59, //!< client to service : Comm Sleep from Shadow
+ SS_POWER_SHUTDOWN_RESP = 0x57, //!< service to shadow : Shutdown complete from System Manager
+
+ SS_POWER_CRNT_STATE_QUERY = 0x60, //!< client to service
+ SS_POWER_CRNT_STATE_QUERY_RSPN = 0x61, //!< service to client
+
+ SS_POWER_SYSTEM_MODE_INFO_REQ = 0x63, //!< Client (Shadow) to Service (Power Service)
+ SS_POWER_SYSTEM_MODE_INFO_RESP = 0x64, //!< Service to client *****
+
+ SS_POWER_INITCOMP_REP = 0x70, //!< Client (Shadow) to Service (Power Service)
+
+ //*************************************************************************
+ // CPMShowPowerPopup Notification Protocol: *
+ // *
+ // Request by the Power Shadow to the Power Service to publish a *
+ // 'Voltage State' notification. *
+ // *
+ // The Request message carries the requested notification. *
+ // The Response message carries the EFrameworkunifiedStatus of the request. *
+ SS_POWER_PUBLISH_POWER_POPUP_REQ, //!< Shadow to Pwr Svc
+ SS_POWER_PUBLISH_POWER_POPUP_RESP, //!< Pwr Svc to Shadow
+ // *
+ // End of CPMShowPowerPopup Notification Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Shutdown Condition Notification Protocol: *
+ // *
+ // Request by the Power Shadow to the Power Service to publish the *
+ // 'Shutdown Condition' notification. *
+ // *
+ // The Request message carries the requested PowerPopup. *
+ // The Response message carries the EFrameworkunifiedStatus of the request. *
+ SS_POWER_PUBLISH_SHUTDOWN_CONDITION_REQ, //!< Shadow to Pwr Svc
+ SS_POWER_PUBLISH_SHUTDOWN_CONDITION_RESP, //!< Pwr Svc to Shadow
+ // *
+ // End of Shutdown Condition Notification Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Startup Confirmation Protocol: *
+ // *
+ // Request by the Power Shadow to the Power Service to forward to the *
+ // System Manager the Startup Confirmation message. *
+ // *
+ // The Request message carries the Startup Confirmation message. *
+ // The Response message carries the EFrameworkunifiedStatus of the request. *
+ SS_POWER_FWD_START_CONFIRMATION_MSG_REQ, //!< Shadow to Pwr Svc
+ SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, //!< Pwr Svc to Shadow
+ // *
+ // End of Startup Confirmation Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Power Request Protocol: *
+ // *
+ // Power Request message from the Power Shadow to the Power Service with *
+ // _CWORD56_'s "Power_Request" IPC_Command data. *
+ // *
+ // The Request message carries the _CWORD56_'s data. *
+ // The Response message will use the SS_POWER_STATE_CHANGE_RESP protocol *
+ // ID. *
+ SS_POWER_POWER_REQUEST_MSG, //!< Shadow to Pwr Svc
+ // *
+ // End of Power Request Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Shutdown Request Protocol: *
+ // *
+ // Shutdown Request message from the Power Shadow to the Power Service *
+ // with _CWORD56_'s "Shutdown_Request" IPC_Command data. *
+ // *
+ // The Request message carries the _CWORD56_'s data. *
+ // The Response message will use the SS_POWER_STATE_CHANGE_RESP protocol *
+ // ID. *
+ SS_POWER_SHUTDOWN_REQUEST_MSG, //!< Shadow to Pwr Svc
+ // *
+ // End of Shutdown Request Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // User Mode Protocol: *
+ // *
+ // Request by the Power Service to the System Manager, originally from *
+ // the Power Shadow, to turn on or off the video & audio output of HMI *
+ // and Audio services. *
+ // User Mode 'On' => turn video & audio output on *
+ // User Mode 'Off' => turn video & audio output off *
+ // *
+ // The Request message carries the requested User Mode state. *
+ // The Response message carries the actual User Mode state. *
+ SS_POWER_USER_MODE_SET_RESP, //!< Power Service to Shadow
+ // *
+ // Note: See the corresponding Power Service / System Manager *
+ // 'SS_SystemManagerProtocol' enums in /SystemServices/inc/ *
+ // ss_system_manager_protocol.h *
+ // *
+ // End of User Mode Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Heartbeat Protocol: *
+ // *
+ // Request by the Power Service to the System Manager, originally from *
+ // the Power Shadow, to support the heartbeat request response system. *
+ // *
+ // The Request message carries the expected application processor *
+ // heartbeat response interval in units of seconds. *
+ // The Response message has a data length of zero and serves as a *
+ // periodic heartbeat message to the boot micro. *
+ SS_POWER_HEARTBEAT_REQ, //!< Shadow to Power Service
+ SS_POWER_HEARTBEAT_RESP, //!< Power Service to Shadow
+ // *
+ // End of Heartbeat Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Hard Reset Request Protocol : *
+ // *
+ // Request by the Power Service to the Shadow to support the sending of *
+ // a reset request with type argument to the boot micro. *
+ // *
+ // The Request message carries epsCpuResetReason as data payload. *
+ SS_POWER_HARD_RESET_REQ, //!< Power Service to Shadow
+ // *
+ // End of Hard Reset Request Protocol *
+ //*************************************************************************
+}SS_PowerServiceProtocol;
+
+#endif /* POWER_SERVICE_CLIENT_INCLUDE_SYSTEM_SERVICE_SS_POWER_SERVICE_PROTOCOL_H_ */ // NOLINT (build/header_guard)
+/** @}*/ // end of interface_unified
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
+// EOF
diff --git a/systemservice/interface_unified/library/include/system_service/ss_services.h b/systemservice/interface_unified/library/include/system_service/ss_services.h
new file mode 100755
index 0000000..d414670
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_services.h
@@ -0,0 +1,63 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_services.h
+ * @brief \~english This file supports contains the queue names of all System Services processes.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_SERVICES_H_ // NOLINT (build/header_guard)
+#define SS_SERVICES_H_
+
+#include <agl_thread.h>
+
+
+// Caution:ServiceName length mas is 15
+// System_Services domain services 0123456789ABCDE
+#define SS_DEV_DETECT_THD "SS_Dev_Detect_Thd"
+#define SS_DEV_DETECT_SRV MN_SS_DEVDETECTSRV
+#define SS_DEV_DETECT_BSP_THD "SS_DeviceDetectErr"
+#define SS_GROUP_LAUNCH_TRIGGER "SS_GroupLaunchTrigger"
+#define SERVICE_HEARTBEAT "SS_HeartBeatService"
+#define SERVICE_LOGGER MN_SS_LOGGERSRV
+#define SS_UDEV_DEV_DETECT_DLL "SS_UDEV_DeviceDetect"
+#define SS_PLM_SERVICE "SS_PLMService"
+#define SERVICE_POWER MN_SS_POWERSERVICE
+#define SS_RESOURCE_MONITOR_SERVICE "SS_ResourceMonitorService"
+#define SERVICE_SOFTWAREUPDATE "SS_SofUpdateSrv"
+#define SERVICE_SYSMANAGER MN_SS_SYSMANAGER
+#define SS_WINSYS MN_SS_WINSYS
+#define SS_RESOURCE_MANAGER MN_SS_RESOURCEMGR
+#define SS_TASK_MANAGER MN_SS_TASKMANAGER
+#define SERVICE_VUP MN_VUPSERVICE
+#define SS_UPDATESERVICE MN_SS_UPDATESERVICE
+
+/// @}
+
+#endif /* SS_SERVICES_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_sm_client_if.h b/systemservice/interface_unified/library/include/system_service/ss_sm_client_if.h
new file mode 100755
index 0000000..70b9425
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_sm_client_if.h
@@ -0,0 +1,1064 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_sm_client_if.h
+ * @brief \~english This file supports the AGL framework client interface to System manager.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+
+
+#ifndef __SS_SYSTEM_MANAGER_CLIENT_IF_H__ // NOLINT (build/header_guard)
+#define __SS_SYSTEM_MANAGER_CLIENT_IF_H__
+
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/ns_logger_if.h>
+#include <string>
+#include "system_service/ss_power_service.h"
+#include "system_service/ss_system_manager_if.h"
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RegisterSMSessionAckCallback
+/// \~english @par Summary
+/// API for setting the FrameworkunifiedOnStop response
+/// \~english @param [in] CallbackPtr
+/// EFrameworkunifiedStatus - Pointer to a callback function
+/// \~english @par
+/// - TRUE : Not carried out in the automatic response.
+/// - FALSE : Carry out the response in automatic. (Default)
+/// \~english @retval VOID None
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// In the case of is_start_required = TURE, Client Services of System Manager, automatically \n
+/// System Manager and the session at the same time is building and start-up. \n
+/// It is possible to receive a call back at the timing when the session establishment is completed \n
+/// by this API. \n
+/// is_start_required is, as a Launch Configuration information, have the following meanings.
+/// \~english @par
+/// is_start_required \n
+/// - True: Create a session with the System Manager.(Service to use the Dispatcher.) \n
+/// - False: Not create a session with the System Manager.(Do not use the Dispatcher Service.)
+/// OnStart/Stop/DebugDump Callback is not called. HeartBeat function does not apply.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus RegisterSMSessionAckCallback(EFrameworkunifiedStatus (*CallbackPtr)(HANDLE));
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SetDataResetModeToSystemManager
+/// \~english @par Summary
+/// API to record the data reset mode of the next boot in a non-volatile area.
+/// \~english @param [in] dataResetMode
+/// ESMDataResetModeInfo - Data reset mode information
+/// \~english @par
+/// - e_SS_SM_DATA_RESET_MODE_NONE : Do not initialize
+/// - e_SS_SM_DATA_RESET_MODE_USER : User data initialization
+/// - e_SS_SM_DATA_RESET_MODE_FACTORY : Factory initialization
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusBadConnection Socket connection error
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - Specified log type is invalid(In the case of value which does not correspond to enum eSMUserLogType).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a send and receive type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Send and receive for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the send and receive of the System
+/// Manager message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the send and receive buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Send and receive and reception of System Manager message for the session fails to socket connection.
+/// [eFrameworkunifiedStatusBadConnection]
+/// - Any error has occurred at the time of send and receive of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - Send and receive of System Manager message for the session fails to shared memory access.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget x Method
+/// \~english @par Detail
+/// The data reset mode to save in a non-volatile area, the function return.\n
+/// System Manager is to expand the resident service data reset mode of the non-volatile area as\n
+/// an argument of FrameworkunifiedOnStart.\n
+/// Task Manager is Callback data initialization interface of the same information as an argument.\n
+/// All of, the completion of the FrameworkunifiedOnStart processing of all resident services (System Manager) \n
+/// and, at the timing when the Callback of data initialization interface of all non-resident \n
+/// service has been completed (Task Manager), a data reset mode, initialized to e_SS_SM_DATA_RESET_ NONE. \n
+/// In other words, when the reset until initialization occurs, the same data reset mode again to \n
+/// the argument, FrameworkunifiedOnStart or, Callback of data initialization interface is performed.
+/// \~english @see SetProgUpdateStateToSystemManager
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SetDataResetModeToSystemManager(ESMDataResetModeInfo dataResetMode);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SetProgUpdateStateToSystemManager
+/// \~english @par Summary
+/// API to record the program update state in the non-volatile information.
+/// \~english @param [in] updateState
+/// SMProgUpdateState - Program update status
+/// \~english @par
+/// - SS_SM_PROG_UPDATE_STATE_UPDATED : Program update
+/// - SS_SM_PROG_UPDATE_STATE_MAP_UPDATED : Map update
+/// - SS_SM_PROG_UPDATE_STATE_MAPDIFF_UPDATED : Map difference updating
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusBadConnection Socket connection error
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - Specified program update status information is invalid (in the case of a value that does not correspond to
+/// the enum SMProgUpdateState). [eFrameworkunifiedStatusInvldParam]
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a send and receive type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Send and receive for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the send and receive of the System
+/// Manager message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the send and receive buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Send and receive and reception of System Manager message for the session fails to socket connection.
+/// [eFrameworkunifiedStatusBadConnection]
+/// - Any error has occurred at the time of send and receive of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - Send and receive of System Manager message for the session fails to shared memory access.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// The program update state to save in a non-volatile area, the function return.\n
+/// updateState is it is possible to specify more than one by setting the OR.\n
+/// Based on the setting state, to determine isProgUpdated, isMapUpdated, the value \n
+/// of the isMapDiffUpdated provided in GetInterfaceunifiedOnStartExtInfo and GetInterfaceunifiedOnStopExtInfo.\n
+/// Task Manager is provided in data initialization interface, the same information to the non-resident service.\n
+/// Set state is initialized with the same timing as data reset mode.\n
+/// (See SetDataResetModeToSystemManager)
+/// \~english @see SetDataResetModeToSystemManager, GetInterfaceunifiedOnStartExtInfo, GetInterfaceunifiedOnStopExtInfo
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SetProgUpdateStateToSystemManager(SMProgUpdateState progUpdateState);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendCpuResetRequestToSystemManager
+/// \~english @par Summary
+/// API to request LOG saved to the internal non-volatile area
+/// \~english @param [in] l_eCpuResetReason
+/// ESMCpuResetReason - Reset factor
+/// \~english @param [in] f_messageStr
+/// std::string - Abnormal message string
+/// \~english @param [in] f_suffixStr
+/// std::string - Suffix string of abnormal LOG file
+/// \~english @par
+/// enum ESMCpuResetReason Variable
+/// - e_SS_SM_CPU_RESET_REASON_NORMAL : Normal Reset
+/// - e_SS_SM_CPU_RESET_REASON_DATA_RESET : Data Reset
+/// - e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET : User forced reset
+/// - e_SS_SM_CPU_RESET_REASON_GENERIC_ERR : Generic Error reset
+/// - e_SS_SM_CPU_RESET_REASON_DSP_ERR : DSP Error
+/// - e_SS_SM_CPU_RESET_REASON_IMMRESET_NORMAL : Reset immediately
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a transmission type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Transmission for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the transmission of the System Manager
+/// message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmission buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - Transmission of System Manager message for the session fails to shared memory access. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// Collect the LOG information and stores it in the built-in non-volatile area.\n
+/// String specified in f_suffixStr is added as a suffix to the end of the abnormal LOG file name.
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SendCpuResetRequestToSystemManager(ESMCpuResetReason l_eCpuResetReason,
+ std::string f_messageStr = "", std::string f_suffixStr = "");
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SetNextWakeupTypeToSystemManager
+/// \~english @par Summary
+/// Set the next wakeup type.
+/// \~english @param [in] f_wakeupType
+/// ESMNextWakeupType - Wakeup type
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail
+/// - The API sets the next wakeup type (COLD/HOT/Not specified).
+/// \n
+/// - Include ss_sm_client_if.h
+/// - Library libSS_SystemIfUnified.so
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SetNextWakeupTypeToSystemManager(ESMNextWakeupType f_wakeupType);
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Set_UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc_StateVar
+/// \~english @par Summary
+/// API for setting the FrameworkunifiedOnStop response
+/// \~english @param [in] f_setTrue
+/// BOOL - Response presence or absence of specified
+/// \~english @par
+/// - TRUE : Not carried out in the automatic response.
+/// - FALSE : Carry out the response in automatic. (Default)
+/// \~english @retval VOID None
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// In case you can not return the response in the synchronized by FrameworkunifiedOnStop, by setting to \n
+/// TRUE in this API, it is possible to implement the completion notice to the system_manager \n
+/// the service side.
+/// At this time, the service is by to Publish the Notification of "service name/StopComp", \n
+/// you are possible to notify the STOP completion to system_manager.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+VOID Set_UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc_StateVar(BOOL f_SetTrue);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendUserInvokedLoggingRequestToSystemManager
+/// \~english @par Summary
+/// API to request LOG saved to the internal non-volatile area
+/// \~english @param [in] f_userInvokedLogType
+/// \ref eSMUserLogType - User invoked log type.
+/// \~english @param [in] f_messageStr
+/// std::string - Abnormal message string
+/// \~english @param [in] f_suffixStr
+/// std::string - Suffix string of abnormal LOG file
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - Log type is invalid(In the case of value which does not correspond to enum eSMUserLogType).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a transmission type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Transmission for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the transmission of the System Manager
+/// message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmission buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - Transmission of System Manager message for the session fails to shared memory access. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// Collect the LOG information and stores it in the built-in non-volatile area.\n
+/// String specified in f_suffixStr is added as a suffix to the end of the abnormal LOG file name.
+/// \~english @see SendClearLogsRequestToSystemManager
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendUserInvokedLoggingRequestToSystemManager(eSMUserLogType f_userInvokedLogType,
+ std::string f_messageStr = "", std::string f_suffixStr = "");
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendInterfaceunifiedOnStopResponseToSystemManager
+/// \~english @par Summary
+/// API to send a FrameworkunifiedOnStop response
+/// \~english @param [in] f_eStatus
+/// EFrameworkunifiedStatus - End status
+/// \~english @par
+/// - eFrameworkunifiedStatusOK : End processing completion
+/// - eFrameworkunifiedStatusFail : End processing uncompleted
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a transmission type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Transmission for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the transmission of the System Manager
+/// message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmission buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - Transmission of System Manager message for the session fails to shared memory access. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget only
+/// \~english @par Detail
+/// In case you can not return the response in the synchronized by FrameworkunifiedOnStop, by setting to \n
+/// TRUE in this API, it is possible to implement the completion notice to the system_manager \n
+/// the service side.
+/// At this time, the service is by to Publish the Notification of "service name/StopComp", \n
+/// you are possible to notify the STOP completion to system_manager.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendInterfaceunifiedOnStopResponseToSystemManager(EFrameworkunifiedStatus f_eStatus);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetInterfaceunifiedOnStartExtInfo
+/// \~english @par Summary
+/// API to get the extended information of the start-up parameters.
+/// \~english @param [out] f_info
+/// T_SS_SM_START_ExtDataStructType - Startup parameters extended information
+/// \~english @par
+/// T_SS_SM_START_ExtDataStructType Structure
+/// \~english @code
+/// typedef struct {
+/// {
+/// BOOL isProgUpdated;
+/// EMRelaunchStatus relaunchStatus;
+/// BOOL isMapUpdated;
+/// BOOL isMapDiffUpdated;
+/// uint8_t reserved[];
+/// }T_SS_SM_START_ExtDataStructType;
+/// @endcode
+/// \~english @par
+/// isProgUpdated:Presence or absence of a program update
+/// - TRUE : Yes program update
+/// - FALSE : No program update
+/// \~english @par
+/// relaunchStatus:Relaunch state of self-service
+/// - e_SS_SM_RELAUNCH_STATUS_NONE : Relaunch non-occurrence (first start)
+/// - e_SS_SM_RELAUNCH_STATUS_SAFE : Normal Relaunch
+/// - e_SS_SM_RELAUNCH_STATUS_ERR : Abnormal Relaunch
+/// \~english @par
+/// isMapUpdated:Presence or absence of a map update
+/// - TRUE : Yes map update
+/// - FALSE : No map update
+/// \~english @par
+/// isMapDiffUpdated:The presence or absence of the map difference updating
+/// - TRUE : Yes map difference update
+/// - FALSE : No map difference update
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusBadConnection Failure to socket connection
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred(Socket Connection/Memory Allocation/Event Control)
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a transmission type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Transmission for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the transmission of the System Manager
+/// message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmission buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Transmission and reception of System Manager message for the session fails to socket connection.
+/// [eFrameworkunifiedStatusBadConnection]
+/// - In the case of the message queue open error for reception of System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - System Manager message for the session fails to acquire the message buffer for reception. [eFrameworkunifiedStatusFail]
+/// - System Manager message for the session fails in the event control for the reception. [eFrameworkunifiedStatusFail]
+/// - Any error has occurred at the time of transmission and receive of the System Manager message for the
+/// session. [eFrameworkunifiedStatusFail]
+/// - Transmission of System Manager message for the session fails to shared memory access. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// Returns the extended information of the parameters of FrameworkunifiedOnStart(). \n
+/// It is assumed that that will be called in the FrameworkunifiedOnStart (), return the correct value when it is called prior
+/// \n
+/// to the issuance FrameworkunifiedOnStart() is not guaranteed.\n
+/// System startup to relaunchStatus is e_SS_SM_RELAUNCH_STATUS_NONE, the service is a case that has been Relaunch
+/// \n
+/// by the exit (SS_SM_EXIT_RELAUNCH) _SS_SM_RELAUNCH_STATUS_SAFE, if the Relaunch due to the abnormality occurs
+/// to \n
+/// set the e_SS_SM_RELAUNCH_STATUS_ERR.
+/// \~english @see GetInterfaceunifiedOnStopExtInfo, FrameworkunifiedOnStart
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetInterfaceunifiedOnStartExtInfo(T_SS_SM_START_ExtDataStructType &f_info); // NOLINT (runtime/references)
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetInterfaceunifiedOnStopExtInfo
+/// \~english @par Summary
+/// API to get the extended information of the end parameter.
+/// \~english @param [out] f_info
+/// T_SS_SM_STOP_ExtDataStructType - Exit extended parameter information
+/// \~english @par
+/// T_SS_SM_STOP_ExtDataStructType Structure
+/// \~english @code
+/// typedef struct {
+/// {
+/// BOOL isProgUpdated;
+/// uint8_t reserved[];
+/// }T_SS_SM_START_ExtDataStructType;
+/// @endcode
+/// \~english @par
+/// isProgUpdated:Presence or absence of a program update
+/// - TRUE : Yes program update
+/// - FALSE : No program update
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusBadConnection Failure to socket connection
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred(Socket Connection/Memory Allocation/Event Control)
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a send and receive type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor not for the transmission and reception of the System Manager of the session message.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) occurs during the transmission and reception of the System Manager
+/// of the session message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - The size of the transmit and receive buffer of the System Manager of the session message is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - It failed to socket connection for transmission and reception of the System Manager of the session message.
+/// [eFrameworkunifiedStatusBadConnection]
+/// - Open error of the message queue for the reception of the System Manager of the session message.
+/// [eFrameworkunifiedStatusFail]
+/// - And fail to acquire the message buffer for reception of the System Manager of the session message.
+/// [eFrameworkunifiedStatusFail]
+/// - It failed in the event control for the reception of the System Manager of the session message.
+/// [eFrameworkunifiedStatusFail]
+/// - It failed during transmission and reception of the System Manager of the session message. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission and reception of the System Manager of the session
+/// message. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only(None communication)
+/// \~english @par Detail
+/// Returns the extended information of the parameters of FrameworkunifiedOnStop(). \n
+/// It is assumed that that will be called in the FrameworkunifiedOnStop (), return of the correct value in the case \n
+/// that has been called before FrameworkunifiedOnStop() entry into force is not guaranteed.
+/// \~english @see GetInterfaceunifiedOnStartExtInfo, FrameworkunifiedOnStop
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetInterfaceunifiedOnStopExtInfo(T_SS_SM_STOP_ExtDataStructType &f_info); // NOLINT (runtime/references)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendDebugDumpResponseToSystemManager
+/// \~english @par Summary
+/// Send a debug dump response to system_manager
+/// \~english @param [in] f_bFormatStrRequired
+/// BOOL - Specify whether to dump the application name or not
+/// \~english @param [in] f_cFormat
+/// PCSTR - Display format for the dump (the same character strings format as the printf format)
+/// \~english @param [in] arg_list
+/// ... - Dump data in line with f_cFormat format
+/// \~english @par
+/// f_bFormatStrRequired
+/// - true Dump the application name
+/// - false Do not dump the application name
+/// \~english @retval None
+/// \~english @par Precondition
+/// - None
+/// \~english @par Change in the internal status
+/// - The change in the internal status does not occur by this API.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget only
+/// \~english @par Detail
+/// When f_bFormatStrRequired is true, write the application name to the buffer for dump. \n
+/// Write the data to the buffer for dump in line with f_cFormat. \n
+/// Send OnDebugDumpResponseReceived to the SystemManger in order to request the SystemManger to
+/// write the contents in the buffer for dump to the log file for debug. \n
+/// The maximum size of the buffer for dump is 4Kbyte and the string size of the application name
+/// is deducted when the application name is dumped. \n
+/// When dumping a string which exceeds 4Kbyte, drop what exceeds the buffer.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////
+void SendDebugDumpResponseToSystemManager(BOOL f_bFormatStrRequired, PCSTR f_cFormat, ...)
+#ifdef __GNUC__
+ __attribute__((format(printf, 2, 3)));
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendInterfaceunifiedEmmcLogsRequestToSystemManager
+/// \~english @par Summary
+/// API to request a copy to the specified path of the LOG file of the built-in non-volatile area.
+/// \~english @param [in] f_path
+/// std::string - LOG destination file PATH
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - LOG destination file PATH is NULL(If f_path.c_str() is NULL). [eFrameworkunifiedStatusInvldBuf]
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a transmission type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Transmission for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the transmission of the System Manager
+/// message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmission buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - Transmission of System Manager message for the session fails to shared memory access. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method only
+/// \~english @par Detail
+/// To copy all of the files that exist in LOG storage area of the built-in non-volatile area in \n
+/// the path specified in the f_path. \n
+/// If you do not have a copy target, asynchronous response command: Returns the eFrameworkunifiedStatusOK as \n
+/// the message data of SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_RSPN.
+/// \~english @see SendClearLogsRequestToSystemManager
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendInterfaceunifiedEmmcLogsRequestToSystemManager(std::string f_path);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendClearLogsRequestToSystemManager
+/// \~english @par Summary
+/// API to clear the stored in the built-in non-volatile area log.
+/// \~english @param [in] f_info
+/// TSystemManagerClearLogsInfo - A pointer to the LOG clear information
+/// \~english @par
+/// TSystemManagerClearLogsInfo Structure
+/// \~english @code
+/// typedef struct T_SystemManagerClearLogsInfo{
+/// {
+/// void *rsv;
+/// }TSystemManagerClearLogsInfo;
+/// @endcode
+/// \~english @par
+/// rsv : Reserve area
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Invalid pointer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error(It failed to open/allocation of shared memory)
+/// \~english @par Preconditions
+/// - Dispatcher for the System Manager is generated, and Availability of the service is TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - Pointer to the LOG clear information (f_info) is NULL [eFrameworkunifiedStatusInvldParam]
+/// - System Manager of the session does not exist. [eFrameworkunifiedStatusNullPointer]
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - System Manager handle type for the session is not a transmission type. [eFrameworkunifiedStatusInvldHndlType]
+/// - System Manager message queue for the session is full. [eFrameworkunifiedStatusMsgQFull]
+/// - Transmission for the file descriptor of System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Place to interrupt by the system call (signal) has occurred during the transmission of the System Manager
+/// message for the session. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmission buffer of the System Manager message for the session is invalid.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// - Transmission of System Manager message for the session fails to shared memory access. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget x Sync
+/// \~english @par Detail
+/// To delete a LOG stored in the built-in non-volatile area.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendClearLogsRequestToSystemManager(TSystemManagerClearLogsInfo *f_info);
+
+/** @}*/ // end of SystemIf
+/** @}*/ // end of interface_unified
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief AttachCallbackToSystemManager
+///
+/// \note This function is called by System Manager session clients to attach
+/// a callback function to the client application with System Manager
+/// configured as the specified sender of the specified protocol message.
+///
+/// \param [in] f_hApp
+/// HANDLE - Handle to message queue of the System Manager attached client.
+/// \param [in] iCmd
+/// UI_32 iCmd - Command ID
+/// \param [in] fpOnCmd
+/// CbFuncPtr fpOnCmd - Function pointer to be called in the form upon
+/// the invokation of the specified command ID. The callback function
+/// must have the following signature : void (*)(HANDLE).
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus AttachCallbackToSystemManager(HANDLE hApp, UI_32 iCmd, CbFuncPtr fpOnCmd);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief Set of complementary detach functions that accept same arguments
+/// as the InterfaceunifiedAttach_XYZ_ToDispatcher() functions do.
+///
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus DetachCallbacksFromInterfaceunifiedDispatcher(HANDLE hApp,
+ PCSTR pServiceName,
+ const FrameworkunifiedProtocolCallbackHandler* pMsgHandler,
+ UI_32 uiHandlerCount,
+ HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+/// \brief
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus DetachParentCallbacksFromInterfaceunifiedDispatcher(HANDLE hChildApp,
+ const FrameworkunifiedProtocolCallbackHandler* pMsgHandler,
+ UI_32 uiHandlerCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief GetSystemManagerSessionHandle
+///
+/// \note This function returns the session handle with System Manager
+///
+/// \return HANDLE - A session handle with System Manager
+/////////////////////////////////////////////////////////////////////////////////////
+extern HANDLE GetSystemManagerSessionHandle(void);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendShutdownToSystemManager
+///
+/// \note This function is called to send Shutdown command to System Manager
+///
+/// \param [in] pData
+/// Pwr_ServiceSetInterface *pData - Pointer to Shutdown Command data
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SendShutdownToSystemManager(Pwr_ServiceSetInterface *pData);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendSystemModeRequestToSystemManager
+///
+/// \note This function is called to send system mode request to System Manager
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SendSystemModeRequestToSystemManager(void);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendInitCompReportToSystemManager
+///
+/// \note This function is called to send init comp report to System Manager
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SendInitCompReportToSystemManager(void);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendWakeUpToSystemManager
+///
+/// \note This function is called to send the Wakeup command to System Manager
+///
+/// \param [in] pData
+/// wakeInfo *pData - Pointer to Wakeup Command data
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SendWakeUpToSystemManager(wakeInfo *pData);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendStartupConfirmationToSystemManager
+///
+/// \note This function is called to send the startup confirmation information
+/// to System Manager
+///
+/// \param [in] l_startupConfirmationMsg
+/// StartupConfirmationMsgStrut &l_startupConfirmationMsg - startup confirmation
+/// data
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SendStartupConfirmationToSystemManager(StartupConfirmationMsgStrut
+ &l_startupConfirmationMsg);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendSystemErrorToSystemManager
+///
+/// \note This function is called by an application via Native Services to send
+/// notice of a critical error to System Manager when a non recoverable
+/// run-time error is encountered.
+///
+/// \param [in]
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendSystemErrorToSystemManager(EFrameworkunifiedSystemError f_systemError);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief Send_CWORD56_HeartBeatRequestToSystemManager
+///
+/// \note This function forwards a _CWORD56_ heartbeat request received by power
+/// services from the power shadow to System Manager.
+///
+/// \param [in]
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Send_CWORD56_HeartBeatRequestToSystemManager(EPWR_HB_REQ_MSG_STRUCT f_HbReq);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendBootMicroResetNotificationToSystemManager
+///
+/// \param ResetReason Enumerated boot micro reset reason.
+///
+/// This function is called by Logging Shadow to inform System Manager of a
+/// boot micro reset condition.
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendBootMicroResetNotificationToSystemManager(eSMBootMicroResetReason ResetReason);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendDiagLogEventRequestToSystemManager
+///
+/// \note This function is called by logger to initiate log artifact collection
+/// and storage on behalf of diagnostic services.
+///
+/// \param f_copyDestPathStr
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendDiagLoggingRequestToSystemManager(std::string f_copyDestPathStr);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendCANLoggingRequestToSystemManager
+///
+/// \note This function is called by logger to initiate log artifact collection
+/// and storage when signaled via CAN.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendCANLoggingRequestToSystemManager(void);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendDTCLoggingRequestToSystemManager
+///
+/// \note This function is called by logger to initiate log artifact collection
+/// and storage when signaled via diagnostic command.
+///
+/// \param f_dtc Diagnostic trouble code.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendDTCLoggingRequestToSystemManager(UI_32 f_dtc);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief RegisterBootMicroLogRequestCb
+///
+/// This function is called by Logging Shadow to register a callback function for
+/// the boot micro log request that may be generated by System Manager when an
+/// error event occurs.
+///
+/// \param [in] hApp AGL Framework Application Handle
+///
+/// \param [in] fpOnCmd Call back function with the signature:
+/// EFrameworkunifiedStatus fnct(HANDLE hApp);
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RegisterBootMicroLogRequestCb(HANDLE hApp, CbFuncPtr fpOnCmd);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendBootMicroLogResponseToSystemManager
+///
+/// This function is called by Logging Shadow to provide a string representation of
+/// the binary boot-micro log data.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendBootMicroLogResponseToSystemManager(std::string f_logString);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+/// \brief Redirect either formatted, or unformatted response output to System Manager.
+///
+/// \see SendDebugDumpResponseToSystemManager
+////////////////////////////////////////////////////////////////////////////////////////////
+#define SSDEBUGDUMP(args...) (SendDebugDumpResponseToSystemManager(TRUE, ## args))
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SM_Deletable
+////////////////////////////////////////////////////////////////////////////////////////////
+#define SSDEBUGDUMP_RAW(args...) (SendDebugDumpResponseToSystemManager(FALSE, ## args))
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendLogStartRequestToSystemManager
+///
+/// \note This function is call by SS_Logger when the logging process has
+/// completed and no additional request for artifacts will be generated.
+///
+/// \param none.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendLogStartRequestToSystemManager(EErrorEventType f_errorEventType);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendLogArtifactRequestToSystemManager
+///
+/// \note This function is call by SS_Logger to request SM to acquire and
+// return by reference (filename), the specified logging artifact.
+///
+/// \param [in] f_artifactId, enumerated artifact number.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendLogArtifactRequestToSystemManager(EArtifactId f_artifactId);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendLogCompleteRequestToSystemManager
+///
+/// \note This function is call by SS_Logger when the logging process has
+/// completed and no additional request for artifacts will be generated.
+///
+/// \param none.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendLogCompleteRequestToSystemManager(EFrameworkunifiedStatus f_eStatus = eFrameworkunifiedStatusOK);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief SendEelExportRequestToSystemManager
+///
+/// \note This function forwards the Device Detection EEL_export trigger
+/// received by SS Logger to System Manager.
+///
+/// \param f_path Destination path for the trigger artifacts.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendEelExportRequestToSystemManager(std::string f_path);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup interface_unified
+///
+/// \brief DebugDump request callback function.
+///
+/// \note This function is called when System Manager requests the receiving
+/// application to generate their debugdump.
+///
+/// \param hApp
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus OnSystemManagerDebugDump(HANDLE hApp);
+
+#endif // __SS_SYSTEM_MANAGER_CLIENT_IF_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_sm_client_if_local.h b/systemservice/interface_unified/library/include/system_service/ss_sm_client_if_local.h
new file mode 100755
index 0000000..a4d0fa9
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_sm_client_if_local.h
@@ -0,0 +1,66 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_sm_client_if_local.h
+ * @brief \~english This file supports the api of debug dump response to System Manager
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef __SS_SYSTEM_MANAGER_CLIENT_IF_LOCAL_H__ // NOLINT (build/header_guard)
+#define __SS_SYSTEM_MANAGER_CLIENT_IF_LOCAL_H__
+
+#include <native_service/frameworkunified_framework_types.h>
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup system_manager
+/// \~english @par Summary:
+/// Responds to SystemManager that debug dump output has finished
+/// \~english @param [in] f_messageStr
+/// std::string & - Dump data
+/// \~english @retval
+/// - None
+/// \~english @par Preconditions:
+/// - None
+/// \~english @par Change of the internal state:
+/// - No change of internal state by this API occurs
+/// \~english @par Causes of failures:
+/// - None
+/// \~english @par Detail:
+/// Send OnDebugDumpResponseReceived to SystemManager and request
+/// to write the contents of dump data to /tmp/systemmanager_debugdump.log.\n
+/// The maximum size of the dump buffer is 4KByte.\n
+/// When dumping more than 4KBytes, the overflow from the buffer is discarded.
+///
+/// \~english @par Classification:
+/// - Public
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+
+VOID SendDebugDumpResponseToSystemManager(std::string & f_messageStr); // NOLINT (runtime/references)
+
+#endif /*__SS_SYSTEM_MANAGER_CLIENT_IF_LOCAL_H__*/ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_sm_thread_names.h b/systemservice/interface_unified/library/include/system_service/ss_sm_thread_names.h
new file mode 100755
index 0000000..61ee275
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_sm_thread_names.h
@@ -0,0 +1,45 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_sm_thread_names.h
+ * @brief This file supports System Manager thread naming.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SS_SM_THREAD_NAMES_H_ // NOLINT (build/header_guard)
+#define SS_SM_THREAD_NAMES_H_
+
+// thread name max length is 15
+// 0123456789ABCDE
+#define SS_SMHeartbeat "SM.Heartbeat"
+
+#endif /* SS_SM_THREAD_NAMES_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_sm_thread_names_local.h b/systemservice/interface_unified/library/include/system_service/ss_sm_thread_names_local.h
new file mode 100755
index 0000000..36dda06
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_sm_thread_names_local.h
@@ -0,0 +1,46 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_sm_thread_names_local.h
+ * @brief This file supports System Manager thread naming.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SS_SM_THREAD_NAMES_LOCAL_H_ // NOLINT (build/header_guard)
+#define SS_SM_THREAD_NAMES_LOCAL_H_
+
+// thread name max length is 15
+// 0123456789ABCDE
+#define SS_SMLauncher "SM.ProcLaunch"
+#define SS_SMLowMemMonitor "SM.LowMemMon"
+
+#endif /* SS_SM_THREAD_NAMES_LOCAL_H_ */ // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_string_maps.h b/systemservice/interface_unified/library/include/system_service/ss_string_maps.h
new file mode 100755
index 0000000..4001ed4
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_string_maps.h
@@ -0,0 +1,680 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_string_maps.h
+ * @brief \~english This file supports the a generic std::map<std::string> wrapper.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_STRING_MAPS_H_ // NOLINT (build/header_guard)
+#define SS_STRING_MAPS_H_
+
+#include "system_service/ss_power_service.h"
+#include "system_service/ss_system_manager_if.h"
+#include "system_service/ss_system_manager_protocol.h"
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from BOOL type to string
+/// \~english @param [in] f_enum
+/// BOOL - the member what will convert farm BOOL type to string type
+/// \~english @code
+/// typedef int BOOL;
+/// #define TRUE (1==1)
+/// #define true (1==1)
+/// #define FALSE (0==1)
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from BOOL type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(BOOL f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EErrorEventType type to string
+/// \~english @param [in] f_enum
+/// EErrorEventType - the member what will convert farm EErrorEventType type to string type.error event type.
+/// \~english @code
+/// enum EErrorEventType {
+/// eErrorEventTypeProcessCrash = 0,
+/// eErrorEventTypeHeartBeatFailure,
+/// eErrorEventTypeSystemLowMemory,
+/// eErrorEventTypeReserved1, // Formerly SS_SM_EVENT_ERROR_HIGH_CPU_LOAD, now HMI enum place holder.
+/// eErrorEventTypeUserInvokedUserForceReset,
+/// eErrorEventTypeReserved2,
+/// eErrorEventTypeReserved3,
+/// eErrorEventTypeUserInvokedCollectAllLogs,
+/// eErrorEventTypeBootMicroReset,
+/// eErrorEventTypeProcessExit,
+/// eErrorEventTypeUserInvokedCollectScreenShot,
+/// eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs,
+/// eErrorEventTypeEelExport,
+/// eErrorEventTypeInterfaceunifiedEmmcLogs,
+/// eErrorEventTypeDiagEvent,
+/// eErrorEventTypeCanEvent,
+/// eErrorEventTypeDtcEvent,
+/// eErrorEventTypeModConnFailed,
+/// eErrorEventTypeStartRespFailed,
+/// eErrorEventTypeUserInvokedCollectDevLogs,
+/// eErrorEventTypeModuleInvokedResetRequest,
+/// eErrorEventTypeModuleInvokedCollectDebugLogs,
+/// eErrorEventTypeUserInvokedClearLogs,
+/// eErrorEventTypeUserInvokedCollectNaviLog,
+/// eErrorEventTypeGroupRelaunch,
+/// eErrorEventTypeMaxValue
+/// };
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EErrorEventType type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EErrorEventType f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EFrameworkunifiedSystemError type to string
+/// \~english @param [in] f_enum
+/// EFrameworkunifiedSystemError - the member what will convert farm EFrameworkunifiedSystemError type to string type.The type of system
+/// error.
+/// \~english @codes
+/// typedef enum _EFrameworkunifiedSystemError {
+/// eFrameworkunifiedSystemErrorNone = 0,
+/// eFrameworkunifiedDSPHardwareReset = 1
+/// } EFrameworkunifiedSystemError;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EFrameworkunifiedSystemError type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EFrameworkunifiedSystemError f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_LHC_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_LHC_TYPE - the member what will convert farm EPWR_LHC_TYPE type to string type.Limp home cutoff
+/// protocol type.
+/// \~english @codes
+/// typedef enum {
+/// epslhcINVALID = 0xFF,
+/// epslhcDISABLED = 0x00,
+/// epslhcENABLED = 0x01
+/// } ePwrServiceLHCType, EPWR_LHC_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_LHC_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_LHC_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_PROD_MODE_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_PROD_MODE_TYPE - the member what will convert farm EPWR_PROD_MODE_TYPE type to string type.The type of
+/// production mode protocol.
+/// \~english @codes
+/// typedef enum {
+/// epspmINVALID = 0xFF,
+/// epspmDISABLED = 0x00,
+/// epspmENABLED = 0x01
+/// } ePwrServiceProdModeType, EPWR_PROD_MODE_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_PROD_MODE_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_PROD_MODE_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_SC_COLD_START_REQ_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_SC_COLD_START_REQ_TYPE - the member what will convert farm EFrameworkunifiedSystemError type to string type.The type
+/// of cold start.
+/// \~english @codes
+/// typedef enum {
+/// epsscrtINVALID = 0xFF,
+/// epsscrtNOT_REQUIRED = 0x00,
+/// epsscrtREQUIRED = 0x01
+/// } EPWR_SC_COLD_START_REQ_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_SC_COLD_START_REQ_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_SC_COLD_START_REQ_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_SC__CWORD56__BOOT_MODE_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_SC__CWORD56__BOOT_MODE_TYPE - the member what will convert farm EPWR_SC__CWORD56__BOOT_MODE_TYPE type to string
+/// type.The type of startup confirmation.
+/// \~english @codes
+/// typedef enum {
+/// eps_CWORD56_bmINVALID = 0xFF,
+/// eps_CWORD56_bmAPPLICATION_MODE = 0x00,
+/// eps_CWORD56_bmPROGRAMMING_MODE = 0x08
+/// } EPWR_SC__CWORD56__BOOT_MODE_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_SC__CWORD56__BOOT_MODE_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_SC__CWORD56__BOOT_MODE_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_SHUTDOWN_TRIGGER_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_SHUTDOWN_TRIGGER_TYPE - the member what will convert farm EPWR_SHUTDOWN_TRIGGER_TYPE type to string
+/// type.The type of shutdown trigger.
+/// \~english @codes
+/// typedef enum {
+/// epssdmsdtINVALID = 0xFF,
+/// epssdmsdtTESTACC_OFF = 0x00,
+/// epssdmsdtON_KEY = 0x01,
+/// epssdmsdtIGN_LOCK = 0x02,
+/// epssdmsdtPWR_SAVE = 0x03,
+/// epssdmsdtTMP_STARTUP = 0x04,
+/// epssdmsdtDIAG_DEACTIVATION = 0x05,
+/// epssdmsdtABNORMAL_VOLTAGE = 0x06,
+/// epssdmsdtABNORMAL_TEMP = 0x07,
+/// epssdmsdtBATTERYCUTOFF = 0x08,
+/// epssdmsdtLIMPHOME = 0x09,
+/// epssdmsdtHU_CAN_ERROR = 0x0A,
+/// epssdmsdtBODY_CAN_ERROR = 0x0B,
+/// epssdmsdtTRANSPORT_MODE = 0x0C,
+/// epssdmsdtPRODUCTION_MODE = 0x0D,
+/// epssdmsdtIGN_OFF = 0x0E,
+/// epssdmsdtGENERIC_ERROR_RESET = 0x0F,
+/// epssdmsdtFATAL_ERROR_RESET = 0x10,
+/// epssdmsdtUSER_DATA_RESET = 0x11,
+/// epssdmsdtFACTORY_DATA_RESET = 0x12,
+/// epssdmsdtFAST_SLEEP_MODE = 0x13,
+/// epssdmsdtNORMAL_RESET = 0x14,
+/// epssdmsdtPROGUPDATE_RESET = 0x15,
+/// } ePowerSrvPwrShutdownTriggerType, EPWR_SHUTDOWN_TRIGGER_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_SHUTDOWN_TRIGGER_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_SHUTDOWN_TRIGGER_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_STARTUP_STAGE_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_STARTUP_STAGE_TYPE - the member what will convert farm EPWR_STARTUP_STAGE_TYPE type to string type.The
+/// type of startup stage.
+/// \~english @codes
+/// typedef enum {
+/// epssusfINVALID = 0xFF,
+/// epssusSYSTEM_SERVICES_STARTED = 0x00,
+/// epssusALL_SERVICES_LAUNCHED = 0x01
+/// }ePowerSrvStartupStageType, EPWR_STARTUP_STAGE_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_STARTUP_STAGE_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_STARTUP_STAGE_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_SYSTEM_MODE_INFO type to string
+/// \~english @param [in] f_enum
+/// EPWR_SYSTEM_MODE_INFO - the member what will convert farm EPWR_SYSTEM_MODE_INFO type to string type.The type
+/// of system mode info.
+/// \~english @codes
+/// typedef enum {
+/// epssinfINVALID = 0xFF,
+/// epssinfNORMAL = 0x00,
+/// epssinfPROGRAMMING = 0x08,
+/// }ePowerSrvSystemModeInfo, EPWR_SYSTEM_MODE_INFO;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_SYSTEM_MODE_INFO type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_SYSTEM_MODE_INFO f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_TRANSPORT_MODE_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_TRANSPORT_MODE_TYPE - the member what will convert farm EPWR_TRANSPORT_MODE_TYPE type to string
+/// type.The type of transport mode protocol.
+/// \~english @codes
+/// typedef enum {
+/// epstmINVALID = 0xFF,
+/// epstmDISABLED = 0x00,
+/// epstmENABLED = 0x01
+/// } ePwrServiceTransportModeType, EPWR_TRANSPORT_MODE_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_TRANSPORT_MODE_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_TRANSPORT_MODE_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from \ref ePwrServiceUserModeChangeReasonType "EPWR_USER_MODE_CHANGE_REASON_TYPE" type to string
+/// \~english @param [in] f_enum
+/// \ref ePwrServiceUserModeChangeReasonType "EPWR_USER_MODE_CHANGE_REASON_TYPE" - the member what will convert farm \ref ePwrServiceUserModeChangeReasonType "EPWR_USER_MODE_CHANGE_REASON_TYPE" type
+/// to string type.The type of user mode change reason.
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from type \ref ePwrServiceUserModeChangeReasonType "EPWR_USER_MODE_CHANGE_REASON_TYPE" to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_USER_MODE_CHANGE_REASON_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_USER_MODE_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_USER_MODE_TYPE - the member what will convert farm EPWR_USER_MODE_TYPE type to string type.The type of
+/// user mode.
+/// \~english @codes
+/// typedef enum {
+/// epsumINVALID = 0xFF,
+/// epsumOFF = 0x00,
+/// epsumON = 0x01,
+/// } ePwrServiceUserModeType, EPWR_USER_MODE_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_USER_MODE_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_USER_MODE_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from EPWR_WAKEUP_FACTOR_TYPE type to string
+/// \~english @param [in] f_enum
+/// EPWR_WAKEUP_FACTOR_TYPE - the member what will convert farm EPWR_WAKEUP_FACTOR_TYPE type to string type.The
+/// type of startup reason.
+/// \~english @codes
+/// typedef enum {
+/// epswfINVALID = 0xFF,
+/// epswfTESTACC = 0x00,
+/// epswfON_KEY = 0x01,
+/// epswfIGN_ACC = 0x02,
+/// epswfDR_OPEN_CLOSE = 0x03,
+/// epswfDX_ACTIVATION = 0x04,
+/// epswfPASS_ACTIVATION = 0x05,
+/// epswfSPVACTIVATION = 0x06,
+/// epswfUSER_DATA_RESET = 0x07
+/// } ePowerSrvWakeupFactors, EPWR_WAKEUP_FACTOR_TYPE;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EPWR_WAKEUP_FACTOR_TYPE type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EPWR_WAKEUP_FACTOR_TYPE f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr JP_ZPT
+/// \~english @par Summary
+/// change member from EFrameworkunifiedStatus type to string
+/// \~english @param [in] f_enum
+/// EFrameworkunifiedStatus - the member what will convert farm EFrameworkunifiedStatus type to string type.Status and return types.
+/// \~english @codes
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from EFrameworkunifiedStatus type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(EFrameworkunifiedStatus f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from ESMBootModeInfo type to string
+/// \~english @param [in] f_enum
+/// ESMBootModeInfo - the member what will convert farm ESMBootModeInfo type to string type.The type of boot
+/// mode information.
+/// \~english @codes
+/// typedef enum {
+/// e_SS_SM_BOOT_MODE_INVALID = -1
+/// , e_SS_SM_BOOT_MODE_APPLICATION
+/// , e_SS_SM_BOOT_MODE_PROGRAMMING
+/// }ESMBootModeInfo;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from ESMBootModeInfo type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(ESMBootModeInfo f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from ESMCpuResetReason type to string
+/// \~english @param [in] f_enum
+/// ESMCpuResetReason - the member what will convert farm ESMCpuResetReason type to string type.The type of CPU
+/// reset reason.
+/// \~english @codes
+/// typedef enum {
+/// e_SS_SM_CPU_RESET_REASON_INVALID = -1
+/// , e_SS_SM_CPU_RESET_REASON_NORMAL = 0
+/// , e_SS_SM_CPU_RESET_REASON_DATA_RESET
+/// , e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET
+/// , e_SS_SM_CPU_RESET_REASON_GENERIC
+/// , e_SS_SM_CPU_RESET_REASON_GENERIC_ERR = e_SS_SM_CPU_RESET_REASON_GENERIC
+/// , e_SS_SM_CPU_RESET_REASON_DSP_ERR
+/// , e_SS_SM_CPU_RESET_REASON_IMMRESET_NORMAL
+/// , e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR
+/// }ESMCpuResetReason;
+/// @endcode
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from ESMCpuResetReason type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(ESMCpuResetReason f_enum);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetStr
+/// \~english @par Summary
+/// change member from \ref _SS_SystemManagerProtocol "SS_SystemManagerProtocol" type to string
+/// \~english @param [in] f_enum
+/// \ref _SS_SystemManagerProtocol "SS_SystemManagerProtocol" - the member what will convert farm \ref SS_SystemManagerProtocol "SS_SystemManagerProtocol" type to string
+/// type.The type of system manager protocol.
+/// \~english @retval SS_String
+/// \~english @par Preconditions
+/// - None.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// change member from \ref _SS_SystemManagerProtocol) "SS_SystemManagerProtocol" type to string. \n
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+extern SS_String GetStr(SS_SystemManagerProtocol f_enum);
+
+#endif /* SS_STRING_MAPS_H_ */ // NOLINT (build/header_guard)
+// EOF ss_string_maps.h
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_sys_boot_area_map.h b/systemservice/interface_unified/library/include/system_service/ss_sys_boot_area_map.h
new file mode 100755
index 0000000..7df0c88
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_sys_boot_area_map.h
@@ -0,0 +1,39 @@
+/*
+ * @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.
+ */
+/**
+ * @file ss_sys_boot_area_map.h
+ * @brief \~english This file supports system area type definitions
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef __SS_SYS_BOOT_AREA_MAP_H__ // NOLINT (build/header_guard)
+#define __SS_SYS_BOOT_AREA_MAP_H__
+
+#include <system_service/ss_sm_boot_access.h>
+
+#endif /* __SS_SYS_BOOT_AREA_MAP_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_if.h b/systemservice/interface_unified/library/include/system_service/ss_system_if.h
new file mode 100755
index 0000000..1e3ef14
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_if.h
@@ -0,0 +1,119 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_system_if.h
+ * @brief \~english This file contains api build the session of heartbeat observation system manager
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_SYSTEM_IF_H_ // NOLINT (build/header_guard)
+#define SS_SYSTEM_IF_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_sm_framework_if.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup system_manager
+/// \~english @par Summary:
+/// Establish SystemManger and HeartBeat monitoring session
+/// \~english @param [in] hApp
+/// HANDLE - Handle for application
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Handle error
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue error
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF File descriptor error
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR System call error
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Message buffer error
+/// \~english @retval eFrameworkunifiedStatusErrOther Session establishment failure
+/// \~english @retval eFrameworkunifiedStatusFail Message sharing memory error
+
+/// \~english @par Preconditions:
+/// - Dispather for application is created / initialized(FrameworkunifiedCreateDispatcherWithoutLoop etc.)
+/// \~english @par Change of the internal state:
+/// - No change of internal state by this API occurs
+/// \~english @par Causes of failures:
+/// - Handle(hApp) specified in the argument is not appropriate(invalid) [eFrameworkunifiedStatusNullPointer]
+/// - Management information area acquisition(malloc) failed [eFrameworkunifiedStatusNullPointer]
+/// - Message queue for session for service is full [eFrameworkunifiedStatusMsgQFull]
+/// - Invalid file descriptor for sending session messages for service [eFrameworkunifiedStatusErrNoEBADF]
+/// - System call(signal) interrupt occurs
+/// while sending a session message for a service [eFrameworkunifiedStatusErrNoEINTR]
+/// - The size of the message transmission buffer for service is incorrect [eFrameworkunifiedStatusInvldBufSize]
+/// - Some error occurred when sending session message for service [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending session messages for service [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail:
+/// Establish HeartBeat monitoring and SystemManager session.\n
+///
+/// \~english @par Classification:
+/// Public
+/// \~english @see FrameworkunifiedMcOpenSender, FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedSendMsg
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE hApp);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(IMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND)
+#define FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(x) \
+ x.onInitilization = FrameworkunifiedOnInitialization; \
+ x.onDestroy = FrameworkunifiedOnDestroy; \
+ x.onStart = FrameworkunifiedOnStart; \
+ x.onStop = FrameworkunifiedOnStop; \
+ x.onDebugDump = FrameworkunifiedOnDebugDump; \
+ x.createStateMachine = FrameworkunifiedCreateStateMachine; \
+ x.ssFrameworkInterface = FrameworkunifiedSSFrameworkInterface; \
+ x.onPreStart = FrameworkunifiedOnDummy; \
+ x.onPreStop = FrameworkunifiedOnDummy; \
+ x.onBackgroundStart = FrameworkunifiedOnDummy; \
+ x.onBackgroundStop = FrameworkunifiedOnDummy;
+#else
+#define FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(x) \
+ x.onInitilization = FrameworkunifiedOnInitialization; \
+ x.onDestroy = FrameworkunifiedOnDestroy; \
+ x.onStart = FrameworkunifiedOnStart; \
+ x.onStop = FrameworkunifiedOnStop; \
+ x.onDebugDump = FrameworkunifiedOnDebugDump; \
+ x.createStateMachine = FrameworkunifiedCreateStateMachine; \
+ x.ssFrameworkInterface = FrameworkunifiedSSFrameworkInterface; \
+ x.onPreStart = FrameworkunifiedOnPreStart; \
+ x.onPreStop = FrameworkunifiedOnPreStop; \
+ x.onBackgroundStart = FrameworkunifiedOnBackgroundStart; \
+ x.onBackgroundStop = FrameworkunifiedOnBackgroundStop;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* SS_SYSTEM_IF_H_ */ // NOLINT (build/header_guard)
+/** @}*/ // end of interface_unified
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_manager_if.h b/systemservice/interface_unified/library/include/system_service/ss_system_manager_if.h
new file mode 100755
index 0000000..e6b4f8d
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_manager_if.h
@@ -0,0 +1,335 @@
+/*
+ * @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 system_manager
+/// \file ss_system_manager_if.h
+/// \brief This file supports the System Manager client interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SYSTEM_MANAGER_IF_H_ // NOLINT (build/header_guard)
+#define SS_SYSTEM_MANAGER_IF_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_sm_ram_access.h>
+#include "system_service/ss_system_if.h"
+#include "system_service/ss_error_event_common.h"
+#include "system_service/ss_power_service.h"
+
+/// \ingroup system_manager
+/// \brief Boot mode information
+typedef enum {
+ e_SS_SM_BOOT_MODE_INVALID = -1
+ , e_SS_SM_BOOT_MODE_APPLICATION
+ , e_SS_SM_BOOT_MODE_PROGRAMMING
+}ESMBootModeInfo;
+
+/// \ingroup system_manager
+/// \brief Data reset mode information
+typedef enum {
+ e_SS_SM_DATA_RESET_MODE_NONE
+ , e_SS_SM_DATA_RESET_MODE_USER
+ , e_SS_SM_DATA_RESET_MODE_FACTORY
+ , e_SS_SM_DATA_RESET_MODE_PROGUPDATE // cannot use this
+}ESMDataResetModeInfo;
+
+/// \ingroup system_manager
+/// \brief Program update status
+typedef UI_32 SMProgUpdateState;
+#define SS_SM_PROG_UPDATE_STATE_NONE 0x0000
+#define SS_SM_PROG_UPDATE_STATE_UPDATED 0x0001
+#define SS_SM_PROG_UPDATE_STATE_MAP_UPDATED 0x0002
+#define SS_SM_PROG_UPDATE_STATE_MAPDIFF_UPDATED 0x0004
+
+/// Set Next Wakeup type information
+typedef enum {
+ e_SS_SM_NEXT_WAKEUP_TYPE_NONE = 0
+ , e_SS_SM_NEXT_WAKEUP_TYPE_COLD
+ , e_SS_SM_NEXT_WAKEUP_TYPE_HOT
+}ESMNextWakeupType;
+
+/// \ingroup system_manager
+/// \brief DRAM backup status
+typedef enum {
+ e_SS_SM_DRAM_BACKUP_UNSET = -1
+ , e_SS_SM_DRAM_BACKUP_OK
+ , e_SS_SM_DRAM_BACKUP_NG
+}ESMDramBackupStatus;
+
+/// \ingroup system_manager
+/// \brief Reset status
+typedef enum {
+ e_SS_SM_RESET_STATUS_UNSET = -1
+ , e_SS_SM_RESET_STATUS_NONE
+ , e_SS_SM_RESET_STATUS_NG
+ , e_SS_SM_RESET_STATUS_IMMEDIATE
+}ESMResetStatus;
+
+/// \ingroup system_manager
+/// \brief Relaunch status
+typedef enum {
+ e_SS_SM_RELAUNCH_STATUS_NONE
+ , e_SS_SM_RELAUNCH_STATUS_SAFE
+ , e_SS_SM_RELAUNCH_STATUS_ERR
+}EMRelaunchStatus;
+
+
+/// \ingroup system_manager
+/// \brief CPU Reset Reason
+typedef enum {
+ e_SS_SM_CPU_RESET_REASON_INVALID = -1
+ , e_SS_SM_CPU_RESET_REASON_NORMAL = 0
+ , e_SS_SM_CPU_RESET_REASON_DATA_RESET
+ , e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET
+ , e_SS_SM_CPU_RESET_REASON_GENERIC
+ , e_SS_SM_CPU_RESET_REASON_GENERIC_ERR = e_SS_SM_CPU_RESET_REASON_GENERIC
+ , e_SS_SM_CPU_RESET_REASON_DSP_ERR
+ , e_SS_SM_CPU_RESET_REASON_IMMRESET_NORMAL
+ , e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR // DRAM backup will be discarded after reset
+}ESMCpuResetReason;
+
+/// \ingroup system_manager
+/// \brief CPU Reset Info
+typedef struct T_SystemManagerCpuResetInfo {
+#define SS_SM_RESET_MSG_STR_SIZE 64
+#define SS_SM_SUFFIX_STR_SIZE 32
+ ESMCpuResetReason resetReason;
+ CHAR messageStr[SS_SM_RESET_MSG_STR_SIZE];
+ CHAR suffixStr[SS_SM_SUFFIX_STR_SIZE];
+ T_SystemManagerCpuResetInfo
+ () : resetReason(e_SS_SM_CPU_RESET_REASON_INVALID) {
+ }
+}TSystemManagerCpuResetInfo;
+
+
+/// \ingroup system_manager
+/// \brief Data Reset Reason
+typedef enum {
+ e_SS_SM_DATA_RESET_TYPE_USER = 0
+ , e_SS_SM_DATA_RESET_TYPE_FACTORY // AKA Shipment Mode
+ , e_SS_SM_DATA_RESET_TYPE_CONFIGURATION
+ , e_SS_SM_DATA_RESET_TYPE_PROGUPDATE // cannot use this
+}ESMDataResetType;
+
+typedef enum {
+ e_SS_SM_SVC_WAKEUP_STATUS_COMPLETE = 0x01
+}ESMServiceWakeupStatus;
+
+/// \ingroup system_manager
+/// \brief Data Reset Reason
+typedef struct T_SS_BootModeListStruct {
+ ESMBootModeInfo hostBootMode;
+ EPWR_SC__CWORD56__BOOT_MODE_TYPE _CWORD56_BootMode;
+} TSS_BootModeListStruct;
+
+//****************************************************************************
+/// \ingroup system_manager *
+/// Data passed in the NTFY_SSSystemMgrPowerOnOff and *
+/// NTFY_SSSystemMgrUserMode notification messages *
+
+/// \ingroup system_manager
+typedef struct T_SS_SM_UserModeOnOffNotification_Struct { // *
+ BOOL isUserModeOn; // *
+ EPWR_WAKEUP_FACTOR_TYPE startupReason; // *
+ EPWR_USER_MODE_CHANGE_REASON_TYPE userModeChangeReason; // *
+ T_SS_SM_UserModeOnOffNotification_Struct // *
+ () : isUserModeOn(FALSE), // *
+ startupReason(epswfINVALID), // *
+ userModeChangeReason(epsumcrNOT_AVAILABLE) { // *
+ } // *
+ T_SS_SM_UserModeOnOffNotification_Struct // *
+ (BOOL f_bUserMode, // *
+ EPWR_WAKEUP_FACTOR_TYPE f_startupReason, // *
+ EPWR_USER_MODE_CHANGE_REASON_TYPE f_changeReason) // *
+ : isUserModeOn(f_bUserMode), // *
+ startupReason(f_startupReason), // *
+ userModeChangeReason(f_changeReason) { // *
+ } // *
+ // *
+} T_SS_SM_UserModeOnOffNotification_StructType; // *
+// *
+// End of Data passed as part of NTFY_SSSystemMgrPowerOnOff notification ... *
+//****************************************************************************
+
+
+//****************************************************************************
+/// \ingroup system_manager
+/**
+ * \~english Parameters of the following message. \n
+ * SS_SM_START 'FrameworkunifiedOnStart'/'evStart' \n
+ * SS_SM_PRE_START 'FrameworkunifiedOnPreStart'/'evPreStart' \n
+ * SS_SM_BACKGROUND_START 'FrameworkunifiedOnBackgroundStart'/'evBackgroundStart' \n
+ */
+typedef struct T_SS_SM_START_DataStruct {
+ EPWR_WAKEUP_FACTOR_TYPE startupReason; //!< \~english
+ BOOL isUserModeOn; //!< \~english
+ ESMDataResetModeInfo dataResetMode; //!< \~english
+ EPWR_SC_SECURITY_STATUS securityStatus; //!< \~english
+ EPWR_SC_WAKEUP_TYPE wakeupType; //!< \~english
+ ESMDramBackupStatus dramBackupStatus; //!< \~english
+ ESMResetStatus resetStatus; //!< \~english
+ UI_32 errResetCount; //!< \~english
+ /**
+ * \~english Constructor
+ */
+ T_SS_SM_START_DataStruct
+ () : startupReason(epswfINVALID),
+ isUserModeOn(FALSE),
+ dataResetMode(e_SS_SM_DATA_RESET_MODE_NONE),
+ securityStatus(epsssINVALID),
+ wakeupType(epsstINVALID),
+ dramBackupStatus(e_SS_SM_DRAM_BACKUP_UNSET),
+ resetStatus(e_SS_SM_RESET_STATUS_UNSET),
+ errResetCount(0) {}
+ /**
+ * \~english Constructor
+ */
+ T_SS_SM_START_DataStruct
+ (EPWR_WAKEUP_FACTOR_TYPE f_startupReason,
+ BOOL f_isUserModeOn,
+ ESMDataResetModeInfo f_dataResetMode,
+ EPWR_SC_SECURITY_STATUS f_securityStatus,
+ EPWR_SC_WAKEUP_TYPE f_wakeupType,
+ ESMDramBackupStatus f_dramBackupStatus,
+ ESMResetStatus f_resetStatus,
+ UI_32 f_resetCount)
+ : startupReason(f_startupReason),
+ isUserModeOn(f_isUserModeOn),
+ dataResetMode(f_dataResetMode),
+ securityStatus(f_securityStatus),
+ wakeupType(f_wakeupType),
+ dramBackupStatus(f_dramBackupStatus),
+ resetStatus(f_resetStatus),
+ errResetCount(f_resetCount) {}
+} T_SS_SM_START_DataStructType;
+// *
+// End of Data passed as part of SS_SM_START 'FrameworkunifiedOnStart'/'evStart' message *
+//****************************************************************************
+
+//****************************************************************************
+/// \ingroup system_manager
+/// Data passed as part of SS_SM_STOP 'FrameworkunifiedOnStop'/'evStop' message *
+typedef struct T_SS_SM_STOP_DataStruct { // *
+ EPWR_SHUTDOWN_TRIGGER_TYPE shutdownTrigger; // *
+ EPWR_USER_MODE_TYPE lastUserMode; // *
+} T_SS_SM_STOP_DataStructType; // *
+// *
+// End of Data passed as part of SS_SM_STOP 'FrameworkunifiedOnStop'/'evStop' message // *
+//****************************************************************************
+
+//****************************************************************************
+/// \ingroup system_manager
+/// Extended Parameter for FrameworkunifiedOnStart *
+typedef struct { // *
+#define SS_SM_START_EXT_INFO_SIZE 64 // *
+#define SS_SM_START_EXT_BODY_SIZE ( sizeof(BOOL) \
+ + sizeof(EMRelaunchStatus) \
+ + sizeof(BOOL) \
+ + sizeof(BOOL) \
+ )
+
+#define SS_SM_START_EXT_RSV_SIZE SS_SM_START_EXT_INFO_SIZE \
+ - SS_SM_START_EXT_BODY_SIZE // *
+ BOOL isProgUpdated; // *
+ EMRelaunchStatus relaunchStatus; // *
+ BOOL isMapUpdated; // *
+ BOOL isMapDiffUpdated; // *
+ uint8_t reserved[SS_SM_START_EXT_RSV_SIZE]; // *
+} T_SS_SM_START_ExtDataStructType; // *
+// *
+// End of Extended Parameter for FrameworkunifiedOnStart *
+//****************************************************************************
+
+//****************************************************************************
+/// \ingroup system_manager
+/// Extended Parameter for FrameworkunifiedOnStop *
+typedef struct { // *
+#define SS_SM_STOP_EXT_INFO_SIZE 64 // *
+#define SS_SM_STOP_EXT_BODY_SIZE (sizeof(BOOL)) // *
+#define SS_SM_STOP_EXT_RSV_SIZE SS_SM_STOP_EXT_INFO_SIZE \
+ - SS_SM_STOP_EXT_BODY_SIZE // *
+ BOOL isProgUpdated; // *
+ uint8_t reserved[SS_SM_STOP_EXT_RSV_SIZE]; // *
+}T_SS_SM_STOP_ExtDataStructType; // *
+// *
+// End of Extended Parameter for FrameworkunifiedOnStop *
+//****************************************************************************
+
+struct SMErrorEventNtfData {
+#define SM_MODULE_NAME_SIZE 64
+ EErrorEventType EventType;
+ CHAR ModuleName[SM_MODULE_NAME_SIZE];
+ BOOL isNeedReboot;
+};
+
+//*************************************************************************
+// Boot Micro Logging Protocol *
+// *
+enum eSMBootMicroResetReason {
+ SS_SM_BOOT_MICRO_RESET_REASON_SELF_RESET = 0,
+ SS_SM_BOOT_MICRO_RESET_REASON_USER_FORCE_RESET,
+ SS_SM_BOOT_MICRO_RESET_REASON_DSP_RESET,
+ SS_SM_BOOT_MICRO_RESET_REASON_HB_TIMEOUT
+};
+// *
+// End of Boot Micro Logging Protocol *
+//*************************************************************************
+
+
+//****************************************************************************
+/// \ingroup system_manager *
+/// Error Event Logging enumerations *
+///
+enum eSMUserLogType {
+ e_SS_SM_CAPTURE_ALL_LOGS = 1, //!< \~english Capture all logs
+ e_SS_SM_SCREEN_CAPTURE, //!< \~english Capture screenshot
+ e_SS_SM_CAPTURE_INTERFACEUNIFIED_LOGS, //!< \~english Capture application log
+ e_SS_SM_USER_FORCE_RESET, //!< \~english Capture logs are forcibily reset
+ e_SS_SM_CAPTURE_DEV_LOGS, //!< \~english Capture device log
+ e_SS_SM_CAPTURE_MODULE_LOGS, //!< \~english Capture debug log
+ e_SS_SM_CAPTURE_DTC_LOGS, //!< \~english Capture DTC event log
+ e_SS_SM_CAPTURE_NAVI_LOGS, //!< \~english Capture Navi event log
+ e_SS_SM_CAPTURE_GROUP_RELAUNCH //!< \~english Capture log by Group Relaunch
+};
+// *
+// Error Event Logging enumerations *
+//****************************************************************************
+
+//****************************************************************************
+/// \ingroup system_manager *
+/// \brief Error Event Logging Info *
+typedef struct T_SystemManagerLoggingRequestInfo {
+#define SS_SM_LOG_MSG_STR_SIZE 64
+ eSMUserLogType logType;
+ CHAR messageStr[SS_SM_LOG_MSG_STR_SIZE];
+ CHAR suffixStr[SS_SM_SUFFIX_STR_SIZE];
+}TSystemManagerLoggingRequestInfo;
+//
+// Error Event Logging Info *
+//****************************************************************************
+
+//****************************************************************************
+/// \ingroup system_manager *
+/// \brief Error Event Clear Logs Info *
+typedef struct T_SystemManagerClearLogsInfo {
+ void *rsv;
+}TSystemManagerClearLogsInfo;
+//
+// Error Event Clear Logs Info *
+//****************************************************************************
+
+#endif /* SS_SYSTEM_MANAGER_IF_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_manager_if_local.h b/systemservice/interface_unified/library/include/system_service/ss_system_manager_if_local.h
new file mode 100755
index 0000000..5c67aa6
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_manager_if_local.h
@@ -0,0 +1,40 @@
+/*
+ * @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 system_manager
+/// \file ss_system_manager_if_local.h
+/// \brief This file supports the System Manager client interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SYSTEM_MANAGER_IF_LOCAL_H_ // NOLINT (build/header_guard)
+#define SS_SYSTEM_MANAGER_IF_LOCAL_H_
+
+#define SS_MAX_NUM_MODULES (128)
+
+// EXIT_SUCCESS exit succeccfully
+// EXIT_FAILURE exit with failure
+// SS_SM_EXIT_RELAUNCH exit for relaunch request
+#define SS_SM_EXIT_RELAUNCH (2)
+
+/// \ingroup system_manager
+/// Message data payload structure from system manager to heartbeat
+typedef struct T_SMRequestMsg {
+ CHAR pstModuleName[MAX_QUEUE_NAME_SIZE];
+}TSMRequestMessage;
+
+#endif /* SS_SYSTEM_MANAGER_IF_LOCAL_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_manager_notifications.h b/systemservice/interface_unified/library/include/system_service/ss_system_manager_notifications.h
new file mode 100755
index 0000000..008d4f3
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_manager_notifications.h
@@ -0,0 +1,49 @@
+/*
+ * @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 system_manager
+/// \file ss_system_manager_notifications.h
+/// \brief This file supports the System Manager client interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SYSTEM_MANAGER_NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+#define SS_SYSTEM_MANAGER_NOTIFICATIONS_H_
+
+#include "system_service/ss_services.h"
+
+/// \addtogroup system_manager
+/// @{
+
+#define NTFY_SSSystemMgrAvailability SERVICE_SYSMANAGER"/Availability" ///< System Manager availability -
+ // eFrameworkunifiedServiceAvailable or eInterfaceunifiedServiceUnavailable
+#define NTFY_SSSystemMgrState SERVICE_SYSMANAGER"/State" ///< System Manager state - Init,
+ // Connecting, Disconnecting and Ready
+#define NTFY_SSSystemMgrPowerOnOff SERVICE_SYSMANAGER"/PowerOnOffState" ///< Power ON notification for
+ // Audio & Display
+#define NTFY_SSSystemMgrStartUpType SERVICE_SYSMANAGER"/StartUpType" ///< Notification for start up type
+#define NTFY_SSServiceWakeupStatus SERVICE_SYSMANAGER"/ServiceWakeupStatus" ///< Service Wakeup state
+#define NTFY_SSNeedAplRestart SERVICE_SYSMANAGER"/NeedAplRestart" ///< Notification for Need APL Restart
+
+
+/// Notification used by HMI to know when a Shutdown Request has been received
+/// from the _CWORD56_
+#define NTFY_SSSystemMgrShutdownStarted SERVICE_SYSMANAGER"/ShutdownStarted"
+
+/// @}
+
+#endif /* SS_SYSTEM_MANAGER_NOTIFICATIONS_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_manager_notifications_local.h b/systemservice/interface_unified/library/include/system_service/ss_system_manager_notifications_local.h
new file mode 100755
index 0000000..cbb743f
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_manager_notifications_local.h
@@ -0,0 +1,51 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_system_manager_notifications_local.h
+ * @brief \~english This file supports the System Manager client interface.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SS_SYSTEM_MANAGER_NOTIFICATIONS_LOCAL_H_ // NOLINT (build/header_guard)
+#define SS_SYSTEM_MANAGER_NOTIFICATIONS_LOCAL_H_
+
+
+/// TRUE : UserMode is UserOn
+/// FALSE : UserMode is UserOff
+/// Notification for User Mode
+#define NTFY_SSSystemMgrUserMode SERVICE_SYSMANAGER"/UserMode"
+
+/// Notification for data reset
+#define NTFY_SSSystemMgrDataReset SERVICE_SYSMANAGER"/DataReset"
+
+/// Notification used by Audio and System Services for Dynamic Launch
+#define NTFY_SSLastSourceType SERVICE_SYSMANAGER"/LastSourceType"
+
+
+#endif /* SS_SYSTEM_MANAGER_NOTIFICATIONS_LOCAL_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_manager_protocol.h b/systemservice/interface_unified/library/include/system_service/ss_system_manager_protocol.h
new file mode 100755
index 0000000..99d7e13
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_manager_protocol.h
@@ -0,0 +1,329 @@
+/*
+ * @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 system_manager
+/// \file ss_system_manager_protocol.h
+/// \brief This file supports the System Manager client interface.
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SS_SYSTEM_MANAGER_PROTOCOL_H__ // NOLINT (build/header_guard)
+#define __SS_SYSTEM_MANAGER_PROTOCOL_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+/// \addtogroup system_manager
+/// @{
+
+#define SS_SM_MAX_MODULE_NAME_LENGTH (256)
+#define SS_SM_MAX_TEST_CASE_NAME_SIZE (128)
+#define SS_SM_MAX_RESP_MSG_SIZE (2048)
+
+// system manager protocol --> define all protocol messages in and out of system manager
+// that are pertinent to the functionality offered by system manager.
+/**
+ * \~english System control protocol type.
+ */
+typedef enum _SS_SystemManagerProtocol {
+ // System Manager - command Protocol
+ SS_SYSTEM_MANAGER_PROTOCOL_BEGINNING_INDEX = 0x800, //!< \~english
+ SS_SM_NOTIFY_SYSTEM_LAUNCH_COMPLETE = SS_SYSTEM_MANAGER_PROTOCOL_BEGINNING_INDEX //!< System Manager to Power manager
+ , SS_SM_PROTOCOL_INTERFACE_END //!< \~english
+
+ // SystemManager-command Protocol
+ , SS_SM_START //!< \~english Normal-boot start request.
+ , SS_SM_START_COMPL_RSPN //!< \~english Normal-boot start completion notification.
+ , SS_SM_STOP //!< \~english Shutdown request.
+ , SS_SM_STOP_COMPL_RSPN //!< \~english Shutdown completion notification.
+ // SystemManager-command Protocol
+ , SS_SM_WAKEUP_MODULES_CMPL_RSPN //!< \~english Response to request of power state transition to power_service.(message format to use: \ref _wakeinfo "wakeInfo")
+ , SS_SM_SHUTDOWN_MODULES_CMPL_RSPN //!< SM to power
+
+ , SS_SM_WAKEUP_MODULES //!< client to service
+ , SS_SM_POWER_OFF_MODULES //!< client to service
+ , SS_SM_SHUTDOWN_MODULES //!< client to service
+
+ , SS_SM_CRNT_STATE_QUERY //!< client to service
+ , SS_SM_CRNT_STATE_QUERY_RSPN //!< service to client
+ , SS_SM_SYSTEM_MODE_INFO_REQ //!< client to service
+ , SS_SM_SYSTEM_MODE_INFO_RSPN //!< service to client
+ , SS_SM_INITCOMP_REP //!< client to service
+
+ , SS_SM_PROTOCOL_OPEN_SESSION_REQ //!< \~english
+ , SS_SM_PROTOCOL_OPEN_SESSION_ACK //!< \~english
+
+ //*************************************************************************
+ // Get Extended Parameter Protocol *
+ // *
+ // Protocol between applications and SM *
+ , SS_SM_GET_START_EXT_INFO //!< FrameworkunifiedOnStart Extended Parameter
+ , SS_SM_GET_STOP_EXT_INFO //!< FrameworkunifiedOnStop Extended Parameter
+ // End of Get Extended Parameter Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Reset Mode Protocol: *
+ // *
+ // Request by Privileged clients to set the data reset mode: *
+ // None, UserData Reset or *
+ // Factory Reset *
+ // *
+ // The Set Request message carries the requested reset Mode. *
+ // Set Result message is not defined, because the Set Request is send by *
+ // FrameworkunifiedInvokeSync() *
+ , SS_SM_DATA_RESET_MODE_SET_REQ //!< Client to Service (Sys Mgr)
+ // *
+ // End of Reset Mode Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Program Update Status Protocol: *
+ // *
+ // Request by Privileged clients to set the program update status: *
+ // None or Program Updated *
+ // *
+ // The Set Request message carries the requested program update status. *
+ // Set Result message is not defined, because the Set Request is send by *
+ // FrameworkunifiedInvokeSync() *
+ , SS_SM_PROG_UPDATE_STATE_SET_REQ //!< Client to Service (Sys Mgr)
+ // *
+ // End of Reset Mode Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // 'CPU Reset' Protocol: *
+ // *
+ // CPU Reset request from applications to SM and SM to PS *
+ // /// < Client to Service when *
+ // /// message originating from *
+ // /// Application to SS\SM. *
+ // /// < Service to Client when *
+ // /// message originating from *
+ // /// SS\SM to SS\PS. *
+ , SS_SM_CPU_RESET_REQ //!< \~english
+ // *
+ // End of CPU Reset Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // 'Local Data Reset' Protocol: *
+ // *
+ // Local Data Reset request from applications to SM. *
+ // /// < Client to Service when *
+ // /// message originating from *
+ // /// Application to SS\SM. *
+ , SS_SM_LOCAL_DATA_RESET_REQ //!< \~english
+ // *
+ // End of Local Data Reset Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // 'Remote Data Reset' Protocol: *
+ // *
+ // Remote Data Reset request from SM to PS *
+ // /// < Service to Client when *
+ // /// message originating from *
+ // /// SS\SM to SS\PS. *
+ , SS_SM_REMOTE_DATA_RESET_REQ //!< \~english
+ // *
+ // End of Remote Data Reset Protocol *
+ //*************************************************************************
+
+
+ //*************************************************************************
+ // Startup Confirmation Protocol: *
+ // *
+ // Request by the Power Shadow to the Power Service to forward to the *
+ // System Manager the Startup Confirmation message. *
+ // *
+ // The Request message carries the Startup Confirmation message. *
+ // The Response message carries the EFrameworkunifiedStatus of the request. *
+ , SS_SM_FWD_STARTUP_CONFIRMATION_MSG_REQ //!< Pwr Svc to Sys Mgr
+ , SS_SM_FWD_START_CONFIRMATION_MSG_RESP //!< Sys Mgr to Pwr Svc
+ // *
+ // End of Startup Confirmation Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Power Request Protocol: *
+ // *
+ // Power Request message from the Power Shadow to the System Manager with *
+ // _CWORD56_'s "Power_Request" IPC_Command data. *
+ // *
+ // The Request message carries the _CWORD56_'s data. *
+ // The Response message carries the EFrameworkunifiedStatus of the request. *
+ , SS_SM_POWER_REQUEST_MSG //!< \~english Startup process start request from power_service.
+ , SS_SM_POWER_REQUEST_MSG_RESP //!< Sys Mgr to Pwr Svc
+ // *
+ // End of Power Request Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // User Mode Protocol: *
+ // *
+ // Request from the Power Service to the System Manager, originally from *
+ // the Power Shadow, to turn on or off the video & audio output of HMI *
+ // and Audio services. *
+ // User Mode 'On' => turn video & audio output on *
+ // User Mode 'Off' => turn video & audio output off *
+ // *
+ // The Request message carries the requested User Mode state. *
+ // The Response message carries the actual User Mode state. *
+ , SS_SM_USER_MODE_SET_RESP //!< Service (Sys Mgr) to Client (Pwr Svc)
+ // *
+ // Note: See the corresponding Power Shadow / Power Service *
+ // 'SS_PowerServiceProtocol' enums in *
+ // /SystemServices/inc/ss_power_service_protocol.h *
+ // End of User Mode Protocol *
+ //*************************************************************************
+
+ , SS_SM_NEXT_WAKEUP_TYPE_SET_REQ //!< \~english
+
+ //*************************************************************************
+ // Error Event Protocol *
+ //
+ , SS_SM_EVENT_ERROR //!< SM to HMI(_CWORD77_)
+ , SS_SM_EVENT_ERROR_TO_SSL //!< SM to SSL
+ , SS_SM_ERROR_EVENT_LOGGING_START_REQ //!< SSL to SM
+ , SS_SM_ERROR_EVENT_LOGGING_START_RSPN //!< SM to SSL
+ , SS_SM_ERROR_EVENT_ARTIFACT_REQ //!< SSL to SM
+ , SS_SM_ERROR_EVENT_ARTIFACT_RSPN //!< SM to SSL
+ , SS_SM_ERROR_EVENT_LOGGING_COMPLETE //!< SSL to SM
+ , SS_SM_ERROR_EVENT_LOGGING_COMPLETE_RSPN //!< SM to SSL
+
+ , SS_SM_ERROR_EVENT_TIMER_ID_LOGGER_START_REQ //!< \~english
+ , SS_SM_ERROR_EVENT_TIMER_ID_DEBUG_DUMP_RSPN //!< \~english
+ , SS_SM_ERROR_EVENT_TIMER_ID_BOOT_MICRO_LOG_RSPN //!< \~english
+ , SS_SM_ERROR_EVENT_TIMER_ID_CORE_FILE_POLL //!< \~english
+
+ , SS_SM_USER_INVOKED_LOG_REQ //!< Key Shadow to SM
+
+ , SS_SM_ERROR_EVENT_EEL_EXPORT_REQ //!< SSL to SM
+ , SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_REQ //!< SSL to SM
+ , SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_RSPN //!< SM to SVC
+ , SS_SM_ERROR_EVENT_CLR_LOGS_REQ //!< SVC to SM
+ , SS_SM_ERROR_EVENT_PROCESS_EXIT //!< SM\CD to SM
+ , SS_SM_ERROR_EVENT_DIAG_LOG_REQ //!< SSL to SM
+ , SS_SM_ERROR_EVENT_CAN_LOG_REQ //!< SSL to SM
+ , SS_SM_ERROR_EVENT_DTC_LOG_REQ //!< SSL to SM
+ //
+ // End of Error Event Protocol *
+ //*************************************************************************
+
+ , SS_SM_GROUP_LAUNCH_TRIGGER //!< \~english
+
+ //*************************************************************************
+ // Debug Dump Protocol *
+ // *
+ // Protocol between applications and SM *
+ , SS_SM_DEBUG_DUMP //!< SM to client
+ , SS_SM_DEBUG_DUMP_RSPN //!< client to SM
+ // *
+ // End of Debug Dump Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // IAT Propagate Error (Module Relaunch Request) *
+ // *
+ // Protocol between applications and SM *
+ , SS_SM_MODULE_RELAUNCH_REQ //!< client to SM
+ // *
+ // End of IAT Propagate Error (Module Relaunch Request) *
+ //*************************************************************************
+
+ //*************************************************************************
+ // CPU High Load *
+ // *
+ // Protocol between SS_CPU_Monitor and SM *
+ , SS_SM_CPU_HIGH_LOAD_DETECTED //!< client to SM
+ // *
+ // End of CPU High Load *
+ //*************************************************************************
+
+ //*************************************************************************
+ // IAT Propagate Error (System Error) *
+ // *
+ // Protocol between application and SM *
+ , SS_SM_PROPAGATE_SYSTEM_ERROR //!< client to SM
+ // *
+ // End of IAT Propagate Error (System Error) *
+ //*************************************************************************
+
+ //*************************************************************************
+ // _CWORD56_ HeartBeat Request Protocol *
+ // *
+ // Protocol between Power Services and SM *
+ , SS_SM__CWORD56__HEARTBEAT_REQ //!< PS to SM
+ , SS_SM__CWORD56__HEARTBEAT_RSPN //!< SM to PS
+ // *
+ // End of _CWORD56_ HeartBeat Request Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // User Data Reset Event Protocol *
+ // *
+ // Protocol between SM and Service *
+ , SS_SM_EVENT_USER_DATA_RESET //!< SM to MS
+ // *
+ // End of User Data Reset Event Protocol *
+ //*************************************************************************
+
+ //*************************************************************************
+ // Boot Micro Logging Protocol *
+ // *
+ // Protocol between SS_Logger and SM. *
+ , SS_SM_BOOT_MICRO_RESET_NTF //!< Logging Shadow to SM
+ , SS_SM_BOOT_MICRO_LOG_REQ //!< SM to Logging Shadow
+ , SS_SM_BOOT_MICRO_LOG_RSP //!< Logging Shadow to SM aka ENDING_INDEX
+ // *
+ // End Boot Micro Logging Protocol *
+ //*************************************************************************
+
+ // SystemManager-command Protocol
+ , SS_SM_PRE_START //!< \~english Pre-boot(+BA) start request.
+ , SS_SM_PRE_START_COMPL_RSPN //!< \~english Pre-boot(+BA) start completion notification.
+ , SS_SM_PRE_STOP //!< \~english Pre-boot(+BA) stop request.
+ , SS_SM_PRE_STOP_COMPL_RSPN //!< \~english Pre-boot(+BA) stop completion notification.
+ , SS_SM_BACKGROUND_START //!< \~english Background-boot(+BA) start request.
+ , SS_SM_BACKGROUND_START_COMPL_RSPN //!< \~english Background-boot(+BA) start completion notification.
+ , SS_SM_BACKGROUND_STOP //!< \~english Background-boot(+BA) stop request.
+ , SS_SM_BACKGROUND_STOP_COMPL_RSPN //!< \~english Background-boot(+BA) stop completion notification.
+
+ // UPDATE IF ANOTHER 'LAST' ENUMERATION IS ADDED !
+ , SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX = SS_SM_BACKGROUND_STOP_COMPL_RSPN //!< \~english
+} SS_SystemManagerProtocol;
+
+typedef struct _SS_SMCurrentState {
+ CHAR testCaseIdString[SS_SM_MAX_TEST_CASE_NAME_SIZE];
+ CHAR respMsgString[SS_SM_MAX_RESP_MSG_SIZE];
+}SS_SMCurrentState;
+
+typedef struct _SMCompleteAck {
+ UI_16 unSessionId;
+ CHAR szServiceName[MAX_QUEUE_NAME_SIZE];
+} SMStopCompleteAck;
+
+typedef struct _SMGroupLaunchTrigger {
+ UI_32 NextGroupId;
+}SMGroupLaunchTrigger;
+//*************************************************************************
+
+
+/// @}
+
+#endif /* __SS_SYSTEM_MANAGER_PROTOCOL_H__ */ // NOLINT (build/header_guard)
+// EOF
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_manager_protocol_local.h b/systemservice/interface_unified/library/include/system_service/ss_system_manager_protocol_local.h
new file mode 100755
index 0000000..5f86820
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_manager_protocol_local.h
@@ -0,0 +1,45 @@
+/*
+ * @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 system_manager
+/// \file ss_system_manager_protocol_local.h
+/// \brief This file supports the System Manager client interface.
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SS_SYSTEM_MANAGER_PROTOCOL_LOCAL_H__ // NOLINT (build/header_guard)
+#define __SS_SYSTEM_MANAGER_PROTOCOL_LOCAL_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+/// \addtogroup system_manager
+/// @{
+
+#define SS_SM_MAX_MODULE_LOG_MASK_LENGTH (50)
+#define SS_SM_MAX_MODULE_PATH_LENGTH (256)
+#define SS_SM_MAX_MODULE_ARGS_LENGTH (512)
+
+//*************************************************************************
+// Version Number Structure Specification: *
+typedef UI_64 SS_VersionNumberType;
+// End of Version Number Structure Specification *
+//*************************************************************************
+
+/// @}
+
+#endif /* __SS_SYSTEM_MANAGER_PROTOCOL_LOCAL_H__ */ // NOLINT (build/header_guard)
+// EOF
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_process.h b/systemservice/interface_unified/library/include/system_service/ss_system_process.h
new file mode 100755
index 0000000..a4ae743
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_process.h
@@ -0,0 +1,1118 @@
+/*
+ * @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_SystemServicesIf
+/// \brief This file supports the System Manager OS process abstraction.
+///
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file ss_system_process.h
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup interface_unified
+ * @ingroup system_service
+ * @{
+ */
+#ifndef __Process_H__ // NOLINT (build/header_guard)
+#define __Process_H__
+
+#include <spawn.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/cl_process.h>
+#include <system_service/ss_system_types.h>
+#include <signal.h>
+#include <vector>
+#include <string>
+#include <map>
+
+const long lProcess_VALIDATION_VALUE = 2198645; // NOLINT (runtime/int)
+// Used to define a unique value that represents this class.
+// This value is stored in the object when the object is created,
+// and cleared when the object is destroyed.
+
+const int iProcess_DEFAULT_PROCESS_PRIORITY = 10;
+// This is the default process priority that all new processes will use.
+
+const int iProcess_MAXIMUM_PROCESS_PRIORITY = 60;
+// This is the maximum priority a process can have
+
+const long iProcess_DEFAULT_PROCESS_FLAGS = POSIX_SPAWN_SETSCHEDULER // NOLINT (runtime/int)
+ | POSIX_SPAWN_SETSCHEDPARAM;
+
+// This flag field is a bit wise OR of spawning options to use when a process
+// is created.
+
+const int iProcess_MAXIMUM_NUMBER_OF_PROCESS_ARGUMENTS = 25;
+// This is the maximum number of command line (i.e. argv[]) arguments we can
+// send to a process. This includes; exectuable file name + process arguments + NULL
+
+const int iProcess_MAXIMUM_PROCESS_NAME_LENGTH = 32;
+// This is the maximum number of characters that a process name can be in bytes.
+
+class Process;
+
+typedef std::map<SS_String, Process *> ProcessMap;
+
+/**
+ * @class TimerCtrl
+ * \~english @brief OS process
+ * \~english @par Brief Introduction
+ * This class is the System Manager OS process abstraction.
+ *
+ */
+class Process {
+ public:
+ enum eProcessLoadMode {
+ WAIT, // The invoked program is loaded into available memory, is executed,
+ // and then the original program resumes execution.
+ NOWAIT, // Causes the current program to execute concurrently with the new child process.
+ };
+
+ enum eProcessSchedulingPolicy {
+ FIFO, // A fixed priority scheduler in which the highest ready process runs until it
+ // blocks or is preempted by a higher priority process.
+ ROUND_ROBIN, // The same as FIFO, except processes at the same priority level time-slice.
+ OTHER // A general time sharing scheduler in which a process decays in priority if it
+ // consumes too much processor before blocking. It reverts to its default priority
+ // when it blocks. Should it fail to run over a 2 second period and it has decayed
+ // then it's boosted one priority level up to a maximum of its default priority.
+ };
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Process
+ /// \~english @par Summary
+ /// - Default Constructor, called when the class is instantiated.
+ /// \~english @param [in] - cpu_assign
+ /// - Assignment information of CPU.
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - initialize all var
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - initialize all var in class as default value
+ /// \~english @see ~Process
+ ////////////////////////////////////////////////////////////////////////////////////
+ Process(int cpu_assign = 0x0);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Process
+ /// \~english @par Summary
+ /// - Copy Constructor
+ /// \~english @param [in] - p_rhs_i
+ /// - Process - Reference to a Process that you want to copy.
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Used to create an object and copy another object to the new object.
+ /// \~english @see ~Process
+ ////////////////////////////////////////////////////////////////////////////////////
+ Process(const Process& p_rhs_i);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~Process
+ /// \~english @par Summary
+ /// - Destructor function
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - set m_lValidationTag with 0
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Destructor, called when the object is destroyed.\n
+ /// set m_lValidationTag with 0 and kill process.
+ /// \~english @see Process
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~Process();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup operator=
+ /// \~english @par Summary
+ /// - Assignment Operator
+ /// \~english @param [in]
+ /// \~english @retval Process - New Process object
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Assignment Operator, called when one object is assigned to another object.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ Process& operator=(const Process& p_rhs_i);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetProcessId
+ /// \~english @par Summary
+ /// - get process id
+ /// \~english @param None
+ /// \~english @retval process pid - the process pid of the process running.
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - This method will return to the caller the PosixBasedOS001 Specific Process ID.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ int const GetProcessId(void) {
+ return static_cast<int>(m_tProcessId);
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetCallingArgumentList
+ /// \~english @par Summary
+ /// - This method will set the calling argument list that this object represents
+ /// \~english @param [in] p_pcArgv_i
+ /// - const char *[] - Pointer to array of null terminated parameter list.
+ /// \~english @param [in] p_iArgc_i
+ /// - const int - - Number of arguments in the array passed.
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - put the new arguments into m_strlstArgv
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Set the executable filename first. This is always the 1st argument
+ /// - in the argument list. Then set the argument list for the process
+ /// - which is held in m_strlstArgv.
+ /// - First make sure that the argument list is empty.
+ /// - Once empty, put the new arguments into the list
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void SetCallingArgumentList(const char *p_pcArgv_i[], const int p_iArgc_i);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetCallingArgumentList
+ /// \~english @par Summary
+ /// - This method will set the calling argument list that this object represents.
+ /// \~english @param [in] p_strlstParameters_i
+ /// - const StringList& - String list of arguments that will be used to start.
+ /// \~english @retval None.
+ /// \~english @par Preconditions
+ /// - no preconditions.
+ /// \~english @par Change of the internal state
+ /// - set m_strlstArgv with p_strlstParameters_i.
+ /// \~english @par Causes of failures
+ /// - None.
+ /// \~english @par Classification
+ /// - Public.
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - if p_strlstParameters_i is not empty,then clear m_strlstArgv \n
+ /// - and set m_strlstArgv with p_strlstParameters_i.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void SetCallingArgumentList(const StringList& p_strlstParameters_i);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetExecutableFileName
+/// \~english @par Summary
+/// - Get executable file name
+/// \~english @param None
+/// \~english @retval Pointer
+/// - Points to SS_String object that holds the path and executable file name for this process
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will return a pointer to the executable filename that this object represents
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ const char * const GetExecutableFileName() {
+ return m_strFile.c_str();
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetProcessReturnCode
+ /// \~english @par Summary
+ /// - This function will return the processes exit/return code.
+ /// \~english @param None
+ /// \~english @retval process exit code - Code for the last process to execute
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - set m_iReturnCode with WEXITSTATUS(iProcessReturn)
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - This function will return the processes exit/return code.\n
+ /// This is not the value of ERRNO as returned by GetLastPosixBasedOS001ErrorCode().
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ int GetProcessReturnCode(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetSchedulingPolicy
+ /// \~english @par Summary
+ /// - This method will change the scheduling policy for the process this object represents.
+ /// \~english @param [in] p_eSchedulingPolicy_i
+ /// - const eProcessSchedulingPolicy - Scheduling Policy for this process
+ /// \~english @par
+ /// - eProcessSchedulingPolicy
+ /// \~english @code
+ /// - enum eProcessSchedulingPolicy {
+ /// FIFO, A fixed priority scheduler in which the highest ready process runs until it\n
+ /// blocks or is preempted by a higher priority process.
+ /// ROUND_ROBIN, The same as FIFO, except processes at the same priority level time-slice.
+ /// OTHER A general time sharing scheduler in which a process decays in priority if it\n
+ /// consumes too much processor before blocking. It reverts to its default priority\n
+ /// when it blocks. Should it fail to run over a 2 second period and it has decayed\n
+ /// then it's boosted one priority level up to a maximum of its default priority.
+ /// };
+ /// @endcode
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// -If the result of function is not 0,then set m_iErrorCode with errno
+ /// - else set m_iErrorCode with 0.
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Attempt to change the scheduling policy for the process that this object
+ /// represents. If the change fails, restore the previous settings.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void SetSchedulingPolicy(
+ const eProcessSchedulingPolicy p_eSchedulingPolicy_i);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetSchedulingPolicy
+/// \~english @par Summary
+/// - Get currently configured scheduling policy
+/// \~english @param None
+/// \~english @retval FIFO - A fixed priority scheduler in which the highest ready process runs until it\n
+/// blocks or is preempted by a higher priority process.
+/// \~english @retval ROUND_ROBIN - The same as FIFO, except processes at the same priority level time-slice.
+/// \~english @retval OTHER - A general time sharing scheduler in which a process decays in priority if it\n
+/// consumes too much processor before blocking. It reverts to its default priority\n
+/// when it blocks. Should it fail to run over a 2 second period and it has decayed\n
+/// then it's boosted one priority level up to a maximum of its default priority.
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - If the result of calling function sched_getscheduler(m_tProcessId) is -1
+/// then set m_iErrorCode with errno
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will return to the caller the currently configured process scheduling policy.
+/// If the result of calling function sched_getscheduler(m_tProcessId) is -1,
+/// then return ROUND_ROBIN.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ eProcessSchedulingPolicy const GetSchedulingPolicy(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetPriority
+ /// \~english @par Summary
+ /// - This method will change the priority for the process this object represents.
+ /// \~english @param [in] p_iPriority_i
+ /// - int - Priority of the process
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - If the result of function sched_setparam(m_tProcessId, &cur_sch_params)\n
+ /// is -1,then set m_iErrorCode with errno, else set m_iErrorCode with 0.
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Using p_iPriority_i to change the priority for the process\n
+ /// this object represents,if the result of function \n
+ /// sched_setparam(m_tProcessId, &cur_sch_params) is -1
+ /// m_iErrorCode will be seted with errno,else be seted with 0
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void SetPriority(const int p_iPriority_i);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetPriority Notice:Can't find the body of this function
+ /// \~english @par Summary
+ /// - This method will change the priority for the specified process ID.
+ /// \~english @param [in] p_iPid_i
+ /// - pid_t - PID of the process to change the priority
+ /// \~english @param [in] p_iPriority_i
+ /// - int - Priority of the process
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// -
+ /// \~english @par Causes of failures
+ /// -
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// -none
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void SetPriority(const pid_t p_iPid_i, const int p_iPriority_i);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IncreasePriorityByOne
+ /// \~english @par Summary
+ /// - This method will increase the priority for the process this\n
+ /// object represents by one.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Retrieve the current priority of the process. Check to see if already at max.\n
+ /// If so just return. Otherwise increase by one and set the priority...
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void IncreasePriorityByOne(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DecreasePriorityByOne
+ /// \~english @par Summary
+ /// - This method will decrease the priority for the process this object represents by one.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no precondition
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - Retrieve the current priority of the process. Check to see if already at minimum.
+ /// If so just return. Otherwise decrease by one and set the priority...
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void DecreasePriorityByOne(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetPriority
+ /// \~english @par Summary
+ /// - This method will return to the caller the currently configured process priority.
+ /// \~english @param None
+ /// \~english @retval int priority - process priority
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - If the result of function sched_getparam(m_tProcessId, &cur_sch_params) is less than -1,\n
+ /// then m_iErrorCode will be seted with errno.
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - If the result of function sched_getparam(m_tProcessId, &cur_sch_params)\n
+ /// is less than -1,will be return -1,else return Currently configured process priority.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ int const GetPriority(void);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetProcessName
+ /// \~english @par Summary
+ /// - This method will set this objects process name member variable to the provided string value.
+ /// \~english @param [in] p_strProcessName_i
+ /// - SS_String - Process Name to set the m_strProcessName member variable to
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - Using p_strProcessName_i to set m_strProcessName
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - This method will set this objects process name member variable to the provided string value.\n
+ /// If the user of this object wishes to register the name with PosixBasedOS001 OS,\n
+ /// the AttachName() method should be called.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void SetProcessName(const SS_String& p_strProcessName_i);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetProcessName
+ /// \~english @par Summary
+ /// - Get process name
+ /// \~english @param None
+ /// \~english @retval SS_String - Process Name
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - This method will return to the caller the registered name of this process.\n
+ /// been registered with the OS, a NULL string will be returned. If a name has not
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ SS_String GetProcessName(void) const {
+ return m_strProcessName;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CreateProcess
+ /// \~english @par Summary
+ /// - This method will create a process with the executable provided and \n
+ /// mode as a calling parameter.The caller can also provide a list of arguments \n
+ /// that will be provided to the executable at startup.
+ /// \~english @param [in] p_strFile_i
+ /// - SS_String - Path and Filename of executable to create process for
+ /// \~english @param [in] p_strlstArgv_i
+ /// - StringList - List of ARGV values for new process
+ /// \~english @param [in] p_eMode_i
+ /// - eProcessLoadMode - Mode to create and load new process
+ /// \~english @param [in] p_strProcessName_i
+ /// - SS_String - This is the name that will be registered to the OS for this process
+ /// \~english @param [in] p_eSchedulingPolicy_i
+ /// - eProcessSchedulingPolicy
+ /// \~english @param [in] p_iPriority_i
+ /// - int - Priority for this process
+ /// \~english @param [in] unix_user_name
+ /// - char* - unix user name
+ /// \~english @param [in] p_lSpawnFlags_i
+ /// - long - Spawning flags. These are PosixBasedOS001 specific....
+ /// \~english @par
+ /// eProcessLoadMode enum
+ /// \~english @code
+ /// - enum eProcessLoadMode {
+ /// WAIT, //The invoked program is loaded into available memory, is executed,
+ /// //and then the original program resumes execution.
+ /// NOWAIT, // Causes the current program to execute concurrently with the new child process.
+ /// };
+ /// @endcode
+ /// \~english @par
+ /// eProcessSchedulingPolicy enum
+ /// \~english @code
+ /// - enum eProcessSchedulingPolicy {
+ /// FIFO, // A fixed priority scheduler in which the highest ready process runs until it
+ /// // blocks or is preempted by a higher priority process.
+ /// ROUND_ROBIN, // The same as FIFO, except processes at the same priority level time-slice.
+ /// OTHER // A general time sharing scheduler in which a process decays in priority if it
+ /// // consumes too much processor before blocking. It reverts to its default priority
+ /// // when it blocks. Should it fail to run over a 2 second period and it has decayed
+ /// // then it's boosted one priority level up to a maximum of its default priority.
+ /// };
+ /// @endcode
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - set m_iErrorCode with 0
+ /// set m_iReturnCode with 0
+ /// set m_eProcessLoadMode with p_eMode_i;
+ /// set m_strFile with p_strFile_i;
+ /// set m_strProcessName with p_strProcessName_i;
+ /// use the result of function CL_ProcessCreate() to set m_tProcessId
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// -This method will create a PosixBasedOS001 process with the executable provided\n
+ /// and mode as a calling parameter.The caller can also provide a list of arguments\n
+ /// that will be provided to the executable at startup.The calling p_strProcessName \m
+ /// parameter is a textual name that will be associated with the newly created process\n
+ /// by the OS. The process state information will be maintained by this object.\n
+ /// Upon successful creation of the process, the scheduling policy and priority\n
+ /// of the process will be set to the provided values. The user can change these\n
+ /// values through the SetSchedulingPolicy() and SetPriority() method calls.\n
+ /// Using unix_user_name to get uid and gid,set uid and gid when calling\n
+ /// CL_ProcessCreateAttrSetUid() and CL_ProcessCreateAttrSetGid\n
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcess(const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const StringList& p_strlstArgv_i, // List of ARGV values for new process
+ const eProcessLoadMode p_eMode_i, // Mode to create and load new process
+ const SS_String& p_strProcessName_i, // This is the name that will be registered to the OS for this process
+ const eProcessSchedulingPolicy p_eSchedulingPolicy_i, // Scheduling Policy for this process
+ const int p_iPriority_i, // Priority for this process
+ const char* unix_user_name, const long p_lSpawnFlags_i); // Spawning flags. These are PosixBasedOS001 specific.... // NOLINT (runtime/int)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CreateProcess
+ /// \~english @par Summary
+ /// - This method will create a PosixBasedOS001 process with the executable\n
+ /// provided and mode as a calling parameter.
+ /// \~english @param [in] p_strFile_i
+ /// - SS_String - Path and Filename of executable to create process for
+ /// \~english @param [in] p_strProcessName_i
+ /// - SS_String - This is the name that will be registered to the OS for this process
+ /// \~english @param [in] unix_user_name
+ /// - char* - unix user name
+ /// \~english @param [in] p_lSpawnFlags_i
+ /// - long - Posix Spawning flags. These are PosixBasedOS001 specific
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - The caller can also provide a list of arguments that will be provided\n
+ /// to the executable at startup.The calling p_strProcessName parameter is a textual name\n
+ /// that will be associated with the newly created process by the OS.\n
+ /// The process state information will be maintained by this object.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcess(const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const SS_String& p_strProcessName_i, // This is the name that will be registered to the OS for this process
+ const char* unix_user_name = NULL, const long p_lSpawnFlags_i = // NOLINT (runtime/int)
+ iProcess_DEFAULT_PROCESS_FLAGS); // Spawning flags.
+ // These are PosixBasedOS001 specific....
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CreateProcess
+ /// \~english @par Summary
+ /// - This method will create a process with the executable
+ /// provided and mode as a calling parameter.
+ /// \~english @param [in] p_strFile_i
+ /// - SS_String - Path and Filename of executable to create
+ /// process for
+ /// \~english @param [in] p_strProcessName_i
+ /// - SS_String - This is the name that will be registered to the
+ /// OS for this process
+ /// \~english @param [in] p_iPriority_i
+ /// - int - Priority of process
+ /// \~english @param [in] unix_user_name
+ /// - char* - unix user name
+ /// \~english @param [in] p_lSpawnFlags_i
+ /// - long - Posix Spawning flags. These are PosixBasedOS001
+ /// specific
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - The caller can also provide a list of arguments that will be
+ /// provided\n
+ /// to the executable at startup.The calling p_strProcessName
+ /// parameter is a textual name\n
+ /// that will be associated with the newly created process by
+ /// the OS.\n
+ /// The process state information will be maintained by this
+ /// object.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcess(const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const SS_String& p_strProcessName_i, // This is the name that will be registered to the OS for this process
+ const int p_iPriority_i, // Priority of this process
+ const char* unix_user_name = NULL, const long p_lSpawnFlags_i = // NOLINT (runtime/int)
+ iProcess_DEFAULT_PROCESS_FLAGS); // Spawning flags.
+ // These are PosixBasedOS001 specific....
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CreateProcess
+/// \~english @par Summary
+/// - This method will create a process with the executable provided and mode as a calling parameter.
+/// \~english @param [in] p_strFile_i
+/// - SS_String - p_strFile_i Path and Filename of executable to create process for
+/// \~english @param [in] unix_user_name
+/// - char* - unix user name
+/// \~english @param [in] p_lSpawnFlags_i
+/// - long - Spawning flags. These are PosixBasedOS001 specific.
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - The caller can also provide a list of arguments that will be provided\n
+/// to the executable at startup.The calling p_strProcessName parameter is a textual name\n
+/// that will be associated with the newly created process by the OS.\n
+/// The process state information will be maintained by this object.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcess(const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const char* unix_user_name = NULL, const long p_lSpawnFlags_i = // NOLINT (runtime/int)
+ iProcess_DEFAULT_PROCESS_FLAGS); // Spawning flags.
+ // These are PosixBasedOS001 specific....
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CreateProcess
+/// \~english @par Summary
+/// - This method will create a process with the executable provided and mode as a calling parameter.
+/// \~english @param [in] p_strFile_i
+/// - SS_String - p_strFile_i Path and Filename of executable to create process for
+/// \~english @param [in] p_strProcessName_i
+/// - SS_String - This is the name that will be registered to the OS for this process
+/// \~english @param [in] p_strlstArgv_i
+/// - StringList - List of ARGV values for new process
+/// \~english @param [in] unix_user_name
+/// - char* - unix user name
+/// \~english @param [in] p_lSpawnFlags_i
+/// - long - Spawning flags. These are PosixBasedOS001 specific.
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - The caller can also provide a list of arguments that will be provided\n
+/// to the executable at startup.The calling p_strProcessName parameter is a textual name\n
+/// that will be associated with the newly created process by the OS.\n
+/// The process state information will be maintained by this object.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcess(const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const SS_String& p_strProcessName_i, // This is the name that will be registered to the OS for this process
+ const StringList& p_strlstArgv_i, // List of ARGV values for new process
+ const char* unix_user_name = NULL, const long p_lSpawnFlags_i = // NOLINT (runtime/int)
+ iProcess_DEFAULT_PROCESS_FLAGS); // Spawning flags.
+ // These are PosixBasedOS001 specific....
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CreateProcess
+/// \~english @par Summary
+/// - This method will create a process with the executable provided and mode as a calling parameter.
+/// \~english @param [in] p_strFile_i
+/// - SS_String - Path and Filename of executable to create process for
+/// \~english @param [in] p_strProcessName_i
+/// - SS_String - This is the name that will be registered to the OS for this process
+/// \~english @param [in] p_iPriority_i
+/// - int - Priority for this process
+/// \~english @param [in] p_strlstArgv_i
+/// - StringList - List of ARGV values for new process
+/// \~english @param [in] unix_user_name
+/// - char* - unix user name
+/// \~english @param [in] p_lSpawnFlags_i
+/// - long - Spawning flags.These are PosixBasedOS001 specific.
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - The caller can also provide a list of arguments that will be provided\n
+/// to the executable at startup.The calling p_strProcessName parameter is a textual name\n
+/// that will be associated with the newly created process by the OS.\n
+/// The process state information will be maintained by this object.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcess(const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const SS_String& p_strProcessName_i, // This is the name that will be registered to the OS for this process
+ const int p_iPriority_i, // Priority for this process
+ const StringList& p_strlstArgv_i, // List of ARGV values for new process
+ const char* unix_user_name = NULL, const long p_lSpawnFlags_i = // NOLINT (runtime/int)
+ iProcess_DEFAULT_PROCESS_FLAGS); // Spawning flags.
+ // These are PosixBasedOS001 specific....
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CreateProcess
+ /// \~english @par Summary
+ /// - This method will create a process with the executable provided and mode as a calling parameter.
+ /// \~english @param [in] p_strFile_i
+ /// - SS_String - Path and Filename of executable to create process for
+ /// \~english @param [in] c_argv
+ /// - char - This is the argument that will be registered to the OS for this process
+ /// \~english @param [in] environment_string
+ /// - char - enviroment for this process
+ /// \~english @param [in] cl_attr
+ /// - CL_ProcessAttr_t - List of ARGV values for new process
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// -no preconditions
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// - The caller can also provide a list of arguments that will be provided\n
+ /// that will be associated with the newly created process by the OS.\n
+ /// The process state information will be maintained by this object.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcess(const SS_String* p_str_file, char* const * c_argv,
+ char* environment_string, const CL_ProcessAttr_t *cl_attr);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CreateProcessWait
+/// \~english @par Summary
+/// - This method will create a process with the executable provided.
+/// \~english @param [in] p_strFile_i
+/// - SS_String - Path and Filename of executable to create process for
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will create a process with the executable provided.\n
+/// The process state information will be maintained by this object.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcessWait(const SS_String& p_strFile_i); // Path and Filename of executable to create process for
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CreateProcessWait
+/// \~english @par Summary
+/// - This method will create a PosixBasedOS001 process with the executable provided.
+/// \~english @param [in] p_strFile_i
+/// - SS_String - Path and Filename of executable to create process for
+/// \~english @param [in] p_strlstArguments_i
+/// - StringList - List of process calling arguments
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will create a PosixBasedOS001 process with the executable provided.\n
+/// The process state information will be maintained by this object.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void CreateProcessWait(const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const StringList& p_strlstArguments_i); // List of process calling arguments
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup KillProcess
+/// \~english @par Summary
+/// - This method will send the specified signal to the process represented by this object
+/// \~english @param [in] signal
+/// - int - signal
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - Intialize the objects m_iErrorCode member variable to 0
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will send the specified signal to the process represented by this object.\n
+/// All variables associated with this object will be initialized to a know value.\n
+/// If this process has a name registered with the OS, that name will be removed.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void KillProcess(int signal = SIGKILL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup DoesProcessExist
+/// \~english @par Summary
+/// -Check if the process existed
+/// \~english @param None
+/// \~english @retval TRUE - Process Exists
+/// \~english @retval FALSE - Process does not exist
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// -None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will return a BOOLean indicating whether this process exists.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////
+ BOOL DoesProcessExist(void);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup DisableAutoKill
+/// \~english @par Summary
+/// -none
+/// \~english @param None
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - set m_fAutoKill as FALSE
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will disable the Auto Kill function in the destructor,\n
+/// thus letting the process whom this object represents continue running.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void DisableAutoKill(void) {
+ m_fAutoKill = FALSE;
+ }
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup EnableAutoKill
+/// \~english @par Summary
+/// - Enable the Auto Kill
+/// \~english @param None
+/// \~english @retval None
+/// \~english @par Preconditions
+/// -no preconditions
+/// \~english @par Change of the internal state
+/// - set m_fAutoKill as TRUE
+/// \~english @par Causes of failures
+/// - None
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - This method will Enable the Auto Kill function in the destructor,\n
+/// thus killing the process whom this object represents.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+ void EnableAutoKill(void) {
+ m_fAutoKill = TRUE;
+ }
+
+ private:
+ // Class Data Members
+ //---------------------------------------------
+
+ long m_lValidationTag; // Used to check if this is a valid // NOLINT (runtime/int)
+ // object or not.
+
+ int m_cpu_assign;
+ pid_t m_tProcessId; // This is the process ID for this process. All command, control,
+ // and status gathering will use this ID.
+ eProcessLoadMode m_eProcessLoadMode; // This is the process load mode provided by the caller when this
+ // process was created.
+ SS_String m_strFile; // This is the executable path and file name of this process
+ StringList m_strlstArgv; // This is the calling parameter Argv list provided by the caller.
+ SS_String m_strProcessName; // This is the name that was registered to the OS for process identification
+
+ int m_iErrorCode; // This was the returned PosixBasedOS001 error code for the last call. The programmer
+ // can look at this error code if an error was detected and an
+ // exception was thrown.
+ BOOL m_fAutoKill; // Used to indicate to destructor to kill the process whom this object
+ // represents on exit.
+ int m_iReturnCode;
+
+ //////////////////////////////////////////////////////////////////////
+ /// Copy
+ ///
+ /// Copies data members from the specified object to this object.
+ /// No attempt is made to free dynamically allocated objects within
+ /// this object (you must do that before calling this function).
+ ///
+ ///////////////////////////////////////////////////////////////////////
+ void Copy(const Process& p_rhs_i);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ConvertToPosixBasedOS001SchedularPolicy
+ /// This method will return to the caller the equivalent PosixBasedOS001 schedular policy for the process
+ /// that this object represents
+ ///
+ ///
+ /// Calling Arguments:
+ /// Scheduling Policy
+ ///
+ /// \return policy
+ /// FIFO, A fixed priority scheduler in which the highest ready process runs until it
+ /// blocks or is preempted by a higher priority process.
+ /// ROUND_ROBIN, The same as FIFO, except processes at the same priority level time-slice.
+ /// OTHER A general time sharing scheduler in which a process decays in priority if it
+ /// consumes too much processor before blocking. It reverts to its default priority
+ /// when it blocks. Should it fail to run over a 2 second period and it has decayed
+ /// then it's boosted one priority level up to a maximum of its default priority.
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+ int const ConvertToPosixBasedOS001SchedularPolicy(
+ const eProcessSchedulingPolicy p_eSchedulingPolicy_i);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ConvertFromPosixBasedOS001SchedularPolicy
+ ///
+ /// This method will return to the caller the eProcessSchedulingPolicy based on the PosixBasedOS001 schedular
+ /// policy for the process that this object represents
+ ///
+ ///
+ /// Calling Arguments:
+ /// PosixBasedOS001 Scheduling Policy
+ ///
+ /// \return policy
+ /// FIFO, A fixed priority scheduler in which the highest ready process runs until it
+ /// blocks or is preempted by a higher priority process.
+ /// ROUND_ROBIN, The same as FIFO, except processes at the same priority level time-slice.
+ /// OTHER A general time sharing scheduler in which a process decays in priority if it
+ /// consumes too much processor before blocking. It reverts to its default priority
+ /// when it blocks. Should it fail to run over a 2 second period and it has decayed
+ /// then it's boosted one priority level up to a maximum of its default priority.
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////
+ eProcessSchedulingPolicy const ConvertFromPosixBasedOS001SchedularPolicy(
+ const int p_iPosixBasedOS001chedulingPolicy_i);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemServicesIf
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \brief Check environment variable MOCK_LIBRARY where Mock Library Name to set in LD_PRELOAD is set
+ /// and output character string to set in LD_PRELOAD if there is setting.
+ /// \return
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ void CheckLdPreLoad(SS_String *process_path, char *environment_string);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemServicesIf
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \brief Acquire the character string of the environment variable and set it in String Vector
+ /// and return in a pointer of Vector.
+ /// \return vector<SS_String> pointer
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ std::vector<SS_String> *GetEnvironVector(void);
+// ----------------------------------------
+// ---------------- End -------------------
+};
+#endif // NOLINT (build/header_guard)
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_timer.h b/systemservice/interface_unified/library/include/system_service/ss_system_timer.h
new file mode 100755
index 0000000..f95d1f9
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_timer.h
@@ -0,0 +1,670 @@
+/*
+ * @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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// brief This file supports a generic timer abstraction.
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ss_system_timer.h
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_manager
+ * @ingroup system_service
+ * @{
+ */
+
+
+#ifndef SS_SYSTEM_TIMER_H_ // NOLINT (build/header_guard)
+#define SS_SYSTEM_TIMER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <list>
+#include <map>
+
+
+const PCSTR TIMER_SERVICE_NAME = "TIMER";
+
+
+/**
+ * @class Timer
+ * \~english @brief Timer
+ * \~english @par Brief Introduction
+ * Class to provide Timer function
+ *
+ */
+class Timer {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Timer
+ /// \~english @par Summary
+ /// Default constructor of Timer class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// To generate a Timer class, and initialize member variables. \n
+ /// After the constructor, be sure to call the Initialize. \n
+ /// \~english @see ~Timer, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ Timer();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Timer
+ /// \~english @par Summary
+ /// Constructor of Timer class.
+ /// \~english @param [in] hdl
+ /// HANDLE - HANDLE for Application
+ /// \~english @param [in] id
+ /// UI_32 - Timer ID corresponding to the callback function
+ /// \~english @param [in] CbFn
+ /// CbFuncPtr - Pointer to a callback function to be called when the timer expires
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) has been
+ /// done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To generate a Timer class. \n
+ /// To initialize timer information structure of the member variables. \n
+ /// To initialize the member variables of the class with an argument. Therefore, there is no need to call the
+ /// Initialize() function when using this constructor.
+ /// \~english @see ~Timer, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ Timer(HANDLE hdl, UI_32 id, CbFuncPtr CbFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~Timer
+ /// \~english @par Summary
+ /// Destructor of Timer class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To delete a Timer class. \n
+ /// If the initialization is complete state, to end by calling the Shutdown().
+ /// \~english @see Timer
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~Timer();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Initialize
+ /// \~english @par Summary
+ /// Initialization of the Timer class.
+ /// \~english @param [in] hApp
+ /// HANDLE - HANDLE for Application
+ /// \~english @param [in] id
+ /// UI_32 - Timer ID corresponding to the callback function
+ /// \~english @param [in] CbFn
+ /// CbFuncPtr - Pointer to a callback function to be called when the timer expires
+ /// \~english @retval TRUE Initialization success
+ /// \~english @retval FALSE Initialization failed
+ /// \~english @par Preconditions
+ /// - Generation/initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop etc) has been
+ /// done.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Handle(hApp) that has been specified by the argument is NULL. [FALSE]
+ /// - Timer ID(id) that has been specified by the argument is 0. [FALSE]
+ /// - Pointer to a callback function that has been specified by the argument is NULL. [FALSE]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// To initialize the member variables of the following.
+ /// - HANDLE for Application
+ /// - Timer information structure
+ /// - Pointer to a callback function
+ /// - HANDLE of message queue
+ /// - Timer Object
+ /// \~english @par
+ /// A timer class to initialization completion state.
+ /// \~english @see ~Timer, Shutdown
+ ////////////////////////////////////////////////////////////////////////////////////
+ BOOL Initialize(HANDLE hApp, UI_32 id, CbFuncPtr CbFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Reinitialize
+ /// \~english @par Summary
+ /// - Reinitialize the timer by specifying a timer value information
+ /// \~english @param [in] id
+ /// UI_32 - timer id that you want to reinitialize
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - set m_tTi.iCmd with id
+ /// - using the result of function McOpenSender(FrameworkunifiedGetAppName(m_hApp)) to set m_hSnd
+ /// - create a timer and give the handle to m_hTmr
+ /// - set m_bInit with TRUE
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Method only
+ /// \~english @par Detail
+ /// Reinitialize the timer by specifying a timer value information, \n
+ /// create a new timer if it is not initialize.
+ /// \~english @see Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ void Reinitialize(UI_32 id);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Shutdown
+ /// \~english @par Summary
+ /// The end of the Timer class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// In the case of initialization completion state, it is completed by the following process.\n
+ /// - Stop the Timer
+ /// - Delete Timer Object
+ /// - Set NULL to a timer object variable
+ /// - Close message queue
+ /// - Set NULL to a message queue HANDLE variable
+ /// - The timer class to uninitialized.
+ /// \~english @par
+ /// \nIf you want to re-use this timer, call again Initialize() function.
+ /// \~english @see Timer, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ void Shutdown();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetTime
+ /// \~english @par Summary
+ /// Set the timer value information.
+ /// \~english @param [in] ss
+ /// UI_32 - Timeout expiration time(sec)
+ /// \~english @param [in] sms
+ /// UI_32 - Timeout expiration time(nano sec)
+ /// \~english @param [in] rs
+ /// UI_32 - Timeout expiration time at the time of repeat(sec)
+ /// \~english @param [in] rms
+ /// UI_32 - Timeout expiration time at the time of repeat(nano sec)
+ /// \~english @retval TRUE Setting success
+ /// \~english @retval FALSE Setting failed
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Not been initialized. [FALSE]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Set a timer value information specified by the argument to the timer information structure.
+ /// \~english @see Timer
+ ////////////////////////////////////////////////////////////////////////////////////
+ BOOL SetTime(UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Start
+ /// \~english @par Summary
+ /// The start of the timer by specifying a timer value information.
+ /// \~english @param [in] ss
+ /// UI_32 - Timeout expiration time(sec)
+ /// \~english @param [in] sms
+ /// UI_32 - Timeout expiration time(nano sec)
+ /// \~english @param [in] rs
+ /// UI_32 - Timeout expiration time at the time of repeat(sec)
+ /// \~english @param [in] rms
+ /// UI_32 - Timeout expiration time at the time of repeat(nano sec)
+ /// \~english @retval TRUE Stop success
+ /// \~english @retval FALSE Stop failed
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Not been initialized. [FALSE]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method only
+ /// \~english @par Detail
+ /// In the case of initialization completion state, start the timer. \n
+ /// After timer start, again, if you start the timer, it does not work guarantee.
+ /// \~english @see Stop
+ ////////////////////////////////////////////////////////////////////////////////////
+ BOOL Start(UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Start
+ /// \~english @par Summary
+ /// Stop the timer.
+ /// \~english @param None
+ /// \~english @retval TRUE Stop success
+ /// \~english @retval FALSE Stop failed
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// - Set the timeout value in SetTime().
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Not been initialized. [FALSE]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method only
+ /// \~english @par Detail
+ /// In the case of initialization completion state, start the timer. \n
+ /// After timer start, again, if you start the timer, it does not work guarantee.
+ /// \~english @see SetTime, Stop
+ ////////////////////////////////////////////////////////////////////////////////////
+ BOOL Start();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Stop
+ /// \~english @par Summary
+ /// Stop the timer.
+ /// \~english @param None
+ /// \~english @retval TRUE Stop success
+ /// \~english @retval FALSE Stop failed
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// - The timer has been started
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Not been initialized. [FALSE]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Method only
+ /// \~english @par Detail
+ /// In the case of initialization completion state, stop the timer. \n
+ /// After the timer has stopped, again, if you stop the timer, it does not do anything to just processing
+ /// Internal error occurs.
+ /// \~english @see Start
+ ////////////////////////////////////////////////////////////////////////////////////
+ BOOL Stop();
+
+ private:
+ BOOL m_bInit; /// flag that indicated if the class has been initialized or not
+ HANDLE m_hApp; /// refs to an applications hApp handle
+ HANDLE m_hSnd; /// refs to applications message queue
+ HANDLE m_hTmr; /// refs to a timer handle
+ NSTimerInfo m_tTi; /// timer parameters
+ CbFuncPtr m_CbFn; /// pointer to the callback method
+};
+
+/** @}*/ // end of Timer
+/** @}*/ // end of system_manager
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
+
+/**
+ * @class TimerCtrl
+ * \~english @brief TimerCtrl
+ * \~english @par Brief Introduction
+ * Class to provide TimerCtrl function
+ *
+ */
+class TimerCtrl {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup TimerCtrl
+ /// \~english @par Summary
+ /// Default Constructor, called when the class is instantiated.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ ///
+ /// \~english @par Change of the internal state
+ /// - set m_hApp as NULL,m_nTimersMax as DEFAULT_NTIMERS
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// To generate a TimerCtrl class. \n
+ /// After the constructor, be sure to call the Initialize. \n
+ /// \~english @see ~TimerCtrl, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ TimerCtrl();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup TimerCtrl
+ /// \~english @par Summary
+ /// Constructor, called when the class is instantiated.
+ /// \~english @param [in] ntimers
+ /// UI_32 - number of timers objects in the pool
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ ///
+ /// \~english @par Change of the internal state
+ /// - initialize var m_hApp and m_nTimersMax
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// To generate a TimerCtrl class. \n
+ /// After the constructor, be sure to call the Initialize. \n
+ /// \~english @see ~TimerCtrl, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ TimerCtrl(UI_32 ntimers); // NOLINT (runtime/explicit)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Initialize
+ /// \~english @par Summary
+ /// Initialize the class after instantiation.
+ /// \~english @param [in] hApp
+ /// HANDLE - HANDLE to you applications hApp.
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ ///
+ /// \~english @par Change of the internal state
+ /// - initialize var m_hApp and m_aTimers
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// The function is to initialize the member val of the class with param hApp,\n
+ /// if hApp is not null, then set m_hApp with hApp and initialize m_aTimers.
+ /// \~english @see ~TimerCtrl, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ VOID Initialize(HANDLE hApp);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Shutdown
+ /// \~english @par Summary
+ /// handle something when shut down timer control.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize()..
+ /// \~english @par Change of the internal state
+ /// - Clear m_aTimer,shut down timer in m_rTimer and delete it.clear m_rTimer.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Completely shuts down the timer control, this method calls Stop, cleans up. You must call
+ /// Initialize again if you want reuse this class.
+ /// \~english @see ~TimerCtrl, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ VOID Shutdown();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CreateTimer
+ /// \~english @par Summary
+ /// get a timer control from pool
+ /// \~english @param [in] CbFn
+ /// CbFn - Pointer to a callback function to be called when the timer expires
+ /// \~english @retval Timer id - If id is in m_aTimers
+ /// \~english @retval 0 - If id is not in m_aTimers
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - insert one Timer to m_rTimers
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// gets a the first id from m_aTimers if m_aTimer is not empty, using this id to create a timer,\n
+ /// put this timer into m_rTimers,and return the id.
+ /// \~english @see DeleteTimer
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_32 CreateTimer(CbFuncPtr CbFn);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup DeleteTimer
+ /// \~english @par Summary
+ /// delete a timer from m_rTimers using the param.
+ /// \~english @param [in] id
+ /// UI_32 - timer id that you want to delete
+ /// \~english @retval Timer id -If id is in m_aTimers
+ /// \~english @retval 0 - If id is not in m_aTimers
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - delete one Timer to m_rTimers that id is the param.\n
+ /// and put id of the timer into m_aTimers.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// delete your timer and returns it's id to the pool of timers.
+ /// \~english @see CreateTimer
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_32 DeleteTimer(UI_32 id);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetTimer
+ /// \~english @par Summary
+ /// Sets the timer timeout values
+ /// \~english @param [in] id
+ /// UI_32 - timer id that you want to set
+ /// \~english @param [in] ss
+ /// UI_32 - Start time in seconds
+ /// \~english @param [in] sms
+ /// UI_32 - Start time in milliseconds
+ /// \~english @param [in] rs
+ /// UI_32 - Repeat time in seconds
+ /// \~english @param [in] rms
+ /// UI_32 - Repeat time in milliseconds
+ /// \~english @retval Timer id - If id is in m_aTimers
+ /// \~english @retval 0 - If id is not in m_aTimers
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - set the timer infomation in m_rTimers with ss, sms, rs, rms
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// using ss, sms, rs, rms to set the timer infomation, timer'is is param.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_32 SetTimer(UI_32 id, UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StartTimer
+ /// \~english @par Summary
+ /// Sets the timer timeout values and starts the timer.
+ /// \~english @param [in] id
+ /// UI_32 - timer id that you want to start
+ /// \~english @param [in] ss
+ /// UI_32 - Timeout expiration time(sec)
+ /// \~english @param [in] sms
+ /// UI_32 - Timeout expiration time(nano sec)
+ /// \~english @param [in] rs
+ /// UI_32 - Timeout expiration time at the time of repeat(sec)
+ /// \~english @param [in] rms
+ /// UI_32 - Timeout expiration time at the time of repeat(nano sec)
+ /// \~english @retval Timer id - If id is in m_aTimers
+ /// \~english @retval 0 - If id is not in m_aTimers
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// In the case of initialization completion state, start the timer that id is the first param. \n
+ /// After timer start, again, if you start the timer, it does not work guarantee.
+ /// \~english @see Stop
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_32 StartTimer(UI_32 id, UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StartTimerMulti
+ /// \~english @par Summary
+ /// The start of the timer by specifying a timer value information and reinitialize timer id.
+ /// \~english @param [in] id
+ /// UI_32 - timer id that you want to start
+ /// \~english @param [in] ss
+ /// UI_32 - Timeout expiration time(sec)
+ /// \~english @param [in] sms
+ /// UI_32 - Timeout expiration time(nano sec)
+ /// \~english @param [in] rs
+ /// UI_32 - Timeout expiration time at the time of repeat(sec)
+ /// \~english @param [in] rms
+ /// UI_32 - Timeout expiration time at the time of repeat(nano sec)
+ /// \~english @param [in] subId
+ /// UI_32 - using subId to reinitialize timer id
+ /// \~english @retval Timer id - If id is in m_aTimers
+ /// \~english @retval 0 - If id is not in m_aTimers
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Finds the timer by specifying, shut down the timer, \n
+ /// and reinitialize it using new id of this timer and starts the timer
+ /// \~english @see Stop
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_32 StartTimerMulti(UI_32 id, UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms, UI_32 subId);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StartTimer
+ /// \~english @par Summary
+ /// Start the timer.
+ /// \~english @param [in] id
+ /// UI_32 - timer id that you want to start
+ /// \~english @retval Timer id - If id is in m_aTimers
+ /// \~english @retval 0 - If id is in not m_aTimers
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// - Set the timeout value in SetTimer().
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// In the case of initialization completion state, \n
+ /// start of the timer by specifying a timer value information.
+ /// \~english @see SetTime, Stop
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_32 StartTimer(UI_32 id);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup StopTimer
+ /// \~english @par Summary
+ /// Stop the timer.
+ /// \~english @param [in] id
+ /// UI_32 - timer id that you want to stop
+ /// \~english @retval Timer id - If id is in m_aTimers
+ /// \~english @retval 0 - If id is not in m_aTimers
+ /// \~english @par Preconditions
+ /// - That has been initialized in the Initialize().
+ /// - Set the timeout value in SetTimer().
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// In the case of start completion state, \n
+ /// stop of the timer by specifying a timer value information
+ /// \~english @see SetTimer, StartTimer
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_32 StopTimer(UI_32 id);
+
+ private:
+ HANDLE m_hApp; ///
+ UI_32 m_nTimersMax; ///
+ std::list<UI_32> m_aTimers; ///
+ std::map<UI_32, Timer*> m_rTimers; ///
+};
+
+
+#endif /* SS_SYSTEM_TIMER_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_system_types.h b/systemservice/interface_unified/library/include/system_service/ss_system_types.h
new file mode 100755
index 0000000..adcaf2b
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_system_types.h
@@ -0,0 +1,36 @@
+/*
+ * @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_SystemServicesIf
+/// \brief This file supports string vector type definitions.
+///
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ */
+#ifndef SS_SYSTEM_TYPES_H_ // NOLINT (build/header_guard)
+#define SS_SYSTEM_TYPES_H_
+
+#include <vector>
+#include <string>
+
+
+typedef std::string SS_String;
+typedef std::vector< std::string > StringList;
+typedef std::vector< std::string >::iterator StringListIter;
+
+#endif /* SS_SYSTEM_TYPES_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_templates.h b/systemservice/interface_unified/library/include/system_service/ss_templates.h
new file mode 100755
index 0000000..581e616
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_templates.h
@@ -0,0 +1,303 @@
+/*
+ * @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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// This file supports templates for high use common tasks.
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @file ss_templates.h
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef __SS_TEMPLATES_H__ // NOLINT (build/header_guard)
+#define __SS_TEMPLATES_H__
+
+#include <stdio.h>
+#include <errno.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <map>
+#include "system_service/ss_system_types.h"
+#include "system_service/ss_string_maps.h"
+
+#ifndef ZONE_ERR
+#define ZONE_ERR ZONEMASK(31)
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup ReadMsg
+/// \~english @par Summary
+/// check the data information of msg.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE Application
+/// \~english @param [in] Data
+/// T - The reference to the Data memory location
+/// \~english @param [in] f_eRetrieveMethod
+/// ESMRetrieveTypes - The msg retrieval method ( release or retain )
+/// \~english @par
+/// T template type
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Preconditions
+/// -
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - System Manager handle for the session is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - data'size is not corruct. [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method only
+/// \~english @par Detail
+/// Check hApp ptr, msg size, msg reception, read msg if all ok
+/// \~english @par
+/// eFrameworkunifiedStatus:Result
+/// - eFrameworkunifiedStatusOK:Success
+/// - Except eFrameworkunifiedStatusOK:Fail
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+template <typename T> EFrameworkunifiedStatus ReadMsg(
+ HANDLE hApp,
+ T &Data, // NOLINT (runtime/references)
+ ESMRetrieveTypes f_eRetrieveMethod = eSMRRelease) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if ( NULL == hApp ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: NULL = hApp");
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ } else if (sizeof(Data) != FrameworkunifiedGetMsgLength(hApp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__
+ , " Error: message buffer sizes mismatch: expected %ld, received %d"
+ , sizeof(Data), FrameworkunifiedGetMsgLength(hApp));
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else if ( eFrameworkunifiedStatusOK != (l_eStatus =
+ FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&Data, sizeof(Data), f_eRetrieveMethod))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__
+ , " Error: FrameworkunifiedGetMsgDataOfSize() errored: 0x%x", l_eStatus);
+ }
+ return l_eStatus;
+} // End of template <typename T> EFrameworkunifiedStatus ReadMsg ()
+ /* Copy & paste easy-to-use little 't' template
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if ( eFrameworkunifiedStatusOK != ( l_eStatus = ReadMsg<T>
+ ( hApp
+ , Data )))
+ {
+ LOG_ERROR("ReadMsg()");
+ }
+ else
+ */
+
+//****************************************************************************
+/*!
+ \def LOG_ERROR(pStr)
+ Log pStr and l_eStatus
+ */
+#define LOG_ERROR(pStr) \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__ \
+ , " Error: %s errored: %d/'%s'" \
+ , pStr \
+ , l_eStatus \
+ , GetStr(static_cast<EFrameworkunifiedStatus>(l_eStatus)).c_str());
+
+//****************************************************************************
+/*!
+ \def LOG_ERROR(pStr)
+ Log pStr and l_eStatus
+ */
+#define LOG_SUCCESS(pStr) \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s successful", pStr);
+
+//****************************************************************************
+/*!
+ \def LOG_STATUS(l_eStatus,pStr)
+ Log pStr and success or failure. Include l_eStatus when not successful.
+ */
+#define LOG_STATUS(l_eStatus, pStr) \
+ if ( eFrameworkunifiedStatusOK != l_eStatus ) \
+ { \
+ LOG_ERROR(pStr); \
+ } \
+ else \
+ { \
+ LOG_SUCCESS(pStr); \
+ } // End of #define LOG_STATUS(l_eStatus,pStr)
+
+//****************************************************************************
+/*!
+ \def CALL_AND_LOG_STATUS(fnc)
+ Call the function and log the returned EFrameworkunifiedStatus.
+ */
+#define CALL_AND_LOG_STATUS(fnc) \
+ l_eStatus = (fnc); \
+ LOG_STATUS(l_eStatus, #fnc)
+ // End of #define CALL_AND_LOG_STATUS(fnc)
+
+//****************************************************************************
+/*!
+ \def LOG_STATUS_IF_ERRORED(l_eStatus, pStr)
+ Log pStr on failure, including EFrameworkunifiedStatus.
+ */
+#define LOG_STATUS_IF_ERRORED(l_eStatus, pStr) \
+ if ( eFrameworkunifiedStatusOK != l_eStatus ) \
+ { \
+ LOG_ERROR(pStr); \
+ } // End of #define LOG_STATUS_IF_ERRORED(l_eStatus,pStr)
+
+//****************************************************************************
+/*!
+ \def CALL_AND_LOG_STATUS_IF_ERRORED(fnc)
+ Call the function and log the returned EFrameworkunifiedStatus on failure.
+ */
+#define CALL_AND_LOG_STATUS_IF_ERRORED(fnc) \
+ l_eStatus = (fnc); \
+ LOG_STATUS_IF_ERRORED(l_eStatus, #fnc)
+ // End of #define CALL_AND_LOG_STATUS_IF_ERRORED(fnc)
+
+//****************************************************************************
+/*!
+ \def MAP_ENTRY( f_map, f_enum )
+ Simplify initializing string map entry.
+
+ Use to set a map entry's key and value to the specified enum and the enum's
+ literal text ( i.e., stringified ) equivalent.
+ */
+#define MAP_ENTRY(f_map, f_enum) \
+ f_map[ f_enum ] = #f_enum
+
+//****************************************************************************
+/*!
+ \def INTERFACEUNIFIEDLOG_RECEIVED_FROM
+ Log whom we received message or notification from.
+
+ Use this macro to ensure that the string "Received from" is uniformly
+ logged; this string can be grepped on to find when/where callback functions
+ were invoked.
+ */
+#define INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp) \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from %s", FrameworkunifiedGetMsgSrc(hApp))
+
+//****************************************************************************
+/*!
+ \def INTERFACEUNIFIEDLOG_WHEN_COMPILED
+ Log when this file was compiled.
+
+ Useful when overlaying a delivered object file ( from an official build ) with
+ a debug-built obj file - verifies that the debug file did indeed get loaded.
+ */
+#define INTERFACEUNIFIEDLOG_WHEN_COMPILED \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s was compiled at %s @ %s", \
+ __FILE__, __DATE__, __TIME__);
+
+
+#define SS_ASERT(x) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SS_ASSERT"); \
+ }
+
+#define SS_ASERT_ERRNO(x) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SS_ASSERT %d:%s", errno, strerror(errno)); \
+ }
+
+#define SS_ASERT_LOG(x, fmt, ...) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SS_ASSERT " fmt, ## __VA_ARGS__); \
+ }
+
+#define SS_STATIC_ASERT(expr) \
+ { \
+ char STATIC_ASSERTION_FAILED[(expr) ? 1 : -1]; \
+ (void)STATIC_ASSERTION_FAILED; \
+ }
+
+/**
+ * @class EnumStringMap
+ * \~english @brief EnumStringMap
+ * \~english @par Brief Introduction
+ * Class to provide EnumStringMap template function
+ *
+ */
+template <typename enumT, void(*fp)(std::map<enumT, SS_String> & m_strMap)> class EnumStringMap { // NOLINT (runtime/references)
+public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup EnumStringMap
+ /// \~english @par Summary
+ /// Default constructor of EnumStringMap class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To generate a EnumStringMap class, and initialize member variables. \n
+ /// After the constructor, be sure to call the Initialize. \n
+ /// \~english @see ~EnumStringMap, Initialize
+ ////////////////////////////////////////////////////////////////////////////////////
+ EnumStringMap() {
+ (*fp)(m_strMap);
+ }
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~EnumStringMap
+ /// \~english @par Summary
+ ///
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To delete a EnumStringMap object. \n
+ /// \~english @see EnumStringMap
+ ////////////////////////////////////////////////////////////////////////////////////
+ ~EnumStringMap() {}
+ SS_String GetStr( enumT f_enum) { return m_strMap[ f_enum ];}
+private:
+ std::map<enumT, SS_String> m_strMap;
+};
+// End of template <typename enumT, void(*fp)(std::map<enumT, SS_String> & m_strMap)> class EnumStringMap
+
+#endif /* __SS_TEMPLATES_H__ */ // NOLINT (build/header_guard)
+
diff --git a/systemservice/interface_unified/library/include/system_service/ss_test_clients.h b/systemservice/interface_unified/library/include/system_service/ss_test_clients.h
new file mode 100755
index 0000000..a50e61f
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_test_clients.h
@@ -0,0 +1,31 @@
+/*
+ * @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 system_manager
+/// \file ss_test_clients.h
+/// \brief This file supports test client queue names.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_TC_SERVICES_H_ // NOLINT (build/header_guard)
+#define SS_TC_SERVICES_H_
+
+
+#define TC_Power "PwrTestClient"
+#define TC_SysManager "SMTestClient"
+
+#endif /* SS_TC_SERVICES_H_ */ // NOLINT (build/header_guard)
diff --git a/systemservice/interface_unified/library/include/system_service/ss_version.h b/systemservice/interface_unified/library/include/system_service/ss_version.h
new file mode 100755
index 0000000..856f334
--- /dev/null
+++ b/systemservice/interface_unified/library/include/system_service/ss_version.h
@@ -0,0 +1,33 @@
+/*
+ * @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 sys_resource
+/// \file ss_version.h
+/// \brief This file supports System Manager version number management.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_VERSION_H__ // NOLINT (build/header_guard)
+#define SS_VERSION_H__
+
+#define MAJORNO 0x01
+#define MINORNO 0x00
+#define REVISION 0x01
+
+#endif // SS_VERSION_H__ // NOLINT (build/header_guard)
+
+
diff --git a/systemservice/interface_unified/library/src/libSS_SystemIfUnified.ver b/systemservice/interface_unified/library/src/libSS_SystemIfUnified.ver
new file mode 100755
index 0000000..7a646f2
--- /dev/null
+++ b/systemservice/interface_unified/library/src/libSS_SystemIfUnified.ver
@@ -0,0 +1,78 @@
+/*
+ * @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.
+ */
+
+#
+# libNS_FrameworkUnified version script
+#
+{
+ global:
+ ### .text section ###
+ extern "C++" {
+ AttachCallbackToSystemManager*;
+ DetachCallbacksFromInterfaceunifiedDispatcher*;
+ DetachParentCallbacksFromInterfaceunifiedDispatcher*;
+ GetStr*;
+ GetSystemManagerSessionHandle*;
+ SendInterfaceunifiedOnStopResponseToSystemManager*;
+ GetInterfaceunifiedOnStartExtInfo*;
+ GetInterfaceunifiedOnStopExtInfo*;
+ OnSystemManagerDebugDump*;
+ FrameworkunifiedSSFrameworkInterface*;
+ RegisterSMSessionAckCallback*;
+ RemountPartition*;
+ SendBootModeSetRequestToSystemManager*;
+ SetDataResetModeToSystemManager*;
+ SetProgUpdateStateToSystemManager*;
+ SendCANLoggingRequestToSystemManager*;
+ SendCpuResetRequestToSystemManager*;
+ SendDTCLoggingRequestToSystemManager*;
+ SendDebugDumpResponseToSystemManager*;
+ SendDiagLoggingRequestToSystemManager*;
+ SendEelExportRequestToSystemManager*;
+ SendLogArtifactRequestToSystemManager*;
+ SendLogCompleteRequestToSystemManager*;
+ SendLogStartRequestToSystemManager*;
+ SendInterfaceunifiedEmmcLogsRequestToSystemManager*;
+ SendClearLogsRequestToSystemManager*;
+ SendShutdownToSystemManager*;
+ SendStartupConfirmationToSystemManager*;
+ SendSystemModeRequestToSystemManager*;
+ SendInitCompReportToSystemManager*;
+ Send_CWORD56_HeartBeatRequestToSystemManager*;
+ SendVarCodeDataToSystemManager*;
+ SendWakeUpToSystemManager*;
+ SetBootLoaderInfoRequestToSystemManager*;
+
+ GetBootLoaderInfoRequestToSystemManager*;
+
+ SetWakeupOrderToSystemManager*;
+ SetNextWakeupTypeToSystemManager*;
+ Set_UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc_StateVar*;
+ SendUserInvokedLoggingRequestToSystemManager*;
+ RegisterBootMicroLogRequestCb*;
+ SendBootMicroResetNotificationToSystemManager*;
+ SendBootMicroLogResponseToSystemManager*;
+ SS_ConvLastInfoToOrder*;
+ DeviceDetectionServiceIf::*;
+ LoggerServiceIf::*;
+ Process::*;
+ Timer::*;
+ TimerCtrl::*;
+ };
+ local:
+ *;
+};
+
diff --git a/systemservice/interface_unified/library/src/makefile_PosixBasedOS001 b/systemservice/interface_unified/library/src/makefile_PosixBasedOS001
new file mode 100755
index 0000000..68fa52e
--- /dev/null
+++ b/systemservice/interface_unified/library/src/makefile_PosixBasedOS001
@@ -0,0 +1,180 @@
+#
+# @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.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = SS_PowerServiceIf
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+##COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+ifdef DYNAMIC_OFF
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(PRJ_ROOT)../$(COMPONENT_NAME)/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC_OFF
+# For a dynamic library
+ $(SLIB_CMD)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
+
diff --git a/systemservice/interface_unified/library/src/ss_devicedetection_service_ifc.cpp b/systemservice/interface_unified/library/src/ss_devicedetection_service_ifc.cpp
new file mode 100755
index 0000000..1f68df6
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_devicedetection_service_ifc.cpp
@@ -0,0 +1,673 @@
+/*
+ * @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_SystemServices_DeviceDetection
+/// \brief This file contains service interface functions.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "system_service/ss_devicedetection_service_ifc.h"
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <string.h>
+
+#ifdef AGL_STUB
+#else
+#include "dcmd_sim_mmcsd.h"
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#ifdef AGL_STUB
+#else
+#include <sys/dcmd_cam.h>
+#endif
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <linux/cdrom.h>
+#include <asm-generic/param.h>
+
+#include "system_service/ss_services.h"
+#include "system_service/ss_devicedetection_service_protocol.h"
+#include "system_service/ss_devicedetection_service_protocol_local.h"
+#include "system_service/ss_devicedetection_service_notifications.h"
+#include "system_service/ss_devicedetection_service_local.h"
+#include "system_service/ss_devicedetection_service_types_local.h"
+#include "ss_devicedetection_service_if_interfaceunifiedlog.h"
+
+DeviceDetectionServiceIf::DeviceDetectionServiceIf()
+ : m_hApp(NULL),
+ m_hService(NULL),
+ m_hSession(NULL) {
+}
+
+DeviceDetectionServiceIf::~DeviceDetectionServiceIf() {
+ CloseSessionRequest(); // if the session is still connected
+ if ((NULL != m_hApp) && (NULL != m_hService)) {
+ FrameworkunifiedCloseService(m_hApp, m_hService);
+ }
+ m_hService = NULL;
+ m_hSession = NULL;
+ m_hApp = NULL;
+} // LCOV_EXCL_BR_LINE 10:Because destructor
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::NotifyOnDeviceDetectionAvailability(
+ CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp && NULL != f_pCallBackFn) {
+ // Subscriptions
+ FrameworkunifiedNotificationCallbackHandler
+ g_aryDeviceDetect_Notif_Cbs[] = {
+ // Notifications name, Call back function
+ { NTFY_SS_Device_Detection_Service_Availability, f_pCallBackFn},
+ };
+
+ if (0 != strcmp(SS_DEV_DETECT_SRV, FrameworkunifiedGetAppName(m_hApp))) {
+ // Subscribe and attach call backs to notifications
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedSubscribeNotificationsWithCallback(
+ m_hApp, g_aryDeviceDetect_Notif_Cbs,
+ _countof(g_aryDeviceDetect_Notif_Cbs)))) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Error: FrameworkunifiedAttachNotificationCallbacksToDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::DetachDeviceDetectionAvailabilityCb() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp) {
+ if (0 != strcmp(SS_DEV_DETECT_SRV, FrameworkunifiedGetAppName(m_hApp))) {
+ // Unsubscribe and detach call backs to notifications
+ if (eFrameworkunifiedStatusOK != (eStatus =
+ FrameworkunifiedUnsubscribeNotificationWithCallback(m_hApp, NTFY_SS_Device_Detection_Service_Availability))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: InterfaceunifiedDetachNotificationCallback Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::NotifyOnOpenSessionAck(
+ CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp && NULL != f_pCallBackFn) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
+ SS_DEV_DETECT_SRV,
+ PROTOCOL_OPEN_SESSION_ACK,
+ f_pCallBackFn))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::DetachOpenSessionAckCb() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(m_hApp,
+ SS_DEV_DETECT_SRV,
+ PROTOCOL_OPEN_SESSION_ACK))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedDetachCallbackFromDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::NotifyOnCloseSessionAck(
+ CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hApp && NULL != f_pCallBackFn) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
+ SS_DEV_DETECT_SRV,
+ PROTOCOL_CLOSE_SESSION_ACK,
+ f_pCallBackFn))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::DetachCloseSessionAckCb() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hApp) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(
+ m_hApp,
+ SS_DEV_DETECT_SRV,
+ PROTOCOL_CLOSE_SESSION_ACK))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedDetachCallbackFromDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::RegisterForDeviceDetectionEvent(
+ SS_DeviceDetectionServerEvents f_eDevDetectEvent, CbFuncPtr f_pCallBackFn,
+ PCSTR pFilepath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ char l_filepathname[FILEPATH_SIZE] = { '\0' };
+ int len = 0;
+
+ if (NULL != pFilepath) {
+ len = strlen(pFilepath);
+ strcpy(l_filepathname, pFilepath); // NOLINT (runtime/printf)
+ }
+
+ if (NULL != m_hSession && NULL != f_pCallBackFn) {
+ if (CheckDetectEvent(f_eDevDetectEvent)) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
+ SS_DEV_DETECT_SRV,
+ f_eDevDetectEvent,
+ f_pCallBackFn, m_hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+
+ eStatus = FrameworkunifiedSendMsg(m_hSession, SS_REGISTER_DETECT_EVENT,
+ sizeof(SS_DeviceDetectionServerEvents),
+ &f_eDevDetectEvent);
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
+ SS_DEV_DETECT_SRV,
+ f_eDevDetectEvent,
+ f_pCallBackFn, m_hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+
+ // client registers for the event
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedRegisterEvent(m_hSession, f_eDevDetectEvent))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedRegisterEvents Failed Status:0x%x", eStatus);
+ }
+
+ if (NULL != pFilepath) {
+ eStatus = FrameworkunifiedSendMsg(m_hSession, SS_REGISTER_FILEPATHNAME, len,
+ l_filepathname);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::UnRegisterForDeviceDetectionEvent(
+ SS_DeviceDetectionServerEvents f_eDevDetectEvent) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(m_hApp,
+ SS_DEV_DETECT_SRV,
+ f_eDevDetectEvent,
+ m_hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: InterfaceunifiedDetachCallbackToDispatcher Failed Status:0x%x ", eStatus);
+ }
+
+ // client registers for the event
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedUnRegisterEvent(m_hSession, f_eDevDetectEvent))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedUnRegisterEvents Failed Status:0x%x", eStatus);
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(m_hSession, SS_UNREGISTER_DETECT_EVENT,
+ sizeof(SS_DeviceDetectionServerEvents),
+ &f_eDevDetectEvent))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "UnRegister Detect Event[0x%x] Send Error[0x%x]", f_eDevDetectEvent, eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+BOOL DeviceDetectionServiceIf::Initialize(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_eStatus = TRUE;
+
+ if (NULL != hApp) {
+ m_hApp = hApp;
+ } else {
+ l_eStatus = FALSE; // eFrameworkunifiedStatusInvldHandle;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::OpenSessionRequest() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp) {
+ // if the session is there then we need to close it first!
+ if (NULL != m_hService) {
+ CloseSessionRequest();
+ FrameworkunifiedCloseService(m_hApp, m_hService);
+ m_hService = NULL;
+ }
+ BOOL l_bServiceAvailable = FrameworkunifiedIsServiceAvailable(m_hApp);
+ if (FALSE == l_bServiceAvailable) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "DeviceError: Service is unavailable");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // Now open the service.
+ if (l_bServiceAvailable
+ && (NULL != (m_hService = OpenService()))) { // LCOV_EXCL_BR_LINE 8:Because l_bServiceAvailable is always TRUE
+ // [DM: TODO] Check if we need to open a session with some data sent to Server.
+ UI_32 l_pTestData = 1;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedOpenSessionWithData(m_hService,
+ (PVOID) &l_pTestData,
+ sizeof(UI_32)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: FrameworkunifiedOpenSessionWithData Failed");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: FrameworkunifiedOpenService Failed");
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: OpenSessionRequest Failed %X",
+ l_eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+HANDLE DeviceDetectionServiceIf::OpenService() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ HANDLE l_hService = NULL;
+
+ if (NULL == (l_hService = FrameworkunifiedOpenService(m_hApp, SS_DEV_DETECT_SRV))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: FrameworkunifiedOpenService : Failed to open Device Detection Service");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_hService;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::DecodeOpenSessionResponse() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hApp) { // LCOV_EXCL_BR_LINE 8:Because when m_hApp is NULL, m_hService is NULL
+ if (NULL == (m_hSession = FrameworkunifiedGetOpenSessionHandle(m_hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: Error in extracting OpenSessionAck response.");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Logger Session Name: %s, Session Id: %d",
+ FrameworkunifiedGetSessionName(m_hSession), FrameworkunifiedGetSessionId(m_hSession));
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Error. m_hService: %p, m_hApp: %p is NULL. Open session handle not acquired,"
+ " l_eStatus: eFrameworkunifiedStatusInvldHandle.", m_hService, m_hApp);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::CloseSessionRequest() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(m_hService, m_hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedCloseSession Failed");
+ }
+ m_hSession = NULL; // clear our session handle
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+BOOL DeviceDetectionServiceIf::CheckDetectEvent(
+ SS_DeviceDetectionServerEvents f_eDevDetectEvent) {
+ BOOL chkevt = FALSE;
+
+ switch (f_eDevDetectEvent) {
+ case SS_DEV_INFO_ANY_USB_EV:
+ case SS_DEV_DETECT_ANY_USB_EV:
+ case SS_DEV_DETECT_ANY_SD_EV:
+ case SS_DEV_DETECT_ANY_DISC_EV:
+ case SS_DEV_DETECT_ANY_USB_NCM_EV:
+
+ case SS_DEV_DETECT_ANY_USB_DCM_NCM_EV:
+ case SS_DEV_DETECT_ANY_USB__CWORD57__EV:
+ case SS_DEV_DETECT_ANY_USB_ACM_EV:
+ case SS_DEV_DETECT_ANY_USB_DEV_MNG_EV:
+ case SS_DEV_DETECT_ANY_USB_VEHICLE_CTRL_EV:
+ case SS_DEV_DETECT_ANY_USB_DSRC_APP_EV:
+ case SS_DEV_DETECT_ANY_USB_DSRC_CTRL_EV:
+ case SS_DEV_DETECT_ANY_USB_IR_VICS_DATA_EV:
+ case SS_DEV_ERR_USB_OVER_CURRENT_EV:
+ case SS_DEV_DETECT_ANY_USB_MTP_EV:
+ case SS_DEV_INFO_ANY_USB_NOTIFY_EV:
+ case SS_DEV_DETECT_ANY_USB__CWORD57__ROLE_EV:
+ case SS_DEV_INFO_SD_FORMAT_COMP_EV:
+ case SS_DEV_INFO_ANY_USB_DVDP_EV:
+ chkevt = TRUE;
+ break;
+ default:
+ break;
+ }
+ return chkevt;
+}
+
+static void ReadString(const char *file, char *buf, int len) {
+ int fd;
+ ssize_t r;
+ char *tmp;
+
+ if (file == NULL) { // LCOV_EXCL_BR_LINE 8:Because file is not NULL
+ // LCOV_EXCL_START 8:Because file is not NULL
+ buf[0] = '\0';
+ return;
+ // LCOV_EXCL_STOP
+ }
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0) { // LCOV_EXCL_BR_LINE 6:Because the sequence at the time of open failure cannot be passed
+ // LCOV_EXCL_START 6:Because the sequence at the time of open failure cannot be passed
+ buf[0] = '\0';
+ return;
+ // LCOV_EXCL_STOP
+ }
+
+ r = read(fd, buf, len);
+ close(fd);
+ if (r > 0 && r < len) {
+ buf[r] = '\0';
+ r--;
+ /* If there is a line feed code'\n' at the end of the acquired data, replace it with '\0' */
+ while (buf[r] == '\n') {
+ buf[r] = '\0';
+ if (r == 0)
+ break;
+ r--;
+ }
+ /* If there is a line feed code'\n' in the middle of the acquired data, replace with '\0' */
+ tmp = buf;
+ while ((tmp = strchr(tmp, '\n')) != NULL) {
+ *tmp = ' ';
+ tmp++;
+ }
+ return;
+ } else {
+ buf[0] = '\0';
+ }
+}
+
+static bool isMounttedDir(char* pMountDir) {
+ char buf[4096];
+
+ if (!pMountDir) { // LCOV_EXCL_BR_LINE 8:Because pMountDir is not NULL
+ // LCOV_EXCL_START 8:Because pMountDir is not NULL
+ return false;
+ // LCOV_EXCL_STOP
+ }
+
+ ReadString("/proc/mounts", buf, sizeof(buf));
+ if (strstr(buf, pMountDir)) { // The mount folder is already in use as a mount point
+ return true;
+ }
+
+ return false;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::MountSD(uint8_t part_num,
+ BOOL *already_mounted) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "part_num %d", part_num);
+
+ if (NULL == m_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_hSession is NULL");
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ if (part_num > 3) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ char mount_dir[256];
+ if (part_num != 0) {
+ sprintf(mount_dir, "/mnt/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
+ } else {
+ sprintf(mount_dir, "/mnt/mmcblk1"); // NOLINT (runtime/printf)
+ }
+ if (isMounttedDir(mount_dir)) {
+ *already_mounted = TRUE;
+ return eFrameworkunifiedStatusOK;
+ } else {
+ *already_mounted = FALSE;
+ }
+
+ char filename[256];
+ struct stat st;
+ if (part_num != 0) {
+ sprintf(filename, "/dev/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
+ } else {
+ sprintf(filename, "/dev/mmcblk1"); // NOLINT (runtime/printf)
+ }
+ if (stat(filename, &st) != 0) {
+ return eFrameworkunifiedStatusAccessError;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedSendMsg(m_hSession, SS_DEV_MOUNT_SD, sizeof(uint8_t),
+ &part_num))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Send MountSD msg Sucessfully");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::UmountSD(uint8_t part_num,
+ BOOL *already_umounted) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "part_num %d", part_num);
+
+ if (NULL == m_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_hSession is NULL");
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ if (part_num > 3) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ char mount_dir[256];
+ if (part_num != 0) {
+ sprintf(mount_dir, "/mnt/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
+ } else {
+ sprintf(mount_dir, "/mnt/mmcblk1"); // NOLINT (runtime/printf)
+ }
+
+ if (isMounttedDir(mount_dir)) {
+ *already_umounted = FALSE;
+ } else {
+ *already_umounted = TRUE;
+ return eFrameworkunifiedStatusOK;
+ }
+
+ char filename[256];
+ struct stat st;
+
+ if (part_num != 0) {
+ sprintf(filename, "/dev/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
+ } else {
+ sprintf(filename, "/dev/mmcblk1"); // NOLINT (runtime/printf)
+ }
+ if (stat(filename, &st) != 0) {
+ return eFrameworkunifiedStatusAccessError;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedSendMsg(m_hSession, SS_DEV_UMOUNT_SD, sizeof(uint8_t),
+ &part_num))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Send UmountSD msg Sucessfully");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return eStatus;
+}
+
+static const uint8_t VBUS_RESET_INTERVAL_MIN = 11;
+
+static EFrameworkunifiedStatus SendUsbVBusResetMsg(HANDLE handle, int8_t port, uint8_t interval) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == handle) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Invalid Handle.");
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ int16_t data[] = {port, interval};
+ eStatus = FrameworkunifiedSendMsg(handle, SS_USB_VBUS_RESET, sizeof(data), data);
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Send Error[0x%x]", eStatus);
+ return eStatus;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::UsbVBusReset(int8_t port, uint8_t interval) {
+ return SendUsbVBusResetMsg(m_hSession, port, interval);
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::UsbVBusReset(int8_t port) {
+ return SendUsbVBusResetMsg(m_hSession, port, VBUS_RESET_INTERVAL_MIN);
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::RoleSwStateNotify(
+ SS_DEV_ROLE_SW_STATE state) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ EFrameworkunifiedStatus result = eFrameworkunifiedStatusFail;
+ UI_32 rcvlength = 0;
+ UI_32 bufflength;
+
+ if (NULL == m_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "No Session");
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ bufflength = sizeof(EFrameworkunifiedStatus);
+ eStatus = FrameworkunifiedInvokeSync(m_hSession, SS_DEV_ROLE_SW_STATE_NOTIFY,
+ sizeof(SS_DEV_ROLE_SW_STATE), &state, bufflength,
+ &result, &rcvlength);
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Send Error[0x%x]", eStatus);
+ return eStatus;
+ }
+
+ if (bufflength != rcvlength) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedInvokeSync Response Error. bufflen[%d], rcvlen[%d]", bufflength,
+ rcvlength);
+ return eStatus;
+ }
+
+ eStatus = result;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus DeviceDetectionServiceIf::FormatSD(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == m_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid Handle.");
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ if (access("/dev/mmcblk1", F_OK) != 0) {
+ return eFrameworkunifiedStatusAccessError;
+ }
+
+ eStatus = FrameworkunifiedSendMsg(m_hSession, SS_DEV_FORMAT_SD, 0, NULL);
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Send Error[0x%x]", eStatus);
+ return eStatus;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+} // LCOV_EXCL_BR_LINE 10:Because the last line
+
diff --git a/systemservice/interface_unified/library/src/ss_framework_if.cpp b/systemservice/interface_unified/library/src/ss_framework_if.cpp
new file mode 100755
index 0000000..91d323a
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_framework_if.cpp
@@ -0,0 +1,55 @@
+/*
+ * @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_SystemManagerIf
+/// \brief This file provides support for the System Manager AGL framework
+/// interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <string.h>
+#include "system_service/ss_system_if.h"
+#include "system_service/interfaceunified_system_application.h"
+#include "system_service/ss_services.h"
+#include "system_service/ss_test_clients.h"
+#include "system_service/ss_templates.h"
+#include "ss_system_if_interfaceunifiedlog.h"
+
+HANDLE g_SystemIf_hApp = NULL;
+
+EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ g_SystemIf_hApp = hApp;
+ PCSTR pAppNameStr = FrameworkunifiedGetAppName(hApp);
+
+ if (0 != strcmp(SERVICE_SYSMANAGER, pAppNameStr) &&
+ 0 != strcmp(TC_Power, pAppNameStr)) {
+ l_eStatus = InterfaceunifiedSystemConnectToSystemManagerService(hApp);
+ LOG_STATUS(l_eStatus, "InterfaceunifiedSystemConnectToSystemManagerService()");
+
+ if (0 != strcmp(TC_SysManager, pAppNameStr)) {
+ l_eStatus = InterfaceunifiedSystemConnectToHeartBeatService(hApp);
+ LOG_STATUS(l_eStatus, "InterfaceunifiedSystemConnectToHeartBeatService()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // LCOV_EXCL_BR_LINE 10:Because the last line
diff --git a/systemservice/interface_unified/library/src/ss_heartbeat_client.cpp b/systemservice/interface_unified/library/src/ss_heartbeat_client.cpp
new file mode 100755
index 0000000..a080e9a
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_heartbeat_client.cpp
@@ -0,0 +1,156 @@
+/*
+ * @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_SystemManagerIf
+/// \brief This file provides support for the System Manager client
+/// heartbeat service interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <new>
+#include "system_service/ss_heartbeat_service_protocol.h"
+#include "system_service/ss_heartbeat_notifications.h"
+#include "system_service/ss_heartbeat_if.h"
+#include "system_service/ss_services.h"
+#include "system_service/ss_sm_thread_names.h"
+#include "system_service/ss_templates.h"
+#include "ss_system_if_interfaceunifiedlog.h"
+
+CHeartBeatServiceIf * pHeartBeatServiceIf = NULL;
+
+template <typename C, eFrameworkunifiedStatus(C::*M)(HANDLE)>
+
+// LCOV_EXCL_START 6:Because process initialization
+EFrameworkunifiedStatus HeartBeatIfCallback(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
+ C * pObj = static_cast<C *>(pHeartBeatServiceIf);
+ if (pObj) {
+ l_eStatus = (pObj->*M)(hApp);
+ }
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: InterfaceunifiedSystemConnectToHeartBeatService
+ @note: . Called from framework for every app to start connection to HeartBeat
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus OK or Fail
+*****************************************************************************/
+EFrameworkunifiedStatus InterfaceunifiedSystemConnectToHeartBeatService(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ /// Avoid opening a session to the HeartBeat
+ /// service Since it uses the framework as well
+ /// Avoid opening a session to System Manager For testing
+ // TODO(my_username): Remove system manager check
+ if ((0 != strcmp(SERVICE_SYSMANAGER, FrameworkunifiedGetAppName(hApp)))) {
+ FrameworkunifiedProtocolCallbackHandler g_aryHeartBeat_Protocol_Cbs[] = {
+ // Command ID, Call back functions
+ { SS_HEARTBEAT_REQUEST, HeartBeatIfCallback<CHeartBeatServiceIf, &CHeartBeatServiceIf::OnHeartBeatRequest>}
+ }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ /// Attach the valid callback for this service
+ if ( eFrameworkunifiedStatusOK != // LCOV_EXCL_BR_LINE 6:Because process initialization
+ (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hApp,
+ SS_SMHeartbeat,
+ g_aryHeartBeat_Protocol_Cbs,
+ _countof(g_aryHeartBeat_Protocol_Cbs)))) {
+ LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher()");
+ } else {
+ // LCOV_EXCL_BR_LINE 5:Because constructor
+ pHeartBeatServiceIf =
+ new(std::nothrow) CHeartBeatServiceIf(FALSE, NULL, FrameworkunifiedGetAppName(hApp));
+ } // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Heartbeat service name duplicated.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_eStatus; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: CHeartBeatServiceIf constructor
+ @param -
+*****************************************************************************/
+CHeartBeatServiceIf::CHeartBeatServiceIf(BOOL avail, HANDLE service, PCSTR name) {
+ g_tHeartBeatSession.szServiceName = name; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ g_tHeartBeatSession.fAvailable = avail;
+ g_tHeartBeatSession.hService = service;
+}
+
+// LCOV_EXCL_START 10:Because destructor
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: CHeartBeatServiceIf destructor
+*****************************************************************************/
+CHeartBeatServiceIf::~CHeartBeatServiceIf() {
+ if (pHeartBeatServiceIf != NULL) {
+ delete pHeartBeatServiceIf;
+ pHeartBeatServiceIf = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 6:Because process initialization
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: OnHeartBeatRequest
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus OK or Fail
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatServiceIf::OnHeartBeatRequest(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_availability;
+
+ if (g_tHeartBeatSession.hService == NULL) {
+ if ( NULL == (g_tHeartBeatSession.hService = FrameworkunifiedMcOpenSender(hApp, SS_SMHeartbeat)) ) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedMcOpenSender(%s) returned NULL",
+ SS_SMHeartbeat);
+ return l_eStatus;
+ }
+ }
+
+ if ( (0 == strcmp(SS_SMHeartbeat, FrameworkunifiedGetMsgSrc(hApp))) ) {
+ if (NULL != g_tHeartBeatSession.hService) {
+ l_availability = FrameworkunifiedGetSelfAvailability(hApp);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(g_tHeartBeatSession.hService, SS_HEARTBEAT_RESPONSE,
+ sizeof(l_availability), &l_availability))) {
+ LOG_ERROR("FrameworkunifiedSendMsg");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid handle[_g_hHeartBeatSessionHandle = :NULL]");
+ }
+ }
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
diff --git a/systemservice/interface_unified/library/src/ss_last_to_order.cpp b/systemservice/interface_unified/library/src/ss_last_to_order.cpp
new file mode 100755
index 0000000..140101f
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_last_to_order.cpp
@@ -0,0 +1,186 @@
+/*
+ * @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.
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <agl_wakeup_order.h>
+#include <list>
+#include <fstream>
+#include <iostream>
+#include <stdexcept>
+#include <string>
+#include "system_service/ss_last_to_order.h"
+#include "ss_last_to_order_local.h"
+
+#include "system_service/ss_templates.h"
+#include "ss_system_if_interfaceunifiedlog.h"
+#define SCO_STATE_LOG(...) FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, __VA_ARGS__);
+#define SCO_ERROR_LOG(...) FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, __VA_ARGS__);
+#define SCO_ASSERT(x) SS_ASERT(x);
+
+//************* CONFIG FILE Format ****************
+#define ORDERNAME_MAX 64
+#define CONTENT_NAME_MAX 128
+#pragma pack(push, 1)
+typedef struct {
+ char lastinfo[SS_CCAT_MAX][CONTENT_NAME_MAX];
+ char orderName[ORDERNAME_MAX];
+}SS_LASTINFO_TO_OEDER_PACKED_t;
+#pragma pack(pop)
+//*************************************************
+
+
+typedef struct {
+ SS_LAST_INFO_t lastinfo;
+ std::string orderName;
+}SS_LASTINFO_TO_OEDER_t;
+
+
+
+//****************************
+// load configuration file
+//****************************
+static int
+loadConfig(std::string &cfgPath, std::list<SS_LASTINFO_TO_OEDER_t> *p_cfgList) throw() { // NOLINT (runtime/references)
+ int ret = 0;
+
+ try {
+ std::ifstream fin(cfgPath.c_str(), std::ios::in | std::ios::binary);
+ if (!fin) {
+ SCO_ERROR_LOG("cfg file error %s", cfgPath.c_str());
+ throw std::domain_error("open error");
+ }
+ char magic[4];
+
+ fin.read(reinterpret_cast<char*>(&magic), sizeof(magic));
+ if (fin.fail()) {
+ throw std::domain_error("read magic");
+ }
+
+ if (memcmp(magic, "CTOO", sizeof(magic)) != 0) {
+ throw std::domain_error("magic error");
+ }
+
+ uint32_t numOfElement = 0;
+ fin.read(reinterpret_cast<char*>(&numOfElement), sizeof(numOfElement));
+ if ( fin.fail() ) {
+ throw std::domain_error("read numOfElement");
+ }
+
+ for (uint32_t ii = 0; ii < numOfElement; ii++) {
+ SS_LASTINFO_TO_OEDER_PACKED_t element;
+ fin.read(reinterpret_cast<char*>(&element), sizeof(element));
+ if ( fin.fail() ) {
+ throw std::domain_error("read element");
+ }
+ SS_LASTINFO_TO_OEDER_t tmp;
+ tmp.lastinfo[SS_CCAT_F_VIDEO] = element.lastinfo[SS_CCAT_F_VIDEO];
+ tmp.lastinfo[SS_CCAT_F_SUB_VIDEO] = element.lastinfo[SS_CCAT_F_SUB_VIDEO];
+ tmp.lastinfo[SS_CCAT_F_AUDIO] = element.lastinfo[SS_CCAT_F_AUDIO];
+ tmp.lastinfo[SS_CCAT_R_VIDEO] = element.lastinfo[SS_CCAT_R_VIDEO];
+ tmp.lastinfo[SS_CCAT_R_AUDIO] = element.lastinfo[SS_CCAT_R_AUDIO];
+ tmp.orderName = element.orderName;
+ p_cfgList->push_back(tmp);
+ }
+ SCO_STATE_LOG("%s is loaded", cfgPath.c_str());
+ } catch (std::exception &e) {
+ if (ret == 0) ret = -1;
+ SCO_ERROR_LOG("%s", e.what());
+ SCO_ASSERT(0);
+ } catch (...) {
+ SCO_ASSERT(0);
+ ret = -1;
+ }
+ return ret;
+}
+
+
+
+static
+bool
+isPassCondition(SS_CONT_CATEGORY_t cat, SS_LAST_INFO_t &lastInfo, SS_LASTINFO_TO_OEDER_t &tblElement) { // NOLINT (runtime/references)
+ std::string &tblStr = tblElement.lastinfo[cat];
+
+ if (tblStr != "EMPTY") {
+ //Category with content specification
+ SS_LAST_INFO_t::iterator iteCont = lastInfo.find(cat);
+ if (iteCont == lastInfo.end() || iteCont->second != tblStr) {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+
+//****************************
+// SS_ConvLastInfoToOrder
+//****************************
+EFrameworkunifiedStatus
+SS_ConvLastInfoToOrder(SS_LAST_INFO_t &curInfo, std::string &order, const char* p_cfgPath/* = NULL*/) { // NOLINT (runtime/references)
+ std::string cfgPath = (p_cfgPath) ? p_cfgPath : SS_LAST_TO_ORDER_CONF_PATH;
+
+ static std::list<SS_LASTINFO_TO_OEDER_t> s_convList;
+ static std::string s_readCfgPath = "__default__";
+ bool isHit = false;
+
+ // If the same CONFIG, do not READ after the second.
+ if (s_readCfgPath != cfgPath) {
+ int ret;
+ s_convList.clear();
+
+ ret = loadConfig(cfgPath, &s_convList);
+ if (ret != 0) { goto ERROR; }
+ s_readCfgPath = cfgPath;
+
+#if 0 // DEBUG
+ for (std::list<SS_LASTINFO_TO_OEDER_PACKED_t>::iterator tblElt = s_convList.begin();
+ tblElt != s_convList.end();
+ tblElt++) {
+ SCO_STATE_LOG("FV:%s FSV:%s FA:%s RV:%s RA:%s O:%s",
+ tblElt->lastinfo[SS_CCAT_F_VIDEO], tblElt->lastinfo[SS_CCAT_F_SUB_VIDEO], tblElt->lastinfo[SS_CCAT_F_AUDIO],
+ tblElt->lastinfo[SS_CCAT_R_VIDEO], tblElt->lastinfo[SS_CCAT_R_AUDIO], tblElt->orderName);
+ }
+#endif
+ }
+
+ for (std::list<SS_LASTINFO_TO_OEDER_t>::iterator tblElt = s_convList.begin();
+ tblElt != s_convList.end();
+ tblElt++) {
+ if (isPassCondition(SS_CCAT_F_VIDEO , curInfo, *tblElt) == false) {
+ continue;
+ } else if (isPassCondition(SS_CCAT_F_SUB_VIDEO, curInfo, *tblElt) == false) {
+ continue;
+ } else if (isPassCondition(SS_CCAT_F_AUDIO , curInfo, *tblElt) == false) {
+ continue;
+ } else if (isPassCondition(SS_CCAT_R_VIDEO , curInfo, *tblElt) == false) {
+ continue;
+ } else if (isPassCondition(SS_CCAT_R_AUDIO , curInfo, *tblElt) == false) {
+ continue;
+ }
+
+ isHit = true;
+ order = tblElt->orderName;
+ break;
+ }
+ if (!isHit) {
+ order = WON_DEFAULT;
+ }
+ return eFrameworkunifiedStatusOK;
+ERROR:
+ return eFrameworkunifiedStatusFail;
+}
diff --git a/systemservice/interface_unified/library/src/ss_logger_service_ifc.cpp b/systemservice/interface_unified/library/src/ss_logger_service_ifc.cpp
new file mode 100755
index 0000000..1766bfa
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_logger_service_ifc.cpp
@@ -0,0 +1,781 @@
+/*
+ * @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_SystemServices_Logger
+/// \brief This file supports the _CWORD77_ logger service.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "system_service/ss_logger_service_ifc.h"
+#include <string.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <string>
+#include "system_service/ss_logger_service_protocol.h"
+#include "system_service/ss_logger_service_notifications.h"
+#include "system_service/ss_logger_service.h"
+#include "system_service/ss_logger_service_local.h"
+#include "system_service/ss_services.h"
+#include "ss_logger_service_if_interfaceunifiedlog.h"
+
+LoggerServiceIf::LoggerServiceIf()
+ : m_hApp(NULL),
+ m_hService(NULL),
+ m_hSession(NULL) {
+}
+
+LoggerServiceIf::~LoggerServiceIf() {
+ CloseSessionRequest(); // if the session is still connected
+
+ m_hService = NULL;
+ m_hSession = NULL;
+ m_hApp = NULL;
+} // LCOV_EXCL_BR_LINE 10:Because destructor
+
+EFrameworkunifiedStatus LoggerServiceIf::NotifyOnLoggerServiceAvailability(
+ CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp && NULL != f_pCallBackFn) {
+ // Subscriptions
+ FrameworkunifiedNotificationCallbackHandler g_aryLogger_Notif_Cbs[] = {
+ // Notifications name, Call back function
+ { NTFY_SS_LoggerService_Availability, f_pCallBackFn }, };
+
+ if (0 != strcmp(SERVICE_LOGGER, FrameworkunifiedGetAppName(m_hApp))) {
+ // Subscribe and attach call backs to notifications
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedSubscribeNotificationsWithCallback(
+ m_hApp, g_aryLogger_Notif_Cbs, _countof(g_aryLogger_Notif_Cbs)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedAttachNotificationCallbacksToDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::NotifyOnOpenSessionAck(CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp && NULL != f_pCallBackFn) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
+ SERVICE_LOGGER,
+ PROTOCOL_OPEN_SESSION_ACK,
+ f_pCallBackFn))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ", eStatus);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::NotifyOnCloseSessionAck(CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hApp && NULL != f_pCallBackFn) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
+ SERVICE_LOGGER,
+ PROTOCOL_CLOSE_SESSION_ACK,
+ f_pCallBackFn))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ", eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+BOOL LoggerServiceIf::Initialize(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_eStatus = TRUE;
+
+ if (NULL != hApp) {
+ m_hApp = hApp;
+ } else {
+ l_eStatus = FALSE; // eFrameworkunifiedStatusInvldHandle;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::OpenSessionRequest() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (NULL != m_hApp) {
+ // if the session is there then we need to close it first!
+ if (NULL != m_hService) {
+ CloseSessionRequest();
+ m_hService = NULL;
+ }
+ BOOL l_bServiceAvailable = FrameworkunifiedIsServiceAvailable(m_hApp);
+ if (FALSE == l_bServiceAvailable) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Service is unavailable");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // Now open the service.
+ if (l_bServiceAvailable
+ && (NULL != (m_hService = OpenService()))) { // LCOV_EXCL_BR_LINE 8:Because bServiceAvailable is always TRUE
+ // [DM: TODO] Check if we need to open a session with some data sent to Server.
+ UI_32 l_pTestData = 1;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedOpenSessionWithData(m_hService,
+ (PVOID) &l_pTestData,
+ sizeof(UI_32)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "FrameworkunifiedOpenSessionWithData Failed, errval :%d", l_eStatus);
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "FrameworkunifiedOpenService Failed, errval :%d", l_eStatus);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+HANDLE LoggerServiceIf::OpenService() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ HANDLE l_hService = NULL;
+
+ if (NULL == (l_hService = FrameworkunifiedOpenService(m_hApp, SERVICE_LOGGER))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "FrameworkunifiedOpenService : Failed to open Logger Service");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_hService;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::DecodeOpenSessionResponse() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ std::string l_strSessionName;
+ if (NULL != m_hService
+ && NULL != m_hApp) { // LCOV_EXCL_BR_LINE 8:Because there is no case where m_hApp is NULL and m_hService is not NULL
+ if (NULL == (m_hSession = FrameworkunifiedGetOpenSessionHandle(m_hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Error in extracting OpenSessionAck response.");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ l_strSessionName = FrameworkunifiedGetSessionName(m_hSession);
+ if (l_strSessionName.empty()) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SessionName is empty");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (FrameworkunifiedSetSessionHandle(m_hApp, l_strSessionName.c_str(), m_hSession))) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSetSessionHandle() failed");
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::CloseSessionRequest() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(m_hService, m_hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedCloseSession Failed");
+ }
+ m_hSession = NULL; // clear our session handle
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::RegisterForLoggerEvent(
+ SS_LoggerServerEvents f_eLoggerEvent, CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hSession && NULL != f_pCallBackFn) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
+ SERVICE_LOGGER,
+ f_eLoggerEvent,
+ f_pCallBackFn, m_hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ", eStatus);
+ }
+
+ // client registers for the event
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedRegisterEvent(m_hSession, f_eLoggerEvent))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedRegisterEvents Failed Status:0x%x",
+ eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedRegisterEvents Status:0x%x", eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::UnRegisterForLoggerEvent(
+ SS_LoggerServerEvents f_eLoggerEvent) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hSession) {
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SendDiagStat
+/// API to send CAN Diagnostic status data(it has mileage info) to Logger Service
+/// (Command: SS_LOGGER_MILEAGE_DATA)
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus LoggerServiceIf::SendDiagStat(STLOGGER_CANDIAGSTAT *pCanDiagStat_t) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ STLOGGER_CANDIAGSTAT l_candiagstat;
+
+ memcpy(&l_candiagstat, pCanDiagStat_t, sizeof(STLOGGER_CANDIAGSTAT));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Before Valid Session");
+ if (NULL != m_hService && NULL != m_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Entered Valid Session");
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_MILEAGE_DATA,
+ sizeof(STLOGGER_CANDIAGSTAT), &l_candiagstat))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Msg Send Successfully");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_CANGetCurrentDateAndTime
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_CANGetCurrentDateAndTime(
+ STCanCurrentDateTime stDateAndTime) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_DATETIME,
+ sizeof(stDateAndTime), &stDateAndTime))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_CANSetVIN
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_CANSetVIN(STVIN_NUMBER& stVinNumber) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ stVinNumber.VINstr[stVinNumber.VIN_LEN - 1] = '\0';
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_VIN,
+ sizeof(STVIN_NUMBER), &stVinNumber))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg() Failed with error: %X",
+ l_eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Service or Session Handle NULL");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// LoggerIf_SetLoggerParams
+/// API is to inform Logger Service about the device selected to store the logs
+/// and about Enable/Disable Logging.
+/// (Command: SS_LOGGER_SET_PARAMS)
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_SetLoggerParams(ELOGGER_STAT eLoggerStatus,
+ EDEV_TYPE eDevType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ STLoggerSetParams l_stLoggerParams;
+
+ l_stLoggerParams.Logger_State = eLoggerStatus;
+ l_stLoggerParams.Device_Type = eDevType;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_PARAMS,
+ sizeof(STLoggerSetParams), &l_stLoggerParams))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// LoggerIf_UDPLogging
+/// API is to inform Logger Service about UDP logging
+/// and about Enable/Disable Logging.
+/// (Command: SS_LOGGER_UDP_LOGGING)
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_UDPLogging(ELOGGER_STAT eLoggerStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_UDP_LOGGING,
+ sizeof(ELOGGER_STAT), &eLoggerStatus))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_ScreenCaptureEventACK(
+ STScreenCaptureEvt stScreenCaptureInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SCREENCAPTURE_EVT_ACK,
+ sizeof(stScreenCaptureInfo),
+ &stScreenCaptureInfo))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Screen shot ACK sent successfully.");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. m_hSession is NULL. Screen shot capture ACK not sent.");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_EventLoggingCommonInfo
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_EventLoggingCommonInfo(
+ STEventLoggerCommonInfo stEventCommonInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_EVENT_COMMONINFO,
+ sizeof(stEventCommonInfo),
+ &stEventCommonInfo))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_EventLoggingEventInfo
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_EventLoggingEventInfo(
+ STEventLoggerEventInfo stEventInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER__CWORD56__EVENT_INFO,
+ sizeof(stEventInfo), &stEventInfo))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_EventLoggingResetInfo
+/// (Command: SS_LOGGER__CWORD56__RESET_INFO)
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_EventLoggingResetInfo(
+ STEventLoggerResetInfo stResetInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER__CWORD56__RESET_INFO,
+ sizeof(stResetInfo), &stResetInfo))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_EventLoggingResetInfo
+/// (Command: SS_LOGGER_DIAGDTC_ACTIVE)
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_PersistEventLogOnActiveDTC(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_DIAGDTC_ACTIVE, 0x00,
+ NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_EventLoggingResetInfo
+/// (Command: SS_LOGGER_SHUTDOWN_COMPLETE)
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_Shutdown_Complete(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != m_hService && NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SHUTDOWN_COMPLETE,
+ 0x00, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :StoreEventLogsToUSB
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::StoreEventLogsToUSB(
+ EEvtLogUSBDevNumber eUSBDevNumber) {
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Copy the Event logs in to USB command received:%X", eUSBDevNumber);
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGERCOPYEVENTUSB,
+ sizeof(EEvtLogUSBDevNumber), &eUSBDevNumber))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :StoreEmergencyErrorLogsToUSB
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::StoreEmergencyErrorLogsToUSB(
+ EDevNumber eDevNumber) {
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO, __FUNCTION__,
+ "Copy the Emergency Error logs in to External Device command received:%X",
+ eDevNumber);
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGERCOPYEMERGENCYLOGS,
+ sizeof(EDevNumber), &eDevNumber))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :ClearEventLogs
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::ClearEventLogs(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Request for clearing the event logs");
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGERCLEAREVENT, 0, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :ReadStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::ReadStatisticalCounter(
+ EStatCounterGroupID eCounterGroup) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Request to read the statistical counter for group ID:%X",
+ eCounterGroup);
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_READ_STATL_COUNTER,
+ sizeof(EStatCounterGroupID), &eCounterGroup))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :ReadStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::ResetStatisticalCounter(
+ EStatCounterGroupID eCounterGroup) {
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Request to reset the statistical counter for group ID:%X",
+ eCounterGroup);
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_RESET_STATL_COUNTER,
+ sizeof(EStatCounterGroupID), &eCounterGroup))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function LoggerServiceIf::StartDTCLoggingToEmmc
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::StartDTCLoggingToEmmc(UI_32 f_dtc) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Request to start logging for DTC:0x%4X",
+ f_dtc);
+ l_eStatus = this->SendMessage(eSSLoggerCANProtocolIDDTCTrigger,
+ (UI_32) sizeof(f_dtc), &f_dtc);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function LoggerServiceIf::StartCANLogging
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::StartCANLogging(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Request to start CAN logging.");
+ l_eStatus = this->SendMessage(eSSLoggerCANProtocolIDCANTrigger, 0, NULL);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function LoggerServiceIf::RegisterLoggingStartNotification
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::RegisterLoggingStartNotification(
+ CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (NULL == this->m_hApp) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == this->m_hApp)");
+ } else if (NULL == f_pCallBackFn) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == f_pCallBackFn)");
+ } else {
+ l_eStatus = FrameworkunifiedSubscribeToSessionEventWithCallback(this->m_hApp,
+ eSSLoggerCANEventStart,
+ f_pCallBackFn,
+ this->m_hSession);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedSubscribeToSessionEventWithCallback(eSSLoggerCANEventStart) returned %X",
+ l_eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function LoggerServiceIf::RegisterLoggingStartNotification
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::RegisterLoggingFinishNotification(
+ CbFuncPtr f_pCallBackFn) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (NULL == this->m_hApp) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == this->m_hApp)");
+ } else if (NULL == f_pCallBackFn) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == f_pCallBackFn)");
+ } else {
+ l_eStatus = FrameworkunifiedSubscribeToSessionEventWithCallback(
+ this->m_hApp, eSSLoggerCANEventFinished, f_pCallBackFn,
+ this->m_hSession);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedSubscribeToSessionEventWithCallback(eSSLoggerCANEventFinished) returned %X",
+ l_eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :SendMessage
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::SendMessage(UI_32 f_cmdID, UI_32 f_size,
+ void* f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if ((NULL != m_hSession)
+ && ((f_pData != NULL) || (f_size == 0))) { // LCOV_EXCL_BR_LINE 8:Because there is no case where f_pData is NULL and f_size is not 0
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, f_cmdID, f_size, f_pData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_SetDiagID
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_SetDiagID(UI_16 f_u16DiagID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_DIAGID,
+ sizeof(UI_16), &f_u16DiagID))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed %d", l_eStatus);
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerIf_UploadEventLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_UploadEventLog() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_hSession) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_UPLOAD_EVENTLOG, 0x00,
+ NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed %d", l_eStatus);
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // LCOV_EXCL_BR_LINE 10:Because the last line
diff --git a/systemservice/interface_unified/library/src/ss_power_client.cpp b/systemservice/interface_unified/library/src/ss_power_client.cpp
new file mode 100755
index 0000000..30bdbaa
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_power_client.cpp
@@ -0,0 +1,254 @@
+/*
+ * @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_PowerServiceIf
+/// \brief This file supports Power Service client management.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <inttypes.h>
+#include <string.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <string>
+#include "system_service/ss_power_service.h"
+#include "system_service/ss_power_service_protocol.h"
+#include "system_service/ss_power_service_notifications.h"
+#include "system_service/ss_services.h"
+#include "system_service/ss_system_if.h"
+#include "system_service/ss_templates.h"
+#include "ss_power_if_interfaceunifiedlog.h"
+
+typedef struct {
+ BOOL fAvailable;
+ HANDLE hSession;
+ HANDLE hService;
+ std::string szServiceName;
+} TPowerSession;
+
+static EFrameworkunifiedStatus OnPowerCloseSesionAck(HANDLE hApp);
+static EFrameworkunifiedStatus OnPowerOpenSessionAck(HANDLE hApp);
+static EFrameworkunifiedStatus OnPowerAvailability(HANDLE hApp);
+static EFrameworkunifiedStatus OnPowerAvailable(HANDLE hApp);
+static EFrameworkunifiedStatus OnPowerUnavailable(HANDLE hApp);
+static TPowerSession g_tPowerSession = { };
+
+/// Base on the a user group affiliation we will call there start and stop methods
+/// Note: there group and subgroup strings are empty we will call start on the every
+/// first case of
+EFrameworkunifiedStatus InterfaceunifiedSystemConnectToPowerSerivce(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Subscriptions
+ FrameworkunifiedNotificationCallbackHandler g_aryPower_Notif_Cbs[] = {
+ // Notifications name, Call back function
+ { szNTFY_PowerAvailability, OnPowerAvailability }, };
+
+ /// Avoid opening a session to the Power
+ /// service Since it uses the framework as well
+ if (0 != strcmp(SERVICE_POWER, FrameworkunifiedGetAppName(hApp))) {
+ // Subscribe and attach call backs to notifications, to Notification Service!
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedSubscribeNotificationsWithCallback(
+ hApp, g_aryPower_Notif_Cbs, _countof(g_aryPower_Notif_Cbs)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedAttachNotificationCallbacksToDispatcher Failed Status:0x%x ",
+ eStatus);
+ } else {
+ /// Need to save the Group and Subgroup values
+ g_tPowerSession.szServiceName = FrameworkunifiedGetAppName(hApp);
+
+ /// Cleanup any other data members
+ g_tPowerSession.fAvailable = FALSE;
+ g_tPowerSession.hService = NULL;
+ g_tPowerSession.hSession = NULL;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus OnPowerAvailability(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Power Service Availability notification received ****");
+
+ if (sizeof(BOOL) == FrameworkunifiedGetMsgLength(hApp)) {
+ BOOL avalibility = FALSE;
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &avalibility, sizeof(BOOL)))) {
+ if (TRUE == avalibility) {
+ eStatus = OnPowerAvailable(hApp);
+ } else {
+ eStatus = OnPowerUnavailable(hApp);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedAttachNotificationCallbacksToDispatcher Failed Status:0x%x ",
+ eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus OnPowerAvailable(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ // if the service is available before the close happens then close the session and service first.
+ if (NULL != g_tPowerSession.hService && NULL != g_tPowerSession.hSession) {
+ EFrameworkunifiedStatus interfaceunifiedRet = FrameworkunifiedCloseSession(g_tPowerSession.hService,
+ g_tPowerSession.hSession);
+ SS_ASERT(interfaceunifiedRet == eFrameworkunifiedStatusOK);
+ g_tPowerSession.hSession = NULL;
+ g_tPowerSession.hService = NULL;
+ }
+
+ PCSTR power_name = FrameworkunifiedGetMsgSrc(hApp);
+
+ // opening the service
+ if (NULL == (g_tPowerSession.hService = FrameworkunifiedOpenService(hApp, power_name))) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_ERR, __FUNCTION__, "Power: Failed to open service");
+ } else {
+ FrameworkunifiedProtocolCallbackHandler g_aryPower_Protocol_Cbs[] = {
+ // Command ID, Call back functions
+ { PROTOCOL_OPEN_SESSION_ACK, OnPowerOpenSessionAck },
+ { PROTOCOL_CLOSE_SESSION_ACK, OnPowerCloseSesionAck }, };
+
+ /// Attach the valid callback for this service
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hApp, power_name, g_aryPower_Protocol_Cbs,
+ _countof(g_aryPower_Protocol_Cbs)))) {
+ EPWR_SESSION_TYPE tOpenSessionReq = epsstBASIC;
+ /// opening the session with service
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedOpenSessionWithData(g_tPowerSession.hService,
+ &tOpenSessionReq,
+ sizeof(tOpenSessionReq)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedOpenSession Failed Status:0x%x ",
+ eStatus);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "%s has received PowerService Available.",
+ FrameworkunifiedGetAppName(hApp));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedAttachCallbacksToDispatcher Failed Status:0x%x ", eStatus);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus OnPowerUnavailable(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ if (0 == strcmp(SERVICE_POWER, FrameworkunifiedGetAppName(hApp))) {
+ if ((g_tPowerSession.hSession != NULL)
+ && (g_tPowerSession.hService != NULL)) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedCloseSession(g_tPowerSession.hService,
+ g_tPowerSession.hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedCloseSession Failed Status:0x%x",
+ eStatus);
+ }
+ g_tPowerSession.hSession = NULL;
+ g_tPowerSession.hService = NULL;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "%s has received PowerService Unavailable.", FrameworkunifiedGetAppName(hApp));
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Error INVALID HANDLE [g_tPowerSession.hSession :0x%" PRIxPTR "]; [g_tPowerSession.hService :0x%" PRIxPTR "] ", // NOLINT (whitespace/line_length)
+ (uintptr_t) g_tPowerSession.hSession, (uintptr_t) g_tPowerSession.hService);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////
+/// Function: OnHeartBeatClientOpenSessionAck
+/// HeartBeat Service OpenSession callback
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus OnPowerOpenSessionAck(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ g_tPowerSession.hSession = FrameworkunifiedGetOpenSessionHandle(hApp);
+ if (NULL != g_tPowerSession.hSession) {
+ g_tPowerSession.fAvailable = TRUE;
+ eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "%s Session to PowerService has been successfully opened.",
+ FrameworkunifiedGetAppName(hApp));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetOpenSessionHandle returned : %" PRIxPTR "",
+ (uintptr_t) g_tPowerSession.hSession);
+ g_tPowerSession.hSession = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////
+/// Function: OnHeartBeatClientCloseSessionAck
+/// HeartBeat Service CloseSession callback
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus OnPowerCloseSesionAck(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Close Service
+ if (NULL != g_tPowerSession.hService) {
+ eStatus = FrameworkunifiedCloseService(hApp, g_tPowerSession.hService);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: FrameworkunifiedCloseService() errored %d/'%s",
+ eStatus, GetStr(eStatus).c_str());
+ }
+ g_tPowerSession.hService = NULL;
+ g_tPowerSession.hSession = NULL;
+ }
+ g_tPowerSession.fAvailable = FALSE;
+ eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "%s Session to PowerService has been successfully closed.",
+ FrameworkunifiedGetAppName(hApp));
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+
+ return eStatus;
+}
diff --git a/systemservice/interface_unified/library/src/ss_pwrsvc_if.cpp b/systemservice/interface_unified/library/src/ss_pwrsvc_if.cpp
new file mode 100755
index 0000000..86d8ebb
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_pwrsvc_if.cpp
@@ -0,0 +1,343 @@
+/*
+ * @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_PowerServiceIf
+/// \brief This file supports the Power Service module interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "system_service/ss_power_service_if.h"
+#include <string.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include "system_service/ss_power_service.h"
+#include "system_service/ss_power_service_protocol.h"
+#include "system_service/ss_power_service_notifications.h"
+#include "system_service/ss_system_if.h"
+#include "system_service/ss_services.h"
+#include "system_service/ss_string_maps.h"
+#include "system_service/ss_templates.h"
+#include "ss_power_if_interfaceunifiedlog.h"
+
+HANDLE OpenPowerService(HANDLE f_hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ HANDLE l_hService = NULL;
+ if (NULL == f_hApp) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_App");
+ } else if (NULL == (l_hService = FrameworkunifiedOpenService(f_hApp, SERVICE_POWER))) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedOpenService(f_hApp, SERVICE_POWER)");
+ }
+ return l_hService;
+}
+
+EFrameworkunifiedStatus ClosePowerService(HANDLE f_hApp, HANDLE f_hService) {
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hApp) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_App");
+ } else if (NULL == f_hService) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hService");
+ } else {
+ l_eStatus = FrameworkunifiedCloseService(f_hApp, f_hService);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedCloseService(f_hApp, f_hService)");
+ f_hService = NULL;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Session Related Requests
+/// Any client can also use FrameworkunifiedOpenSession and FrameworkunifiedOpenSessionWithData.
+/// In that case, the PVOID data passed as a parameter should be MM_OpenSessionRequestIf
+/// to open a session with the Power Service.
+/// The client can also use the below API for Opening a session with Power Service.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus PwrServiceOpenSessionRequest(HANDLE f_hService,
+ EPWR_SESSION_TYPE f_eSessionType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (NULL == f_hService) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hService");
+ } else if (epsstUNKNOWN == f_eSessionType) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("epsstUNKNOWN == f_eSessionType");
+ } else {
+ l_eStatus = FrameworkunifiedOpenSessionWithData(f_hService, &f_eSessionType,
+ sizeof(f_eSessionType));
+ LOG_STATUS(l_eStatus, "FrameworkunifiedOpenSessionWithData()");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PwrServiceCloseSessionRequest(HANDLE f_hService, HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (NULL == f_hService) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hService");
+ } else if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ CALL_AND_LOG_STATUS(FrameworkunifiedCloseSession(f_hService, f_hSession));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PwrServiceDecodeOpenSessionResponse(HANDLE f_hApp,
+ HANDLE& f_hSession) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == f_hApp) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_App");
+ } else {
+ if (NULL == (f_hSession = FrameworkunifiedGetOpenSessionHandle(f_hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedGetOpenSessionHandle('%s') returned NULL",
+ FrameworkunifiedGetAppName(f_hApp));
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PwrServiceSetVoltageState(HANDLE f_hSession,
+ EPWR_VOLTAGE_STATE_TYPE f_eVoltage_state) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else if (epsvsINVALID == f_eVoltage_state) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("epsvsINVALID == f_eVoltage_state");
+ } else {
+ Pwr_ServiceSetInterface l_tServiceSetIf;
+ std::memset(&l_tServiceSetIf, 0, sizeof(l_tServiceSetIf));
+ l_tServiceSetIf.data.voltage.state = f_eVoltage_state;
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_VOLTAGE_STATE,
+ sizeof(l_tServiceSetIf), (PVOID) &l_tServiceSetIf);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_VOLTAGE_STATE)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PwrServiceSetCrankState(HANDLE f_hSession,
+ EPWR_CRANK_STATE_TYPE f_eCrank_state) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else if (epscsINVALID == f_eCrank_state) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("epsvsINVALID == f_eCrank_state");
+ } else {
+ Pwr_ServiceSetInterface l_tServiceSetIf;
+ std::memset(&l_tServiceSetIf, 0, sizeof(l_tServiceSetIf));
+ l_tServiceSetIf.data.crank.state = f_eCrank_state;
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_CRANK_STATE,
+ sizeof(l_tServiceSetIf), (PVOID) &l_tServiceSetIf);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_CRANK_STATE)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PwrServiceSendShutdownRequest(
+ HANDLE f_hSession, EPWR_SHUTDOWN_REQUEST_MSG_STRUCT &f_eState) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ Pwr_ServiceSetInterface l_tServiceSetIf;
+ std::memset(&l_tServiceSetIf, 0, sizeof(l_tServiceSetIf));
+ l_tServiceSetIf.data.shutdownRequestMsg = f_eState;
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_SHUTDOWN_REQUEST_MSG,
+ sizeof(l_tServiceSetIf), &l_tServiceSetIf);
+
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_SHUTDOWN_REQUEST_MSG)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus PwrServiceSendShutdownRequest(
+
+EFrameworkunifiedStatus PwrServiceSendSetShutdownPopupRequest(
+ HANDLE f_hSession, EPWR_SHUTDOWN_POPUP_TYPE f_eShutdownPopup) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ Pwr_ServiceSetInterface l_tServiceSetIf;
+ std::memset(&l_tServiceSetIf, 0, sizeof(l_tServiceSetIf));
+ switch (f_eShutdownPopup) {
+ case epsspPowerSave1:
+ case epsspPowerSave2:
+ case epsspPowerSave3:
+ case epsspPowerSaveClr:
+ case epsspLowVoltage1:
+ case epsspLowVoltage2:
+ case epsspLowVoltage3:
+ case epsspLowVoltageClr:
+ case epsspBattCouplingSW1:
+ case epsspBattCouplingSW2:
+ case epsspBattCouplingSW3:
+ case epsspBattCouplingSWClr:
+ case epsspAbnormalTemp_1st:
+ case epsspAbnormalTemp_Clr:
+ case epsspLimpHome_1st:
+ case epsspLimpHome_2nd:
+ case epsspLimpHome_3rd:
+ case epsspLimpHome_Clr:
+ case epsspProdMd_1st:
+ case epsspProdMd_Clr:
+ case epsspTransMd_1st:
+ case epsspTransMd_Clr:
+ case epsspAllClr:
+ l_tServiceSetIf.data.shutdownPopup.shutdownPopupEvent =
+ f_eShutdownPopup;
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession,
+ SS_POWER_PUBLISH_SHUTDOWN_CONDITION_REQ,
+ sizeof(l_tServiceSetIf), &l_tServiceSetIf);
+ LOG_STATUS(l_eStatus,
+ "FrameworkunifiedSendMsg(SS_POWER_PUBLISH_SHUTDOWN_CONDITION_REQ)");
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Unknown 'ShutdownPopup' value: 0x%X/%d",
+ f_eShutdownPopup, f_eShutdownPopup);
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus PwrServiceSendSetShutdownPopupRequest( HANDLE f_hSession,
+
+EFrameworkunifiedStatus PwrServiceSendStartupConfirmationMsgRequest(
+ HANDLE f_hSession, EPWR_SC_MSG_STRUCT f_eState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ Pwr_ServiceSetInterface l_tServiceSetIf;
+ std::memset(&l_tServiceSetIf, 0, sizeof(l_tServiceSetIf));
+ l_tServiceSetIf.data.startupConfirmationMsg = f_eState;
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_FWD_START_CONFIRMATION_MSG_REQ,
+ sizeof(l_tServiceSetIf), &l_tServiceSetIf);
+
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_FWD_START_CONFIRMATION_MSG_REQ)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus PwrServiceSendStartupConfirmationMsgRequest ( HANDLE f_hSession,
+
+EFrameworkunifiedStatus PwrServiceSystemModeInfoRequest(HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_SYSTEM_MODE_INFO_REQ, 0, NULL);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_SYSTEM_MODE_INFO_REQ)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PwrServiceSendInitCompReport(HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_INITCOMP_REP, 0, NULL);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_INITCOMP_REP)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PwrServiceSendPowerRequest(
+ HANDLE f_hSession, EPWR_POWER_REQUEST_MSG_STRUCT_WITH_UMCR &f_eState) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ Pwr_ServiceSetInterface l_tServiceSetIf;
+ std::memset(&l_tServiceSetIf, 0, sizeof(l_tServiceSetIf));
+ l_tServiceSetIf.data.powerRequestMsg = f_eState;
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_POWER_REQUEST_MSG,
+ sizeof(l_tServiceSetIf), (PVOID) &l_tServiceSetIf);
+
+ char l_cBuf[200] = { 0 };
+ snprintf(
+ l_cBuf,
+ sizeof(l_cBuf),
+ "FrameworkunifiedSendMsg(SS_POWER_POWER_REQUEST_MSG(%s, %s))",
+ GetStr(l_tServiceSetIf.data.powerRequestMsg.userMode).c_str(),
+ GetStr(l_tServiceSetIf.data.powerRequestMsg.userModeChangeReason).c_str());
+ LOG_STATUS(l_eStatus, l_cBuf);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus PwrServiceSendPowerRequest( HANDLE f_hSession
+
+EFrameworkunifiedStatus PwrServiceSendHeartBeatRequest(HANDLE f_hSession,
+ EPWR_HB_REQ_MSG_STRUCT *f_eHbReqMsg) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == f_hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("NULL == f_hSession");
+ } else {
+ l_eStatus = FrameworkunifiedSendMsg(f_hSession, SS_POWER_HEARTBEAT_REQ,
+ sizeof(EPWR_HB_REQ_MSG_STRUCT),
+ reinterpret_cast<void *>(f_eHbReqMsg));
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_HEARTBEAT_REQ)");
+ }
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // LCOV_EXCL_BR_LINE 10:Because the last line
diff --git a/systemservice/interface_unified/library/src/ss_sm_client.cpp b/systemservice/interface_unified/library/src/ss_sm_client.cpp
new file mode 100755
index 0000000..664a98d
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_sm_client.cpp
@@ -0,0 +1,1509 @@
+/*
+ * @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_SystemManagerIf
+/// \brief This file provides support for the System Manager client interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "system_service/ss_sm_client_if.h"
+#include <sys/mount.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+#include <native_service/frameworkunified_sm_hsmframework.h>
+
+#include <string>
+
+#include "system_service/ss_system_manager_if.h"
+#include "system_service/ss_system_manager_protocol.h"
+#include "system_service/ss_system_manager_notifications.h"
+#include "system_service/ss_system_if.h"
+#include "system_service/ss_services.h"
+#include "system_service/ss_power_service_protocol.h"
+#include "system_service/ss_templates.h"
+#include "system_service/ss_string_maps.h"
+#include "system_service/ss_error_message.h"
+#include "system_service/ss_sm_client_if_local.h"
+
+#include "system_service/ss_boot_map.h"
+#include "ss_system_if_interfaceunifiedlog.h"
+
+typedef struct {
+ BOOL fAvailable;
+ HANDLE hService;
+ std::string szServiceName;
+ std::string strIAm;
+} TSystemManagerSession; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+typedef enum {
+ MODULE_STATE_INVALID = 0, /// Initial state of all modules
+ MODULE_STATE_CONNECTING, /// Attempting to established a session connection
+ MODULE_STATE_CONNECTED, /// A session connection has been established
+ MODULE_STATE_STARTING, /// Received a START from System Manager,
+ /// called FrameworkunifiedOnStart or enqueued evStart
+ MODULE_STATE_START_FAILED, /// Application returned error from FrameworkunifiedOnStart
+ MODULE_STATE_STARTED, /// Sent Start Response to System Manager
+ MODULE_STATE_STOPPING, /// Received a Stop Request from System Manager,
+ /// called FrameworkunifiedOnStop or enqueued evStop
+ MODULE_STATE_STOP_FAILED, /// Application returned error from FrameworkunifiedOnStop
+ MODULE_STATE_STOPPED, /// Sent Start Response to System Manager
+ MODULE_STATE_DEBUG_DUMPING,
+ MODULE_STATE_STARTED_PRE, //!< Sent Pre-Start Response to System Manager
+ MODULE_STATE_START_PRE_FAILED, //!< Application returned error from FrameworkunifiedOnPreStart
+ MODULE_STATE_STOPPED_PRE, //!< Sent Pre-Stop Response to System Manager
+ MODULE_STATE_STOP_PRE_FAILED, //!< Application returned error from FrameworkunifiedOnPreStop
+ MODULE_STATE_STARTED_BACKGROUND, //!< Sent Background-Start Response to System Manager
+ MODULE_STATE_START_BACKGROUND_FAILED, //!< Application returned error from FrameworkunifiedOnBackgroundStart
+ MODULE_STATE_STOPPED_BACKGROUND, //!< Sent Background-Stop Response to System Manager
+ MODULE_STATE_STOP_BACKGROUND_FAILED //!< Application returned error from FrameworkunifiedOnBackgroundStop
+} ModuleStateType;
+
+static SMStopCompleteAck g_responseCompleteAck;
+
+static EFrameworkunifiedStatus OnSystemManagerStart(HANDLE hApp);
+static EFrameworkunifiedStatus OnSystemManagerStop(HANDLE hApp);
+static EFrameworkunifiedStatus OnSystemManagerPreStart(HANDLE hApp);
+static EFrameworkunifiedStatus OnSystemManagerPreStop(HANDLE hApp);
+static EFrameworkunifiedStatus OnSystemManagerBackgroundStart(HANDLE hApp);
+static EFrameworkunifiedStatus OnSystemManagerBackgroundStop(HANDLE hApp);
+static EFrameworkunifiedStatus OnSystemManagerOpenSessionAck(HANDLE hApp);
+static EFrameworkunifiedStatus DebugDumpAppCbStatistics(HANDLE hApp);
+static EFrameworkunifiedStatus DebugDumpMemoryMap(HANDLE hApp);
+static EFrameworkunifiedStatus SystemManagerOpenSender(HANDLE hApp);
+
+static TSystemManagerSession g_tSystemManagerSession = { }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+static pthread_mutex_t gMutexObj = PTHREAD_MUTEX_INITIALIZER;
+
+static EFrameworkunifiedStatus SendMsgToSystemManager(UI_32 uiCmd, UI_32 uiLength,
+ PCVOID pData);
+static EFrameworkunifiedStatus SendMsgToSystemManager(UI_32 uiCmd, PCSTR f_pCmdName,
+ UI_32 uiLength, PCVOID pData);
+
+static EFrameworkunifiedStatus InvokeSyncRequestToSystemManager(UI_32 uiCmd,
+ PCSTR f_pCmdName,
+ UI_32 uiLength, PCVOID pData,
+ UI_32 uiResLength,
+ PVOID pResData);
+
+static EFrameworkunifiedStatus CommonSystemManagerStartStopCallbackProcessing(
+ HANDLE hApp, UI_32 f_InterfaceunifiedEvID, SS_String f_pInterfaceunifiedEvName, CbFuncPtr f_InterfaceunifiedFncCb,
+ PCSTR f_pInterfaceunifiedFncName, ModuleStateType f_moduleSuccessState,
+ ModuleStateType f_moduleFailureState, BOOL f_bUseNotificationVsFncFlag,
+ PCSTR f_pUseNotificationText, SS_SystemManagerProtocol f_ProtocolId,
+ PCSTR f_pProtocolName);
+
+static EFrameworkunifiedStatus SendInterfaceunifiedOnResponseToSystemManager(
+ SS_SystemManagerProtocol f_ProtocolID, PCSTR f_pProtocolName,
+ PCSTR f_InterfaceunifiedOnFncName, ModuleStateType f_moduleSuccessState,
+ ModuleStateType f_moduleFailureState, EFrameworkunifiedStatus f_eStatus);
+
+// Pointer of function which is called when SM OpenSession Ack is received.
+// client can register this function pointer using RegisterSMSessionAckCallback() API
+static CbFuncPtr CallbackFnPtr = NULL;
+
+static BOOL UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc = FALSE;
+
+static VOID LoadCbHandlerCmdIDsIntoDetachCbIDsArray(
+ const FrameworkunifiedProtocolCallbackHandler* pMsgHandler, UI_32 * puiCmdIdArray,
+ UI_32 uiHandlerCount);
+
+static VOID SetModuleState(ModuleStateType f_moduleState, BOOL f_bLog = TRUE);
+
+static ModuleStateType g_moduleState = MODULE_STATE_INVALID;
+extern HANDLE g_SystemIf_hApp;
+
+//******************************************************************************
+void Init_SS_IF_ModuleState_StrMap(
+ std::map<ModuleStateType, SS_String> & m_strMap) { // NOLINT (runtime/references)
+// LCOV_EXCL_BR_START 11:Unexpected branch
+ MAP_ENTRY(m_strMap, MODULE_STATE_INVALID);
+ MAP_ENTRY(m_strMap, MODULE_STATE_CONNECTING);
+ MAP_ENTRY(m_strMap, MODULE_STATE_CONNECTED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STARTING);
+ MAP_ENTRY(m_strMap, MODULE_STATE_START_FAILED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STARTED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STOPPING);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STOP_FAILED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STOPPED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STARTED_PRE);
+ MAP_ENTRY(m_strMap, MODULE_STATE_START_PRE_FAILED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STOPPED_PRE);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STOP_PRE_FAILED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STARTED_BACKGROUND);
+ MAP_ENTRY(m_strMap, MODULE_STATE_START_BACKGROUND_FAILED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STOPPED_BACKGROUND);
+ MAP_ENTRY(m_strMap, MODULE_STATE_STOP_BACKGROUND_FAILED);
+ MAP_ENTRY(m_strMap, MODULE_STATE_DEBUG_DUMPING);
+// LCOV_EXCL_BR_STOP
+} // End of void Init_SS_IF_ModuleState_StrMap(std::map<ModuleStateType, SS_String> & m_strMap)
+
+class EnumStringMap<ModuleStateType, Init_SS_IF_ModuleState_StrMap> g_oSS_IF_ModuleStateStrMap;
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+SS_String GetStr(ModuleStateType f_enum) {
+ return g_oSS_IF_ModuleStateStrMap.GetStr(f_enum);
+}
+
+HANDLE GetSystemManagerSessionHandle(void) {
+ return g_tSystemManagerSession.hService;
+} // End of HANDLE GetSystemManagerSessionHandle(void)
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus InterfaceunifiedSystemConnectToSystemManagerService(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CallbackFnPtr = NULL;
+
+ /// Avoid opening a session to the SystemManager
+ /// service Since it uses the framework as well
+ if (0 != strcmp(SERVICE_SYSMANAGER, FrameworkunifiedGetAppName(hApp))) {
+ // LCOV_EXCL_BR_LINE 6:Duplicate check(AppName has been checked by the caller)
+ memset(&g_responseCompleteAck, 0, sizeof(g_responseCompleteAck));
+ g_responseCompleteAck.unSessionId = 0;
+ strcpy(g_responseCompleteAck.szServiceName, SERVICE_SYSMANAGER); // NOLINT (runtime/printf)
+
+ pthread_mutex_lock(&gMutexObj);
+
+ /// Need to save the Group and Subgroup values
+ g_tSystemManagerSession.szServiceName = SERVICE_SYSMANAGER;
+ g_tSystemManagerSession.strIAm = FrameworkunifiedGetAppName(hApp);
+
+ /// Cleanup any other data members
+ g_tSystemManagerSession.fAvailable = FALSE;
+ g_tSystemManagerSession.hService = NULL;
+
+ pthread_mutex_unlock(&gMutexObj);
+
+ l_eStatus = SystemManagerOpenSender(hApp);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SystemManagerOpenSender()");
+ } else {
+ // LCOV_EXCL_START 6:Duplicate check(AppName has been checked by the caller)
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " I am SystemManager ! Not registering for '%s' notification",
+ NTFY_SSSystemMgrAvailability);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////
+/// Function: SystemManagerOpenSender
+///
+///////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus SystemManagerOpenSender(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ pthread_mutex_lock(&gMutexObj);
+
+ // LCOV_EXCL_START 6:Duplicate check(hService is NULL only)
+ if (g_tSystemManagerSession.hService != NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warn: hService != NULL");
+ pthread_mutex_unlock(&gMutexObj);
+ return eFrameworkunifiedStatusFail;
+ }
+ // LCOV_EXCL_STOP
+
+ // opening the service
+ if (NULL
+ == (g_tSystemManagerSession.hService = FrameworkunifiedMcOpenSender(hApp,
+ SERVICE_SYSMANAGER))) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedMcOpenSender(SERVICE_SYSMANAGER)");
+ } else {
+ FrameworkunifiedProtocolCallbackHandler l_SystemManager_Protocol_Cbs[] = {
+ // Command ID, Call back functions
+ { SS_SM_PROTOCOL_OPEN_SESSION_ACK, OnSystemManagerOpenSessionAck },
+ { SS_SM_START, OnSystemManagerStart },
+ { SS_SM_STOP, OnSystemManagerStop },
+ { SS_SM_PRE_START, OnSystemManagerPreStart },
+ { SS_SM_PRE_STOP, OnSystemManagerPreStop },
+ { SS_SM_BACKGROUND_START, OnSystemManagerBackgroundStart },
+ { SS_SM_BACKGROUND_STOP, OnSystemManagerBackgroundStop },
+ { SS_SM_DEBUG_DUMP, OnSystemManagerDebugDump },
+ }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ /// Attach the valid callback for this service
+ if (eFrameworkunifiedStatusOK != // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hApp, SERVICE_SYSMANAGER, l_SystemManager_Protocol_Cbs,
+ _countof(l_SystemManager_Protocol_Cbs)))) {
+ LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher()");
+ } else if (eFrameworkunifiedStatusOK != // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ (l_eStatus = FrameworkunifiedSendMsg(g_tSystemManagerSession.hService,
+ SS_SM_PROTOCOL_OPEN_SESSION_REQ, 0, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: FrameworkunifiedSendMsg(%s) errored: 0x%X/%s",
+ g_tSystemManagerSession.szServiceName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ } // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ pthread_mutex_unlock(&gMutexObj);
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ g_moduleState = MODULE_STATE_CONNECTING;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+}
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerOpenSessionAck
+/// Service Manager OpenSession callback
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus OnSystemManagerOpenSessionAck(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL == hApp) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("NULL == hApp");
+ } else {
+ pthread_mutex_lock(&gMutexObj);
+ if (NULL == g_tSystemManagerSession.hService) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetOpenSessionHandle()");
+ g_tSystemManagerSession.fAvailable = FALSE;
+ } else {
+ LOG_SUCCESS("FrameworkunifiedGetOpenSessionHandle(hApp)");
+ g_tSystemManagerSession.fAvailable = TRUE;
+ g_moduleState = MODULE_STATE_CONNECTED;
+ }
+ pthread_mutex_unlock(&gMutexObj);
+
+ if ((eFrameworkunifiedStatusOK == l_eStatus) && (CallbackFnPtr != NULL)) {
+ // Call the RegisterSMSessionAckCallback()-registered function
+ if (eFrameworkunifiedStatusOK != (l_eStatus = (CallbackFnPtr)(hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: The 'CallbackFnPtr' function as set by "
+ "the RegisterSMSessionAckCallback() function "
+ "errored: 0x%x/%s",
+ l_eStatus, GetStr(l_eStatus).c_str());
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // EFrameworkunifiedStatus OnSystemManagerOpenSessionAck( HANDLE hApp )
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////
+/// Macro:
+///
+///////////////////////////////////////////////////////////
+#define SETUP_AND_CALL_COMMON_SYSTEM_MANAGER_START_STOP_PROCESSING( \
+ hApp, evInterfaceunifiedId, InterfaceunifiedFnc, ModStateSuccess, ModStateFailure, \
+ NotifFlag, NotifText, ProtocolId) \
+ l_eStatus = CommonSystemManagerStartStopCallbackProcessing( \
+ hApp, \
+ evInterfaceunifiedId, \
+ #evInterfaceunifiedId, \
+ InterfaceunifiedFnc, \
+ #InterfaceunifiedFnc "()", \
+ ModStateSuccess, \
+ ModStateFailure, \
+ NotifFlag, \
+ NotifText, \
+ ProtocolId, \
+ #ProtocolId); \
+ LOG_STATUS(l_eStatus, \
+ "CommonSystemManagerStartStopCallbackProcessing(" #InterfaceunifiedFnc "())");
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerStart
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus OnSystemManagerStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = FrameworkunifiedGetDefaultCbHandler(&cbFuncs);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedGetDefaultCbHandler()");
+
+ // Call CommonSystemManagerStartStopCallbackProcessing(), & log status
+ SETUP_AND_CALL_COMMON_SYSTEM_MANAGER_START_STOP_PROCESSING(
+ hApp, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart), cbFuncs.onStart, MODULE_STATE_STARTED,
+ MODULE_STATE_START_FAILED, FALSE, "", SS_SM_START_COMPL_RSPN);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus OnSystemManagerStart( HANDLE hApp )
+
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerStop
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus OnSystemManagerStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = FrameworkunifiedGetDefaultCbHandler(&cbFuncs);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedGetDefaultCbHandler()");
+
+ // Call CommonSystemManagerStartStopCallbackProcessing(), & log status
+ SETUP_AND_CALL_COMMON_SYSTEM_MANAGER_START_STOP_PROCESSING(
+ hApp, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop), cbFuncs.onStop, MODULE_STATE_STOPPED,
+ MODULE_STATE_STOP_FAILED, UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc,
+ " 'UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc' is 'True': "
+ "setting 'l_eStatus' to 'eFrameworkunifiedStatusFail'",
+ SS_SM_STOP_COMPL_RSPN);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus OnSystemManagerStop( HANDLE hApp )
+
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerPreStart
+///
+///////////////////////////////////////////////////////////
+static EFrameworkunifiedStatus OnSystemManagerPreStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = FrameworkunifiedGetDefaultCbHandler(&cbFuncs); // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedGetDefaultCbHandler()");
+
+ // Call CommonSystemManagerStartStopCallbackProcessing(), & log status
+ SETUP_AND_CALL_COMMON_SYSTEM_MANAGER_START_STOP_PROCESSING(
+ hApp,
+ FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedPreStart),
+ cbFuncs.onPreStart,
+ MODULE_STATE_STARTED_PRE,
+ MODULE_STATE_START_PRE_FAILED,
+ FALSE,
+ "",
+ SS_SM_PRE_START_COMPL_RSPN);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:Excluded for function that are expanded inline
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus OnSystemManagerPreStart( HANDLE hApp )
+
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerPreStop
+///
+///////////////////////////////////////////////////////////
+static EFrameworkunifiedStatus OnSystemManagerPreStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = FrameworkunifiedGetDefaultCbHandler(&cbFuncs); // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedGetDefaultCbHandler()");
+
+ // Call CommonSystemManagerStartStopCallbackProcessing(), & log status
+ SETUP_AND_CALL_COMMON_SYSTEM_MANAGER_START_STOP_PROCESSING(
+ hApp,
+ FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedPreStop),
+ cbFuncs.onPreStop,
+ MODULE_STATE_STOPPED_PRE,
+ MODULE_STATE_STOP_PRE_FAILED,
+ FALSE,
+ "",
+ SS_SM_PRE_STOP_COMPL_RSPN);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:Excluded for function that are expanded inline
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus OnSystemManagerPreStop( HANDLE hApp )
+
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerBackgroundStart
+///
+///////////////////////////////////////////////////////////
+static EFrameworkunifiedStatus OnSystemManagerBackgroundStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = FrameworkunifiedGetDefaultCbHandler(&cbFuncs); // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedGetDefaultCbHandler()");
+
+ // Call CommonSystemManagerStartStopCallbackProcessing(), & log status
+ SETUP_AND_CALL_COMMON_SYSTEM_MANAGER_START_STOP_PROCESSING(
+ hApp,
+ FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedBackgroundStart),
+ cbFuncs.onBackgroundStart,
+ MODULE_STATE_STARTED_BACKGROUND,
+ MODULE_STATE_START_BACKGROUND_FAILED,
+ FALSE,
+ "",
+ SS_SM_BACKGROUND_START_COMPL_RSPN);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:Excluded for function that are expanded inline
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus OnSystemManagerBackgroundStart( HANDLE hApp )
+
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerBackgroundStop
+///
+///////////////////////////////////////////////////////////
+static EFrameworkunifiedStatus OnSystemManagerBackgroundStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = FrameworkunifiedGetDefaultCbHandler(&cbFuncs); // LCOV_EXCL_BR_LINE 11:Excluded due to gcov restrictions(others)
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedGetDefaultCbHandler()");
+
+ // Call CommonSystemManagerStartStopCallbackProcessing(), & log status
+ SETUP_AND_CALL_COMMON_SYSTEM_MANAGER_START_STOP_PROCESSING(
+ hApp,
+ FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedBackgroundStop),
+ cbFuncs.onBackgroundStop,
+ MODULE_STATE_STOPPED_BACKGROUND,
+ MODULE_STATE_STOP_BACKGROUND_FAILED,
+ FALSE,
+ "",
+ SS_SM_BACKGROUND_STOP_COMPL_RSPN);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:Excluded for function that are expanded inline
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus OnSystemManagerBackgroundStop( HANDLE hApp )
+
+///////////////////////////////////////////////////////////
+/// Function: CommonSystemManagerStartStopCallbackProcessing
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CommonSystemManagerStartStopCallbackProcessing(
+ HANDLE hApp, UI_32 f_InterfaceunifiedEvID, SS_String f_pInterfaceunifiedEvName, CbFuncPtr f_InterfaceunifiedFncCb,
+ PCSTR f_pInterfaceunifiedFncName, ModuleStateType f_moduleSuccessState,
+ ModuleStateType f_moduleFailureState, BOOL f_bUseNotificationVsFncFlag,
+ PCSTR f_pUseNotificationText, SS_SystemManagerProtocol f_ProtocolId,
+ PCSTR f_pProtocolName) {
+ EFrameworkunifiedStatus l_eStatus;
+ EFrameworkunifiedStatus l_StatusFncReturned;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SS_String l_pInterfaceunifiedFncName;
+
+ if (f_moduleSuccessState == g_moduleState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Module state already is '%s', just "
+ "returning '%s' to System Manager",
+ GetStr(g_moduleState).c_str(), f_pProtocolName);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ l_StatusFncReturned = l_eStatus;
+ } else {
+ // If client application is a state machine, post an Event instead of calling
+ // InterfaceunifiedOnXYZ()
+ if (FrameworkunifiedIsStateMachineApp(hApp)) {
+ l_pInterfaceunifiedFncName = "FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(" + f_pInterfaceunifiedEvName + " ))";
+ CFrameworkunifiedHSMFramework* l_pStateMachine = FrameworkunifiedGetStateMachine(hApp);
+ if (NULL == l_pStateMachine) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetStateMachine()");
+ l_StatusFncReturned = l_eStatus;
+ } else {
+ l_eStatus = l_pStateMachine->FrameworkunifiedPostEvent(f_InterfaceunifiedEvID);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: l_pStateMachine->FrameworkunifiedPostEvent(%s) "
+ "errored: %d/'%s'",
+ f_pInterfaceunifiedEvName.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
+ l_StatusFncReturned = l_eStatus;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " f_bUseNotificationVsFncFlag is '%s'",
+ GetStr(f_bUseNotificationVsFncFlag).c_str());
+ if (f_bUseNotificationVsFncFlag) {
+ //
+ // DON'T send an 'Ok' back to the SendInterfaceunifiedOnResponse function: if
+ // it detects a 'Ok' it will send a SS_SM_<protocol>_RSPN back
+ // to System Manager, telling System Manager that the request
+ // has been completely serviced.
+ l_StatusFncReturned = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", f_pUseNotificationText);
+ } else {
+ //
+ // Always send an 'Ok' back for the evInterfaceunified<protocol> version
+ // of InterfaceunifiedOn<protocol>; the l_eStatus applies to the
+ // FrameworkunifiedPostEvent() function, not the actual <protocol> event
+ // handler.
+ l_StatusFncReturned = eFrameworkunifiedStatusOK;
+ }
+ } // End else successful FrameworkunifiedPostEvent()
+ } // End else valid FrameworkunifiedGetStateMachine()
+ } else { // End if FrameworkunifiedIsStateMachineApp() is TRUE
+ l_pInterfaceunifiedFncName = f_pInterfaceunifiedFncName;
+ if (f_InterfaceunifiedFncCb) {
+ l_eStatus = (f_InterfaceunifiedFncCb)(hApp);
+ LOG_STATUS(l_eStatus, f_pInterfaceunifiedFncName);
+ l_StatusFncReturned = l_eStatus;
+ } else {
+ SS_ASERT(0);
+ l_StatusFncReturned = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+
+ l_eStatus = SendInterfaceunifiedOnResponseToSystemManager(f_ProtocolId, f_pProtocolName,
+ l_pInterfaceunifiedFncName.c_str(),
+ f_moduleSuccessState,
+ f_moduleFailureState,
+ l_StatusFncReturned);
+ const char l_cFormat[] = "SendInterfaceunifiedOnResponseToSystemManager(%s)";
+ char l_cBuf[sizeof(l_cFormat) + strlen(f_pProtocolName) + 1]; // NOLINT (runtime/arrays)
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, f_pProtocolName);
+ LOG_STATUS_IF_ERRORED(l_eStatus, l_cBuf);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of CommonSystemManagerStartStopCallbackProcessing(
+
+
+///////////////////////////////////////////////////////////
+/// Function: SendInterfaceunifiedOnStopResponseToSystemManager()
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendInterfaceunifiedOnStopResponseToSystemManager(EFrameworkunifiedStatus f_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = SendInterfaceunifiedOnResponseToSystemManager(
+ SS_SM_STOP_COMPL_RSPN, "SS_SM_STOP_COMPL_RSPN", "FrameworkunifiedOnStop()",
+ MODULE_STATE_STOPPED, MODULE_STATE_STOP_FAILED, f_eStatus);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendInterfaceunifiedOnResponseToSystemManager("
+ "SS_SM_STOP_COMPL_RSPN");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SendInterfaceunifiedOnStopResponseToSystemManager(EFrameworkunifiedStatus f_eStatus)
+
+///////////////////////////////////////////////////////////
+/// Function: GetInterfaceunifiedOnStartExtInfo()
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetInterfaceunifiedOnStartExtInfo(T_SS_SM_START_ExtDataStructType &f_info) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = InvokeSyncRequestToSystemManager(
+ SS_SM_GET_START_EXT_INFO, "SS_SM_GET_START_EXT_INFO", 0, NULL,
+ sizeof(T_SS_SM_START_ExtDataStructType), (PVOID) & f_info);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "InvokeSyncRequestToSystemManager()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////
+/// Function: GetInterfaceunifiedOnStopExtInfo()
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetInterfaceunifiedOnStopExtInfo(T_SS_SM_STOP_ExtDataStructType &f_info) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = InvokeSyncRequestToSystemManager(
+ SS_SM_GET_STOP_EXT_INFO, "SS_SM_GET_STOP_EXT_INFO", 0, NULL,
+ sizeof(T_SS_SM_STOP_ExtDataStructType), (PVOID) & f_info);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "InvokeSyncRequestToSystemManager()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+///////////////////////////////////////////////////////////
+/// Function: OnSystemManagerDebugDump
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus OnSystemManagerDebugDump(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+
+ g_moduleState = MODULE_STATE_DEBUG_DUMPING;
+ l_eStatus = FrameworkunifiedGetDefaultCbHandler(&cbFuncs);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedGetDefaultCbHandler()");
+
+ if (cbFuncs.onDebugDump) {
+ l_eStatus = cbFuncs.onDebugDump(hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedOnDebugDump()");
+ } else {
+ SS_ASERT(0);
+ }
+
+ l_eStatus = DebugDumpAppCbStatistics(hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "DebugDumpAppCbStatistics()");
+
+ l_eStatus = DebugDumpMemoryMap(hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "DebugDumpMemoryMap()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus OnSystemManagerDebugDump( HANDLE hApp )
+
+///////////////////////////////////////////////////////////
+/// Function: DebugDumpAppCbStatistics
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DebugDumpAppCbStatistics(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+l_eStatus = eFrameworkunifiedStatusOK;
+
+FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////
+/// Function: DebugDumpMemoryMap
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DebugDumpMemoryMap(HANDLE hApp) {
+#define MEM_MAP_READ_SIZE 4096
+#define DUMP_MAX_SIZE 131072 // 128KB
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ char buf[MEM_MAP_READ_SIZE];
+ std::string bufString;
+ int fd, ret;
+
+ fd = open("/proc/self/maps", O_RDONLY);
+ if (fd != -1) {
+ while ((ret = read(fd, buf, MEM_MAP_READ_SIZE)) > 0) {
+ if ((bufString.size() + ret) > DUMP_MAX_SIZE) {
+ // If read it again, it will break because it overflows
+ break;
+ }
+ bufString.append(buf, ret);
+ }
+ close(fd);
+ if (ret >= 0) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ SendDebugDumpResponseToSystemManager(bufString);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// SendDebugDumpResponseToSystemManager
+//////////////////////////////////////////
+VOID SendDebugDumpResponseToSystemManager(BOOL f_bFormatStrRequired,
+ PCSTR f_cFormat, ...) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ va_list l_argList;
+ const UI_32 l_maxDebugDumpMsgSize = (1024 * 4);
+ CHAR l_cMsg[l_maxDebugDumpMsgSize] = { 0 };
+ PCSTR l_pAppName;
+
+ pthread_mutex_lock(&gMutexObj);
+
+ l_pAppName = FrameworkunifiedGetAppName(g_SystemIf_hApp); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (f_bFormatStrRequired) {
+ // build a format string
+ // Format: AppName/debugdump_data
+ snprintf(l_cMsg, l_maxDebugDumpMsgSize, "%s/", l_pAppName);
+ }
+
+ va_start(l_argList, f_cFormat);
+ vsnprintf(&l_cMsg[strlen(l_cMsg)], l_maxDebugDumpMsgSize - strlen(l_cMsg),
+ f_cFormat, l_argList);
+ va_end(l_argList);
+
+ if (0 == strcmp(SERVICE_SYSMANAGER, l_pAppName)) {
+ l_eStatus = FrameworkunifiedSendSelf(g_SystemIf_hApp, SS_SM_DEBUG_DUMP_RSPN,
+ strlen(l_cMsg) + 1, l_cMsg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSendSelf(SS_SM_DEBUG_DUMP_RSPN)");
+ } else if (NULL != g_tSystemManagerSession.hService) {
+ l_eStatus = FrameworkunifiedSendMsg(g_tSystemManagerSession.hService,
+ SS_SM_DEBUG_DUMP_RSPN, strlen(l_cMsg) + 1, l_cMsg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSendMsg(SS_SM_DEBUG_DUMP_RSPN)");
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Invalid handle[g_tSystemManagerSession.hService == NULL]");
+ }
+
+ pthread_mutex_unlock(&gMutexObj);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+} // End of EFrameworkunifiedStatus SendDebugDumpResponseToSystemManager( HANDLE hApp )
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+//////////////////////////////////////////
+// SendDebugDumpResponseToSystemManager
+//////////////////////////////////////////
+VOID SendDebugDumpResponseToSystemManager(std::string & f_messageStr) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ pthread_mutex_lock(&gMutexObj);
+
+ if (0 == strcmp(SERVICE_SYSMANAGER, FrameworkunifiedGetAppName(g_SystemIf_hApp))) {
+ l_eStatus = FrameworkunifiedSendSelf(g_SystemIf_hApp, SS_SM_DEBUG_DUMP_RSPN,
+ f_messageStr.size() + 1, f_messageStr.c_str());
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSendSelf(SS_SM_DEBUG_DUMP_RSPN)");
+ } else if (NULL != g_tSystemManagerSession.hService) {
+ l_eStatus = FrameworkunifiedSendMsg(g_tSystemManagerSession.hService,
+ SS_SM_DEBUG_DUMP_RSPN, f_messageStr.size() + 1,
+ f_messageStr.c_str());
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSendMsg(SS_SM_DEBUG_DUMP_RSPN)");
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: hService = NULL");
+ }
+
+ pthread_mutex_unlock(&gMutexObj);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+} // End of EFrameworkunifiedStatus SendDebugDumpResponseToSystemManager(std::string & f_messageStr)
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////
+/// Function: SendInterfaceunifiedOnResponseToSystemManager()
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendInterfaceunifiedOnResponseToSystemManager(
+ SS_SystemManagerProtocol f_ProtocolID, PCSTR f_pProtocolName,
+ PCSTR f_InterfaceunifiedOnFncName, ModuleStateType f_moduleSuccessState,
+ ModuleStateType f_moduleFailureState, EFrameworkunifiedStatus f_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (eFrameworkunifiedStatusOK != f_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: '%s' returned %d/%s, NOT sending '%s' to System Manager",
+ f_InterfaceunifiedOnFncName, f_eStatus, GetStr(f_eStatus).c_str(),
+ f_pProtocolName);
+ l_eStatus = f_eStatus;
+ SetModuleState(f_moduleFailureState);
+ } else {
+ if (f_moduleSuccessState == g_moduleState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Module state already is '%s', just "
+ "returning '%s' to System Manager",
+ GetStr(g_moduleState).c_str(), f_pProtocolName);
+ }
+
+ l_eStatus = SendMsgToSystemManager(static_cast<UI_32>(f_ProtocolID),
+ f_pProtocolName,
+ sizeof(g_responseCompleteAck),
+ &g_responseCompleteAck); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ const char l_cFormat[] = "SendMsgToSystemManager(%s)";
+ char l_cBuf[sizeof(l_cFormat) + strlen(f_pProtocolName) + 1]; // NOLINT (runtime/arrays)
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, f_pProtocolName);
+ LOG_STATUS(l_eStatus, l_cBuf);
+ SetModuleState(f_moduleSuccessState);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of SendInterfaceunifiedOnResponseToSystemManager(
+
+///////////////////////////////////////////////////////////
+/// Function: SendMsgToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendMsgToSystemManager(UI_32 uiCmd, PCSTR f_pCmdName, UI_32 uiLength,
+ PCVOID pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Sending %s", f_pCmdName);
+
+ return SendMsgToSystemManager(uiCmd, uiLength, pData);
+} // End of EFrameworkunifiedStatus SendMsgToSystemManager(UI_32 uiCmd, PCSTR f_pCmdName, UI_32 uiLength, PCVOID pData)
+
+///////////////////////////////////////////////////////////
+/// Function: SendMsgToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendMsgToSystemManager(UI_32 uiCmd, UI_32 uiLength, PCVOID pData) {
+ EFrameworkunifiedStatus l_eStatus;
+ if (NULL == g_tSystemManagerSession.hService) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("NULL == g_tSystemManagerSession.hService");
+ } else {
+ pthread_mutex_lock(&gMutexObj);
+ l_eStatus = FrameworkunifiedSendMsg(g_tSystemManagerSession.hService, uiCmd, uiLength,
+ pData);
+ pthread_mutex_unlock(&gMutexObj);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSendMsg()");
+ }
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SendMsgToSystemManager(UI_32 uiCmd, UI_32 uiLength, PCVOID pData)
+
+///////////////////////////////////////////////////////////
+/// Function: InvokeSyncRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus InvokeSyncRequestToSystemManager(UI_32 uiCmd, PCSTR f_pCmdName,
+ UI_32 uiLength, PCVOID pData,
+ UI_32 uiResLength, PVOID pResData) {
+ EFrameworkunifiedStatus l_eStatus;
+ UI_32 uiRcvLength = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Sending %s", f_pCmdName);
+
+ if (NULL == g_tSystemManagerSession.hService) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("NULL == g_tSystemManagerSession.hService");
+ } else {
+ pthread_mutex_lock(&gMutexObj);
+ l_eStatus = FrameworkunifiedInvokeSync(g_tSystemManagerSession.hService, uiCmd, uiLength,
+ pData, uiResLength, pResData, &uiRcvLength); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (uiResLength != uiRcvLength) {
+ LOG_ERROR("uiResLength != uiRcvLength");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ pthread_mutex_unlock(&gMutexObj);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedInvokeSync()");
+ }
+ return l_eStatus;
+} // End of Function
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+///////////////////////////////////////////////////////////
+/// Function: SendWakeUpToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendWakeUpToSystemManager(wakeInfo *pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = SendMsgToSystemManager(SS_SM_WAKEUP_MODULES,
+ "SS_SM_WAKEUP_MODULES",
+ sizeof(wakeInfo),
+ (PCVOID) pData);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SendWakeUpToSystemManager(wakeInfo *pData)
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+///////////////////////////////////////////////////////////
+/// Function: SendShutdownToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendShutdownToSystemManager(Pwr_ServiceSetInterface *pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = SendMsgToSystemManager(SS_SM_SHUTDOWN_MODULES,
+ "SS_SM_SHUTDOWN_MODULES",
+ sizeof(Pwr_ServiceSetInterface),
+ (PCVOID) pData);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SendShutdownToSystemManager(Pwr_ServiceSetInterface *pData)
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////
+/// Function: RegisterSMSessionAckCallback
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RegisterSMSessionAckCallback(EFrameworkunifiedStatus (*CallbackPtr)(HANDLE)) {
+ CallbackFnPtr = CallbackPtr;
+ return eFrameworkunifiedStatusOK;
+} // End of EFrameworkunifiedStatus RegisterSMSessionAckCallback(EFrameworkunifiedStatus (*CallbackPtr)(HANDLE))
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+///////////////////////////////////////////////////////////
+/// Function: SendSystemModeRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendSystemModeRequestToSystemManager(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = SendMsgToSystemManager(SS_SM_SYSTEM_MODE_INFO_REQ,
+ "SS_SM_SYSTEM_MODE_INFO_REQ", 0,
+ NULL);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SendSystemModeRequestToSystemManager(void)
+
+///////////////////////////////////////////////////////////
+/// Function: SendInitCompReportToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendInitCompReportToSystemManager(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = SendMsgToSystemManager(SS_SM_INITCOMP_REP,
+ "SS_SM_INITCOMP_REP", 0, NULL);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SendInitCompReportToSystemManager(void)
+
+
+///////////////////////////////////////////////////////////
+/// Function: AttachCallbackToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus AttachCallbackToSystemManager(HANDLE hApp, UI_32 iCmd,
+ CbFuncPtr fpOnCmd) {
+ return FrameworkunifiedAttachCallbackToDispatcher(
+ hApp, g_tSystemManagerSession.szServiceName.c_str(), iCmd, fpOnCmd);
+} // End of EFrameworkunifiedStatus AttachCallbackToSystemManager( HANDLE hApp, UI_32 iCmd, CbFuncPtr fpOnCmd )
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////
+/// Function: SetDataResetModeToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetDataResetModeToSystemManager(ESMDataResetModeInfo dataResetMode) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_resData;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ switch (dataResetMode) {
+ case e_SS_SM_DATA_RESET_MODE_NONE:
+ case e_SS_SM_DATA_RESET_MODE_USER:
+ case e_SS_SM_DATA_RESET_MODE_FACTORY:
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "dataResetMode %d", dataResetMode);
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ l_eStatus = InvokeSyncRequestToSystemManager(SS_SM_DATA_RESET_MODE_SET_REQ,
+ "SS_SM_DATA_RESET_MODE_SET_REQ",
+ sizeof(dataResetMode),
+ (PVOID) & dataResetMode,
+ sizeof(l_resData),
+ (PVOID) & l_resData); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "InvokeSyncRequestToSystemManager()");
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (eFrameworkunifiedStatusOK != l_resData) {
+ l_eStatus = l_resData;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " l_eStatus %d", l_eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SetDataResetModeToSystemManager(ESMDataResetModeInfo dataResetMode)
+
+///////////////////////////////////////////////////////////
+/// Function: SetProgUpdateStateToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetProgUpdateStateToSystemManager(
+ SMProgUpdateState progUpdateState) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_resData;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (progUpdateState & SS_SM_PROG_UPDATE_STATE_UPDATED) {
+ } else if (progUpdateState & SS_SM_PROG_UPDATE_STATE_MAP_UPDATED) {
+ } else if (progUpdateState & SS_SM_PROG_UPDATE_STATE_MAPDIFF_UPDATED) {
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "unknown %#x", progUpdateState);
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ l_eStatus = InvokeSyncRequestToSystemManager(
+ SS_SM_PROG_UPDATE_STATE_SET_REQ, "SS_SM_PROG_UPDATE_STATE_SET_REQ",
+ sizeof(progUpdateState), (PVOID) & progUpdateState, sizeof(l_resData),
+ (PVOID) & l_resData); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "InvokeSyncRequestToSystemManager()");
+
+ if ((eFrameworkunifiedStatusOK == l_eStatus) && (eFrameworkunifiedStatusOK != l_resData)) {
+ l_eStatus = l_resData;
+ LOG_ERROR("SM RESP");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SetProgUpdateStateToSystemManager(SMProgUpdateState progUpdateState)
+
+///////////////////////////////////////////////////////////
+/// Function: SetNextWakeupTypeToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetNextWakeupTypeToSystemManager(ESMNextWakeupType f_wakeupType) {
+ EFrameworkunifiedStatus l_eStatus;
+ EFrameworkunifiedStatus l_resData;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ switch (f_wakeupType) {
+ case e_SS_SM_NEXT_WAKEUP_TYPE_NONE:
+ case e_SS_SM_NEXT_WAKEUP_TYPE_COLD:
+ case e_SS_SM_NEXT_WAKEUP_TYPE_HOT:
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "unknown type(%d)", f_wakeupType);
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ l_eStatus = InvokeSyncRequestToSystemManager(SS_SM_NEXT_WAKEUP_TYPE_SET_REQ,
+ "SS_SM_NEXT_WAKEUP_TYPE_SET_REQ",
+ sizeof(f_wakeupType),
+ (PVOID) & f_wakeupType,
+ sizeof(l_resData),
+ (PVOID) & l_resData); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "InvokeSyncRequestToSystemManager()");
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (eFrameworkunifiedStatusOK != l_resData) {
+ l_eStatus = l_resData;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " l_eStatus %d", l_eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////
+/// Function: SendCpuResetRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendCpuResetRequestToSystemManager(
+ ESMCpuResetReason l_eCpuResetReason, std::string f_messageStr/* = "" */,
+ std::string f_suffixStr/* = "" */) {
+ TSystemManagerCpuResetInfo l_resetInfo; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ EFrameworkunifiedStatus l_eStatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_resetInfo.resetReason = l_eCpuResetReason;
+ snprintf(l_resetInfo.messageStr, SS_SM_RESET_MSG_STR_SIZE, "%s",
+ f_messageStr.c_str()); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ snprintf(l_resetInfo.suffixStr, SS_SM_SUFFIX_STR_SIZE, "%s",
+ f_suffixStr.c_str()); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_CPU_RESET_REQ, "SS_SM_CPU_RESET_REQ",
+ sizeof(l_resetInfo),
+ (PVOID) & l_resetInfo); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of SendCpuResetRequestToSystemManager
+
+///////////////////////////////////////////////////////////
+/// Function: SendStartupConfirmationToSystemManager
+///
+///////////////////////////////////////////////////////////
+// LCOV_EXCL_START 6:Because the condition cannot be set
+EFrameworkunifiedStatus SendStartupConfirmationToSystemManager(
+ StartupConfirmationMsgStrut &f_startupConfirmationMsg) { //NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ Pwr_ServiceSetInterface tServiceSetIf;
+ tServiceSetIf.data.startupConfirmationMsg = f_startupConfirmationMsg;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_FWD_STARTUP_CONFIRMATION_MSG_REQ,
+ "SS_SM_FWD_STARTUP_CONFIRMATION_MSG_REQ",
+ sizeof(Pwr_ServiceSetInterface),
+ (PCVOID) & tServiceSetIf);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus SendStartupConfirmationToSystemManager(
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+EFrameworkunifiedStatus SendSystemErrorToSystemManager(EFrameworkunifiedSystemError f_systemError) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = SendMsgToSystemManager(SS_SM_PROPAGATE_SYSTEM_ERROR,
+ sizeof(f_systemError),
+ reinterpret_cast<void*>(&f_systemError));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus Send_CWORD56_HeartBeatRequestToSystemManager(
+ EPWR_HB_REQ_MSG_STRUCT f_HbReq) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = SendMsgToSystemManager(SS_SM__CWORD56__HEARTBEAT_REQ,
+ sizeof(f_HbReq),
+ reinterpret_cast<void*>(&f_HbReq));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendMsgToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+VOID Set_UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc_StateVar(BOOL f_SetTrue) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc = f_SetTrue;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc set '%s'",
+ UseStopCompleteNotificationVsInterfaceunifiedOnStopFnc ? "True" : "False");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus SendBootMicroResetNotificationToSystemManager(
+ eSMBootMicroResetReason f_ResetReason) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_BOOT_MICRO_RESET_NTF,
+ "SS_SM_BOOT_MICRO_RESET_NTF",
+ sizeof(f_ResetReason), &f_ResetReason);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendMsgToSystemManager(SS_SM_BOOT_MICRO_RESET_NTF)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus SendUserInvokedLoggingRequestToSystemManager(
+ eSMUserLogType f_userInvokedLogType, std::string f_messageStr/* = "" */,
+ std::string f_suffixStr/* = "" */) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ switch (f_userInvokedLogType) {
+ case e_SS_SM_CAPTURE_ALL_LOGS:
+ case e_SS_SM_SCREEN_CAPTURE:
+ case e_SS_SM_CAPTURE_INTERFACEUNIFIED_LOGS:
+ case e_SS_SM_CAPTURE_DEV_LOGS:
+ case e_SS_SM_CAPTURE_MODULE_LOGS:
+ case e_SS_SM_CAPTURE_DTC_LOGS:
+ case e_SS_SM_CAPTURE_NAVI_LOGS:
+ case e_SS_SM_CAPTURE_GROUP_RELAUNCH:
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Unknown key ID '%d'",
+ f_userInvokedLogType);
+ throw eFrameworkunifiedStatusInvldParam;
+ break;
+ }
+
+ TSystemManagerLoggingRequestInfo l_logInfo = { };
+
+ snprintf(l_logInfo.messageStr, SS_SM_LOG_MSG_STR_SIZE, "%s",
+ f_messageStr.c_str()); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ snprintf(l_logInfo.suffixStr, SS_SM_SUFFIX_STR_SIZE, "%s",
+ f_suffixStr.c_str()); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ l_logInfo.logType = f_userInvokedLogType;
+ l_eStatus = SendMsgToSystemManager(SS_SM_USER_INVOKED_LOG_REQ,
+ "SS_SM_USER_INVOKED_LOG_REQ",
+ sizeof(l_logInfo), &l_logInfo); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendMsgToSystemManager(SS_SM_USER_INVOKED_LOG_REQ)");
+ } catch (EFrameworkunifiedStatus e) {
+ l_eStatus = e;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+}
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+EFrameworkunifiedStatus SendDiagLoggingRequestToSystemManager(
+ std::string f_copyDestPathStr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_DIAG_LOG_REQ,
+ "SS_SM_ERROR_EVENT_DIAG_LOG_REQ",
+ f_copyDestPathStr.length() + 1,
+ f_copyDestPathStr.c_str());
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_DIAG_LOG_REQ)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus SendCANLoggingRequestToSystemManager(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_CAN_LOG_REQ,
+ "SS_SM_ERROR_EVENT_CAN_LOG_REQ", 0, NULL);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_CAN_LOG_REQ)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus SendDTCLoggingRequestToSystemManager(UI_32 f_dtc) {
+ SS_ASERT(0);
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus RegisterBootMicroLogRequestCb(HANDLE hApp, CbFuncPtr fpOnCmd) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (NULL == hApp) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("(NULL == hApp)");
+ } else if (NULL == fpOnCmd) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("(NULL == fpOnCmd)");
+ } else {
+ l_eStatus = FrameworkunifiedSubscribeToSessionEventWithCallback(
+ hApp, SS_SM_BOOT_MICRO_LOG_REQ, fpOnCmd,
+ g_tSystemManagerSession.hService); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "FrameworkunifiedSubscribeToSessionEventWithCallback(SS_SM_BOOT_MICRO_LOG_REQ)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus SendBootMicroLogResponseToSystemManager(std::string f_logString) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_BOOT_MICRO_LOG_RSP,
+ "SS_SM_BOOT_MICRO_LOG_RSP",
+ f_logString.size() + 1,
+ f_logString.c_str());
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendMsgToSystemManager(SS_SM_BOOT_MICRO_LOG_RSP)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+EFrameworkunifiedStatus DetachCallbacksFromInterfaceunifiedDispatcher(
+ HANDLE hApp, PCSTR pServiceName,
+ const FrameworkunifiedProtocolCallbackHandler* pMsgHandler, UI_32 uiHandlerCount,
+ HANDLE hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ PUI_32 l_puiCmdIdArray;
+
+ if (NULL == pServiceName) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("NULL == pServiceName");
+ } else if (NULL == pMsgHandler) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("NULL == pMsgHandler");
+ } else if (0 == uiHandlerCount) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("0 == uiHandlerCount");
+ } else if (NULL == hSession) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("NULL == hSession");
+ } else if (NULL
+ == (l_puiCmdIdArray = new (std::nothrow) UI_32[uiHandlerCount])) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("new (std::nothrow)UI_32[ uiHandlerCount ]");
+ } else {
+ LoadCbHandlerCmdIDsIntoDetachCbIDsArray(pMsgHandler, l_puiCmdIdArray,
+ uiHandlerCount);
+
+ l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp, pServiceName,
+ l_puiCmdIdArray,
+ uiHandlerCount, hSession);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedDetachCallbacksFromDispatcher()");
+ delete[] l_puiCmdIdArray;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus DetachCallbacksFromInterfaceunifiedDispatcher(HANDLE hApp,
+
+EFrameworkunifiedStatus DetachParentCallbacksFromInterfaceunifiedDispatcher(
+ HANDLE hApp, const FrameworkunifiedProtocolCallbackHandler* pMsgHandler,
+ UI_32 uiHandlerCount) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ PUI_32 l_puiCmdIdArray;
+
+ if (NULL == pMsgHandler) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("NULL == pMsgHandler");
+ } else if (0 == uiHandlerCount) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("0 == uiHandlerCount");
+ } else if (NULL
+ == (l_puiCmdIdArray = new (std::nothrow) UI_32[uiHandlerCount])) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("new (std::nothrow)UI_32[ uiHandlerCount ]");
+ } else {
+ LoadCbHandlerCmdIDsIntoDetachCbIDsArray(pMsgHandler, l_puiCmdIdArray,
+ uiHandlerCount);
+
+ l_eStatus = FrameworkunifiedDetachParentCallbacksFromDispatcher(hApp, l_puiCmdIdArray,
+ uiHandlerCount);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedDetachParentCallbacksFromDispatcher()");
+ delete[] l_puiCmdIdArray;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus DetachParentCallbacksFromInterfaceunifiedDispatcher(HANDLE hApp,
+
+VOID LoadCbHandlerCmdIDsIntoDetachCbIDsArray(
+ const FrameworkunifiedProtocolCallbackHandler* pMsgHandler, UI_32 * puiCmdIdArray,
+ UI_32 uiHandlerCount) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ for (UI_32 i = 0; i < uiHandlerCount; i++) {
+ puiCmdIdArray[i] = pMsgHandler[i].iCmd;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+} // End of VOID LoadCbHandlerCmdIDsIntoDetachCbIDsArray(const FrameworkunifiedProtocolCallbackHandler* pMsgHandler,
+
+///////////////////////////////////////////////////////////
+/// Function: SendLogStartRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendLogStartRequestToSystemManager(EErrorEventType f_errorEvent) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_LOGGING_START_REQ,
+ "SS_SM_ERROR_EVENT_LOGGING_START_REQ",
+ sizeof(f_errorEvent), &f_errorEvent);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_LOGGING_START_REQ)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////
+/// Function: SendLogArtifactRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendLogArtifactRequestToSystemManager(EArtifactId f_artifactId) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_ARTIFACT_REQ,
+ "SS_SM_ERROR_EVENT_ARTIFACT_REQ",
+ sizeof(f_artifactId), &f_artifactId);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_ARTIFACT_REQ)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////
+/// Function: SendLogCompleteRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendLogCompleteRequestToSystemManager(EFrameworkunifiedStatus f_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (eFrameworkunifiedStatusOK != f_eStatus) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ l_eStatus = f_eStatus;
+ }
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_LOGGING_COMPLETE,
+ "SS_SM_ERROR_EVENT_LOGGING_COMPLETE",
+ sizeof(l_eStatus), &l_eStatus);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_LOGGING_COMPLETE)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////
+/// Function: SendEelExportRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendEelExportRequestToSystemManager(std::string f_path) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_EEL_EXPORT_REQ,
+ "SS_SM_ERROR_EVENT_EEL_EXPORT_REQ",
+ f_path.length() + 1, f_path.c_str());
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_EEL_EXPORT_REQ)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////
+/// Function: SendInterfaceunifiedEmmcLogsRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendInterfaceunifiedEmmcLogsRequestToSystemManager(std::string f_path) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_REQ,
+ "SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_REQ",
+ f_path.length() + 1, f_path.c_str());
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_REQ)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////
+/// Function: SendClearLogsRequestToSystemManager
+///
+///////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendClearLogsRequestToSystemManager(
+ TSystemManagerClearLogsInfo *f_info) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (!f_info) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ l_eStatus = SendMsgToSystemManager(SS_SM_ERROR_EVENT_CLR_LOGS_REQ,
+ "SS_SM_ERROR_EVENT_CLR_LOGS_REQ", 0,
+ NULL);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendMsgToSystemManager(SS_SM_ERROR_EVENT_CLR_LOGS_REQ)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+VOID SetModuleState(ModuleStateType f_moduleState, BOOL f_bLog) {
+ if (f_bLog) { // LCOV_EXCL_BR_LINE 8:f_bLog is true only
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Changing SM_IF state from '%s' to '%s'",
+ GetStr(g_moduleState).c_str(), GetStr(f_moduleState).c_str());
+ }
+ g_moduleState = f_moduleState;
+} // LCOV_EXCL_BR_LINE 10:Because the last line
+// End of VOID ModuleLaunchParams::SetModuleState(SMModuleState f_moduleState )
+
+// EOF /SS_SystemIf/src/ss_sm_client.cpp
diff --git a/systemservice/interface_unified/library/src/ss_string_maps.cpp b/systemservice/interface_unified/library/src/ss_string_maps.cpp
new file mode 100755
index 0000000..629043a
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_string_maps.cpp
@@ -0,0 +1,462 @@
+/*
+ * @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_SystemManagerIf
+/// \brief This file provides support for the System Manager client interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "system_service/ss_string_maps.h"
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_logger_if.h>
+#include <map>
+#include "system_service/ss_power_service.h"
+#include "system_service/ss_templates.h"
+#include "system_service/ss_system_manager_if.h"
+#include "system_service/ss_system_manager_protocol.h"
+#include "ss_system_if_interfaceunifiedlog.h"
+
+/*
+ * 't'emplate for string-map initialization functions
+void Init_SS_xyz_StrMap(std::map<SS_xyz, SS_String> &m_strMap)
+{
+ MAP_ENTRY( m_strMap, );
+ MAP_ENTRY( m_strMap, );
+} // End of void Init_SS_xyz_StrMap(std::map<SS_xyz, SS_String> &m_strMap)
+*/
+
+
+//******************************************************************************
+void Init_eSMBootMicroResetReason_StrMap(std::map<eSMBootMicroResetReason,
+ SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, SS_SM_BOOT_MICRO_RESET_REASON_SELF_RESET);
+ MAP_ENTRY(m_strMap, SS_SM_BOOT_MICRO_RESET_REASON_USER_FORCE_RESET);
+ MAP_ENTRY(m_strMap, SS_SM_BOOT_MICRO_RESET_REASON_DSP_RESET);
+ MAP_ENTRY(m_strMap, SS_SM_BOOT_MICRO_RESET_REASON_HB_TIMEOUT);
+}
+class EnumStringMap< eSMBootMicroResetReason,
+ Init_eSMBootMicroResetReason_StrMap>
+ m_oeSMBootMicroResetReasonMap;
+// LCOV_EXCL_START 6:Because the condition cannot be set
+SS_String GetStr(eSMBootMicroResetReason f_enum) {
+ return m_oeSMBootMicroResetReasonMap.GetStr(f_enum);
+}
+// LCOV_EXCL_STOP
+
+//******************************************************************************
+void Init_EInterfaceunifiedSystemError_StrMap(std::map<EFrameworkunifiedSystemError, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, eFrameworkunifiedSystemErrorNone);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedDSPHardwareReset);
+}
+class EnumStringMap< EFrameworkunifiedSystemError, Init_EInterfaceunifiedSystemError_StrMap> m_oEInterfaceunifiedSystemErrorMap;
+// LCOV_EXCL_START 6:Because the condition cannot be set
+SS_String GetStr(EFrameworkunifiedSystemError f_enum) {
+ return m_oEInterfaceunifiedSystemErrorMap.GetStr(f_enum);
+}
+// LCOV_EXCL_STOP
+
+//******************************************************************************
+void Init_EErrorEventType_StrMap(std::map<EErrorEventType, SS_String> & m_strMap); // NOLINT (runtime/references)
+class EnumStringMap< EErrorEventType, Init_EErrorEventType_StrMap> m_oEErrorEventTypeMap;
+SS_String GetStr(EErrorEventType f_enum) {
+ return m_oEErrorEventTypeMap.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_BOOL_StrMap(std::map<BOOL, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, TRUE);
+ MAP_ENTRY(m_strMap, FALSE);
+} // End of void Init_BOOL_StrMap(std::map<BOOL, SS_String> & m_strMap)
+class EnumStringMap< BOOL, Init_BOOL_StrMap> m_oBOOLMap;
+SS_String GetStr(BOOL f_enum) {
+ return m_oBOOLMap.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_LimpHomeCutoff_StrMap(std::map<EPWR_LHC_TYPE, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epslhcINVALID);
+ MAP_ENTRY(m_strMap, epslhcDISABLED);
+ MAP_ENTRY(m_strMap, epslhcENABLED);
+} // End of void Init_SS_LimpHomeCutoff_StrMap(std::map<EPWR_LHC_TYPE, SS_String> & m_strMap)
+class EnumStringMap< EPWR_LHC_TYPE, Init_SS_LimpHomeCutoff_StrMap> m_oSS_LimpHomeCutoffMap;
+SS_String GetStr(EPWR_LHC_TYPE f_enum) {
+ return m_oSS_LimpHomeCutoffMap.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_ProductionMode_StrMap(std::map<EPWR_PROD_MODE_TYPE, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epspmINVALID);
+ MAP_ENTRY(m_strMap, epspmDISABLED);
+ MAP_ENTRY(m_strMap, epspmENABLED);
+} // End of void Init_SS_ProductionMode_StrMap(std::map<EPWR_PROD_MODE_TYPE, SS_String> & m_strMap)
+class EnumStringMap< EPWR_PROD_MODE_TYPE, Init_SS_ProductionMode_StrMap>
+ m_oSS_ProductionModeMap;
+SS_String GetStr(EPWR_PROD_MODE_TYPE f_enum) {
+ return m_oSS_ProductionModeMap.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_StartupStage_StrMap(std::map<EPWR_STARTUP_STAGE_TYPE, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epssusfINVALID);
+ MAP_ENTRY(m_strMap, epssusSYSTEM_SERVICES_STARTED);
+ MAP_ENTRY(m_strMap, epssusALL_SERVICES_LAUNCHED);
+} // End of void Init_SS_StartupStage_StrMap(std::map<EPWR_STARTUP_STAGE_TYPE, SS_String> & m_strMap)
+class EnumStringMap< EPWR_STARTUP_STAGE_TYPE, Init_SS_StartupStage_StrMap>
+ m_oSS_StartupStageMap;
+// LCOV_EXCL_START 6:Because the condition cannot be set
+SS_String GetStr(EPWR_STARTUP_STAGE_TYPE f_enum) {
+ return m_oSS_StartupStageMap.GetStr(f_enum);
+}
+// LCOV_EXCL_STOP
+
+//******************************************************************************
+void Init_SS_SystemMode_StrMap(std::map<EPWR_SYSTEM_MODE_INFO, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epssinfINVALID);
+ MAP_ENTRY(m_strMap, epssinfNORMAL);
+ MAP_ENTRY(m_strMap, epssinfPROGRAMMING);
+} // End of void Init_SS_SystemMode_StrMap(std::map<EPWR_SYSTEM_MODE_INFO, SS_String> & m_strMap)
+class EnumStringMap< EPWR_SYSTEM_MODE_INFO, Init_SS_SystemMode_StrMap>
+ m_oSS_SystemModeMap;
+// LCOV_EXCL_START 6:Because the condition cannot be set
+SS_String GetStr(EPWR_SYSTEM_MODE_INFO f_enum) {
+ return m_oSS_SystemModeMap.GetStr(f_enum);
+}
+// LCOV_EXCL_STOP
+
+//******************************************************************************
+void Init_SS_TransportMode_StrMap(std::map<EPWR_TRANSPORT_MODE_TYPE, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epstmINVALID);
+ MAP_ENTRY(m_strMap, epstmDISABLED);
+ MAP_ENTRY(m_strMap, epstmENABLED);
+} // End of void Init_SS_TransportMode_StrMap(std::map<EPWR_TRANSPORT_MODE_TYPE, SS_String> & m_strMap)
+class EnumStringMap< EPWR_TRANSPORT_MODE_TYPE, Init_SS_TransportMode_StrMap>
+ m_oSS_TransportModeMap;
+SS_String GetStr(EPWR_TRANSPORT_MODE_TYPE f_enum) {
+ return m_oSS_TransportModeMap.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_EInterfaceunifiedStatus_StrMap(std::map<EFrameworkunifiedStatus, SS_String> & m_strMap); // NOLINT (runtime/references)
+class EnumStringMap< EFrameworkunifiedStatus, Init_EInterfaceunifiedStatus_StrMap> m_oEInterfaceunifiedStatusMap;
+SS_String GetStr(EFrameworkunifiedStatus f_enum) {
+ return m_oEInterfaceunifiedStatusMap.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_SystemManagerProtocol_StrMap(std::map<SS_SystemManagerProtocol,
+ SS_String> & m_strMap); // NOLINT (runtime/references)
+class EnumStringMap< SS_SystemManagerProtocol,
+ Init_SS_SystemManagerProtocol_StrMap> m_oSSSMProtocolMap;
+SS_String GetStr(SS_SystemManagerProtocol f_enum) {
+ return m_oSSSMProtocolMap.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_ColdStart_StrMap(std::map<EPWR_SC_COLD_START_REQ_TYPE,
+ SS_String> &m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epsscrtINVALID);
+ MAP_ENTRY(m_strMap, epsscrtNOT_REQUIRED);
+ MAP_ENTRY(m_strMap, epsscrtREQUIRED);
+}
+class EnumStringMap< EPWR_SC_COLD_START_REQ_TYPE,
+ Init_SS_ColdStart_StrMap> m_oSSColdStart_Map;
+// LCOV_EXCL_START 6:Because the condition cannot be set
+SS_String GetStr(EPWR_SC_COLD_START_REQ_TYPE f_enum) {
+ return m_oSSColdStart_Map.GetStr(f_enum);
+}
+// LCOV_EXCL_STOP
+
+//******************************************************************************
+void Init_SS__CWORD56__BootMode_StrMap(std::map<EPWR_SC__CWORD56__BOOT_MODE_TYPE, SS_String> &m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, eps_CWORD56_bmINVALID);
+ MAP_ENTRY(m_strMap, eps_CWORD56_bmAPPLICATION_MODE);
+ MAP_ENTRY(m_strMap, eps_CWORD56_bmPROGRAMMING_MODE);
+} // End of void Init_SS__CWORD56__BootMode_StrMap(std::map<EPWR_SC__CWORD56__BOOT_MODE_TYPE, SS_String> &m_strMap)
+class EnumStringMap< EPWR_SC__CWORD56__BOOT_MODE_TYPE,
+ Init_SS__CWORD56__BootMode_StrMap> m_oSS_CWORD56_BootMode_Map;
+SS_String GetStr(EPWR_SC__CWORD56__BOOT_MODE_TYPE f_enum) {
+ return m_oSS_CWORD56_BootMode_Map.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS__CWORD102__BootMode_StrMap(std::map<ESMBootModeInfo, SS_String> &m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, e_SS_SM_BOOT_MODE_INVALID);
+ MAP_ENTRY(m_strMap, e_SS_SM_BOOT_MODE_APPLICATION);
+ MAP_ENTRY(m_strMap, e_SS_SM_BOOT_MODE_PROGRAMMING);
+} // End of void Init_SS__CWORD102__BootMode_StrMap(std::map<ESMBootModeInfo, SS_String> &m_strMap)
+
+class EnumStringMap< ESMBootModeInfo,
+ Init_SS__CWORD102__BootMode_StrMap> m_oSS_CWORD102_BootMode_Map;
+SS_String GetStr(ESMBootModeInfo f_enum) {
+ return m_oSS_CWORD102_BootMode_Map.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_ShutdownTrigger_StrMap(std::map<EPWR_SHUTDOWN_TRIGGER_TYPE,
+ SS_String> & m_strMap); // NOLINT (runtime/references)
+class EnumStringMap< EPWR_SHUTDOWN_TRIGGER_TYPE,
+ Init_SS_ShutdownTrigger_StrMap> m_oSSShutdownTrigger_Map;
+SS_String GetStr(EPWR_SHUTDOWN_TRIGGER_TYPE f_enum) {
+ return m_oSSShutdownTrigger_Map.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_UserMode_StrMap(std::map<EPWR_USER_MODE_TYPE, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ // Map of System Services User Mode enum values to string description
+ MAP_ENTRY(m_strMap, epsumINVALID);
+ MAP_ENTRY(m_strMap, epsumOFF);
+ MAP_ENTRY(m_strMap, epsumON);
+} // End of void Init_SS_UserMode_StrMap(std::map<EPWR_USER_MODE_TYPE, SS_String> & m_strMap)
+
+class EnumStringMap< EPWR_USER_MODE_TYPE,
+ Init_SS_UserMode_StrMap> m_oSSUserMode_Map;
+SS_String GetStr(EPWR_USER_MODE_TYPE f_enum) {
+ return m_oSSUserMode_Map.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_CpuResetReason_StrMap(std::map<ESMCpuResetReason, SS_String> &m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, e_SS_SM_CPU_RESET_REASON_NORMAL);
+ MAP_ENTRY(m_strMap, e_SS_SM_CPU_RESET_REASON_DATA_RESET);
+ MAP_ENTRY(m_strMap, e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET);
+ MAP_ENTRY(m_strMap, e_SS_SM_CPU_RESET_REASON_GENERIC_ERR);
+ MAP_ENTRY(m_strMap, e_SS_SM_CPU_RESET_REASON_DSP_ERR);
+ MAP_ENTRY(m_strMap, e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR);
+} // End of void Init_SS_CpuResetReason_StrMap(std::map<ESMCpuResetReason, SS_String> &m_strMap)
+class EnumStringMap< ESMCpuResetReason,
+ Init_SS_CpuResetReason_StrMap> m_oSS_CpuResetReason_Map;
+// LCOV_EXCL_START 6:Because the condition cannot be set
+SS_String GetStr(ESMCpuResetReason f_enum) {
+ return m_oSS_CpuResetReason_Map.GetStr(f_enum);
+}
+// LCOV_EXCL_STOP
+
+//******************************************************************************
+void Init_SS_UserModeChangeReason_StrMap(std::map<ePwrServiceUserModeChangeReasonType, SS_String> &m_strMap) { // NOLINT (runtime/references)
+ // LCOV_EXCL_BR_START 11:Excluded due to gcov restrictions(other)
+ MAP_ENTRY(m_strMap, epsumcrNOT_AVAILABLE);
+ MAP_ENTRY(m_strMap, epsumcrON_KEY);
+ MAP_ENTRY(m_strMap, epsumcrPARKING_B);
+ MAP_ENTRY(m_strMap, epsumcrPRE_BA);
+ MAP_ENTRY(m_strMap, epsumcrNORMAL);
+ MAP_ENTRY(m_strMap, epsumcrBACKGROUND_BA);
+ // LCOV_EXCL_BR_STOP 11:Excluded due to gcov restrictions(other)
+}
+class EnumStringMap< EPWR_USER_MODE_CHANGE_REASON_TYPE,
+ Init_SS_UserModeChangeReason_StrMap> m_oSS_UMCR_Map;
+SS_String GetStr(EPWR_USER_MODE_CHANGE_REASON_TYPE f_enum) {
+ return m_oSS_UMCR_Map.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_SS_StartupReason_StrMap(std::map<EPWR_WAKEUP_FACTOR_TYPE,
+ SS_String> & m_strMap); // NOLINT (runtime/references)
+class EnumStringMap< EPWR_WAKEUP_FACTOR_TYPE ,
+ Init_SS_StartupReason_StrMap> m_oSSStartupReason_Map;
+SS_String GetStr(EPWR_WAKEUP_FACTOR_TYPE f_enum) {
+ return m_oSSStartupReason_Map.GetStr(f_enum);
+}
+
+//******************************************************************************
+void Init_EErrorEventType_StrMap(std::map<EErrorEventType, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, eErrorEventTypeProcessCrash);
+ MAP_ENTRY(m_strMap, eErrorEventTypeHeartBeatFailure);
+ MAP_ENTRY(m_strMap, eErrorEventTypeSystemLowMemory);
+ MAP_ENTRY(m_strMap, eErrorEventTypeReserved1);
+ MAP_ENTRY(m_strMap, eErrorEventTypeUserInvokedUserForceReset);
+ MAP_ENTRY(m_strMap, eErrorEventTypeReserved2);
+ MAP_ENTRY(m_strMap, eErrorEventTypeReserved3);
+ MAP_ENTRY(m_strMap, eErrorEventTypeUserInvokedCollectAllLogs);
+ MAP_ENTRY(m_strMap, eErrorEventTypeBootMicroReset);
+ MAP_ENTRY(m_strMap, eErrorEventTypeProcessExit);
+ MAP_ENTRY(m_strMap, eErrorEventTypeUserInvokedCollectScreenShot);
+ MAP_ENTRY(m_strMap, eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs);
+ MAP_ENTRY(m_strMap, eErrorEventTypeEelExport);
+ MAP_ENTRY(m_strMap, eErrorEventTypeInterfaceunifiedEmmcLogs);
+ MAP_ENTRY(m_strMap, eErrorEventTypeDiagEvent);
+ MAP_ENTRY(m_strMap, eErrorEventTypeCanEvent);
+ MAP_ENTRY(m_strMap, eErrorEventTypeDtcEvent);
+ MAP_ENTRY(m_strMap, eErrorEventTypeModConnFailed);
+ MAP_ENTRY(m_strMap, eErrorEventTypeStartRespFailed);
+ MAP_ENTRY(m_strMap, eErrorEventTypeUserInvokedCollectDevLogs);
+ MAP_ENTRY(m_strMap, eErrorEventTypeModuleInvokedResetRequest);
+ MAP_ENTRY(m_strMap, eErrorEventTypeModuleInvokedCollectDebugLogs);
+ MAP_ENTRY(m_strMap, eErrorEventTypeUserInvokedClearLogs);
+ MAP_ENTRY(m_strMap, eErrorEventTypeGroupRelaunch);
+ MAP_ENTRY(m_strMap, eErrorEventTypeMaxValue);
+} // End of void Init_EErrorEventType_StrMap(std::map<EErrorEventType, SS_String> & m_strMap)
+
+void Init_SS_SystemManagerProtocol_StrMap(std::map<SS_SystemManagerProtocol, SS_String> &m_strMap) { // NOLINT (runtime/references)
+ // LCOV_EXCL_BR_START 11:Excluded due to gcov restrictions(other)
+ MAP_ENTRY(m_strMap, SS_SM_NOTIFY_SYSTEM_LAUNCH_COMPLETE);
+ MAP_ENTRY(m_strMap, SS_SM_PROTOCOL_INTERFACE_END);
+ MAP_ENTRY(m_strMap, SS_SM_START);
+ MAP_ENTRY(m_strMap, SS_SM_START_COMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_STOP);
+ MAP_ENTRY(m_strMap, SS_SM_STOP_COMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_PRE_START);
+ MAP_ENTRY(m_strMap, SS_SM_PRE_START_COMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_PRE_STOP);
+ MAP_ENTRY(m_strMap, SS_SM_PRE_STOP_COMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_BACKGROUND_START);
+ MAP_ENTRY(m_strMap, SS_SM_BACKGROUND_START_COMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_BACKGROUND_STOP);
+ MAP_ENTRY(m_strMap, SS_SM_BACKGROUND_STOP_COMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_GET_START_EXT_INFO);
+ MAP_ENTRY(m_strMap, SS_SM_GET_STOP_EXT_INFO);
+ MAP_ENTRY(m_strMap, SS_SM_WAKEUP_MODULES_CMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_SHUTDOWN_MODULES_CMPL_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_WAKEUP_MODULES);
+ MAP_ENTRY(m_strMap, SS_SM_SHUTDOWN_MODULES);
+ MAP_ENTRY(m_strMap, SS_SM_CRNT_STATE_QUERY);
+ MAP_ENTRY(m_strMap, SS_SM_CRNT_STATE_QUERY_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_SYSTEM_MODE_INFO_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_SYSTEM_MODE_INFO_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_INITCOMP_REP);
+ MAP_ENTRY(m_strMap, SS_SM_DATA_RESET_MODE_SET_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_PROG_UPDATE_STATE_SET_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_CPU_RESET_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_REMOTE_DATA_RESET_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_FWD_STARTUP_CONFIRMATION_MSG_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_FWD_START_CONFIRMATION_MSG_RESP);
+ MAP_ENTRY(m_strMap, SS_SM_POWER_REQUEST_MSG);
+ MAP_ENTRY(m_strMap, SS_SM_POWER_REQUEST_MSG_RESP);
+ MAP_ENTRY(m_strMap, SS_SM_USER_MODE_SET_RESP);
+
+ MAP_ENTRY(m_strMap, SS_SM_EVENT_ERROR);
+ MAP_ENTRY(m_strMap, SS_SM_EVENT_ERROR_TO_SSL);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_LOGGING_START_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_LOGGING_START_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_ARTIFACT_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_ARTIFACT_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_LOGGING_COMPLETE);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_LOGGING_COMPLETE_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_TIMER_ID_LOGGER_START_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_TIMER_ID_DEBUG_DUMP_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_TIMER_ID_BOOT_MICRO_LOG_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_TIMER_ID_CORE_FILE_POLL);
+ MAP_ENTRY(m_strMap, SS_SM_USER_INVOKED_LOG_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_EEL_EXPORT_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_CLR_LOGS_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_PROCESS_EXIT);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_DIAG_LOG_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_ERROR_EVENT_CAN_LOG_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_GROUP_LAUNCH_TRIGGER);
+ MAP_ENTRY(m_strMap, SS_SM_DEBUG_DUMP);
+ MAP_ENTRY(m_strMap, SS_SM_DEBUG_DUMP_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_CPU_HIGH_LOAD_DETECTED);
+ MAP_ENTRY(m_strMap, SS_SM_PROPAGATE_SYSTEM_ERROR);
+ MAP_ENTRY(m_strMap, SS_SM__CWORD56__HEARTBEAT_REQ);
+ MAP_ENTRY(m_strMap, SS_SM__CWORD56__HEARTBEAT_RSPN);
+ MAP_ENTRY(m_strMap, SS_SM_BOOT_MICRO_RESET_NTF);
+ MAP_ENTRY(m_strMap, SS_SM_BOOT_MICRO_LOG_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_BOOT_MICRO_LOG_RSP);
+ MAP_ENTRY(m_strMap, SS_SM_NEXT_WAKEUP_TYPE_SET_REQ);
+ // LCOV_EXCL_BR_STOP 11:Excluded due to gcov restrictions(other)
+} // End of void Init_SS_SystemManagerProtocol_StrMap(std::map<SS_SystemManagerProtocol, SS_String> &m_strMap)
+
+
+
+void Init_EInterfaceunifiedStatus_StrMap(std::map<EFrameworkunifiedStatus, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusEmptyMediaList);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusSessionLimitMaxedOut);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusDbRecNotFound);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusDbResultError);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusDbExecuteFail);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusSemCloseFail);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusSemUnlockFail);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusSemLockFail);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusFail);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusErrOther);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusOK);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldBuf);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldHandle);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldHndlType);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldQName);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusMsgQFull);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldNotification);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldParam);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldBufSize);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusInvldID);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusCannotRelease);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusBadConnection);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusExit);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusNotImplemented);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusThreadBusy);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusThreadSelfJoin);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusThreadInvalidVal);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusThreadNotExist);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusFault);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusServNotFound);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusServerInUse);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusDbIndexing);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusNullPointer);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusMsgNotProcessed);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusFileLoadSuccess);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusFileLoadError);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusAccessError);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusDuplicate);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusMsgQEmpty);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusThreadAlreadyRunning);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusErrNoEBADF);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusErrNoEAGAIN);
+ MAP_ENTRY(m_strMap, eFrameworkunifiedStatusErrNoEINTR);
+} // End of void Init_EInterfaceunifiedStatus_StrMap(std::map<EFrameworkunifiedStatus, SS_String> & m_strMap){
+
+void Init_SS_ShutdownTrigger_StrMap(std::map<EPWR_SHUTDOWN_TRIGGER_TYPE, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epssdmsdtINVALID);
+ MAP_ENTRY(m_strMap, epssdmsdtTESTACC_OFF);
+ MAP_ENTRY(m_strMap, epssdmsdtON_KEY);
+ MAP_ENTRY(m_strMap, epssdmsdtIGN_LOCK);
+ MAP_ENTRY(m_strMap, epssdmsdtPWR_SAVE);
+ MAP_ENTRY(m_strMap, epssdmsdtTMP_STARTUP);
+ MAP_ENTRY(m_strMap, epssdmsdtDIAG_DEACTIVATION);
+ MAP_ENTRY(m_strMap, epssdmsdtABNORMAL_VOLTAGE);
+ MAP_ENTRY(m_strMap, epssdmsdtABNORMAL_TEMP);
+ MAP_ENTRY(m_strMap, epssdmsdtBATTERYCUTOFF);
+ MAP_ENTRY(m_strMap, epssdmsdtLIMPHOME);
+ MAP_ENTRY(m_strMap, epssdmsdtHU_CAN_ERROR);
+ MAP_ENTRY(m_strMap, epssdmsdtBODY_CAN_ERROR);
+ MAP_ENTRY(m_strMap, epssdmsdtTRANSPORT_MODE);
+ MAP_ENTRY(m_strMap, epssdmsdtPRODUCTION_MODE);
+ MAP_ENTRY(m_strMap, epssdmsdtIGN_OFF);
+ MAP_ENTRY(m_strMap, epssdmsdtGENERIC_ERROR_RESET);
+ MAP_ENTRY(m_strMap, epssdmsdtFATAL_ERROR_RESET);
+ MAP_ENTRY(m_strMap, epssdmsdtUSER_DATA_RESET);
+ MAP_ENTRY(m_strMap, epssdmsdtFACTORY_DATA_RESET);
+ MAP_ENTRY(m_strMap, epssdmsdtFAST_SLEEP_MODE);
+ MAP_ENTRY(m_strMap, epssdmsdtNORMAL_RESET);
+} // End of void Init_SS_ShutdownTrigger_StrMap(std::map<EPWR_SHUTDOWN_TRIGGER_TYPE, SS_String> & m_strMap)
+
+void Init_SS_StartupReason_StrMap(std::map<EPWR_WAKEUP_FACTOR_TYPE, SS_String> & m_strMap) { // NOLINT (runtime/references)
+ MAP_ENTRY(m_strMap, epswfINVALID);
+ MAP_ENTRY(m_strMap, epswfTESTACC);
+ MAP_ENTRY(m_strMap, epswfON_KEY);
+ MAP_ENTRY(m_strMap, epswfIGN_ACC);
+ MAP_ENTRY(m_strMap, epswfDR_OPEN_CLOSE);
+ MAP_ENTRY(m_strMap, epswfDX_ACTIVATION);
+ MAP_ENTRY(m_strMap, epswfPASS_ACTIVATION);
+ MAP_ENTRY(m_strMap, epswfSPVACTIVATION);
+ MAP_ENTRY(m_strMap, epswfUSER_DATA_RESET);
+} // LCOV_EXCL_BR_LINE 10:Because the last line
+// End of void Init_SS_WakeupFactor_StrMap(std::map<EPWR_WAKEUP_FACTOR_TYPE, SS_String> & m_strMap)
+
+// EOF ss_string_maps.cpp
+
+
diff --git a/systemservice/interface_unified/library/src/ss_system_process.cpp b/systemservice/interface_unified/library/src/ss_system_process.cpp
new file mode 100755
index 0000000..71a969a
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_system_process.cpp
@@ -0,0 +1,1147 @@
+/*
+ * @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_SystemManagerIf
+/// \brief This file provides support for the System Manager client interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "system_service/ss_system_process.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <limits.h>
+#include <pwd.h>
+#include <grp.h>
+#include <elfio/elfio_dump.hpp>
+
+#include <string.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <assert.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <vector>
+#include "ss_system_if_interfaceunifiedlog.h"
+
+const char* iProcess_DEFAULT_PROCESS_USER_NAME = "default_user";
+uid_t iProcess_DEFAULT_PROCESS_USER = 4999;
+gid_t iPrpocess_DEFAULT_PROCESS_GROUP = 4999;
+
+/**
+ * Process: Called when the class is instantiated.
+ *
+ * @return
+ */
+Process::Process(int cpu_assign) :
+ m_lValidationTag(lProcess_VALIDATION_VALUE),
+ m_cpu_assign(cpu_assign),
+ m_tProcessId(-1),
+ m_eProcessLoadMode(NOWAIT),
+ m_strFile(""),
+ m_strProcessName(""),
+ m_iErrorCode(0),
+ m_fAutoKill(TRUE),
+ m_iReturnCode(0) {
+}
+
+
+/**
+ * ~Process: Called when the object is destroyed.
+ *
+ * @return
+ */
+Process::~Process() {
+ // ASSERT_VALID (this);
+
+ //
+ // Set the validation tag to NOT valid
+ m_lValidationTag = 0;
+
+ //
+ // Cleanup after ourselves...
+ //
+ if ((m_fAutoKill) && (m_tProcessId != -1) && (m_tProcessId != getpid())) {
+ KillProcess(); // Then remove the process from PosixBasedOS001
+ }
+}
+
+/**
+ * Process: Used to create an object and copy another
+ * object to the new object.
+ *
+ * @param p_rhs_i Reference to the class being copied from.
+ * @return Process( const
+ */
+Process::Process(const Process& p_rhs_i) {
+ // Copy data from the specified object to this object.
+ Copy(p_rhs_i);
+}
+
+
+/**
+ * operator=: Called when one object is assigned
+ * to another object.
+ *
+ * @param p_rhs_i Reference to the class being copied from.
+ * @return Process&
+ */
+Process& Process::operator= (const Process& p_rhs_i) {
+ // Don't do anything if we're being copied on to ourselves.
+ if (this == &p_rhs_i) return (*this);
+
+ // Copy data from the specified object to this object.
+ Copy(p_rhs_i);
+
+ return (*this);
+}
+
+
+/**
+ * Copy: Copies data members from the specified object to this object.
+ * No attempt is made to free dynamically allocated objects within
+ * this object (you must do that before calling this function).
+ *
+ * @param p_rhs_i
+ * @return void
+ */
+void Process::Copy(const Process& p_rhs_i) {
+ // Copy data from the specified object to this object.
+ m_lValidationTag = p_rhs_i.m_lValidationTag;
+
+ m_tProcessId = p_rhs_i.m_tProcessId;
+ m_eProcessLoadMode = p_rhs_i.m_eProcessLoadMode;
+ m_strFile = p_rhs_i.m_strFile;
+ m_strlstArgv = p_rhs_i.m_strlstArgv;
+ m_strProcessName = p_rhs_i.m_strProcessName;
+ m_iErrorCode = p_rhs_i.m_iErrorCode;
+ m_fAutoKill = p_rhs_i.m_fAutoKill;
+ m_iReturnCode = p_rhs_i.m_iReturnCode;
+}
+
+/**
+ * GetProcessReturnCode: This function will return the processes
+ * exit/return code. This is not the value of ERRNO as returned by
+ * GetLastPosixBasedOS001ErrorCode().
+ *
+ * @return code from the process
+ */
+int Process::GetProcessReturnCode() {
+ int iProcessReturn = 0;
+ if (waitpid(m_tProcessId, &iProcessReturn, WNOHANG) > 0) {
+ m_iReturnCode = WEXITSTATUS(iProcessReturn);
+ }
+
+ return m_iReturnCode;
+}
+
+static int getIdsFromUserName(const char* user_name, uid_t *uid, gid_t *gid) {
+ int ret = -1;
+
+ try {
+ if (NULL == user_name) {
+ *uid = geteuid();
+ *gid = getegid();
+ } else {
+ static __thread size_t bufSize = 0;
+ static __thread char *buf = NULL;
+ struct passwd pwd;
+ struct passwd *result;
+
+ if (0 == bufSize) {
+ struct stat statInfo;
+
+ bufSize = -1;
+
+ if (0 != stat("/etc/passwd", &statInfo) || 0 >= statInfo.st_size) {
+ throw "/etc/passwd is not exist";
+ }
+
+ bufSize = statInfo.st_size * 2;
+
+ // Since SystemManager is a resident service,
+ // the area secured here is not explicity released by free()
+ // in anticipation of release at the end of the process
+ buf = reinterpret_cast<char *>(malloc(sizeof(char) * bufSize));
+ if (NULL == buf) {
+ throw "malloc()";
+ }
+ }
+
+ if (NULL == buf) {
+ throw "buf = NULL";
+ }
+
+ ret = getpwnam_r(user_name, &pwd, buf, bufSize, &result);
+ if (ret == 0 && result != NULL) {
+ *uid = pwd.pw_uid;
+ *gid = pwd.pw_gid;
+ } else {
+ throw "getpwnam_r()";
+ }
+ }
+
+ ret = 0;
+ }
+
+ catch (const char *e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "ERROR:%s", e);
+ }
+
+ return ret;
+}
+
+/**
+ * CreateProcess: This method will create a PosixBasedOS001 process with the executable provided and mode as a calling parameter.
+ * The caller can also provide a list of arguments that will be provided to the executable at startup.
+ * The calling p_strProcessName parameter is a textual name that will be
+ * associated with the newly created process by the OS. The process state information
+ * will be maintained by this object.
+ *
+ * Upon successful creation of the process, the scheduling policy and priority
+ * of the process will be set to the provided values. The user can change these
+ * values through the SetSchedulingPolicy() and SetPriority() method calls.
+ *
+ * @param p_strFile_i Path and Filename of executable to create process for
+ * @param p_strlstArgv_i List of ARGV values for new process
+ * @param p_eMode_i Mode to create and load new process
+ * WAIT - The invoked program is loaded into available memory, is executed,
+ * and then the original program resumes execution.
+ * NOWAIT - Causes the current program to execute concurrently with the new child process.
+ * @param p_strProcessName_i This is the name that will be registered to the OS for this process
+ * @param p_eSchedulingPolicy_i Scheduling Policy for this process
+ * FIFO - A fixed priority scheduler in which the highest ready process runs until it
+ * blocks or is preempted by a higher priority process.
+ * ROUND_ROBIN - The same as FIFO, except processes at the same priority level time-slice.
+ * OTHER - A general time sharing scheduler in which a process decays in priority if it
+ * consumes too much processor before blocking. It reverts to its default priority
+ * when it blocks. Should it fail to run over a 2 second period and it has decayed
+ * then it's boosted one priority level up to a maximum of its default priority.
+ * @param p_iPriority_i Priority for this process
+ * @param p_lSpawnFlags_i Spawning flags. These are PosixBasedOS001 specific....
+ * @return void
+ */
+void Process::CreateProcess(
+ const SS_String& p_strFile_i, // Path and Filename of executable to create process for
+ const StringList& p_strlstArgv_i, // List of ARGV values for new process
+ const eProcessLoadMode p_eMode_i, // Mode to create and load new process
+ const SS_String& p_strProcessName_i, // This is the name that will be registered to the OS for this process
+ const eProcessSchedulingPolicy p_eSchedulingPolicy_i, // Scheduling Policy for this process
+ const int p_iPriority_i, // Priority for this process
+ const char* unix_user_name,
+ const long p_lSpawnFlags_i // Posix Spawning flags. These are PosixBasedOS001 specific.... // NOLINT (runtime/int)
+) {
+ //========================================================================================
+ // Perform some idiot checking of the parameters that are passed in.
+ // Check the priority level that is being set to make sure it is in bounds.
+ // Then save off the calling parameters into the objects member variables.
+ // Also check the number of valid calling (argv[]) parameters passed in
+ //========================================================================================
+ m_iErrorCode = 0; // Initialize to NO ERROR
+ m_iReturnCode = 0; // Initialize value (0 usually means good in unix/PosixBasedOS001)
+
+ //
+ // Process filename os provided
+ //
+ if (p_strFile_i.empty()) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+
+ //
+ // Save off process calling arguments
+ //
+ m_eProcessLoadMode = p_eMode_i;
+
+ m_strFile = p_strFile_i;
+
+ if (!p_strProcessName_i.empty())
+ m_strProcessName = p_strProcessName_i;
+
+ //
+ // Copy Argument List...
+ //
+ SetCallingArgumentList(p_strlstArgv_i);
+
+ //
+ // Valid number of calling arguments
+ //
+ int iNumberElements = m_strlstArgv.size();
+ if (iNumberElements > (iProcess_MAXIMUM_NUMBER_OF_PROCESS_ARGUMENTS - 3)) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+
+
+ //========================================================================================
+ // Initialize to the beginning of the provided argument list.
+ // Allocate an array of buffer pointers that will be used for the ARGV calling parameters
+ // for the specified process.
+ // Set the ARGV[0] equal to the process name being created
+ // Set the ARGV[1] equal to the process name to be registered with the OS.
+ // If p_strProcessName_is NULL, do not set the cArgv[1] parameter
+ // Populate the array that will hold the argument list for the new process we are creating.
+ //========================================================================================
+ //
+
+ int iLoop = 1;
+ char * cArgv[iProcess_MAXIMUM_NUMBER_OF_PROCESS_ARGUMENTS];
+
+ cArgv[0] = basename(const_cast<char *>(p_strFile_i.c_str())); // Set the executable filename
+
+ // Go through the list of provided argv calling parameters to the CreateProcess
+ // function, and copy the arguments to the ARGV[] calling argument which will be passed
+ // into the process being created.
+ StringListIter at = m_strlstArgv.begin();
+ for (; at != m_strlstArgv.end(); at++, iLoop++) {
+ cArgv[iLoop] = const_cast<char *>(at->c_str());
+ }
+
+ cArgv[iLoop] = NULL;
+
+ try {
+ CL_ProcessAttr_t clAttr;
+ CL_ProcessSchedPolicy_t clPolicy = CL_PROCESS_SCHED_POLICY_OTHER;
+ int clPriority = 0;
+
+ if (0 != CL_ProcessCreateAttrInit(&clAttr)) {
+ throw "CL_ProcessCreateAttrInit()";
+ }
+
+
+ // In order to collect even the child processes of the service, all are group leaders.
+ if (0 != CL_ProcessCreateAttrSetGroup(&clAttr, 1)) {
+ throw "CL_ProcessCreateAttrInit()";
+ }
+
+ if (0 != CL_ProcessCreateAttrSetCpuAssign(&clAttr, m_cpu_assign)) {
+ throw "CL_ProcessCreateAttrSetCpuAssign()";
+ }
+
+ switch (p_eSchedulingPolicy_i) {
+ case FIFO:
+ clPolicy = CL_PROCESS_SCHED_POLICY_FIFO;
+ break;
+ case ROUND_ROBIN:
+ clPolicy = CL_PROCESS_SCHED_POLICY_RR;
+ break;
+ case OTHER:
+ clPolicy = CL_PROCESS_SCHED_POLICY_OTHER;
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "p_eSchedulingPolicy_i = %d", p_eSchedulingPolicy_i);
+ break;
+ }
+
+ switch (p_eSchedulingPolicy_i) {
+ case FIFO:
+ case ROUND_ROBIN:
+ if ((1 > p_iPriority_i) || (p_iPriority_i > 99)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "p_eSchedulingPolicy_i = %d", p_eSchedulingPolicy_i);
+ } else {
+ clPriority = p_iPriority_i;
+ }
+ break;
+ case OTHER:
+ default:
+ if ((-20 > p_iPriority_i) || (p_iPriority_i > 19)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "p_eSchedulingPolicy_i = %d", p_eSchedulingPolicy_i);
+ } else {
+ clPriority = p_iPriority_i;
+ }
+ break;
+ }
+
+ if (0 != CL_ProcessCreateAttrSetSchedule(&clAttr, clPolicy, clPriority)) {
+ throw "CL_ProcessCreateAttrSetSchedule()";
+ }
+
+ uid_t uid = 0;
+ gid_t gid = 0;
+
+ if (0 != getIdsFromUserName(unix_user_name, &uid, &gid)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "unexpected unix_user_name [%s]", unix_user_name);
+ uid = geteuid();
+ gid = getegid();
+ }
+ if (uid == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "!! uid=root %s", m_strFile.c_str());
+ uid = UINT_MAX;
+ }
+ if (0 != CL_ProcessCreateAttrSetUid(&clAttr, uid)) {
+ throw "CL_ProcessCreateAttrSetUid()";
+ }
+
+ if (0 != CL_ProcessCreateAttrSetGid(&clAttr, gid)) {
+ throw "CL_ProcessCreateAttrSetGid()";
+ }
+
+ if (0 != CL_ProcessCreateAttrSetDisableCloseFds(&clAttr)) {
+ throw "CL_ProcessCreateAttrSetDisableCloseFds()";
+ }
+ char environment_string[2048] = {0}; // Size is provisional
+ fprintf(stderr, "[%s](%d)Process Create Target : %s \n", __func__, __LINE__, m_strFile.c_str());
+
+ CheckLdPreLoad(&m_strFile, environment_string);
+
+ CreateProcess(&m_strFile, const_cast<char* const*>(cArgv), environment_string, &clAttr);
+ }
+
+ catch(const char *e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "%s", e);
+ }
+}
+
+/**
+ * CreateProcess: This method will create a process with the executable provided and mode as a calling parameter.
+ * The caller can also provide a list of arguments that will be provided to the executable at startup.
+ * The calling p_strProcessName parameter is a textual name that will be
+ * associated with the newly created process by the OS. The process state information
+ * will be maintained by this object.
+ *
+ * @param p_str_file Path and Filename of executable to create process for
+ * @param c_argv use process arguments
+ * @param environment_string Set LD_PRELOAD string
+ * @param cl_attr CL_ProcessAttr_t
+ * @return void
+ */
+void Process::CreateProcess(const SS_String *p_str_file, char* const*c_argv, char* environment_string,
+ const CL_ProcessAttr_t *cl_attr) {
+ try {
+ if ((p_str_file == NULL) || (c_argv == NULL) || (cl_attr == NULL)) {
+ throw "CreateProcess() Invaild Param";
+ }
+
+ int process_id = -1;
+ if (environment_string[0] == '\0') {
+ // If there is no LD_PRELOAD setting, set envp to NULL
+ process_id = CL_ProcessCreate(p_str_file->c_str(), c_argv, NULL, cl_attr);
+ } else {
+ // vector holding preferences
+ std::vector<SS_String> *vec_environ = GetEnvironVector();
+
+ // Set LD_PRELOAD string as the last element
+ SS_String ld_preload_string = SS_String(environment_string);
+ vec_environ->push_back(environment_string);
+
+ // Number of acquired environment variables + 1(For terminal) memory allocation
+ size_t env_num = sizeof(char*) * (vec_environ->size() + 1);
+ char **p_environment = static_cast<char **>(malloc(env_num));
+ memset(p_environment, 0x00, env_num);
+
+ // Create environment variable list
+ int i = 0;
+ char **p_environment_tmp = p_environment;
+ for (std::vector<SS_String>::iterator itr = vec_environ->begin(); itr != vec_environ->end(); itr++, i++) {
+ p_environment_tmp[i] = static_cast<char *>(malloc(sizeof(char) * (itr->length() + 1)));
+
+ snprintf(p_environment_tmp[i], itr->length() + 1, "%s", itr->c_str());
+ }
+
+ // Set envp for environment variable
+ process_id = CL_ProcessCreate(p_str_file->c_str(), c_argv, p_environment, cl_attr);
+
+ // Free memory
+ i = 0;
+ p_environment_tmp = p_environment;
+ for (std::vector<SS_String>::iterator itr = vec_environ->begin(); itr != vec_environ->end(); itr++, i++) {
+ free(p_environment_tmp[i]);
+ }
+
+ free(p_environment);
+ delete(vec_environ);
+ }
+
+ if (process_id == -1) {
+ throw "CL_ProcessCreate()";
+ }
+
+ m_tProcessId = process_id;
+ }
+ catch (const char *e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "%s", e);
+ }
+}
+/**
+ * CreateProcess: This method will create a PosixBasedOS001 process with the executable provided and mode as a calling parameter.
+ * The caller can also provide a list of arguments that will be provided to the executable at startup.
+ * The calling p_strProcessName parameter is a textual name that will be
+ * associated with the newly created process by the OS. The process state information
+ * will be maintained by this object.
+ *
+ * @param p_strFile_i Path and Filename of executable to create process for
+ * @param p_strProcessName This is the name that will be registered to the OS for this process
+ * @return void
+ */
+void Process::CreateProcess(const SS_String& p_strFile_i, const SS_String& p_strProcessName,
+ const char* unix_user_name, const long p_lSpawnFlags_i) { // NOLINT (runtime/int)
+ StringList strlstArgv;
+
+ try {
+ CreateProcess(p_strFile_i,
+ strlstArgv,
+ NOWAIT,
+ p_strProcessName,
+ FIFO,
+ iProcess_DEFAULT_PROCESS_PRIORITY,
+ unix_user_name,
+ p_lSpawnFlags_i);
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+/**
+ * CreateProcess: This method will create a process with the executable provided and mode as a calling parameter.
+ * The caller can also provide a list of arguments that will be provided to the executable at startup.
+ * The calling p_strProcessName parameter is a textual name that will be
+ * associated with the newly created process by the OS. The process state information
+ * will be maintained by this object.
+ *
+ *
+ * @param p_strFile_i Path and Filename of executable to create process for
+ * @param p_strProcessName This is the name that will be registered to the OS for this process
+ * @param p_iPriority_i Priority of process
+ * @return void
+ */
+void Process::CreateProcess(const SS_String& p_strFile_i, const SS_String& p_strProcessName, const int p_iPriority_i,
+ const char* unix_user_name, const long p_lSpawnFlags_i) { // NOLINT (runtime/int)
+ StringList strlstArgv;
+
+ try {
+ eProcessSchedulingPolicy policy;
+
+ if (0 < p_iPriority_i) {
+ policy = FIFO;
+ } else {
+ policy = OTHER;
+ }
+
+ CreateProcess(p_strFile_i,
+ strlstArgv,
+ NOWAIT,
+ p_strProcessName,
+ policy,
+ p_iPriority_i,
+ unix_user_name,
+ p_lSpawnFlags_i);
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+/**
+ * CreateProcess: This method will create a process with the executable provided and mode as a calling parameter.
+ * The caller can also provide a list of arguments that will be provided to the executable at startup.
+ * The calling p_strProcessName parameter is a textual name that will be
+ * associated with the newly created process by the OS. The process state information
+ * will be maintained by this object.
+ *
+ * @param p_strFile_i Path and Filename of executable to create process for
+ * @param p_lSpawnFlags_i Spawning flags. These are PosixBasedOS001 specific.
+ * @return void
+ */
+void Process::CreateProcess(const SS_String& p_strFile_i, const char* unix_user_name, const long p_lSpawnFlags_i) { // NOLINT (runtime/int)
+ StringList strlstArgv;
+
+ try {
+ CreateProcess(p_strFile_i,
+ strlstArgv,
+ NOWAIT,
+ basename(const_cast<char *>(p_strFile_i.c_str())),
+ FIFO,
+ iProcess_DEFAULT_PROCESS_PRIORITY,
+ unix_user_name,
+ p_lSpawnFlags_i);
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+
+/**
+ * CreateProcess: This method will create a process with the executable provided and mode as a calling parameter.
+ * The caller can also provide a list of arguments that will be provided to the executable at startup.
+ * The calling p_strProcessName parameter is a textual name that will be
+ * associated with the newly created process by the OS. The process state information
+ * will be maintained by this object.
+ *
+ * @param p_strFile_i Path and Filename of executable to create process for
+ * @param p_strProcessName This is the name that will be registered to the OS for this process
+ * @param p_strlstArgv_i List of ARGV values for new process
+ * @param p_lSpawnFlags_i Spawning flags. These are PosixBasedOS001 specific.
+ * @return void
+ */
+void Process::CreateProcess(const SS_String& p_strFile_i, const SS_String& p_strProcessName_i,
+ const StringList& p_strlstArgv_i, const char* unix_user_name, const long p_lSpawnFlags_i) { // NOLINT (runtime/int)
+ try {
+ CreateProcess(p_strFile_i,
+ p_strlstArgv_i,
+ NOWAIT,
+ p_strProcessName_i,
+ FIFO,
+ iProcess_DEFAULT_PROCESS_PRIORITY,
+ unix_user_name,
+ p_lSpawnFlags_i);
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+void Process::CreateProcess(const SS_String& p_strFile_i, const SS_String& p_strProcessName_i, const int p_iPriority_i,
+ const StringList& p_strlstArgv_i, const char* unix_user_name, const long p_lSpawnFlags_i) { // NOLINT (runtime/int)
+ try {
+ eProcessSchedulingPolicy policy;
+
+ if (0 < p_iPriority_i) {
+ policy = FIFO;
+ } else {
+ policy = OTHER;
+ }
+
+ CreateProcess(p_strFile_i,
+ p_strlstArgv_i,
+ NOWAIT,
+ p_strProcessName_i,
+ policy,
+ p_iPriority_i,
+ unix_user_name,
+ p_lSpawnFlags_i);
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+/**
+ * CreateProcessWait: This method will create a process with the executable provided.
+ * The process state information will be maintained by this object.
+ *
+ * @param p_strFile_i Path and Filename of executable to create process for
+ * @return void
+ */
+void Process::CreateProcessWait(const SS_String& p_strFile_i) {
+ StringList strlstArgv;
+
+ try {
+ CreateProcess(p_strFile_i,
+ strlstArgv,
+ WAIT,
+ basename(const_cast<char *>(p_strFile_i.c_str())),
+ FIFO,
+ iProcess_DEFAULT_PROCESS_PRIORITY,
+ iProcess_DEFAULT_PROCESS_USER_NAME,
+ iProcess_DEFAULT_PROCESS_FLAGS);
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+/**
+ * CreateProcessWait: This method will create a PosixBasedOS001 process with the executable provided.
+ * The process state information will be maintained by this object.
+ *
+ *
+ * @param p_strFile_i Path and Filename of executable to create process for
+ * @param p_strlstArguments_i List of process calling arguments
+ * @return void
+ */
+void Process::CreateProcessWait(const SS_String& p_strFile_i, const StringList& p_strlstArguments_i) {
+ try {
+ CreateProcess(p_strFile_i,
+ p_strlstArguments_i,
+ WAIT,
+ basename(const_cast<char *>(p_strFile_i.c_str())),
+ FIFO,
+ iProcess_DEFAULT_PROCESS_PRIORITY,
+ iProcess_DEFAULT_PROCESS_USER_NAME,
+ iProcess_DEFAULT_PROCESS_FLAGS);
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+
+/**
+ * KillProcess: This method will delete the process represented by this object. All variables associated
+ * with this object will be initialized to a know value.
+ *
+ * @param
+ * @return void
+ */
+void Process::KillProcess(int signal) {
+ //=====================================================================================
+ // Intialize the objects m_iErrorCode member variable to 0 (no error).
+ // Then try to delete the process that this object represents.
+ m_iErrorCode = 0;
+
+ if (DoesProcessExist()) {
+ if (-1 == killpg(m_tProcessId, signal)) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+ }
+
+ //
+ // If no errors, clear out any process specific member variables for this object
+ //
+ m_tProcessId = -1;
+ m_strProcessName = "";
+}
+
+/**
+ * SetSchedulingPolicy: This method will change the scheduling policy for the process this
+ * object represents.
+ *
+ * @param p_eSchedulingPolicy_i Scheduling policy
+ * @return void
+ */
+void Process::SetSchedulingPolicy(
+ const eProcessSchedulingPolicy p_eSchedulingPolicy_i // Scheduling policy
+) {
+ //=======================================================================================
+ // Attempt to change the scheduling policy for the process that this object
+ // represents. If the change fails, restore the previous settings.
+ //
+ m_iErrorCode = 0;
+ struct sched_param cur_sch_params;
+ sched_getparam(m_tProcessId, &cur_sch_params);
+ if (0 != sched_setscheduler(m_tProcessId, ConvertToPosixBasedOS001SchedularPolicy(p_eSchedulingPolicy_i),
+ &cur_sch_params)) {
+ m_iErrorCode = errno;
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+/**
+ * SetPriority: This method will change the priority for the process this
+ * object represents.
+ *
+ * @param p_iPriority_i Scheduling Policy for this process
+ * @return void
+ */
+void Process::SetPriority(const int p_iPriority_i) {
+ //=======================================================================================
+ // Attempt to change the priority for the process that this object
+ // represents. If the change fails, restore the previous settings.
+ //
+ m_iErrorCode = 0;
+ struct sched_param cur_sch_params;
+ sched_getparam(m_tProcessId, &cur_sch_params);
+ cur_sch_params.sched_priority = p_iPriority_i;
+
+ if (-1 == sched_setparam(m_tProcessId, &cur_sch_params)) {
+ m_iErrorCode = errno;
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+/**
+ * IncreasePriorityByOne: This method will increase the priority for the process this
+ * object represents by one.
+ *
+ * @param
+ * @return void
+ */
+void Process::IncreasePriorityByOne(void) {
+ //================================================================================
+ // Retrieve the current priority of the process. Check to see if already at max.
+ // If so just return. Otherwise increase by one and set the priority...
+ //
+ try {
+ int iCurrentPriority = GetPriority();
+ if (iCurrentPriority < iProcess_MAXIMUM_PROCESS_PRIORITY) {
+ SetPriority(iCurrentPriority + 1);
+ }
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+/**
+ * DecreasePriorityByOne: This method will decrease the priority for the process this
+ * object represents by one.
+ *
+ *
+ * @return void
+ */
+void Process::DecreasePriorityByOne(void) {
+ //================================================================================
+ // Retrieve the current priority of the process. Check to see if already at minimum.
+ // If so just return. Otherwise decrease by one and set the priority...
+ //
+ try {
+ int iCurrentPriority = GetPriority();
+ if (iCurrentPriority > 1) {
+ SetPriority(iCurrentPriority - 1);
+ }
+ }
+ catch (...) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// ConvertToPosixBasedOS001SchedularPolicy
+//
+// This method will return to the caller the equivalent PosixBasedOS001 schedular policy for the process
+// that this object represents
+//
+//
+// Calling Arguments:
+// NONE
+//
+// Return Argument:
+// FIFO, // A fixed priority scheduler in which the highest ready process runs until it
+// // blocks or is preempted by a higher priority process.
+// ROUND_ROBIN, // The same as FIFO, except processes at the same priority level time-slice.
+// OTHER // A general time sharing scheduler in which a process decays in priority if it
+// // consumes too much processor before blocking. It reverts to its default priority
+// // when it blocks. Should it fail to run over a 2 second period and it has decayed
+// // then it's boosted one priority level up to a maximum of its default priority.
+//
+int const Process::ConvertToPosixBasedOS001SchedularPolicy(const eProcessSchedulingPolicy p_eSchedulingPolicy_i) {
+ int iReturnValue = SCHED_RR; // Default is RR
+ switch (p_eSchedulingPolicy_i) {
+ case FIFO:
+ {
+ iReturnValue = SCHED_FIFO;
+ break;
+ }
+
+ case ROUND_ROBIN:
+ {
+ iReturnValue = SCHED_RR;
+ break;
+ }
+
+ case OTHER:
+ {
+ iReturnValue = SCHED_OTHER;
+ break;
+ }
+ }
+
+ return iReturnValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// ConvertFromPosixBasedOS001SchedularPolicy
+//
+// This method will return to the caller the eProcessSchedulingPolicy based on the PosixBasedOS001 schedular
+// policy for the process that this object represents
+//
+//
+// Calling Arguments:
+// PosixBasedOS001 Scheduling Policy
+//
+// Return Argument:
+// FIFO, // A fixed priority scheduler in which the highest ready process runs until it
+// // blocks or is preempted by a higher priority process.
+// ROUND_ROBIN, // The same as FIFO, except processes at the same priority level time-slice.
+// OTHER // A general time sharing scheduler in which a process decays in priority if it
+// // consumes too much processor before blocking. It reverts to its default priority
+// // when it blocks. Should it fail to run over a 2 second period and it has decayed
+// // then it's boosted one priority level up to a maximum of its default priority.
+//
+Process::eProcessSchedulingPolicy const Process::ConvertFromPosixBasedOS001SchedularPolicy
+ (const int p_iPosixBasedOS001chedulingPolicy_i) {
+ eProcessSchedulingPolicy ePolicy = ROUND_ROBIN; // Default is RR
+ switch (p_iPosixBasedOS001chedulingPolicy_i) {
+ case SCHED_FIFO:
+ {
+ ePolicy = FIFO;
+ break;
+ }
+
+ case SCHED_RR:
+ {
+ ePolicy = ROUND_ROBIN;
+ break;
+ }
+ case SCHED_OTHER:
+ {
+ ePolicy = OTHER;
+ break;
+ }
+ } // Switch
+
+ return ePolicy;
+}
+
+
+/**
+ * DoesProcessExist: This method will return a BOOLean indicating whether this
+ * process exists.
+ *
+ * @return BOOL TRUE - Process Exists, FALSE - Process does not exist
+ */
+BOOL Process::DoesProcessExist(void) {
+ struct sched_param cur_sch_params;
+ if (-1 >= sched_getparam(m_tProcessId, &cur_sch_params)) { // or the segment data
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+
+/**
+ * SetProcessName: This method will set this objects process name member variable to the
+ * provided string value.
+ *
+ * @param p_strProcessName_i Process Name to set the m_strProcessName member variable to
+ * @return void
+ */
+void Process::SetProcessName(const SS_String& p_strProcessName_i) {
+ //
+ // Idiot checking
+ //
+ assert(!p_strProcessName_i.empty());
+
+ m_strProcessName = p_strProcessName_i;
+}
+
+/**
+ * GetSchedulingPolicy: This method will return to the caller the
+ * currently configured process scheduling policy.
+ *
+ * @return Process::eProcessSchedulingPolicy const
+ */
+Process::eProcessSchedulingPolicy const Process::GetSchedulingPolicy(void) {
+ int policy = 0;
+ if (-1 == (policy = sched_getscheduler(m_tProcessId))) {
+ m_iErrorCode = errno;
+ return ROUND_ROBIN; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+
+ return (ConvertFromPosixBasedOS001SchedularPolicy (policy));
+}
+
+
+
+/**
+ * GetPriority: This method will return to the caller the currently configured
+ * process priority.
+ *
+ * @return int const
+ */
+int const Process::GetPriority(void) {
+ struct sched_param cur_sch_params;
+ if (-1 >= sched_getparam(m_tProcessId, &cur_sch_params)) {
+ m_iErrorCode = errno;
+ return -1; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+
+ return (cur_sch_params.sched_priority);
+}
+
+
+
+/**
+ * SetCallingArgumentList: This method will set the calling argument list
+ * that this object represents.
+ *
+ * @param p_pcArgv_i Pointer to NULL terminated argument list.
+ * @param p_iArgc_i Number of parameters
+ * @return void
+ */
+void Process::SetCallingArgumentList(const char *p_pcArgv_i[], const int p_iArgc_i) {
+ ////////////////////////////////////////////////////////////////////////
+ // Set the executable filename first. This is always the 1st argument
+ // in the argument list. Then set the argument list for the process
+ // which is held in m_strlstArgv.
+ //
+ if (p_iArgc_i > (iProcess_MAXIMUM_NUMBER_OF_PROCESS_ARGUMENTS - 3)) {
+ return; // PAD THIS IS BAD!!! TODO: Change this to something meaningful
+ }
+
+ //
+ // First make sure that the argument list is empty.
+ //
+ if (!m_strlstArgv.empty()) {
+ m_strlstArgv.clear(); // Remove all elements from the current list
+ } // Process Argument list is NOT empty
+
+ //
+ // Once empty, put the new arguments into the list
+ //
+ StringListIter at = m_strlstArgv.begin();
+ int iLoop;
+ for (iLoop = 0; iLoop < p_iArgc_i; iLoop ++) {
+ at = m_strlstArgv.insert(at, p_pcArgv_i[iLoop]);
+ }
+}
+
+
+/**
+ * SetCallingArgumentList: This method will set the calling argument
+ * list that this object represents.
+ *
+ * @param p_strlstParameters_i List of parameters
+ * @return void
+ */
+void Process::SetCallingArgumentList(const StringList& p_strlstParameters_i) {
+ if (p_strlstParameters_i.size()) {
+ m_strlstArgv.clear(); // Empty the current list.
+ m_strlstArgv = p_strlstParameters_i;
+ }
+}
+
+/**
+ * Search if libTestFwCommon.so is dynamically linked.
+ *
+ * @param process_path Search target binary path
+ * @return bool
+ */
+static bool CheckLinkedTestfwLibrary(SS_String *process_path) {
+ if (NULL == process_path) {
+ fprintf(stderr, "[%s](%d)Invaild Param.\n", __func__, __LINE__);
+ return false;
+ }
+
+ ELFIO::elfio reader;
+ if (!reader.load(process_path->c_str())) {
+ fprintf(stderr, "[%s](%d)%s is not ELF!\n", __func__, __LINE__, process_path->c_str());
+ return false;
+ }
+
+ ELFIO::Elf_Half n = reader.sections.size();
+ for ( ELFIO::Elf_Half i = 0; i < n; ++i ) {
+ ELFIO::section* sec = reader.sections[i];
+ if ( SHT_DYNAMIC == sec->get_type() ) {
+ ELFIO::dynamic_section_accessor dynamic(reader, sec);
+
+ ELFIO::Elf_Xword dynamic_num = dynamic.get_entries_num();
+ if ( dynamic_num > 0 ) {
+ for ( ELFIO::Elf_Xword i = 0; i < dynamic_num; ++i ) {
+ ELFIO::Elf_Xword dynamic_tag = 0;
+ ELFIO::Elf_Xword dynamic_value = 0;
+ SS_String dynamic_str;
+ dynamic.get_entry(i, dynamic_tag, dynamic_value, dynamic_str);
+
+ // Search if the acquired dynamic section string contains libTestFwCommon.so
+ if (SS_String::npos != dynamic_str.find("libTestFwCommon.so")) {
+ fprintf(stderr, "[%s](%d)libTestFwCommon is linked.\n", __func__, __LINE__);
+ return true;
+ }
+
+ // Check for continuation of dynamic section element
+ if ( DT_NULL == dynamic_tag ) {
+ break;
+ }
+ }
+ } else {
+ // If dynamic section is not found
+ fprintf(stderr, "[%s](%d)dynamic symbol is not find.\n", __func__, __LINE__);
+ }
+ }
+ }
+
+ fprintf(stderr, "[%s](%d)libTestFwCommon is not find. \n", __func__, __LINE__);
+ return false;
+}
+
+/**
+ * This method is a private method to be called from CreateProcess func.
+ * Check environment variable MOCK_LIBRARY where Mock Library Name to set in LD_PRELOAD is set
+ * and output character string to set in LD_PRELOAD if there is setting.
+ *
+ * @param process_path,environment_string
+ * @return void
+ */
+void Process::CheckLdPreLoad(SS_String *process_path, char *environment_string) {
+ if ((process_path == NULL || environment_string == NULL)) {
+ fprintf(stderr, "[%s](%d)Invaild Param.\n", __func__, __LINE__);
+ return;
+ }
+
+ // Check if environment variable MOCK_LIBRARY for LD_PRELOAD setting is set
+ char *value_mock_library = getenv("MOCK_LIBRARY");
+
+ if (value_mock_library != NULL) {
+ // When MOCK_LIBRARY is set
+ fprintf(stderr, "[%s](%d)MOCK_LIBRARY = %s \n", __func__, __LINE__, value_mock_library);
+
+ // Check whether the process to be started is a core unit or TestFW, and execute LD_PRELOAD if libTestFwCommon.so is linked
+ if (CheckLinkedTestfwLibrary(process_path)) {
+ SS_String key_value;
+ SS_String key_ld_preload = "LD_PRELOAD=";
+
+ // Create LD_PRELOAD setting string
+ // LD_PRELOAD is enabled when the string is an envp argument in the form "LD_PRELOAD=hoge_mock.so hoge_mock.so ..."
+ key_value = key_ld_preload + value_mock_library;
+ strncpy(environment_string, key_value.c_str(), key_value.length());
+ fprintf(stderr, "[%s](%d)Set envp: %s \n", __func__, __LINE__, environment_string);
+ return;
+ } else {
+ // If the unit does not require LD_PRELOAD setting, set envairoment_string to NULL.
+ fprintf(stderr, "[%s](%d)Core Unit is not setting LD_PRELOAD\n", __func__, __LINE__);
+ return;
+ }
+ } else {
+ // If it is not set to MOCK_LIBRARY, it is not necessary to set LD_PRELOAD, so set envairoment_string to NULL.
+ fprintf(stderr, "[%s](%d)The MOCK_LIBRARY variable was unestablished.\n", __func__, __LINE__);
+ return;
+ }
+}
+
+/**
+ * Acquire the character string of the environment variable and set it in String Vector
+ * and return in a pointer of Vector.
+ *
+ * @param process_path,environment_string
+ * @return vector<SS_String> pointer
+ */
+extern char ** environ;
+std::vector<SS_String> *Process::GetEnvironVector(void) {
+ // If LD_PRELOAD is set, copy existing environment settings and set to environment_pointer
+
+ std::vector<SS_String>* vector_environ = new std::vector<SS_String>;
+
+ char **environ_tmp = environ;
+
+ // Insert environ_string into the vector table
+ int i = 0;
+ while (environ_tmp[i] != NULL) {
+ SS_String str_env(environ_tmp[i]);
+ vector_environ->push_back(str_env);
+ i++;
+ }
+
+ return vector_environ;
+}
+// ----------------------------------------
diff --git a/systemservice/interface_unified/library/src/ss_system_timer.cpp b/systemservice/interface_unified/library/src/ss_system_timer.cpp
new file mode 100755
index 0000000..24209fb
--- /dev/null
+++ b/systemservice/interface_unified/library/src/ss_system_timer.cpp
@@ -0,0 +1,228 @@
+/*
+ * @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_SystemManagerIf
+/// \brief This file provides support for the System Manager client interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "system_service/ss_system_timer.h"
+#include <native_service/ns_timer_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <utility>
+#include "ss_system_timer_local.h"
+
+Timer::Timer() :
+ m_bInit(FALSE), m_hApp(NULL), m_hSnd(NULL), m_hTmr(NULL) {
+ bzero(&m_tTi, sizeof(m_tTi));
+}
+
+Timer::Timer(HANDLE hdl, UI_32 id, CbFuncPtr CbFn):
+ m_bInit(FALSE), m_hApp(NULL), m_hSnd(NULL), m_hTmr(NULL) {
+ bzero(&m_tTi, sizeof(m_tTi));
+ Initialize(hdl, id, CbFn);
+}
+
+Timer::~Timer() {
+ if (m_bInit) {
+ Shutdown();
+ }
+} // LCOV_EXCL_BR_LINE 10:Because destructor
+
+BOOL Timer::Initialize(HANDLE hApp, UI_32 id, CbFuncPtr CbFn) {
+ if (!m_bInit && hApp && id && CbFn) {
+ m_hApp = hApp;
+ m_tTi.iCmd = id;
+ m_tTi.t_sec = 0;
+ m_tTi.t_nsec = 0;
+ m_tTi.rpt_sec = 0;
+ m_tTi.rpt_nsec = 0;
+ m_CbFn = CbFn;
+ m_hSnd = McOpenSender(FrameworkunifiedGetAppName(m_hApp));
+ m_hTmr = NS_TimerCreate(m_tTi, CALLBACK_MESSAGE, m_hSnd);
+ m_bInit = TRUE;
+ }
+ return m_bInit;
+}
+
+void Timer::Reinitialize(UI_32 id) {
+ if (!m_bInit && id) {
+ m_tTi.iCmd = id;
+
+ m_tTi.t_sec = 0;
+ m_tTi.t_nsec = 0;
+ m_tTi.rpt_sec = 0;
+ m_tTi.rpt_nsec = 0;
+
+ m_hSnd = McOpenSender(FrameworkunifiedGetAppName(m_hApp));
+ m_hTmr = NS_TimerCreate(m_tTi, CALLBACK_MESSAGE, m_hSnd);
+ m_bInit = TRUE;
+ }
+ return;
+}
+
+void Timer::Shutdown() {
+ if (m_bInit) {
+ Stop();
+ NS_TimerDelete(m_hTmr);
+ m_hTmr = NULL;
+ McClose(m_hSnd);
+ m_hSnd = NULL;
+ m_bInit = FALSE;
+ }
+}
+
+BOOL Timer::SetTime(UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms) {
+ if (m_bInit) {
+ m_tTi.t_sec = ss;
+ m_tTi.t_nsec = (ss || sms) ? sms*NS_PER_MS : 1; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ m_tTi.rpt_sec = rs;
+ m_tTi.rpt_nsec = rms*NS_PER_MS;
+ }
+ return m_bInit;
+}
+
+BOOL Timer::Start(UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms) {
+ if (m_bInit) {
+ SetTime(ss, sms, rs, rms);
+ FrameworkunifiedAttachCallbackToDispatcher(m_hApp, TIMER_SERVICE_NAME, m_tTi.iCmd, m_CbFn);
+ NS_TimerSetTime(m_hTmr, m_tTi);
+ }
+ return m_bInit;
+}
+
+BOOL Timer::Start() {
+ if (m_bInit) {
+ FrameworkunifiedAttachCallbackToDispatcher(m_hApp, TIMER_SERVICE_NAME, m_tTi.iCmd, m_CbFn);
+ m_tTi.t_nsec = (m_tTi.t_sec || m_tTi.t_nsec) ? m_tTi.t_nsec : 1; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ NS_TimerSetTime(m_hTmr, m_tTi);
+ }
+ return m_bInit;
+}
+
+BOOL Timer::Stop() {
+ if (m_bInit) {
+ NSTimerInfo ti = m_tTi;
+ ti.t_sec = 0;
+ ti.t_nsec = 0;
+ ti.rpt_sec = 0;
+ ti.rpt_nsec = 0;
+ NS_TimerSetTime(m_hTmr, ti);
+ FrameworkunifiedDetachCallbackFromDispatcher(m_hApp, TIMER_SERVICE_NAME, ti.iCmd);
+ }
+ return m_bInit;
+}
+
+// LCOV_EXCL_START 6:Because the condition cannot be set
+TimerCtrl::TimerCtrl()
+ : m_hApp(NULL), m_nTimersMax(DEFAULT_NTIMERS) {
+}
+
+TimerCtrl::TimerCtrl(UI_32 ntimers)
+ : m_hApp(NULL), m_nTimersMax(ntimers) {
+}
+
+void TimerCtrl::Initialize(HANDLE hApp) {
+ if ( NULL != hApp ) {
+ m_hApp = hApp;
+ if (m_aTimers.empty() && m_rTimers.empty()) {
+ for (UI_32 i = DEFAULT_TIMERID; i < DEFAULT_TIMERID+m_nTimersMax; ++i) {
+ m_aTimers.push_back(i);
+ }
+ }
+ }
+}
+
+void TimerCtrl::Shutdown() {
+ m_aTimers.clear();
+ while (m_rTimers.begin() != m_rTimers.end()) {
+ Timer* p_timer = m_rTimers.begin()->second;
+ p_timer->Shutdown();
+ delete p_timer;
+ m_rTimers.erase(m_rTimers.begin());
+ }
+}
+
+UI_32 TimerCtrl::CreateTimer(CbFuncPtr CbFn) {
+ if (!m_aTimers.empty()) {
+ UI_32 id = m_aTimers.front();
+ m_aTimers.pop_front();
+ Timer* p_timer = new Timer(m_hApp, id, CbFn);
+ m_rTimers.insert(std::pair<UI_32, Timer*>(id, p_timer));
+ return id;
+ }
+ return 0;
+}
+
+UI_32 TimerCtrl::DeleteTimer(UI_32 id) {
+ if (m_rTimers.find(id) != m_rTimers.end()) {
+ Timer* p_timer = m_rTimers.find(id)->second;
+ p_timer->Shutdown();
+ delete p_timer;
+ m_rTimers.erase(m_rTimers.find(id));
+ m_aTimers.push_back(id);
+ return id;
+ }
+ return 0;
+}
+
+UI_32 TimerCtrl::SetTimer(UI_32 id, UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms) {
+ if (m_rTimers.find(id) != m_rTimers.end()) {
+ Timer* p_timer = m_rTimers.find(id)->second;
+ p_timer->SetTime(ss, sms, rs, rms);
+ return id;
+ }
+ return 0;
+}
+UI_32 TimerCtrl::StartTimer(UI_32 id, UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms) {
+ if (m_rTimers.find(id) != m_rTimers.end()) {
+ Timer* p_timer = m_rTimers.find(id)->second;
+ p_timer->Start(ss, sms, rs, rms);
+ return id;
+ }
+ return 0;
+}
+
+UI_32 TimerCtrl::StartTimerMulti(UI_32 id, UI_32 ss, UI_32 sms, UI_32 rs, UI_32 rms, UI_32 subId) {
+ if (m_rTimers.find(id) != m_rTimers.end()) {
+ Timer* p_timer = m_rTimers.find(id)->second;
+ p_timer->Shutdown();
+ p_timer->Reinitialize(id + subId);
+ p_timer->Start(ss, sms, rs, rms);
+ return id;
+ }
+ return 0;
+}
+
+UI_32 TimerCtrl::StartTimer(UI_32 id) {
+ if (m_rTimers.find(id) != m_rTimers.end()) {
+ Timer* p_timer = m_rTimers.find(id)->second;
+ p_timer->Start();
+ return id;
+ }
+ return 0;
+}
+
+UI_32 TimerCtrl::StopTimer(UI_32 id) {
+ if (m_rTimers.find(id) != m_rTimers.end()) {
+ Timer* p_timer = m_rTimers.find(id)->second;
+ p_timer->Stop();
+ return id;
+ }
+ return 0;
+}
+// LCOV_EXCL_STOP
diff --git a/systemservice/interface_unified/scfg/gpf_ss_cpu_mon_config.cfg b/systemservice/interface_unified/scfg/gpf_ss_cpu_mon_config.cfg
new file mode 100755
index 0000000..dcf4d02
--- /dev/null
+++ b/systemservice/interface_unified/scfg/gpf_ss_cpu_mon_config.cfg
@@ -0,0 +1,14 @@
+# CPU Monitor Group Configuration File
+
+[Monitor]
+StartupDelayMs=20000
+SamplePeriodMs=1000
+HistoryLengthMs=10000
+
+[Trigger]
+IdleThresholdBelowPercent=10
+IdleThresholdTimeToExceedMs=3000
+PostDetectNextSampleTimeMs=3000
+
+[MonteCarlo]
+Enabled=FALSE
diff --git a/systemservice/interface_unified/scfg/gpf_ss_ps_config.cfg b/systemservice/interface_unified/scfg/gpf_ss_ps_config.cfg
new file mode 100755
index 0000000..4d30809
--- /dev/null
+++ b/systemservice/interface_unified/scfg/gpf_ss_ps_config.cfg
@@ -0,0 +1,20 @@
+[PowerLogicPlugin]
+dll=ss_powerlogic.dll
+
+[LVI1]
+Hysteresis_Enabled=TRUE
+Hysteresis_Tries=1
+Hysteresis_Timeout=200
+Timeouts_Timeout=200
+
+[LVI2]
+Hysteresis_Enabled=TRUE
+Hysteresis_Tries=1
+Hysteresis_Timeout=200
+Timeouts_Timeout=200
+
+[Shutdown]
+Hysteresis_Enabled=TRUE
+Hysteresis_Tries=1
+Hysteresis_Timeout=200
+Timeouts_Timeout=200
diff --git a/systemservice/interface_unified/scfg/gpf_ss_showmem.cfg b/systemservice/interface_unified/scfg/gpf_ss_showmem.cfg
new file mode 100755
index 0000000..0067483
--- /dev/null
+++ b/systemservice/interface_unified/scfg/gpf_ss_showmem.cfg
@@ -0,0 +1,6 @@
+# CPU Monitor, Show Memory Configuration File
+
+[Monitor]
+Enabled=TRUE
+StartupDelayMs=0
+SamplePeriodMs=1000
diff --git a/systemservice/interface_unified/scfg/ss_cpu_high_load_monitor.cfg b/systemservice/interface_unified/scfg/ss_cpu_high_load_monitor.cfg
new file mode 100755
index 0000000..9ae63d6
--- /dev/null
+++ b/systemservice/interface_unified/scfg/ss_cpu_high_load_monitor.cfg
@@ -0,0 +1,85 @@
+# CPU High Load Monitor Configuration File
+
+[Monitor]
+Enabled=TRUE
+
+[MonteCarlo]
+Enabled=TRUE
+SamplingTimeSec=3
+SamplingIntervalMicroSec=500
+InitiationTimingSec=15
+AnlysisProcessCount=3
+SleepTimeMSec=100
+LogCount=5
+
+[TopCalculation]
+Count=10
+TimeDivisionModuloArg=1000
+SleepTimeMilliSec=50
+
+# ClearThreadPrio is 1 and CountUpThreadPrio is 11.
+[WDT0]
+PrioMin=1
+PrioMax=10
+TriggerCount=10
+CountIncPeriodMs=1000
+CountClrPeriodMs=1000
+SupplementalConsoleLoggingEnabled=FALSE
+SupplementalRamFilePhysAddrStart=0x00000000
+SupplementalRamFileLen=0x00032000
+
+# ClearThreadPrio is 11 and CountUpThreadPrio is 17
+[WDT1]
+PrioMin=11
+PrioMax=16
+TriggerCount=10
+CountIncPeriodMs=1000
+CountClrPeriodMs=1000
+SupplementalConsoleLoggingEnabled=FALSE
+SupplementalRamFilePhysAddrStart=0x00000000
+SupplementalRamFileLen=0x00032000
+
+# ClearThreadPrio is 17 and CountUpThreadPrio is 19.
+# GtfStartup (Prio18) and _CWORD77_(Prio17) tend to occupy CPU, so I created dedicated group.
+[WDT2]
+PrioMin=17
+PrioMax=18
+TriggerCount=10
+CountIncPeriodMs=1000
+CountClrPeriodMs=1000
+SupplementalConsoleLoggingEnabled=FALSE
+SupplementalRamFilePhysAddrStart=0x00000000
+SupplementalRamFileLen=0x00032000
+
+# ClearThreadPrio is 19 and CountUpThreadPrio is 31
+[WDT3]
+PrioMin=19
+PrioMax=30
+TriggerCount=10
+CountIncPeriodMs=1000
+CountClrPeriodMs=1000
+SupplementalConsoleLoggingEnabled=FALSE
+SupplementalRamFilePhysAddrStart=0x00000000
+SupplementalRamFileLen=0x00032000
+
+# ClearThreadPrio is 31 and CountUpThreadPrio is 49
+[WDT4]
+PrioMin=31
+PrioMax=48
+TriggerCount=5
+CountIncPeriodMs=1000
+CountClrPeriodMs=1000
+SupplementalConsoleLoggingEnabled=FALSE
+SupplementalRamFilePhysAddrStart=0x00000000
+SupplementalRamFileLen=0x00032000
+
+# ClearThreadPrio is 49 and CountUpThreadPrio is 255
+[WDT5]
+PrioMin=49
+PrioMax=254
+TriggerCount=5
+CountIncPeriodMs=1000
+CountClrPeriodMs=1000
+SupplementalConsoleLoggingEnabled=FALSE
+SupplementalRamFilePhysAddrStart=0x00000000
+SupplementalRamFileLen=0x00032000
diff --git a/systemservice/interface_unified/scfg/ss_logger.cfg b/systemservice/interface_unified/scfg/ss_logger.cfg
new file mode 100755
index 0000000..ffb4c50
--- /dev/null
+++ b/systemservice/interface_unified/scfg/ss_logger.cfg
@@ -0,0 +1,133 @@
+[LOGGING]
+LogMaxFileSize=5242880
+PerformanceLogSize=262144
+EmmcOutputPath=/nv/BS/ss/logger_service/rwdata/frameworkunifiedlog
+EmmcOutputNaviLogPath=/nv/BS/ss/logger_service/rwdata/log2/awlog
+Usb0MountPath=/mnt/sda1
+Usb1MountPath=/mnt/sdb1
+SdMountPath=/fs/sd0
+EmmcOutputMax=56
+#Value of EmmcOutputErrMax is related to SM function of logging or not,
+#caused by error-reboot, illegal-reset.
+#So,check to influece upon each other in case of changing this value.
+EmmcOutputErrMax=10
+EmmcOutputGrpRelaunchMax=5
+EmmcOutputNaviLogMax=10
+EmmcOutputNaviLogNmlMax=20
+EmmcOutputNaviLogErrMax=10
+ExternalLogNum=6
+ExternalLogMax=20
+
+# "[EXTERNAL_X]" have to start from "1" to ExternalLogNum
+# "ExtLogPath" is file or directory path of External log
+# "OutputPath" is file or directory path in Archive file
+# "Remove" is removed or not after it is archived
+
+[EXTERNAL_1]
+ExtLogPath=/ramd/log/frameworkunifiedlog/radio
+OutputPath=radio
+Remove=false
+
+[EXTERNAL_2]
+ExtLogPath=/ramd/log/frameworkunifiedlog/connectivity
+OutputPath=connectivity
+Remove=false
+
+[EXTERNAL_3]
+ExtLogPath=/ramd/log/frameworkunifiedlog/graphics.log
+OutputPath=graphics.log
+Remove=false
+
+[EXTERNAL_4]
+ExtLogPath=/ramd/log/frameworkunifiedlog/winsys.log
+OutputPath=winsys.log
+Remove=false
+
+[EXTERNAL_5]
+ExtLogPath=/ramd/log/frameworkunifiedlog/appfw
+OutputPath=appfw
+Remove=false
+
+[EXTERNAL_6]
+ExtLogPath=/nv/ptdata/sec/tomoyo
+OutputPath=tomoyo
+Remove=true
+
+[SETLOGMASK]
+MASK0=0xDC000000
+MASK1=0x00000000
+MASK2=0x00000000
+MASK3=0x00000000
+MASK4=0x00000000
+MASK5=0x00000000
+MASK6=0x00000000
+MASK7=0x00000000
+MASK8=0x00000000
+MASK9=0x00000000
+MASK10=0x00000000
+MASK11=0x00000000
+MASK12=0x00000000
+MASK13=0x00000000
+MASK14=0x00000000
+MASK15=0x00000000
+
+[STORAGE]
+ThreadName=/SSLoggerStrage
+Priority=34
+Timeout=50000
+TimeoutAfter=5
+
+
+# Reader types
+# 0 : eReaderWriterTypeFile : not valid for reading
+# 1 : eReaderWriterTypeQueue : reading from a queue
+# 2 : eReaderWriterTypeUdp : not valid for reading
+# 3 : eReaderWriterTypeUdpAndFile : not valid for reading
+# 4 : eReaderWriterTypeInvalid : invalid type
+
+# Writer types
+# 0 : eReaderWriterTypeFile : Writing to file only
+# 1 : eReaderWriterTypeQueue : not implemented yet
+# 2 : eReaderWriterTypeUdp : writing to UDP only
+# 3 : eReaderWriterTypeUdpAndFile : writing to File and UDP
+# 4 : eReaderWriterTypeInvalid : invalid type
+
+[READERWRITER]
+Count=3
+
+[READERWRITER_00]
+ThreadName=pdg.LogQueR
+Priority=30
+ReaderType=1
+ReaderName=/NSLog
+WriterType=3
+WriterName1=/tmp/frameworkunified_debug.log
+WriterSize1=5242880
+WriterName2=169.254.80.9
+WriterSize2=0
+
+
+[READERWRITER_01]
+ThreadName=pdg.TranQueR
+Priority=30
+ReaderType=1
+ReaderName=/TRANSMIT
+WriterType=3
+WriterName1=/tmp/interfaceunified_transmit.log
+WriterSize1=5242880
+WriterName2=169.254.80.9
+WriterSize2=0
+
+
+[READERWRITER_02]
+ThreadName=pdg.PerformQueR
+Priority=11
+ReaderType=1
+ReaderName=/NSplog
+WriterType=0
+WriterName1=/tmp/frameworkunified_performance.log
+WriterSize1=262144
+WriterName2=
+WriterSize2=0
+
+
diff --git a/systemservice/interface_unified/scfg/system_launch_flashloader.cfg b/systemservice/interface_unified/scfg/system_launch_flashloader.cfg
new file mode 100755
index 0000000..49012de
--- /dev/null
+++ b/systemservice/interface_unified/scfg/system_launch_flashloader.cfg
@@ -0,0 +1,8 @@
+# Version:1.0.0v Service queue names changed and updated Lancher-FL sheet - FL
+# Region:FL
+# Generated on Tuesday, July 23, 2013 6:57:49 PM
+# Launch#|GroupName|Group#|Group Launch Wait Time|GroupTrigger|name|path| priority| critical| retry_cnt| arguments|logging_mask| restart| is_start_required| shutdown_critical| shutdown_wait_time
+[ModulesLaunchConfig]
+Launch1=CoreModules|1|100000|False|NS_NPPService|/agl/bin/NS_NPPService|51|True|1|--a SS_SystemManager|NULL|me|False|True|15
+Launch2=CoreModules|1|100000|False|SS_LoggerService|/agl/bin/SS_LoggerService|10|False|3|-p thrd=pdg.LogQueReader:30,thrd=pdg.TransmitQueReader:30,thrd=pdg.DumpQueReader:11,thrd=pdg.PerformanceQueReader:11,thrd=pdg.LogQueWriter:30,thrd=pdg.TransmitQueWriter:30,thrd=pdg.EvntLogQue:8,thrd=pdg.UdpQueWriter:10|NULL|me|True|True|4
+Launch3=SystemModules|2|100000|False|SS_PowerService|/agl/bin/SS_PowerService|12|True|3|NULL|NULL|me|True|False|0
diff --git a/systemservice/interface_unified/scfg_pram/gpf_ss_sm_config_data.cfg b/systemservice/interface_unified/scfg_pram/gpf_ss_sm_config_data.cfg
new file mode 100755
index 0000000..9aef5b8
--- /dev/null
+++ b/systemservice/interface_unified/scfg_pram/gpf_ss_sm_config_data.cfg
@@ -0,0 +1,26 @@
+[Heartbeat]
+MaxHeartBeatRetryCount=4
+AppHeartBeatIntervalInitial=40
+AppHeartBeatIntervalRepeat=30
+
+[CrashDetector]
+Enabled=TRUE
+
+[SysLowMemory]
+TimerValue=5000
+MaxRetryCount=6
+ThresholdValue=5242880
+InterfaceunifiedLogIntervalMs=30000
+
+[UserModeNotification]
+IsBoolean=FALSE
+
+[Module]
+# Set 'ModuleConnectionNumTimesToCheck' to '0' to disable Module Connection checking
+ModuleConnectionNumTimesToCheck=3
+ModuleConnectionTimeOutSec=40
+ModuleStartRespTimeOutSec=120
+
+[CriticalApps]
+CriticalAppsMaxShutdownTimeFastSleep=2;
+CriticalAppsMaxShutdownTimeNormalReset=15; \ No newline at end of file
diff --git a/systemservice/logger_service/LICENSE b/systemservice/logger_service/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/logger_service/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/logger_service/Makefile.server b/systemservice/logger_service/Makefile.server
new file mode 100755
index 0000000..13612f8
--- /dev/null
+++ b/systemservice/logger_service/Makefile.server
@@ -0,0 +1,19 @@
+#
+# @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.
+#
+
+SUBDIRS := server
+
+include ../system_service.mk
diff --git a/systemservice/logger_service/server/Makefile b/systemservice/logger_service/server/Makefile
new file mode 100755
index 0000000..5292a18
--- /dev/null
+++ b/systemservice/logger_service/server/Makefile
@@ -0,0 +1,28 @@
+#
+# @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.
+#
+
+SUBDIRS += lib work
+
+SUBDIRS += realtimeUsbLog
+
+all:
+
+install-data:install_data
+
+install_data:
+ install -d -m 755 $(DESTDIR)/nv/BS/ss/logger_service/rwdata/frameworkunifiedlog
+
+include ../../system_service.mk
diff --git a/systemservice/logger_service/server/SS_LoggerService.conf_bin b/systemservice/logger_service/server/SS_LoggerService.conf_bin
new file mode 100755
index 0000000..440d361
--- /dev/null
+++ b/systemservice/logger_service/server/SS_LoggerService.conf_bin
@@ -0,0 +1,4 @@
+/usr/agl/bin|${OSW_reldbg}
+debug|dbg
+release|rel
+product|rel
diff --git a/systemservice/logger_service/server/include/loggerservicedebug_loggerservicelog.h b/systemservice/logger_service/server/include/loggerservicedebug_loggerservicelog.h
new file mode 100755
index 0000000..5a2f56e
--- /dev/null
+++ b/systemservice/logger_service/server/include/loggerservicedebug_loggerservicelog.h
@@ -0,0 +1,81 @@
+/*
+ * @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_NS_LogTraceSender
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_LOGGERSERVICELOG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_LOGGERSERVICELOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_PRD_INFO3 ZONEMASK(26)
+#define ZONE_PRD_INFO2 ZONEMASK(27)
+#define ZONE_PRD_INFO1 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 "Product Info3"
+#define ZONE_TEXT_27 "Product Info2"
+#define ZONE_TEXT_28 "Product Info1"
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS(LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_INFO, ZONE_FUNC, ZONE_ERR, ZONE_WARN, ZONE_PRD_INFO1, ZONE_PRD_INFO2, ZONE_PRD_INFO3
+#endif
+
+extern const CHAR AppName[];
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_LOGGERSERVICELOG_H_
diff --git a/systemservice/logger_service/server/include/loggerservicedebug_thread_if.h b/systemservice/logger_service/server/include/loggerservicedebug_thread_if.h
new file mode 100755
index 0000000..8a43511
--- /dev/null
+++ b/systemservice/logger_service/server/include/loggerservicedebug_thread_if.h
@@ -0,0 +1,319 @@
+/*
+ * @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_NS_LogTraceSender
+/// \brief This file supports the logging thread interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_THREAD_IF_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_THREAD_IF_H_
+
+#include <pthread.h>
+#ifdef AGL_STUB
+#else
+#include <sys/neutrino.h>
+#include <sys/dispatch.h>
+#endif
+#include <errno.h>
+#include <sched.h>
+#include <stdio.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_logger_service_local.h>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+
+typedef std::string ThreadName; //< service name
+
+typedef enum _EThreadCommandIds {
+ eThrdCmdUsbEject = 5463, ///< USB eject --> frameworkunifieddebug
+ eThrdCmdUsbCaptureLogs, ///< USB Capture log --> frameworkunifieddebug
+ eThrdCmdUsbStoreLogs, ///< USB Store log --> frameworkunifieddebug
+ eThrdCmdWriteFilesToUsb, ///< frameworkunifieddebug --> Writer
+ eThrdCmdWriteDataToFile, ///< Reader --> Writer
+ eThrdCmdWriterStop, ///< frameworkunifieddebug --> Writer (Stop writing to the file)
+ eThrdCmdWriterResume, ///< frameworkunifieddebug --> Writer (Continue writing to the file)
+ eThrdCmdCaptureLogScriptExit, ///< LogCaptureScript - > frameworkunifieddebug
+ eThrdCmdWriteEvntFilesToUsb, ///< Wreite Event files to USB
+ eThrdCmdcopytofile,
+ eThrdCmdClearEvntLogs, ///< Clear event logs
+ eThrdCmdStatisticalCounter, ///< Read statistical counter
+ eThrdCmdStatisticalCounterSuccessResp, ///< Statistical counter positiv Response from child thread
+ eThrdCmdStatisticalCounterErrorResp, ///< Statistical counter Negative Response from child thread
+ eThrdCmdResetStatisticalCntrs,
+ eThrdCmdCopyEventLogUSBResponse, ///< Copy event logs to usb response from child thread
+ eThrdCmdClearEventLogResponse, ///< Clear event logs response fromchild thread
+ eThrdCmdPersistLogs, ///< Statistical counter Response fromchild thread
+ eThrdCmdSetVINnumber,
+ eThrdCmdImmPersistEvtLog,
+ eThrdCmdMileageData,
+ eThrdCmdGetNumberOfEventsLogged,
+ eThrdCmdNumberOfEventsLoggedResponse,
+ eThrdCmdUploadEventLog,
+ eThrdCmdUploadEventLogResponse,
+ eThrdCmdCopyEvntLogToTmp,
+ eThrdCmdCopyEvntLogToTmpResponse
+} EThreadCommandIds;
+
+typedef struct _TThrdWriteDataToFileEvt {
+ static const UI_32 LN_LEN = 1024;
+ CHAR line[LN_LEN];
+ UI_32 length;
+} TThrdWriteLogDataToFileEvt, TThrdWriteTransmitDataToFileEvt;
+
+typedef struct _TThrdWriteFilesToUsbEvt {
+ static const UI_32 LOC_PATH_LEN = 256;
+ CHAR location[LOC_PATH_LEN]; ///< full path where files should be copied too
+ UI_32 loc_len;
+} TThrdWriteLogFilesToUsbEvt, TThrdWriteTransmitFilesToUsbEvt;
+
+typedef struct _TThrdCaptureLogsEvt {
+ static const UI_32 FN_LEN = 256;
+ CHAR location[FN_LEN];
+ CHAR parse_fn[FN_LEN]; ///< full path an name of the file that should be parsed for event actions.
+} TThrdCaptureLogsEvt;
+
+// Structure to hold the USB device informaton
+typedef struct _TThrdEvtLogStore {
+ BOOL IsDeviceAvailable;
+ static const UI_32 FN_LEN = 256;
+ CHAR location[FN_LEN];
+ CHAR parse_fn[FN_LEN]; ///< full path an name of the file that should be parsed for event actions.
+} TThrdEvtLogStore;
+
+typedef struct _TInitFlag {
+ UI_8 mileage_flagbit :1;
+ UI_8 statcounter_flagbit :1;
+ UI_8 eventlog_flagbit :1;
+ UI_8 reghandlers_flagbit :1;
+} TInitFlag;
+
+typedef struct _TSessionData {
+ std::string strSrcName;
+ UI_32 session_id;
+} TSessionData;
+
+typedef struct _TEvntNumber {
+ TSessionData stSessiondata;
+ UI_16 u16numberofeventslogged;
+} TEvntsLogged;
+
+typedef struct _TWriteFilesToUsbCmdData {
+ TSessionData stSessiondata;
+ EEvtLogUSBDevNumber eDevId;
+} TWriteFilesToUsbCmdData;
+
+typedef struct _TWriteFilesToUsbCmdResponse {
+ TSessionData stSessiondata;
+ UI_8 u8Response;
+} TWriteFilesToUsbCmdResponse;
+
+typedef struct _TClearEvntLogCmdResponse {
+ TSessionData stSessiondata;
+ UI_8 u8Response;
+} TClearEvntLogCmdResponse;
+
+typedef struct _TStatisticalCountersCmd {
+ TSessionData stSessiondata;
+ EStatCounterGroupID eGroupId;
+} TStatisticalCountersCmd;
+
+typedef struct _TStatisticalCntCmdSuccessResp {
+ TSessionData stSessiondata;
+ SStatisticalCounter stBuffer;
+} TStatisticalCntCmdSuccessResp;
+
+typedef struct _TUploadEventLogResp {
+ TSessionData stSessiondata;
+ STEventLogPersistBuffer stEventLogBuffer;
+} TUploadEventLogResp;
+
+typedef struct _TEventLogCopyStatus {
+ static const UI_8 FilePathSize = 64;
+ CHAR EventLogFilePath[FilePathSize];
+ UI_8 status;
+} TEventLogCopyStatus;
+
+typedef enum _ECaptureLogScriptResp {
+ ekCLSStatusCompleteSuccessful,
+ ekCLSStatusInitError,
+ ekCLSStatusExecuteError,
+ ekCLSStatusCopyError,
+ ekCLSStatusChmodError,
+} ECaptureLogScriptResp;
+
+class ThreadWrapper {
+ public:
+
+ ThreadWrapper(const char* t_name, void* (*routine)(void*), void* arg) { // LCOV_EXCL_START 8:ThreadWrapper class is never used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ pthread_attr_t attr;
+ struct sched_param params;
+
+ if (EOK != pthread_attr_init(&attr)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_init failed errno: %d", errno);
+ }
+ if (EOK != pthread_attr_getschedparam(&attr, &params)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_getschedparam failed errno: %d", errno);
+ }
+ SI_32 prio = frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(
+ std::string(t_name));
+ if (-1 != prio) {
+ params.sched_priority = prio;
+ if (EOK != pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_setinheritsched failed errno: %d", errno);
+ }
+ if (EOK != pthread_attr_setschedparam(&attr, &params)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_setschedparam failed errno: %d", errno);
+ }
+ }
+
+ if (EOK != pthread_create(&m_thread, &attr, routine, arg)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: pthread_create failed errno: %d",
+ errno);
+ }
+ }
+ // LCOV_EXCL_STOP
+
+
+ ~ThreadWrapper() { // LCOV_EXCL_START 8:ThreadWrapper class is never used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// todo: Need a clean way to cleanup thread in case class closes
+ }
+ // LCOV_EXCL_STOP
+
+
+ operator pthread_t() const { // LCOV_EXCL_START 8:ThreadWrapper class is never used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_thread;
+ }
+ // LCOV_EXCL_STOP
+
+ private:
+ pthread_t m_thread;
+};
+
+
+class CChild {
+ public:
+ CChild(const char* parentsName, const char * sendDataToQue,
+ const char * clientsName, void* (*routine)(void*),
+ const char * sendToUdpQue = "")
+ : m_clientName(clientsName),
+ m_parentName(parentsName),
+ m_sendDataToQueuName(sendDataToQue),
+ m_sendDataToUdpQueName(sendToUdpQue),
+ m_barInit(InitBarrier()),
+ m_thread(clientsName, routine, reinterpret_cast<void*>(this)) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP
+
+ void Join() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (EOK != pthread_join(m_thread, NULL)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: pthread_join failed errno: %d",
+ errno);
+ }
+ }
+ // LCOV_EXCL_STOP
+
+ const char * ParentName() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_parentName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ const char * ClientName() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_clientName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ const char * SendDataToQue() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_sendDataToQueuName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ const char * SendDataToUdpQueue() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_sendDataToUdpQueName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ bool IsValidWaitBarrier() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (m_barInit) {
+ int wbret = pthread_barrier_wait(&m_barrier);
+ return ( PTHREAD_BARRIER_SERIAL_THREAD == wbret) || (0 == wbret);
+ }
+
+ return false;
+ }
+ // LCOV_EXCL_STOP
+
+ private:
+ bool InitBarrier() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ /// Note: the count value should match the number of threads that are readers and usb notifiers
+ return (EOK == pthread_barrier_init(&m_barrier, NULL, 2) ? true : false);
+ }
+ // LCOV_EXCL_STOP
+
+ private:
+ ThreadName m_clientName;
+ ThreadName m_parentName;
+ ThreadName m_sendDataToQueuName;
+ ThreadName m_sendDataToUdpQueName;
+ bool m_barInit;
+ ThreadWrapper m_thread;
+ pthread_barrier_t m_barrier;
+};
+
+class LoggerserviceDebugChildThread {
+ public:
+ typedef enum e {
+ kLoggerserviceDebugLogQueReader,
+ kLoggerserviceDebugTransmitQueReader,
+ kLoggerservicePerformanceLogQueReader,
+ kLoggerserviceDebugCaptureLogScript,
+ kLoggerserviceDebugEventLogque,
+ kLoggerserviceDebugMax
+ } ELoggerserviceDebugThreads;
+
+ LoggerserviceDebugChildThread();
+ virtual ~LoggerserviceDebugChildThread();
+ BOOL Start(ELoggerserviceDebugThreads id, const char* parentsName,
+ const char * sendDataToQue, void* (*routine)(void*),
+ const char * sendToUdpQue = "");
+ void Stop(ELoggerserviceDebugThreads id);
+ void StopAll();
+ const char * Name(ELoggerserviceDebugThreads id);
+ void LiftWaitBarrier(ELoggerserviceDebugThreads id);
+ BOOL Running(ELoggerserviceDebugThreads id) const;
+ private:
+ ThreadName names[kLoggerserviceDebugMax];
+ CChild * threads[kLoggerserviceDebugMax];
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_THREAD_IF_H_
diff --git a/systemservice/logger_service/server/include/loggerservicedebug_writer_Evntworker.h b/systemservice/logger_service/server/include/loggerservicedebug_writer_Evntworker.h
new file mode 100755
index 0000000..cef5c18
--- /dev/null
+++ b/systemservice/logger_service/server/include/loggerservicedebug_writer_Evntworker.h
@@ -0,0 +1,211 @@
+/*
+ * @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_NS_LogTraceSender
+/// \brief frameworkunifieddebug writer thread class, handles writing a log file
+/// all really done by my_writer class.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_WRITER_EVNTWORKER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_WRITER_EVNTWORKER_H_
+
+#include <stdlib.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_eventlogger.h>
+#include <map>
+#include <iostream>
+#include <deque>
+#include "loggerservicedebug_thread_if.h"
+
+
+// File path names for Evnet and counter logs
+extern const CHAR DEBUG_EVNTLOG_PATH_FN[];
+extern const CHAR g_strEvntLogQueWorkerName[];
+extern const CHAR DEBUG_LOG_PATH_FN[];
+extern const CHAR Counter_LOG_PATH_FN[];
+extern const CHAR Counter_LOG_PATH_STARTFN[];
+extern const CHAR Counter_LOG_PATH_SHUTFN[];
+extern const CHAR Mileage_LOG_PATH_FN[];
+
+typedef struct _TevntWriterInfo {
+ static const UI_32 FN_LEN = 256;
+ UI_32 max_filelen;
+ CHAR base_cnt_filename[FN_LEN];
+ CHAR mileage_filename[FN_LEN];
+} TEvntWriterInfo;
+
+typedef enum _eDatatype_ {
+ COMMON_DATA,
+ EVENT_SPECIFIC_DATA
+} EDatatype_SS;
+
+typedef enum _eSystemPhase_ {
+ STARTUP_SS = 0x21,
+ NORMAL_SS = 0x22,
+ SHUTDOWN_SS = 0x23
+} ESystemPhase_SS;
+
+#pragma pack(1)
+typedef struct _stLogEventFull_ {
+ UI_32 ts;
+ UI_8 grp_ID;
+ UI_8 event_id;
+ UI_8 data[4];
+ ESystemPhase_SS phase;
+ UI_16 cnt_ID;
+ EDatatype_SS typeofdata;
+} st_LogEvent_full;
+#pragma pack(0)
+
+// Deque to hold the Event information
+typedef std::deque<st_LogEvent_ss> DEQUE_Event_Type;
+
+// Map to hold the Counter information on phase
+typedef std::map<UI_16, UI_32> Counter;
+
+/*Map to hold the all the counter information */
+typedef std::map<EStatCounterGroupID, Counter> CounterInformation;
+
+class CEvntWriterWorker {
+ public:
+ CEvntWriterWorker();
+ CEvntWriterWorker(TEvntWriterInfo & wi); // NOLINT (runtime/references)
+ virtual ~CEvntWriterWorker();
+ // initialize the object
+ EFrameworkunifiedStatus Initialize(HANDLE hThread);
+
+ /// Copy event logs to USB request from parent thread
+ EFrameworkunifiedStatus OnCmdWriteEventFilesToUsb(HANDLE hThread);
+
+ /// Event logging request from NS logger
+ EFrameworkunifiedStatus OnCmdEventLog(UI_8* pbuf);
+
+ /// Clear event logs request from parent thread
+ EFrameworkunifiedStatus OnCmdClearEventLogs(HANDLE hThread);
+
+ /// Read statistical counter request from parent thread
+ EFrameworkunifiedStatus OnCmdReadStatisticalCounter(HANDLE hThread);
+
+ /// Read statistical counter based on counter group ID
+ EFrameworkunifiedStatus ReadStatisticalCounter(EStatCounterGroupID eStatCounterGroupID,
+ SStatisticalCounter& buffer); // NOLINT (runtime/references)
+
+ /// Reset statistical counter request from parent thread
+ EFrameworkunifiedStatus OnCmdResetStatisticalCounter(HANDLE hThread);
+
+ /// Reset statistical counter based on counter group ID
+ EFrameworkunifiedStatus ResetStatisticalCounter(EStatCounterGroupID eStatCounterGroupID);
+
+ EFrameworkunifiedStatus OnCmdStop(HANDLE hThread);
+
+ EFrameworkunifiedStatus OnCmdStart(HANDLE hThread);
+
+ /// Counter logging request from NS logger
+ EFrameworkunifiedStatus OnCmdIncrcount(UI_8* pbuf);
+
+ /// Event and Counter logging request from NS logger
+ EFrameworkunifiedStatus OnCmdIncrwriteevent(UI_8* pbuf);
+
+ /// Reading counter value from file based on phase
+ EFrameworkunifiedStatus readCountFromFile(PCSTR filename);
+
+ /// Writing counter value from file based on phase
+ EFrameworkunifiedStatus writeCountToFile(PCSTR filename);
+
+ /// Writing event value from file based on phase
+ EFrameworkunifiedStatus write_event_to_file(const CHAR* filename);
+
+ /// Copy event files to USB based onUSB device number
+ UI_8 copy_event_files_to_usb(TThrdEvtLogStore *pStUSBIndo);
+
+ /// Functioncall to populate the counter value to map
+ VOID OnCmdIncrcount_phase(st_LogCount *cnt);
+
+ /// Function call to populate the event value to deque
+ VOID OnCmdWriteEventLogs(st_LogEvent_ss *ev);
+
+ /// Set the VIN number
+ EFrameworkunifiedStatus OnCmdSetVIN(HANDLE hThread);
+
+ /// Get the VIN number
+ VOID OnCmdGetVIN(STVIN_NUMBER& f_stVIN_Number); // NOLINT (runtime/references)
+
+ /// Functional call to write events from deque to local buffer
+ VOID write_events_to_buffer(STEventLogPersistBuffer* f_stEvtLogBuf);
+
+ /// Functional call to read events from buffer to deque
+ VOID read_events_from_buffer(STEventLogPersistBuffer* f_stEvtLogBuf);
+
+ /// Functional call to immediate persist event log
+ EFrameworkunifiedStatus immediate_persist_event_log(HANDLE hThread);
+
+ /// Functional call to set mileage information in Evt thread space
+ EFrameworkunifiedStatus EvtThd_SetMileage(HANDLE hThread);
+
+ /// Functional call to write mileage data to file for persisting
+ EFrameworkunifiedStatus write_mileage_to_file(const CHAR* filename);
+
+ /// Functional call to read mileage data from persistent file during startup
+ EFrameworkunifiedStatus read_mileage_from_file(const CHAR* filename);
+
+ EFrameworkunifiedStatus OnCmdReadNumberOfEventsLogged(HANDLE hThread);
+
+ EFrameworkunifiedStatus EventLogRegisterCbHandlers(HANDLE hThread);
+
+ EFrameworkunifiedStatus OnCmdUploadEventLog(HANDLE hThread);
+
+ EFrameworkunifiedStatus OnCmdCopyEvntLogToTmp(HANDLE hThread);
+ /// Static Members for Event and counter logging
+ static CounterInformation counter;
+ static DEQUE_Event_Type deque_event_info;
+
+ private:
+ STVIN_NUMBER m_stVINnumber;
+ UI_32 m_u32MileageData;
+ UI_32 m_u32NumberEventsLogged;
+ TUploadEventLogResp m_stUploadEventLogResp;
+ EFrameworkunifiedStatus counterIncrementByValue(EStatCounterGroupID group, UI_16 id,
+ UI_32 value);
+ EFrameworkunifiedStatus writeGroupToFile(FILE *fp, EStatCounterGroupID group);
+};
+
+/// Event logging Child thread start and shut down functions
+EFrameworkunifiedStatus EvntWriterWorkerOnStart(HANDLE hThread);
+EFrameworkunifiedStatus EvntWriterWorkerOnStop(HANDLE hThread);
+
+/// USBdevice detectioncall backs
+EFrameworkunifiedStatus DD_USBSrvDetectionCallBack(HANDLE hApp);
+EFrameworkunifiedStatus DD_USBServiceAvailabilityCallBack(HANDLE hThread);
+EFrameworkunifiedStatus DD_USBOpenSessionAckCallBack(HANDLE hThread);
+EFrameworkunifiedStatus DD_USBCloseSessionAckCallBack(HANDLE hApp);
+
+inline void u16copy(PUI_8 pDest, UI_16 Source) {
+ *(pDest++) = (UI_8) (Source & 0x00FF);
+ *(pDest++) = (UI_8) ((Source & 0xFF00) >> 8);
+}
+inline void u32copy(PUI_8 pDest, UI_32 Source) {
+ *(pDest++) = (UI_8) (Source & 0x000000FF);
+ *(pDest++) = (UI_8) ((Source & 0x0000FF00) >> 8);
+ *(pDest++) = (UI_8) ((Source & 0x00FF0000) >> 16);
+ *(pDest++) = (UI_8) ((Source & 0xFF000000) >> 24);
+}
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_WRITER_EVNTWORKER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/reader/mem_reader.h b/systemservice/logger_service/server/include/readerWriter/reader/mem_reader.h
new file mode 100755
index 0000000..a5c65ec
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/reader/mem_reader.h
@@ -0,0 +1,51 @@
+/*
+ * @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.
+ */
+
+/*
+ * mem_reader.h
+ *
+ * Created on: Oct 22, 2013
+ */
+
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_MEM_READER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_MEM_READER_H_
+
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_sharedmem_reader.h>
+#include <string>
+#include "reader.h"
+
+namespace ReaderWriter {
+class CMemReader : public ReaderWriter::CReader {
+ public:
+ CMemReader();
+ virtual ~CMemReader();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize);
+ EFrameworkunifiedStatus Read(UI_8* f_data, UI_32 f_length, SI_32& f_bytesRead); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus ReadToFile(std::string f_fileName, UI_32& f_Written); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus Open(void);
+ BOOL IsOpen(void);
+ void Close();
+ EFrameworkunifiedStatus ResetPosition(void);
+
+ private:
+ CNSSharedMemReader* m_pSharedBuf;
+ UI_32 m_sharedBufSize;
+};
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_MEM_READER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/reader/queue_reader.h b/systemservice/logger_service/server/include/readerWriter/reader/queue_reader.h
new file mode 100755
index 0000000..139796a
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/reader/queue_reader.h
@@ -0,0 +1,49 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_QUEUE_READER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_QUEUE_READER_H_
+
+#include <mqueue.h>
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "reader.h"
+
+namespace ReaderWriter {
+
+class CQueueReader : public CReader {
+ public:
+ CQueueReader();
+ virtual ~CQueueReader();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize);
+ EFrameworkunifiedStatus Read(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesRead); // NOLINT (runtime/references)
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ void Close();
+ private:
+ mqd_t m_handle;
+ std::string m_queName;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_QUEUE_READER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/reader/reader.h b/systemservice/logger_service/server/include/readerWriter/reader/reader.h
new file mode 100755
index 0000000..7b0141d
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/reader/reader.h
@@ -0,0 +1,52 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_READER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_READER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer_cfg.h"
+#include "ss_logger_cfg.h"
+
+namespace ReaderWriter {
+
+class CReader {
+ public:
+ CReader();
+ virtual ~CReader();
+
+ static CReader* OpenReader(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_name, UI_32 f_maxSize);
+ virtual EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize) = 0;
+ virtual BOOL IsOpen(void) = 0;
+ virtual EFrameworkunifiedStatus Open(void) = 0;
+ virtual EFrameworkunifiedStatus Read(UI_8* f_data, UI_32 f_length, SI_32& f_bytesRead) = 0; // NOLINT (runtime/references)
+ virtual EFrameworkunifiedStatus ReadToFile(std::string f_fileName, UI_32& f_Written); // NOLINT (runtime/references)
+
+ virtual void Close() = 0;
+ virtual EFrameworkunifiedStatus ResetPosition(void);
+
+ protected:
+ CLoggerCfg * m_pLoggerCfg;
+};
+} // namespace ReaderWriter
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_READER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/reader_writer.h b/systemservice/logger_service/server/include/readerWriter/reader_writer.h
new file mode 100755
index 0000000..b075472
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/reader_writer.h
@@ -0,0 +1,77 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_H_
+
+#include <pthread.h>
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer_cfg.h"
+#include "readerWriter/reader/reader.h"
+#include "readerWriter/writer/writer.h"
+
+namespace ReaderWriter {
+
+class CReaderWriter {
+ public:
+ CReaderWriter();
+ virtual ~CReaderWriter();
+
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, EReaderType f_readerType,
+ std::string f_readerName, UI_32 f_readerMaxSize,
+ EWriterType f_writerType, std::string f_writer1Name,
+ UI_32 f_writer1MaxSize);
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, EReaderType f_readerType,
+ std::string f_readerName, UI_32 f_readerMaxSize,
+ EWriterType f_writerType, std::string f_writer1Name,
+ UI_32 f_writer1MaxSize, std::string f_writer2Name,
+ UI_32 f_writer2MaxSize);
+ EFrameworkunifiedStatus Start(std::string f_readerName);
+ EFrameworkunifiedStatus Stop();
+ void ThreadFunction(CReaderWriter* l_pObj);
+ void Cleanup(CReaderWriter* l_pObj);
+ EFrameworkunifiedStatus FlushCache(std::string f_filename);
+ EFrameworkunifiedStatus UpdateLoggingParameters(void);
+
+ private:
+ void Pause(void);
+ void Resume(void);
+ static void* ThreadFunctionWrapper(void* param);
+
+ static void CleanupWrapper(void* param);
+ CLoggerCfg* m_pLoggerCfg;
+ CReader* m_reader;
+ CWriter* m_writer;
+ BOOL m_running;
+ pthread_t m_thread;
+ pthread_barrier_t m_barrier;
+ std::string m_readerName;
+
+ pthread_mutex_t m_writeMutex;
+ pthread_mutex_t m_pauseMutex;
+ pthread_cond_t m_condVariable;
+ BOOL m_paused;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/reader_writer_cfg.h b/systemservice/logger_service/server/include/readerWriter/reader_writer_cfg.h
new file mode 100755
index 0000000..b39353b
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/reader_writer_cfg.h
@@ -0,0 +1,35 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_CFG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_CFG_H_
+namespace ReaderWriter {
+typedef enum _ERWType {
+ eReaderWriterTypeFile,
+ eReaderWriterTypeQueue,
+ eReaderWriterTypeUdp,
+ eReaderWriterTypeUdpAndFile, // Only for writer | pass filename and queueName
+ eReaderWriterTypeMem,
+ eReaderWriterTypeInvalid
+} EReaderType, EWriterType;
+}
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_CFG_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/writer/cached_file_writer.h b/systemservice/logger_service/server/include/readerWriter/writer/cached_file_writer.h
new file mode 100755
index 0000000..ad28658
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/writer/cached_file_writer.h
@@ -0,0 +1,45 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_CACHED_FILE_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_CACHED_FILE_WRITER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include "file_writer.h"
+
+#define CACHED_BLOCK_SIZE (UI_32)(4*1024)
+
+namespace ReaderWriter {
+
+class CCachedFileWriter : public CFileWriter {
+ public:
+ CCachedFileWriter();
+ virtual ~CCachedFileWriter();
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus FlushCache(void);
+ private:
+ UI_8 m_buffer[CACHED_BLOCK_SIZE ];
+ UI_32 m_index;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_CACHED_FILE_WRITER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/writer/file_writer.h b/systemservice/logger_service/server/include/readerWriter/writer/file_writer.h
new file mode 100755
index 0000000..caf81c9
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/writer/file_writer.h
@@ -0,0 +1,51 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_FILE_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_FILE_WRITER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "writer.h"
+
+namespace ReaderWriter {
+
+class CFileWriter : public CWriter {
+ public:
+ CFileWriter();
+ virtual ~CFileWriter();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2, UI_32 f_size2);
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ void Close();
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ protected:
+ EFrameworkunifiedStatus WriteData(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ private:
+ int m_FileHandle;
+ off_t m_fileposn;
+ UI_32 m_maxFileSize;
+ std::string m_filename;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_FILE_WRITER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/writer/udp_file_writer.h b/systemservice/logger_service/server/include/readerWriter/writer/udp_file_writer.h
new file mode 100755
index 0000000..65e58e0
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/writer/udp_file_writer.h
@@ -0,0 +1,54 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_FILE_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_FILE_WRITER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "writer.h"
+#include "udp_writer.h"
+#include "file_writer.h"
+
+namespace ReaderWriter {
+
+class CUdpFileWriter : public CWriter {
+ public:
+ CUdpFileWriter();
+ virtual ~CUdpFileWriter();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2, UI_32 f_size2);
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ void Close();
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ EFrameworkunifiedStatus FlushCache(void);
+ EFrameworkunifiedStatus UpdateLoggingParameters(void);
+ private:
+ CUdpWriter *m_pUdpWriter;
+ CFileWriter *m_pFileWriter;
+ CLoggerCfg* m_pLoggerCfg;
+ std::string m_ipAddress;
+ UI_32 m_port;
+ std::string m_FileName;
+ UI_32 m_FileSize;
+};
+} // namespace ReaderWriter
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_FILE_WRITER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/writer/udp_writer.h b/systemservice/logger_service/server/include/readerWriter/writer/udp_writer.h
new file mode 100755
index 0000000..cf0944a
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/writer/udp_writer.h
@@ -0,0 +1,63 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_WRITER_H_
+
+#include <netinet/in.h>
+#include <string>
+#include "writer.h"
+
+#define REMOTE_IP_PORT 3500
+namespace ReaderWriter {
+#define UDP_MAX_LENGTH (UI_32)1024*4
+#define UDP_CACHED_BLOCK_SIZE (UI_32)1024*4
+#define SEND_RETRY_VALUE (UI_8) 5
+
+#define OWN_ADDRESS "169.254.80.8"
+class CUdpWriter : public CWriter {
+ public:
+ CUdpWriter();
+ virtual ~CUdpWriter();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2, UI_32 f_size2);
+
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ void Close();
+ EFrameworkunifiedStatus UpdateLoggingParameters(void);
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ EFrameworkunifiedStatus FlushCache(void);
+ private:
+ EFrameworkunifiedStatus WriteData(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+
+ int m_SocketHandle;
+ sockaddr_in m_oSAInfo;
+ std::string m_IPAddress;
+ UI_32 m_index;
+ UI_32 m_port;
+ BOOL m_InitialTimeElapsed;
+ UI_8 m_buffer[UDP_CACHED_BLOCK_SIZE];
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_WRITER_H_
diff --git a/systemservice/logger_service/server/include/readerWriter/writer/writer.h b/systemservice/logger_service/server/include/readerWriter/writer/writer.h
new file mode 100755
index 0000000..15d93aa
--- /dev/null
+++ b/systemservice/logger_service/server/include/readerWriter/writer/writer.h
@@ -0,0 +1,56 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_WRITER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer_cfg.h"
+#include "ss_logger_cfg.h"
+
+namespace ReaderWriter {
+
+class CWriter {
+ public:
+ CWriter();
+ virtual ~CWriter();
+
+ static CWriter* OpenWriter(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2);
+ virtual EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2,
+ UI_32 f_size2) = 0;
+ virtual EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length,
+ SI_32 &f_bytesWritten) = 0; // NOLINT (runtime/references)
+ virtual void Close() = 0;
+ virtual EFrameworkunifiedStatus FlushCache(void);
+ virtual EFrameworkunifiedStatus UpdateLoggingParameters(void);
+ virtual BOOL IsOpen(void) = 0;
+ virtual EFrameworkunifiedStatus Open(void) = 0;
+
+ protected:
+ CLoggerCfg * m_pLoggerCfg;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_WRITER_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_cfg.h b/systemservice/logger_service/server/include/ss_logger_cfg.h
new file mode 100755
index 0000000..93aaef9
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_cfg.h
@@ -0,0 +1,185 @@
+/*
+ * @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_SS_LoggerService
+/// \brief Provide support for SS Logger module configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
+
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/ns_logger_if.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_logger_service_local.h>
+#include <string>
+#include <vector>
+#include "loggerservicedebug_loggerservicelog.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// CONFIGURATION CLASS DEFINITION
+///////////////////////////////////////////////////////////////////////////////
+/*Default values for the storage thread*/
+#define ERROR_EVENT_STORAGE_QUEUE_NAME "/SSLoggerStrage"
+#define ERROR_EVENT_STORAGE_PRIORITY (UI_8)30
+#define ERROR_EVENT_STORAGE_SLEEP_TIME (useconds_t)50000
+#define ERROR_EVENT_STORAGE_SLEEP_AFTER (UI_8)5
+
+#if ENABLE_PRODUCTION_BUILD == 1
+#define SS_LOGGER_DEFAULT_VALUE eDeactivate
+#else
+#define SS_LOGGER_DEFAULT_VALUE eActivate
+#endif
+
+#define LOGGERSERVICELOG_EMMC_COUNTER_MAX 99999u
+
+struct SLoggerStorageInfo {
+ SLoggerStorageInfo()
+ : Name(ERROR_EVENT_STORAGE_QUEUE_NAME),
+ Priority(ERROR_EVENT_STORAGE_PRIORITY),
+ Timeout(ERROR_EVENT_STORAGE_SLEEP_TIME),
+ TimeoutAfter(ERROR_EVENT_STORAGE_SLEEP_AFTER) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ std::string Name;
+ SI_32 Priority;
+ SI_32 Timeout;
+ SI_32 TimeoutAfter;
+};
+
+enum EInsertEventType {
+ eInsertEventEELStorage,
+ eInsertEventEELActive,
+ eInsertEventLoggerserviceEmmcLogs,
+ eInsertEventInvalid
+};
+
+struct ExternalLogInfo {
+ std::string dirname;
+ std::string path;
+ BOOL remove;
+};
+
+struct ExternalLogList {
+ SI_32 num;
+ SI_32 max;
+ ExternalLogInfo* p_info;
+};
+
+class CLoggerCfg {
+ public:
+ CLoggerCfg(void);
+ ~CLoggerCfg(void);
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus Load(const std::string &f_filePathAndName);
+ EFrameworkunifiedStatus Validate(void);
+ void Print(void);
+
+ EFrameworkunifiedStatus SetLoggingParams(HANDLE f_hApp,
+ STLoggerSetParams f_stLoggerSetParams);
+
+ EFrameworkunifiedStatus SetUDPLogging(HANDLE f_hApp, const ELOGGER_STAT f_eUDPLoggingStatus);
+
+ EFrameworkunifiedStatus PersistLoggingParam(HANDLE f_hApp);
+ std::string getEmmcOutputPath(void);
+ std::string getEmmcOutputNaviLogPath(void);
+ std::string getUsb0MountPath(void);
+ std::string getUsb1MountPath(void);
+ std::string getSdMountPath(void);
+ std::string getDeviceName(void);
+ void setUsb0MountPath(std::string &f_deviceMountpath); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus GetUserInvokedDestination(std::string &f_dest); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus GetEmmcDestination(std::string &f_dest); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus GetEmmcNaviLogDestination(std::string &f_dest); // NOLINT (runtime/references)
+
+ UI_32 GetUserInvokedCounter(void);
+ EFrameworkunifiedStatus GetIncrementAndPersistUserInvokedCounter(HANDLE f_hApp,
+ UI_32 &f_counter); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus GetAndIncrementEmmcCounter(UI_32 &f_counter); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus RefreshEmmcCounter(UI_32 &f_counter) const; // NOLINT (runtime/references)
+
+ void ResetEmmcCounter(void);
+
+ SI_32 m_logMaxFileSize;
+ UI_32 m_logMask[ZONE_MASK_ARRAY_ELTS];
+ SI_32 m_performanceLogMaxFileSize;
+ SI_32 m_emmcOutputMax;
+ SI_32 m_emmcOutputErrMax;
+ SI_32 m_emmcOutputGrpRelaunchMax;
+ SI_32 m_emmcOutputNaviLogMax;
+ SI_32 m_emmcOutputNaviLogNmlMax;
+ SI_32 m_emmcOutputNaviLogErrMax;
+ ExternalLogList m_ExternalLogList;
+
+ std::string m_emmcOutputPath;
+ std::string m_emmcOutputNaviLogPath;
+ std::string m_usb0MountPath;
+ std::string m_usb1MountPath;
+ std::string m_sdMountPath;
+
+ EDEV_TYPE GetConnectedDevice(std::string f_devPath);
+ EInsertEventType GetInsertEventType(std::string f_relPath);
+
+ std::string GetEELActivateRelPath(void);
+ std::string GetDebugFolderContentRelPath(void);
+ std::string GetEELExportRelPath(void);
+
+ BOOL IsUDPLoggingEnabled(void);
+ void AddLoggingParamCB(CbFuncPtr f_fp);
+
+ EFrameworkunifiedStatus GetLoggerStorageInfo(SLoggerStorageInfo &f_info); // NOLINT (runtime/references)
+ BOOL IsLoggingEnabled(void);
+ EFrameworkunifiedStatus EelActivateLogging(HANDLE f_hApp);
+ ExternalLogList GetExternalLogList(void);
+
+ private:
+ void UpdateLoggingStatus(void);
+ std::vector<CbFuncPtr> m_LoggingCallBack;
+ void GetHighestEmmcCounterValue(UI_32 &f_counter); // NOLINT (runtime/references)
+
+ EDEV_TYPE m_eDevType;
+ UI_32 m_UserInvokedLoggingNumber;
+ UI_32 m_EmmcCounter;
+ ELOGGER_STAT m_eLoggerUDPLoggingStatus;
+ BOOL m_udpEnvFlag;
+ ELOGGER_STAT m_eLoggerStatus;
+
+ std::string m_EELStorageRelPath;
+
+ std::string m_EELActivateRelPath;
+
+ std::string m_LoggerserviceEmmcLogsRelPath;
+
+ EFrameworkunifiedStatus SetandPersistLoggingParams(HANDLE f_hApp,
+ STLoggerSetAllParams f_Params,
+ BOOL f_InitCall);
+ SLoggerStorageInfo m_loggerStorageInfo;
+
+ void RemoveCarriageReturn(std::string &f_str); // NOLINT (runtime/references)
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
+
diff --git a/systemservice/logger_service/server/include/ss_logger_common.h b/systemservice/logger_service/server/include/ss_logger_common.h
new file mode 100755
index 0000000..80a56af
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_common.h
@@ -0,0 +1,115 @@
+/*
+ * @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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief This file contains the callback for Notifications and Protocol
+/// commands.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup logger_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_COMMON_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_COMMON_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+
+const CHAR DEBUG_LOG_PATH_DIR[] = "/tmp/frameworkunifiedlog";
+const CHAR DEBUG_LOG_PATH_FN[] = "/tmp/frameworkunified_debug.log";
+const CHAR TRANSMIT_LOG_PATH_FN[] = "/tmp/interfaceunified_transmit.log";
+const CHAR PERFORMANCE_LOG_PATH_FN[] = "/tmp/frameworkunified_performance.log";
+const CHAR DRINITIAL_LOG_PATH_FN[] = "/tmp/loggerservice_drinitial.log";
+const CHAR DRLOCATION_LOG_PATH_FN[] = "/tmp/loggerservice_drlocation.log";
+const CHAR KERNEL_LOG_PATH_FN[] = "/tmp/kernel.log";
+const CHAR KERNEL_BOOT_LOG_PATH_FN[] = "/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/kernelboot.log";
+
+const UI_32 PERFORMANCELOG_FILE_SZ = 256 * 1024;
+
+#define CLEAR_LOG_PATH_FN "/nv/BS/ss/logger_service/rwdata/frameworkunifiedlog/"
+#define NULLCHAR '\0'
+
+#define DEBUG_USB_PATH "/mnt/sda1"
+#define KERNEL_LOG_PATH_DIR "kernellog"
+
+template<typename C, EFrameworkunifiedStatus (C::*M)(HANDLE)>
+class cpp_callback {
+ public:
+ static CallbackFunctionPtr set(void* pInst) {
+ if (pInst == NULL)
+ throw;
+ ms_pInst = pInst;
+ return &cpp_callback::call;
+ }
+ static EFrameworkunifiedStatus call(HANDLE y) {
+ if (ms_pInst == NULL)
+ return eFrameworkunifiedStatusFault;
+ C* c = static_cast<C*>(ms_pInst);
+ return (c->*M)(y);
+ }
+ private:
+ static void* ms_pInst;
+};
+
+template<typename C, EFrameworkunifiedStatus (C::*M)(HANDLE)>
+void* cpp_callback<C, M>::ms_pInst = NULL;
+
+typedef enum _LoggerServiceStatus {
+ eLSInit,
+ eLSStart,
+ eLSStop,
+} ELOGGERSERVICESTATUS;
+
+typedef enum {
+ SS_LOGGER_KLOG_GET, /* type : get kernel.log */
+ SS_LOGGER_KBOOTLOG_CREATE /* type : create kernelboot.log */
+} SS_LOGGER_KLOG_OPE_TYPE;
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StopLoggingFunction
+/// \~english @par Summary
+/// Stop the logging function.
+/// \~english @param [in] hApp
+/// HANDLE - Application handle
+/// \~english @retval
+/// None
+/// \~english @par Detail
+/// - The API stops the logging function.\n
+/// \n
+/// - Include ss_logger_common.h
+/// - Library libSS_SystemIfUnified.so
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+void StopLoggingFunction(HANDLE hApp);
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_COMMON_H_
+
+/** @}*/ // end of LoggerService
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/logger_service/server/include/ss_logger_device_detection.h b/systemservice/logger_service/server/include/ss_logger_device_detection.h
new file mode 100755
index 0000000..5ee67c0
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_device_detection.h
@@ -0,0 +1,66 @@
+/*
+ * @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_NS_InterfaceunifiedLogCapture
+/// \brief This file supports USB logging threads.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_DEVICE_DETECTION_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_DEVICE_DETECTION_H_
+
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include "ss_logger_cfg.h"
+#include "ss_logger_util.h"
+
+extern const char * USB_INSERTED_RULE;
+
+// USB device is ejected
+extern const CHAR USB_EJECTED_RULE[];
+
+// The trigger event file (/log/retrievelog.evt) file is found on USB
+extern const CHAR USB_CAPTURE_LOG_EVENT_RULE[];
+
+// When the command to update system with script is executed all the console
+// output will be redirected to this file on /tmp folder. later it will be
+// moved to USB stick
+extern const CHAR CAPTURE_LOG_FILENAME[];
+
+//
+extern const SI_32 INVALID_FD;
+class CLoggerDeviceDetection {
+ public:
+ CLoggerDeviceDetection();
+ ~CLoggerDeviceDetection();
+
+ EFrameworkunifiedStatus Initialize(HANDLE hApp, CLoggerCfg *f_pLoggerCfg);
+ EFrameworkunifiedStatus DD_ServiceAvailabilityCallBack(HANDLE hApp);
+ EFrameworkunifiedStatus DD_OpenSessionAckCallBack(HANDLE hApp);
+ EFrameworkunifiedStatus DD_CloseSessionAckCallBack(HANDLE hApp);
+ EFrameworkunifiedStatus DD_CloseSessionWithDevDetectionSrv(HANDLE hApp);
+ EFrameworkunifiedStatus DD_MediaDetectCallBack(HANDLE hApp);
+
+ EFrameworkunifiedStatus OnStop(void);
+ private:
+ CLoggerCfg *m_pLoggerCfg;
+
+ /// Device Detection Class Instance
+ DeviceDetectionServiceIf m_devDetect;
+
+ CLoggerUtil *m_loggerUtil;
+};
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_DEVICE_DETECTION_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_error_event.h b/systemservice/logger_service/server/include/ss_logger_error_event.h
new file mode 100755
index 0000000..177c074
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_error_event.h
@@ -0,0 +1,156 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_H_
+
+#include <time.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_system_types.h>
+#include <system_service/ss_system_timer.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <string>
+#include <vector>
+#include "ss_logger_popups.h"
+#include "ss_logger_common.h"
+#include "ss_logger_reader_writer_control.h"
+#include "ss_logger_error_event_cfg.h"
+#include "ss_logger_cfg.h"
+#include "ss_logger_util.h"
+#include "readerWriter/reader_writer.h"
+#include "readerWriter/reader_writer_cfg.h"
+#include "ss_logger_error_event_storage.h"
+#include "ss_logger_error_event_can_evt_reply.h"
+
+class CErrorEvent {
+ public:
+ CErrorEvent();
+ ~CErrorEvent();
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp, CLoggerCfg *f_pLoggerCfg,
+ CReaderWriterControl *f_pReaderWriterControl,
+ HANDLE f_thrdEvntLogWriter,
+ std::string f_strEvntLogQueWorkerName);
+
+ EFrameworkunifiedStatus RegisterSessionErrorEvent(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnOpenSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession);
+
+ EFrameworkunifiedStatus OnCloseSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession);
+
+ EFrameworkunifiedStatus StartLogging(HANDLE f_hApp, EErrorEventType f_eventType);
+
+ EFrameworkunifiedStatus sendDiagEventErrorResponse(EELL_ErrorCode f_errCode);
+
+ EFrameworkunifiedStatus sendDiagEventErrorResponse(EELL_ErrorCode f_errCode,
+ std::string f_destName);
+
+ EFrameworkunifiedStatus sendDiagEventResponse(void);
+
+ EFrameworkunifiedStatus SetDiagEventSourceName(std::string f_serviceName);
+
+ void SetMileage(UI_32 f_mileage);
+
+ void SetDiagSessionHandle(HANDLE hSession);
+
+ EFrameworkunifiedStatus SaveNaviLog(EPWR_SHUTDOWN_TRIGGER_TYPE errorType);
+ EFrameworkunifiedStatus CreateKernelLog(HANDLE f_hApp, SS_LOGGER_KLOG_OPE_TYPE type);
+
+ private:
+ typedef enum {
+ kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN,
+ kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN,
+ kSSL_ERROR_EVENT_TIMER_END
+ } ESSLErrorEventTimers;
+
+ // Logging Protocol Function Prototypes
+ EFrameworkunifiedStatus OnStartLogging(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnLogStartResponse(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnLogStartResponseTimeout(HANDLE f_hApp);
+ EFrameworkunifiedStatus RequestNextArtifact(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnArtifactResponse(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnArtifactResponseTimeout(HANDLE f_hApp);
+
+ // Protocol functions sent to self.
+ EFrameworkunifiedStatus OnArtifactRequest(HANDLE f_hApp);
+
+ // Error Event Artifact Request Function Prototypes
+ EFrameworkunifiedStatus SendLogArtifactResponseToSelf(
+ HANDLE f_hApp, EArtifactId f_artifactId,
+ std::string f_artifactFilePathAndName);
+
+ EFrameworkunifiedStatus OnObtainLoggerserviceLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainTransmitLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainPerformanceLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainScreenShotRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainScreenShotResponse(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainKernelLogInfoRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainDRInitialLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainDRLocationLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseOk(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseWriteFailed(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseNotFound(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseNoWritten(HANDLE f_hApp);
+ EFrameworkunifiedStatus CheckPathForArtifact(HANDLE f_hApp, TLoggingArtifact f_artifact);
+ EFrameworkunifiedStatus OnClearAllLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnNaviLogRequest(HANDLE f_hApp);
+
+ // verify function for external storage
+ EFrameworkunifiedStatus VerifyExtStorage(TLoggerErrorEvent event);
+ bool IsNeedVerify(EErrorEventType type);
+
+ HANDLE m_hApp;
+ bool m_bIsPrevEventCompleted;
+ CErrorEventCfg m_errorEventCfg;
+ TLoggerErrorEvent m_errorEventNtfData;
+ Timer m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_END];
+ std::vector<TLoggingArtifact> m_artifactRequestVec;
+ TArtifactResponseVec m_artifactResponseVec;
+ std::vector<FrameworkunifiedProtocolCallbackHandler> m_requesterCallbacksVec;
+ std::string m_archiveDestination;
+ CLoggerUtil m_loggerUtil;
+ CLoggerPopups m_loggerPopups;
+ CLoggerCfg* m_pLoggerCfg;
+ CLoggerErrorEventStorage m_loggerStorage;
+ CLoggerErrorEventCANEvtReply m_loggerCanEvent;
+ static const UI_32 m_loggingStartRspnToSec = 1;
+ static const UI_32 m_screenShotRspnToSec = 2;
+ CReaderWriterControl* m_pReaderWriterControl;
+
+ std::string m_ServiceName;
+ uint32_t m_time;
+ UI_32 m_currentEventTriggerNumber;
+ HANDLE m_diagsessionhandle;
+
+ HANDLE m_thrdEvntLogWriter;
+
+ public:
+ int m_sfd;
+};
+
+EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact);
+EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp, TLoggingArtifact f_artifact);
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_H_
+
diff --git a/systemservice/logger_service/server/include/ss_logger_error_event_archive.h b/systemservice/logger_service/server/include/ss_logger_error_event_archive.h
new file mode 100755
index 0000000..2b5212d
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_error_event_archive.h
@@ -0,0 +1,77 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+#include <libtar_listhash.h>
+#include <libtar.h>
+
+#include <system_service/ss_system_types.h>
+#include <string>
+#include <vector>
+
+class CErrorEventArchive {
+ public:
+ CErrorEventArchive();
+ ~CErrorEventArchive();
+
+ EFrameworkunifiedStatus openArchive(std::string f_pathAndName);
+
+ EFrameworkunifiedStatus addToArchive(std::vector<std::string> f_filePathAndNameList);
+
+ EFrameworkunifiedStatus addToArchive(std::string f_filePathAndName,
+ std::string f_destinationName, UI_8 f_depth =
+ CErrorEventArchive::MAX_DIRECTORY_DEPTH);
+
+ EFrameworkunifiedStatus closeArchive(void);
+
+ static SI_32 gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode);
+
+ static SI_32 gzCloseArchive();
+
+ static ssize_t gzWriteArchive(int fd, const void* buf, size_t count);
+
+ static ssize_t gzReadArchive(int fd, void* buf, size_t count);
+
+ static const UI_8 MAX_DIRECTORY_DEPTH = 4;
+
+ private:
+ EFrameworkunifiedStatus addFileToArchive(std::string f_filename,
+ std::string f_destinationName);
+
+ EFrameworkunifiedStatus addDirectoryToArchive(std::string f_path,
+ std::string f_destinationName, UI_8 f_depth =
+ CErrorEventArchive::MAX_DIRECTORY_DEPTH);
+
+ tartype_t m_gztype;
+ TAR *m_pTarInfo;
+ std::string m_pathAndName;
+ std::string m_tmpName;
+
+ static const UI_32 TARMODE = 0644;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_error_event_can_evt_reply.h b/systemservice/logger_service/server/include/ss_logger_error_event_can_evt_reply.h
new file mode 100755
index 0000000..b976cdb
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_error_event_can_evt_reply.h
@@ -0,0 +1,48 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports notifying CAN abou HK and CAN error events
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CAN_EVT_REPLY_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CAN_EVT_REPLY_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_logger_service_protocol.h>
+
+#include "ss_logger_cfg.h"
+#include "ss_logger_error_event_cfg.h"
+#include "ss_logger_common.h"
+class CLoggerErrorEventCANEvtReply {
+ public:
+ CLoggerErrorEventCANEvtReply();
+ virtual ~CLoggerErrorEventCANEvtReply();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg);
+
+ BOOL IsEventNeeded(TLoggerErrorEvent f_event);
+ EFrameworkunifiedStatus PublishStartEvent(HANDLE f_hApp, TLoggerErrorEvent f_event);
+ EFrameworkunifiedStatus PublishEndEvent(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ UI_32 f_triggerNumber, uint32_t f_time);
+
+ EFrameworkunifiedStatus PublishErrorEvent(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ BOOL f_isValid, UI_32 f_triggerNumber,
+ uint32_t f_time);
+ private:
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CAN_EVT_REPLY_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_error_event_cfg.h b/systemservice/logger_service/server/include/ss_logger_error_event_cfg.h
new file mode 100755
index 0000000..1a0e39e
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_error_event_cfg.h
@@ -0,0 +1,135 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
+#include <system_service/ss_system_manager_if.h>
+#include <vector>
+#include <map>
+#include <string>
+
+#include "ss_logger_cfg.h"
+
+typedef UI_32 ARTIFACT_BIT_MASK;
+typedef UI_32 EVENT_BIT_MASK;
+
+#define NBR_ARTIFACT_BITS (sizeof(ARTIFACT_BIT_MASK) * 8)
+
+enum EVENT_BIT {
+ EVENT_BIT_NONE = 0x00000000,
+ EVENT_BIT_POPUP = 1 << (UI_32) 1,
+ EVENT_BIT_CAN_NOTIFICATION = 1 << (UI_32) 2,
+ EVENT_BIT_DIAG = 1 << (UI_32) 3,
+};
+
+struct TLoggingErrorEventInformation {
+ ARTIFACT_BIT_MASK ArtifactBitMask;
+ EVENT_BIT_MASK EventBitMask;
+};
+struct TLoggingArtifactCfg {
+ EErrorEventType ErrorType;
+ TLoggingErrorEventInformation Information;
+};
+struct TLoggerErrorEvent {
+ TLoggerErrorEvent()
+ : EventType(eErrorEventTypeMaxValue),
+ ModuleName(""),
+ isNeedReboot(FALSE),
+ EventBitMask(EVENT_BIT_NONE) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ TLoggerErrorEvent(SMErrorEventNtfData l_SMErrorEvent) { // NOLINT (runtime/explicit)
+ EventType = l_SMErrorEvent.EventType;
+ ModuleName = l_SMErrorEvent.ModuleName;
+ isNeedReboot = l_SMErrorEvent.isNeedReboot;
+ EventBitMask = EVENT_BIT_NONE;
+ }
+ EErrorEventType EventType;
+ std::string ModuleName;
+ BOOL isNeedReboot;
+ EVENT_BIT_MASK EventBitMask;
+};
+struct TLoggingArtifact;
+
+typedef EFrameworkunifiedStatus (*TLoggingCbFunction)(HANDLE, TLoggingArtifact);
+
+enum ECallbackType {
+ eCbTypePath = 0,
+ eCbTypeFunction,
+ eCbTypeInvalid
+};
+
+struct TLoggingArtifactCallback {
+ ECallbackType Type;
+ std::string Path;
+ TLoggingCbFunction Function;
+};
+
+struct TLoggingArtifactInformation {
+ std::string OwnerServiceName;
+ UI_32 RequestTimeoutMs;
+ TLoggingArtifactCallback Cb;
+ BOOL Remove;
+};
+struct TLoggingArtifact {
+ EArtifactId ArtifactId;
+ TLoggingArtifactInformation Information;
+};
+
+struct TLoggingArtifactResponse {
+ EArtifactId ArtifactId;
+ std::string Filepath;
+ BOOL Remove;
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+///// External function definition for Logger callbacks
+//////////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact);
+extern EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp,
+ TLoggingArtifact f_artifact);
+
+typedef std::map<EErrorEventType, TLoggingErrorEventInformation> TArtifactBitMaskMap;
+typedef std::map<EArtifactId, TLoggingArtifactInformation> TArtifactMap;
+typedef std::vector<TLoggingArtifactResponse> TArtifactResponseVec;
+
+class CErrorEventCfg {
+ public:
+ CErrorEventCfg(void);
+
+ ~CErrorEventCfg(void);
+
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* p_logger_cfg);
+
+ void GetArtifactRequestVec(
+ EErrorEventType f_eventType,
+ std::vector<TLoggingArtifact> &f_refArtifactRequestVec); // NOLINT (runtime/references)
+ EVENT_BIT_MASK GetEventsForErrorEvent(EErrorEventType f_eventType);
+ private:
+ UI_32 ValidateConfiguration();
+ TArtifactBitMaskMap m_errorEventTypeToArtifactBitMaskMap;
+ TArtifactMap m_errorArtifactMap;
+ UI_32 m_ext_log_num;
+
+ static TLoggingArtifactCfg m_loggerErrorEventCfgTbl[eErrorEventTypeMaxValue];
+ static TLoggingArtifact m_loggerErrorArtifactCfgTbl[eArtifactIdMaxValue];
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_error_event_storage.h b/systemservice/logger_service/server/include/ss_logger_error_event_storage.h
new file mode 100755
index 0000000..8a2cbd4
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_error_event_storage.h
@@ -0,0 +1,82 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
+
+#include <sys/types.h>
+#include <pthread.h>
+#include <mqueue.h>
+#include <time.h>
+#include <native_service/frameworkunified_types.h>
+#include <ss_logger_error_event_cfg.h>
+#include <stub/Clock_API.h>
+#include <string>
+#include "ss_logger_cfg.h"
+
+enum ELoggerStorageThreadCommands {
+ eLoggerStorageThreadCmdOK = 0xAFFE,
+ eLoggerStorageThreadCmdWriteFailed,
+ eLoggerStorageThreadCmdNotFound,
+ eLoggerStorageThreadCmdNoWritten
+};
+
+class CLoggerErrorEventStorage {
+ public:
+ CLoggerErrorEventStorage();
+ virtual ~CLoggerErrorEventStorage();
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp, std::string f_ParentName,
+ CLoggerCfg *f_pLoggerCfg);
+
+ EFrameworkunifiedStatus Start(std::string f_target, TArtifactResponseVec f_responseVector,
+ uint32_t f_time);
+
+ void ThreadFunction(void);
+ void Cleanup(void);
+
+ private:
+ static void* ThreadFunctionWrapper(void* param);
+ static void CleanupWrapper(void* param);
+
+ EFrameworkunifiedStatus PackageAndPlaceArtifacts(std::string f_archiveDestination,
+ TArtifactResponseVec &f_responseVector, // NOLINT (runtime/references)
+ uint32_t l_logTime);
+
+ SI_32 CopyFiles(std::string f_archiveDestination,
+ TArtifactResponseVec &f_responseVector, BOOL isDeleteFiles); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus RemoveDeprecatedArtifacts(TArtifactResponseVec &f_responseVector); // NOLINT (runtime/references)
+ HANDLE m_parentMcQueue;
+ pthread_t m_thread;
+ pthread_mutex_t m_mutex;
+ mqd_t m_sendQueue;
+ mqd_t m_receiveQueue;
+ std::string m_destination;
+ TArtifactResponseVec m_responseVec;
+ struct mq_attr m_mqattr;
+ SI_32 m_mutexInit;
+ CLoggerCfg *m_pLoggerCfg;
+ SLoggerStorageInfo m_loggerStorageInfo;
+ uint32_t m_logTime;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_fs_directory.h b/systemservice/logger_service/server/include/ss_logger_fs_directory.h
new file mode 100755
index 0000000..7e8da15
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_fs_directory.h
@@ -0,0 +1,108 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file contains declaration of class CFSDirectory.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_FS_DIRECTORY_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_FS_DIRECTORY_H_
+#include <native_service/frameworkunified_types.h>
+#include<string>
+
+// Class to provide file system directory operations like create,delete etc.
+class CFSDirectory {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFSDirectory
+ /// Constructor of CFSDirectory class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFSDirectory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFSDirectory
+ /// Destructor of CFSDirectory class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CFSDirectory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to check if the directory exists.
+ ///
+ /// \param [in] f_cDirPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL DoesDirectoryExist(std::string &f_cDirPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to create a directory.
+ ///
+ /// \param [in] f_cDirPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static EFrameworkunifiedStatus CreateDirectory(std::string &f_cDirPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to verify directory.
+ ///
+ /// \param [in] f_cPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL IsDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to delete directory.
+ ///
+ /// \param [in] f_cPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL RemoveDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to delete file in direcotry.
+ ///
+ /// \param [in] f_cPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL RemoveSubDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_FS_DIRECTORY_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_popups.h b/systemservice/logger_service/server/include/ss_logger_popups.h
new file mode 100755
index 0000000..b5b50e8
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_popups.h
@@ -0,0 +1,51 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_POPUPS_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_POPUPS_H_
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <string>
+#include <vector>
+
+#include "ss_logger_cfg.h"
+#include "ss_logger_error_event_cfg.h"
+class CLoggerPopups {
+ public:
+ CLoggerPopups();
+ virtual ~CLoggerPopups();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg);
+ BOOL IsPopupNeeded(TLoggerErrorEvent f_event);
+ BOOL CanShowStartPopup(std::vector<TLoggingArtifact>* f_remainingArtifact);
+ EFrameworkunifiedStatus ShowStartPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::vector<TLoggingArtifact>* f_remainingArtifact,
+ std::string f_dest);
+ EFrameworkunifiedStatus ShowEndPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::string f_dest);
+ EFrameworkunifiedStatus ShowErrorPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ UI_16 f_errCode);
+ std::string getDeviceName(std::string f_dest);
+ private:
+ CLoggerCfg *m_pLoggerCfg;
+ BOOL m_startShown;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_POPUPS_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_reader_writer_control.h b/systemservice/logger_service/server/include/ss_logger_reader_writer_control.h
new file mode 100755
index 0000000..04d1937
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_reader_writer_control.h
@@ -0,0 +1,49 @@
+/*
+ * @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.
+ */
+
+/*
+ * ss_logger_reader_writer_control.h
+ */
+
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_READER_WRITER_CONTROL_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_READER_WRITER_CONTROL_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer.h"
+#include "ss_logger_cfg.h"
+
+enum EReaderWriterType {
+ eReaderWriterLogDebug,
+ eReaderWriterLogTransmit,
+ eReaderWriterLogPerformance,
+ eReaderWriterLogInvalid
+};
+class CReaderWriterControl {
+ public:
+ CReaderWriterControl();
+ virtual ~CReaderWriterControl();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg);
+ EFrameworkunifiedStatus UpdateLoggingParams(void* param);
+ EFrameworkunifiedStatus FlushCache(EReaderWriterType f_type);
+ private:
+ CLoggerCfg * m_pLoggerCfg;
+ ReaderWriter::CReaderWriter m_debugReaderWriter;
+ ReaderWriter::CReaderWriter m_transmitReaderWriter;
+ ReaderWriter::CReaderWriter m_performanceReaderWriter;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_READER_WRITER_CONTROL_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_scrshot.h b/systemservice/logger_service/server/include/ss_logger_scrshot.h
new file mode 100755
index 0000000..5cc9dd9
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_scrshot.h
@@ -0,0 +1,30 @@
+/*
+ * @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_SS_LoggerService
+/// \brief
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SCRSHOT_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SCRSHOT_H_
+
+#define JPEG_PATH_CH0 "/nv/BS/ss/logger_service/rwdata/screenShot/screen_shot_Ch0.jpeg"
+#define JPEG_PATH_CH1 "/nv/BS/ss/logger_service/rwdata/screenShot/screen_shot_Ch1.jpeg"
+#define SCRSHOT_EXE_PATH "/usr/agl/bin/SS_ScrShot"
+#define SCREEN_SHOT_PATH "/nv/BS/ss/logger_service/rwdata/screenShot"
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SCRSHOT_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_service_callbacks.h b/systemservice/logger_service/server/include/ss_logger_service_callbacks.h
new file mode 100755
index 0000000..786054c
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_service_callbacks.h
@@ -0,0 +1,96 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file contains the callback for Notifications and Protocol
+/// commands.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SERVICE_CALLBACKS_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SERVICE_CALLBACKS_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <system_service/ss_error_event_common.h>
+#include "ss_logger_error_event.h"
+#include "ss_logger_reader_writer_control.h"
+#include "ss_logger_cfg.h"
+
+class CLoggerServiceCallbacks {
+ private:
+ static const UI_32 kNUMBER_PROTOCOL_HANDLERS = 17u;
+ FrameworkunifiedProtocolCallbackHandler m_protocolHandlers[kNUMBER_PROTOCOL_HANDLERS];
+ CLoggerCfg *m_pLoggerCfg;
+ CErrorEvent *m_pErrorEvent;
+
+ public:
+ CLoggerServiceCallbacks();
+ ~CLoggerServiceCallbacks();
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp, CLoggerCfg *f_pLoggerCfg,
+ CErrorEvent *f_pErrorEvent);
+
+ EFrameworkunifiedStatus LoggerServerOnOpenSession(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServerOnCloseSession(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_SetMileageData(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_SetLoggerParams(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_UDPLogging(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_SetCurrentDateTime(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_UpdateCommonInfo(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_Handle_CWORD56_Events(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_LogResetEvents(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnCopyEmergencyLog(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnCANTrigger(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnDTCTrigger(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus LoggerServer_On_SHTDWN_Complete(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnSetVIN(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnCopyEvntLog(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnClearEvntLog(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnReadNumberOfEvents(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnReadStatCounter(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnResetStatCounter(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnSetDiagID(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_UploadEventLog(HANDLE hApp);
+
+ HANDLE RetrieveRegisteredClientHandle(HANDLE hApp, PCSTR pRequester);
+};
+
+EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp);
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SERVICE_CALLBACKS_H_
+
diff --git a/systemservice/logger_service/server/include/ss_logger_types.h b/systemservice/logger_service/server/include/ss_logger_types.h
new file mode 100755
index 0000000..11542a5
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_types.h
@@ -0,0 +1,52 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports shared internal logger module data types.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_TYPES_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_TYPES_H_
+
+#include <native_service/frameworkunified_sm_eventdata.h>
+
+typedef enum _ENPS_Archivetype {
+ ARCHTYPE_COMPRESSION = 0, // Compression
+ ARCHTYPE_DECOMPRESSION = 1 // DeCompression
+} ENPS_Archivetype;
+
+typedef CHAR CopyInfoStr[MAX_PATH_LENGTH]; ///< Information passed via the framework
+
+typedef enum _LOGGERSERVICE_COMPRESSION_TYPE {
+ eLoggerserviceNone = 0, // No Compression before file persistence
+ eLoggerserviceDefaultCompression, // Compress file before persistence using default compression method
+ eLoggerserviceCompressUsingLibz // Compress file before persistence using libz
+} LOGGERSERVICE_COMPRESSION_TYPE;
+
+typedef struct _NPS_CopyInfoMsg {
+ CopyInfoStr m_cSourcePath; // Source path
+ CopyInfoStr m_cDestinationPath; // Destination path
+ ENPS_Archivetype m_eArchiveType; // Compression or DeCompression
+ LOGGERSERVICE_COMPRESSION_TYPE m_eCompressionType; // Check for Compression of the file
+} NSP_CopyInfoCmd;
+
+typedef struct _NPS_CopyStatus {
+ BOOL m_bPersistenceChk; // Persistence Success or Failure
+ LOGGERSERVICE_COMPRESSION_TYPE m_eCompressionType; // Check for Compression of the file
+} NSP_CopyStatusResponse, NSP_CopyCancel;
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_TYPES_H_
diff --git a/systemservice/logger_service/server/include/ss_logger_util.h b/systemservice/logger_service/server/include/ss_logger_util.h
new file mode 100755
index 0000000..a49e022
--- /dev/null
+++ b/systemservice/logger_service/server/include/ss_logger_util.h
@@ -0,0 +1,127 @@
+/*
+ * @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_SS_LoggerService
+/// \brief Provide support for SS Logger module utility functions.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_UTIL_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_UTIL_H_
+
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+
+#include <time.h>
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_system_manager_if.h>
+#include <string>
+#include <vector>
+#include "ss_logger_error_event_cfg.h"
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_cfg.h"
+///////////////////////////////////////////////////////////////////////////////
+// DEFINE
+///////////////////////////////////////////////////////////////////////////////
+// If you changed BUF_MAX_SIZE, To contact the secure team.
+// Because There is impact for decrypt tool.
+#define BUF_MAX_SIZE (1024*8)
+#define USB_PATH_SIZE 64
+#ifdef RELEASE_BUILD
+#define DEV_ENC_EXTENSION ".enc1"
+#define REL_ENC_EXTENSION ".enc2"
+#define ALIGNMENT_SIZE 4
+#endif // RELEASE_BUILD
+#define LOGGER_TMP_FN "__LOGGER.tmp"
+
+///////////////////////////////////////////////////////////////////////////////
+// CONFIGURATION CLASS DEFINITION
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _ELoggerserviceLogType {
+ eLoggerservicelogTypeNormal,
+ eLoggerservicelogTypeAbnormal,
+ eLoggerservicelogTypeGrpRelaunch,
+ eLoggerservicelogTypeOther,
+} ELOGGERSERVICELOGTYPE;
+
+class CLoggerUtil {
+ public:
+ CLoggerUtil(void);
+
+ ~CLoggerUtil(void);
+
+ EFrameworkunifiedStatus Initialize(CLoggerCfg *f_pLoggerCfg);
+
+ EFrameworkunifiedStatus checkDestinationAvailable(TLoggerErrorEvent &f_eventNtfData); // NOLINT (runtime/references)
+ std::string getDestination(TLoggerErrorEvent &f_eventNtfData); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus getFilePathAndName(HANDLE f_hApp,
+ TLoggerErrorEvent &f_eventNtfData, // NOLINT (runtime/references)
+ uint32_t f_time, std::string &f_pathAndName); // NOLINT (runtime/references)
+ void SetMilage(UI_32 f_milage);
+
+ EFrameworkunifiedStatus getEmmcNaviLogParams(uint32_t f_time,
+ EPWR_SHUTDOWN_TRIGGER_TYPE errorType,
+ std::string &f_pathAndName, UI_32 &f_logMax); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus deleteOldLog(std::string log_path,
+ std::vector<std::string> &l_vector, // NOLINT (runtime/references)
+ std::string &f_archive_destination, UI_32 max_num); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus deleteOldEmmcLog(std::string &f_archive_destination, // NOLINT (runtime/references)
+ EErrorEventType type);
+ static EFrameworkunifiedStatus forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size);
+ static size_t deleteRequestLogs(std::string f_emmcpath, ELOGGERSERVICELOGTYPE f_reqtype,
+ size_t f_reqsize, ELOGGERSERVICELOGTYPE f_deltype);
+ static EFrameworkunifiedStatus CopyFile(std::string f_source, std::string f_destination);
+ static EFrameworkunifiedStatus CopyUntyped(std::string f_source,
+ std::string f_destination);
+ static EFrameworkunifiedStatus CopyDirectory(std::string f_source,
+ std::string f_destination);
+
+ static EFrameworkunifiedStatus MoveFile(std::string f_source, std::string f_destination);
+ static EFrameworkunifiedStatus MoveUntyped(std::string f_source,
+ std::string f_destination);
+ static EFrameworkunifiedStatus MoveDirectory(std::string f_source,
+ std::string f_destination);
+
+ static ELOGGERSERVICELOGTYPE QueryLoggerservicelogType(std::string f_logname);
+ static void SyncDir(std::string f_dir_path);
+#ifdef RELEASE_BUILD
+ static EFrameworkunifiedStatus PathCheckAndCopyFile(std::string f_source,
+ std::string f_destination);
+#endif // RELEASE_BUILD
+ void SetUsbMountPath(std::string usbpath);
+
+ private:
+ std::string GetUserInvokedFilename(HANDLE f_hApp, uint32_t f_time);
+ std::string GetEmmcFilename(uint32_t f_time);
+ std::string GetEmmcErrorFilename(uint32_t f_time);
+ std::string GetEmmcNaviLogFilename(uint32_t f_time);
+ std::string GetTimeString(uint32_t f_time);
+
+ EFrameworkunifiedStatus getNaviLogFilePathAndName(std::string &f_prefix, uint32_t f_time, // NOLINT (runtime/references)
+ std::string &f_pathAndName); // NOLINT (runtime/references)
+
+ CLoggerCfg *m_pCfg;
+ UI_32 m_Milage;
+ UI_32 m_bootCount;
+ static char m_usbpath[USB_PATH_SIZE];
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_UTIL_H_
+
diff --git a/systemservice/logger_service/server/lib/Makefile b/systemservice/logger_service/server/lib/Makefile
new file mode 100755
index 0000000..fff8c36
--- /dev/null
+++ b/systemservice/logger_service/server/lib/Makefile
@@ -0,0 +1,62 @@
+#
+# @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.
+#
+
+######### installed program #############
+
+
+######### installed library(*.a) #############
+INST_LIBS = libSS_LoggerStoreLogs
+
+######### installed shared library(*.so) #############
+
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+libSS_LoggerStoreLogs_SRCS += ss_logger_store_logs.cpp
+
+######### add source path #############
+
+
+######### add include path #############
+CPPFLAGS += -I./
+CPPFLAGS += -I../include
+
+CPPFLAGS += -Wl,--no-undefined
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+######### add compile option #############
+CPPFLAGS += -DLINUX
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30
+CPPFLAGS += -fno-exceptions
+
+######### linked library #############
+
+
+######### linked library (dynamic) #############
+
+
+######### add library path #############
+LDFLAGS += -g -shared
+LDFLAGS += -Wl,--no-as-needed
+include ../../../system_service.mk
diff --git a/systemservice/logger_service/server/lib/ss_logger_store_logs.cpp b/systemservice/logger_service/server/lib/ss_logger_store_logs.cpp
new file mode 100755
index 0000000..2bd8b79
--- /dev/null
+++ b/systemservice/logger_service/server/lib/ss_logger_store_logs.cpp
@@ -0,0 +1,2233 @@
+/*
+ * @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_SystemServices_Logger
+/// \brief This file supports the logger service interface for SystemManager.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "system_service/ss_logger_store_logs.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <libtar_listhash.h>
+#include <libtar.h>
+#include <zlib.h>
+#include <sys/klog.h>
+
+#include <stdlib.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_system_types.h>
+#include <native_service/ns_ringbuffer.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/cl_lockid.h>
+#include <stub/Clock_API.h>
+#include <vector>
+#include <sstream>
+#include <iomanip>
+#include <string>
+#include <algorithm>
+#include "ss_logger_store_logs_loggerservicelog.h"
+#include "ss_logger_cfg.h"
+
+#define LOGGERSERVICELOG_CONFIG_PATH "/usr/agl/conf/BS/ss/logger_service/rodata/ss_logger.cfg"
+#define LOGGER_TMP_FN "__LOGGER.tmp"
+#define LOGGERSERVICELOG_TMP_OUTPUT_PATH "/tmp"
+#define PSTORE_DIR_PATH "/dev/pstore"
+#define KERNEL_BOOT_LOG_FN "kernelboot.log"
+#define KERNEL_LOG_FN "kernel.log"
+#define COMMUNICATION_DIR_NAME "communication"
+#define ACCOFFON_DIR_NAME "accoffon"
+
+#define PATHNAME_SEPARATOR '/'
+#define PATHNAME_SEPARATOR_STR "/"
+#define SS_STORE_FILENAME_SYSILG_TERM "_SYS_ILG_RESET.tar.gz"
+#define SS_STORE_FILENAME__CWORD52__TERM "__CWORD52_.log"
+#define LOGARCHIVE_FILENAME_STORE_ARCHIVE "/tmp/ss_logger_ilgfilenum"
+#define TMPFILE_MODE 0640
+#define SSLOGGER_PATHNAME (255 + 1)
+#define FILENUMBER_UPPER_LIMIT_OVER 100000u
+#define FILENUMBER_LOWER_LIMIT 1u
+#define FILENUMBER_DIGIT_NUM 5
+#define INVALID_FILENUMBER (FILENUMBER_UPPER_LIMIT_OVER)
+
+
+/* Read all messages remaining in the ring buffer. (allowed for non-root) */
+#define SYSLOG_ACTION_READ_ALL 3
+/* Return size of the log buffer */
+#define SYSLOG_ACTION_SIZE_BUFFER 10
+
+#define ENABLE_DEBUG_LOG 0
+#if ENABLE_DEBUG_LOG
+#define DEB_LOGGERSERVICELOG(zone,funcname,print_fmt, ...) if(zone!=ZONE_FUNC) \
+fprintf(stderr,"%d/%s/%d:="print_fmt"\n", zone, funcname, __LINE__,##__VA_ARGS__)
+#else
+#define DEB_LOGGERSERVICELOG(zone,funcname,print_fmt, ...)
+#endif
+
+typedef struct {
+ std::string output_path;
+ SI_32 output_max;
+ SI_32 output_errmax;
+ SI_32 external_log_num;
+ SI_32 external_log_max;
+} CfgInfo;
+
+typedef struct {
+ std::string file_path;
+ std::string dest_name;
+ BOOL tmp_file_delete;
+} LogInfo;
+
+typedef struct {
+ std::string path;
+ int index;
+} LoggerservicelogInfo;
+
+
+static const char* sys_illegal_log[] = {
+ "frameworkunified_sys.log",
+ };
+
+
+typedef enum {
+ SS_STORELOGS_KERNEL_LOG = 0,
+ SS_STORELOGS_KERNEL_BOOT_LOG
+} SS_STORELOGS_KERNEL_LOG_TYPE;
+
+typedef void (*GetLogFileFunc)(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+
+static const UI_8 MAX_DIRECTORY_DEPTH = 4;
+static const UI_32 TARMODE = 0644;
+
+static EFrameworkunifiedStatus addToArchive(TAR* f_pTarInfo, std::string f_filePathAndName,
+ std::string f_destinationName, UI_8 f_depth =
+ MAX_DIRECTORY_DEPTH);
+static EFrameworkunifiedStatus addDirectoryToArchive(TAR* f_pTarInfo, std::string f_path,
+ std::string f_destinationName,
+ UI_8 f_depth = MAX_DIRECTORY_DEPTH);
+static SI_32 gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode);
+static SI_32 gzCloseArchive();
+static ssize_t gzWriteArchive(int fd, const void* buf, size_t count);
+static ssize_t gzReadArchive(int fd, void* buf, size_t count);
+static EFrameworkunifiedStatus addFileToArchive(TAR* f_pTarInfo, std::string f_filename,
+ std::string f_destinationName);
+static EFrameworkunifiedStatus addAllFileToArchive (TAR* f_pTarInfo, std::string collectDir);
+static EFrameworkunifiedStatus copyFile(std::string f_source, std::string f_destination);
+static EFrameworkunifiedStatus copyDirectory (std::string f_source, std::string f_destination);
+static EFrameworkunifiedStatus copyUntyped (std::string f_source, std::string f_destination);
+static EFrameworkunifiedStatus copyFileToAccOffOnDir(std::vector<LogInfo>& list, SS_STORELOGS_OPE_TYPE type);
+static void getLoggerservicelogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list, // NOLINT (runtime/references)
+ std::vector<LoggerservicelogInfo> &loggerservicelogList); // NOLINT (runtime/references)
+static void getKernellogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getLastKernelLog(std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getKernelLog(std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getKernelBootLog(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getCommunicationlogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getExternallogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+
+//static std::string getFileName(std::string &path, uint32_t f_time, // NOLINT (runtime/references)
+// SS_STORELOGS_OPE_TYPE type);
+static std::string getFileName(std::string &path, uint32_t f_time, // NOLINT (runtime/references)
+ SS_STORELOGS_OPE_TYPE type, UI_32 l_counter);
+
+static void getEmmcCounter(std::string &path, UI_32& f_counter); // NOLINT (runtime/references)
+static void getConfigInfo(CfgInfo& f_cfginfo); // NOLINT (runtime/references)
+static EFrameworkunifiedStatus deleteOldEmmcLog(CfgInfo& f_cfginfo, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ SS_STORELOGS_OPE_TYPE type);
+static EFrameworkunifiedStatus storeLogs(SS_STORELOGS_OPE_TYPE type);
+static EFrameworkunifiedStatus deleteOldLog(std::string log_path,
+ std::vector<std::string>& l_vector, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ UI_32 max_num);
+static size_t deleteRequestLogs(std::string f_emmcpath, ELOGGERSERVICELOGTYPE f_reqtype,
+ size_t f_reqsize, ELOGGERSERVICELOGTYPE f_deltype);
+static EFrameworkunifiedStatus forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size);
+static ELOGGERSERVICELOGTYPE QueryLoggerservicelogType(std::string f_logname);
+static void SyncDir(std::string f_dir_path);
+static BOOL RemoveSubDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+static void CreateSaveFinFlag(SS_STORELOGS_OPE_TYPE type);
+static void ClearLoggerservicelogBuffer(std::vector<LoggerservicelogInfo> &loggerservicelogList); // NOLINT (runtime/references)
+static void copyLoggerservicelogFile(std::string distPath);
+static void deleteTmpAccOffOn(std::string accOffOnDir);
+static void deleteAccOffOnDir(std::string deletePath);
+static void deleteAccOffOnUntyped(std::string deletePath);
+
+static EFrameworkunifiedStatus getFileNumber(const std::string &filename,UI_32 &number);
+static bool compareFileNumber(UI_32 filename1_number,const std::string &filename2);
+static EFrameworkunifiedStatus removeFiles(const std::string &log_path, std::vector<std::string> &l_vector,
+ size_t begin_pos, size_t end_pos);
+static EFrameworkunifiedStatus removeSameNumFiles(std::vector<std::string>::iterator &itr, const std::string &log_path,
+ std::vector<std::string> &l_vector);
+static EFrameworkunifiedStatus deleteOldLogAbnrm(const std::string& log_path, std::vector<std::string>& l_vector,
+ const std::string& f_archive_destination, SI_32 max_num, UI_32 abnrm_total);
+static EFrameworkunifiedStatus storeTempArchive(const std::string &real_name);
+static EFrameworkunifiedStatus getFileNumberFromTempArchive(UI_32 &filenumber);
+
+
+static std::string m_pathAndName; // NOLINT (runtime/string)
+static std::string m_tmpName; // NOLINT (runtime/string)
+
+const GetLogFileFunc GetLogFuncTbl[] = { getKernellogFile,
+ getCommunicationlogFile,
+ getExternallogFile
+ };
+// GZF save variables
+static gzFile g_gztype;
+
+// ->Bus-Error avoidance
+static tartype_t l_gztype;
+
+static EFrameworkunifiedStatus openArchive(TAR** f_pTarInfo, std::string f_pathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+// ->Bus-Error avoidance (because of local variables, content becomes indeterminate when functions exit)
+// tartype_t l_gztype;
+
+ *f_pTarInfo = NULL;
+ g_gztype = NULL;
+ l_gztype.openfunc = (openfunc_t) &gzOpenArchive;
+ l_gztype.closefunc = (closefunc_t) &gzCloseArchive;
+ l_gztype.readfunc = (readfunc_t) &gzReadArchive;
+ l_gztype.writefunc = (writefunc_t) &gzWriteArchive;
+
+ m_pathAndName = f_pathAndName;
+
+ /* check if directory exists */
+ size_t l_found = f_pathAndName.find_last_of('/');
+ std::string l_path = f_pathAndName.substr(0, l_found);
+
+ if (0 != access(l_path.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Directory does not exist. Creating...");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ /* create archive in tmp */
+ m_tmpName = "/tmp/log.tar.gz";
+
+ int l_tarRetVal = tar_open(f_pTarInfo, const_cast<char*>(m_tmpName.c_str()), &l_gztype,
+ O_WRONLY | O_CREAT, TARMODE, TAR_GNU);
+
+ if ((l_tarRetVal != 0) || (*f_pTarInfo == NULL) || g_gztype == NULL) { // LCOV_EXCL_BR_LINE 6: tar_open must return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: tar_open must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open TAR-Archive!");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static EFrameworkunifiedStatus addToArchive(TAR* f_pTarInfo, std::string f_filePathAndName,
+ std::string f_destinationName, UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFileLoadError;
+ struct stat l_stat;
+ int l_statRetVal;
+
+ if (0 != access(f_filePathAndName.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_filePathAndName.c_str());
+ } else if (0 != (l_statRetVal = stat(f_filePathAndName.c_str(), &l_stat))) { // LCOV_EXCL_BR_LINE 5: stat's error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: stat's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_filePathAndName.c_str(), l_statRetVal);
+ // LCOV_EXCL_STOP
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ if (0 < f_depth) { // LCOV_EXCL_BR_LINE 6: f_depth must be greater than 0
+ l_eFrameworkunifiedStatus = addDirectoryToArchive(f_pTarInfo, f_filePathAndName,
+ f_destinationName, f_depth);
+ } else {
+ // LCOV_EXCL_START 6: f_depth must be greater than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Maximum recursive depth reached! File %s not added to archive.",
+ f_filePathAndName.c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ char path[PATH_MAX];
+ if (realpath(f_filePathAndName.c_str(), path) != NULL) {
+ f_filePathAndName = path;
+ l_eFrameworkunifiedStatus = addFileToArchive(f_pTarInfo, f_filePathAndName,
+ f_destinationName);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Archive not opened or could not access file: \"%s\"",
+ f_filePathAndName.c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_filePathAndName.c_str(), l_stat.st_mode);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+
+static EFrameworkunifiedStatus getFileNumberFromTempArchive(UI_32 &filenumber)
+{
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ char buf[FILENUMBER_DIGIT_NUM + 1];
+ int fd;
+ int result;
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ fd = open(LOGARCHIVE_FILENAME_STORE_ARCHIVE, O_RDONLY);
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. open(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ return eFrameworkunifiedStatusAccessError;
+ }
+
+ result = read(fd, buf, FILENUMBER_DIGIT_NUM);
+ if (result != FILENUMBER_DIGIT_NUM) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. read(). path = %s ,result = %d, errno = %d",
+ LOGARCHIVE_FILENAME_STORE_ARCHIVE, result, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ } else {
+ char *endptr;
+ int error_number;
+ int temp_value;
+ buf[FILENUMBER_DIGIT_NUM] = '\x0';
+ errno = EOK;
+ temp_value = strtol(buf, &endptr, 10);
+ error_number = errno;
+ if ((error_number != EOK) || (*endptr != '\x0')) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. Failed to comvert string. source = %s ,errno = %d", buf, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ filenumber = temp_value;
+ }
+ }
+ result = close(fd);
+ if (result != 0) { // LCOV_EXCL_BR_LINE 6: close() must return ok
+ // LCOV_EXCL_START 6: close() must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. close(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ // LCOV_EXCL_STOP
+ }
+ result = remove(LOGARCHIVE_FILENAME_STORE_ARCHIVE);
+ if (result != 0) { // LCOV_EXCL_BR_LINE 6: remove() must return ok
+ // LCOV_EXCL_START 6: remove() must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. remove(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eFrameworkunifiedStatus;
+}
+
+static EFrameworkunifiedStatus storeTempArchive(const std::string &real_name)
+{
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string filename;
+ size_t pos;
+ int fd;
+ int result;
+ const char *p_real_filename;
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ fd = open(LOGARCHIVE_FILENAME_STORE_ARCHIVE, O_CREAT | O_WRONLY, TMPFILE_MODE);
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: open's error case
+ // LCOV_EXCL_START 5: open's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. open(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ return eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+
+ pos = real_name.find_last_of(PATHNAME_SEPARATOR);
+ if (pos == std::string::npos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in string real_name
+ // LCOV_EXCL_START 6: there must be '/' in string real_name
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ p_real_filename = real_name.c_str();
+ // LCOV_EXCL_STOP
+ } else {
+ p_real_filename = &real_name[pos + 1];
+ }
+
+ result = write(fd, p_real_filename, FILENUMBER_DIGIT_NUM);
+ if (result != FILENUMBER_DIGIT_NUM) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. write(). path = %s ,result = %d, errno = %d",
+ LOGARCHIVE_FILENAME_STORE_ARCHIVE, result, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+
+ result = close(fd);
+ if (result != 0) { // LCOV_EXCL_BR_LINE 5: close's error case
+ // LCOV_EXCL_START 5: close's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. close(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eFrameworkunifiedStatus;
+}
+
+
+
+//static EFrameworkunifiedStatus closeArchive(TAR* f_pTarInfo) {
+static EFrameworkunifiedStatus closeArchive(TAR* f_pTarInfo, SS_STORELOGS_OPE_TYPE type) {
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (0 != tar_append_eof(f_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_append_eof's error case
+ // LCOV_EXCL_START 5: tar_append_eof's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_append_eof()");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ if (0 != tar_close(f_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_close's error case
+ // LCOV_EXCL_START 5: tar_close's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not close archive");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eFrameworkunifiedStatus) { // LCOV_EXCL_BR_LINE 6: l_eFrameworkunifiedStatus must be eFrameworkunifiedStatusOK
+ l_eFrameworkunifiedStatus = copyFile(m_tmpName, m_pathAndName);
+ if (eFrameworkunifiedStatusOK == l_eFrameworkunifiedStatus) {
+
+ if (type == SS_STORELOGS_ILLEGAL) {
+ l_eFrameworkunifiedStatus = storeTempArchive(m_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eFrameworkunifiedStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. Failed to store temporary file.");
+ }
+ }
+
+ l_eFrameworkunifiedStatus =
+ (0 == remove(m_tmpName.c_str())) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFault;
+ if (eFrameworkunifiedStatusOK != l_eFrameworkunifiedStatus) { // LCOV_EXCL_BR_LINE 5: remove's error case
+ // LCOV_EXCL_START 5: remove's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN,
+ __FUNCTION__,
+ " Warning. Failed to remove temporary archive. Will overwrite on next event");
+ // LCOV_EXCL_STOP
+ }
+ } else if (eFrameworkunifiedStatusErrNoEAGAIN == l_eFrameworkunifiedStatus) { // LCOV_EXCL_BR_LINE 4: no space error case
+ // LCOV_EXCL_START 4: no space error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // disk space full
+ struct stat st_buf;
+ size_t req_size;
+ if (stat(m_tmpName.c_str(), &st_buf) != -1) {
+ req_size = st_buf.st_size;
+ if (eFrameworkunifiedStatusOK == forceDeleteOldLog(m_pathAndName, req_size)) {
+ l_eFrameworkunifiedStatus = copyFile(m_tmpName, m_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eFrameworkunifiedStatus) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Try Again but Error. Failed to copy to destination.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. force delete failed.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " emmc full: dest=%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Warning. Failed to get tmp log file stat. dest=%s",
+ m_pathAndName.c_str());
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ /* should we copy lost archive to emmc?? */
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed to copy to destination. %s", m_pathAndName.c_str());
+ }
+ remove(m_tmpName.c_str());
+ m_tmpName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static EFrameworkunifiedStatus addFileToArchive(TAR* f_pTarInfo, std::string f_filename,
+ std::string f_destinationName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK; /* check if Tar is open and if file can be read */
+
+ if ((NULL != f_pTarInfo) && (0 == access(f_filename.c_str(), R_OK))
+ && (0 != f_destinationName.length())) {
+ int l_tarRetVal = tar_append_file(f_pTarInfo, const_cast<char*>(f_filename.c_str()),
+ const_cast<char*>(f_destinationName.c_str()));
+ if (0 != l_tarRetVal) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not add file \'%s\' to tar archive.", f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Archive not opened or could not access file: \"%s\"",
+ f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static EFrameworkunifiedStatus addAllFileToArchive (TAR* f_pTarInfo, std::string collectDir)
+{
+ struct dirent l_pDirent;
+ struct dirent* next;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR * l_pDir = opendir(collectDir.c_str());
+ if (l_pDir == NULL) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s", collectDir.c_str());
+ } else {
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_fileSource = collectDir;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ std::string l_fileDestination = l_pDirent.d_name;
+ l_eStatus = addToArchive(f_pTarInfo,l_fileSource,l_fileDestination);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ break;
+ }
+ }
+ }
+ closedir (l_pDir);
+ }
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus addDirectoryToArchive(TAR* f_pTarInfo, std::string f_path,
+ std::string f_destinationName,
+ UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ DIR *l_pDir = opendir(f_path.c_str());
+ if (l_pDir != NULL) {
+ struct dirent* l_pDirent;
+ while ((l_pDirent = readdir(l_pDir)) != NULL) {
+ if ((0 != strcmp(l_pDirent->d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent->d_name, "..")) && /* Ignore special .. directory. */
+ ('.' != l_pDirent->d_name[0])) { /* Ignore hidden files */
+ std::string l_extension = "/";
+ std::string l_fileName = f_path;
+ std::string l_destName = f_destinationName;
+ l_extension.append(l_pDirent->d_name);
+ l_fileName.append(l_extension);
+ l_destName.append(l_extension);
+ l_eFrameworkunifiedStatus = addToArchive(f_pTarInfo, l_fileName, l_destName,
+ static_cast<UI_8>(f_depth - 1));
+ }
+ }
+ closedir(l_pDir);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static SI_32 gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SI_32 l_siFileDescriptor = -1;
+
+ if (f_pcPathname) {
+ PCHAR l_pcGzoflags;
+
+ switch (f_siOflags & O_ACCMODE) { // LCOV_EXCL_BR_LINE 200: only O_WRONLY be set
+ case O_WRONLY:
+ l_pcGzoflags = (PCHAR) "wb";
+ break;
+ // LCOV_EXCL_START 200: only O_WRONLY be set
+ case O_RDONLY:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_pcGzoflags = (PCHAR) "rb";
+ break;
+ // LCOV_EXCL_STOP
+ case O_RDWR:
+ default:
+ return -1;
+ }
+ if (-1 == (l_siFileDescriptor = open(f_pcPathname, f_siOflags, f_siMode))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ }
+
+ if ((f_siOflags & O_CREAT) && fchmod(l_siFileDescriptor, f_siMode)) {
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ }
+
+ g_gztype = gzdopen(l_siFileDescriptor, l_pcGzoflags);
+ if (!g_gztype) {
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path empty.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (SI_32) l_siFileDescriptor;
+}
+
+static SI_32 gzCloseArchive() {
+ return gzclose(g_gztype);
+}
+
+static ssize_t gzWriteArchive(int fd, const void* buf, size_t count) {
+ return gzwrite(g_gztype, const_cast<void*>(buf), (unsigned int) count);
+}
+
+static ssize_t gzReadArchive(int fd, void* buf, size_t count) {
+ return gzread(g_gztype, buf, (unsigned int) count);
+}
+
+static EFrameworkunifiedStatus copyFile(std::string f_source, std::string f_destination) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ssize_t l_nrd;
+ ssize_t l_nwr;
+ char l_buf[1024];
+
+ int l_if = open(f_source.c_str(), O_RDONLY | O_CLOEXEC);
+ if (-1 == l_if) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to open file: %s for reading.", f_source.c_str());
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ std::string l_tmpDest;
+ size_t l_pos = f_destination.find_last_of('/');
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in string f_destination
+ l_tmpDest = f_destination.substr(0, l_pos);
+ l_tmpDest.append("/");
+ l_tmpDest.append(LOGGER_TMP_FN);
+ if (unlink(l_tmpDest.c_str()) != 0) {
+ // always delete tmpLog, and create new tmpLog.
+ }
+ } else {
+ // LCOV_EXCL_START 6: there must be '/' in string f_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_tmpDest = f_destination;
+ // LCOV_EXCL_STOP
+ }
+
+ int l_of = open(l_tmpDest.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
+ 0640);
+ if (-1 == l_of) { // LCOV_EXCL_BR_LINE 5: open's error case
+ // LCOV_EXCL_START 5: open's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest open fail:%s,errno:%d,msg:%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ do {
+ l_nrd = read(l_if, l_buf, sizeof(l_buf));
+ if (l_nrd == -1) { // LCOV_EXCL_BR_LINE 5: read's error case
+ // LCOV_EXCL_START 5: read's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "read fail:%s,errno:%d,msg:%s",
+ f_source.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ l_nwr = write(l_of, l_buf, l_nrd);
+ if (l_nwr == -1) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (ENOSPC == errno) { // LCOV_EXCL_BR_LINE 4: no space error case
+ // LCOV_EXCL_START 4: no space error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "write fail(ENOSPC):%s,errno:%d,msg:%s", l_tmpDest.c_str(),
+ errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusErrNoEAGAIN;
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "write fail:%s,errno:%d,msg%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ break;
+ // LCOV_EXCL_STOP
+ }
+ } while (l_nrd > 0);
+ fsync(l_of);
+ close(l_of);
+ }
+ close(l_if);
+
+ if (rename(l_tmpDest.c_str(), f_destination.c_str()) != 0) { // LCOV_EXCL_BR_LINE 5: rename's error case
+ // LCOV_EXCL_START 5: rename's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "rename %s to %s fail,errno:%d,msg:%s",
+ l_tmpDest.c_str(), f_destination.c_str(), errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in string f_destination
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ } else {
+ // LCOV_EXCL_START 6: there must be '/' in string f_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest invalid:%s", f_destination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+static EFrameworkunifiedStatus copyDirectory (std::string f_source, std::string f_destination)
+{
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ DIR * l_pDir = opendir(f_source.c_str());
+ if (l_pDir == NULL) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s", f_source.c_str());
+ } else {
+ if (mkdir(f_destination.c_str(),0775) == -1) {
+ if (errno == EEXIST) {
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "Directory: %s already exists.", f_destination.c_str());
+ } else {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not create directory: %s. Errno: %s", f_destination.c_str(),strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ SyncDir(f_destination);
+ size_t l_pos = f_destination.find_last_of('/');
+ if (l_pos != std::string::npos) {
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ }
+ }
+
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_fileSource = f_source;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ l_eStatus = copyUntyped(l_fileSource,l_fileDestination);
+ }
+ }
+ closedir (l_pDir);
+ }
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus copyUntyped (std::string f_source, std::string f_destination)
+{
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ struct stat l_stat;
+ SI_8 l_statRetVal;
+ if (0 != access(f_source.c_str(), F_OK)) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. The specified file path and name does not exist: %s", f_source.c_str());
+ } else if (0 != (l_statRetVal = lstat(f_source.c_str(), &l_stat))) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. stat() for file or directory returned error: %s -> %d", f_source.c_str(), l_statRetVal);
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ l_eStatus = copyDirectory(f_source, f_destination);
+ } else if (0 != S_ISLNK(l_stat.st_mode)) {
+ l_eStatus = copyDirectory(f_source, f_destination);
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ l_eStatus = copyFile(f_source, f_destination);
+ } else {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",f_source.c_str(),l_stat.st_mode);
+ }
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus copyFileToAccOffOnDir(std::vector<LogInfo>& list, SS_STORELOGS_OPE_TYPE type)
+{
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ std::string f_destination = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ f_destination.append("/");
+ f_destination.append(ACCOFFON_DIR_NAME);
+ DIR * l_pDir = opendir(LOGGERSERVICELOG_TMP_OUTPUT_PATH);
+ if (l_pDir == NULL) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s", LOGGERSERVICELOG_TMP_OUTPUT_PATH);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ return l_eStatus;
+ } else {
+ closedir (l_pDir);
+ if (mkdir(f_destination.c_str(), 0775) == -1) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not create directory: %s. Errno: %s", f_destination.c_str(),strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ return l_eStatus;
+ }
+ } if (list.size() != 0) {
+ for (UI_32 j = 0; j < list.size(); j++) {
+ std::string dest_name = f_destination;
+ dest_name.append("/");
+ dest_name.append(list.at(j).dest_name);
+ l_eFrameworkunifiedStatus = copyUntyped(list.at(j).file_path, dest_name);
+ if (l_eFrameworkunifiedStatus != eFrameworkunifiedStatusOK) {
+ DEB_LOGGERSERVICELOG(ZONE_WARN, __FUNCTION__, " Error. File %s failed to archive.", list.at(j).file_path.c_str());
+ l_eStatus = l_eFrameworkunifiedStatus;
+ }
+ }
+ copyLoggerservicelogFile(f_destination);
+ }
+ return l_eStatus;
+}
+
+ELOGGERSERVICELOGTYPE QueryLoggerservicelogType(std::string f_logname) {
+// if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+ if (f_logname.find(SS_STORE_FILENAME_SYSILG_TERM) != std::string::npos) {
+ return eLoggerservicelogTypeSysAbnormal;
+ } else if (f_logname.find(SS_STORE_FILENAME__CWORD52__TERM) != std::string::npos) {
+ return eLoggerservicelogType_CWORD52_;
+ } else if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+
+ || f_logname.find("_ERR.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find("_GRP_RELAUNCH.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeGrpRelaunch;
+ } else if (f_logname.find(".tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeNormal;
+ } else {
+ return eLoggerservicelogTypeOther;
+ }
+}
+
+void SyncDir(std::string f_dir_path) {
+ int fd = open(f_dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+#define OPE_ERR_MSG "%s %s failed. errno:%d,msg:%s"
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "open",
+ errno, strerror(errno));
+ } else {
+ if (fsync(fd) == -1) { // LCOV_EXCL_BR_LINE 5: fsync's error case
+ // LCOV_EXCL_START 5: fsync's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "fsync",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ if (close(fd) == -1) { // LCOV_EXCL_BR_LINE 5: close's error case
+ // LCOV_EXCL_START 5: close's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "close",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+#undef OPE_ERR_MSG
+}
+
+// LCOV_EXCL_START 4: no space error case
+size_t deleteRequestLogs(std::string f_emmcpath, ELOGGERSERVICELOGTYPE f_reqtype,
+ size_t f_reqsize, ELOGGERSERVICELOGTYPE f_deltype) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR* l_dirp = NULL;
+ std::vector<std::string> vect;
+ std::vector<std::string>::iterator it;
+ UI_32 l_count = 0;
+ size_t l_totalsize = 0;
+
+ ELOGGERSERVICELOGTYPE filetype;
+
+
+ // create saved file list on eMMC
+ l_dirp = opendir(f_emmcpath.c_str());
+ if (l_dirp != NULL) {
+ struct dirent l_dirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_filename = l_dirent.d_name;
+
+// if (QueryLoggerservicelogType(l_filename) == f_deltype) {
+// vect.push_back(l_filename);
+// }
+ if ((l_filename == ".") && (l_filename == "..")) {
+ continue;
+ }
+ filetype = QueryLoggerservicelogType(l_filename);
+ if (f_deltype == eLoggerservicelogTypeAbnormal) {
+ if ((filetype == eLoggerservicelogTypeAbnormal) || (filetype == eLoggerservicelogTypeSysAbnormal) ||
+ (filetype == eLoggerservicelogType_CWORD52_)) {
+ vect.push_back(l_filename);
+ }
+ } else if (filetype == f_deltype) {
+ vect.push_back(l_filename);
+ }
+
+ }
+ closedir(l_dirp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " open failed eMMC path: %s",
+ f_emmcpath.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return 0;
+ }
+
+ // get num of delete logs
+ std::sort(vect.begin(), vect.end());
+ for (it = vect.begin(); it != vect.end(); it++) {
+ l_count++;
+
+ std::string l_filename = *it;
+ struct stat st_buf;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (stat(l_tmpstr.c_str(), &st_buf) != -1) {
+ l_totalsize += st_buf.st_size;
+ }
+
+ if (l_totalsize > f_reqsize) {
+ break;
+ }
+ }
+
+ // start delete logs
+ if ((l_totalsize > f_reqsize) || (f_reqtype == eLoggerservicelogTypeAbnormal)
+ || (f_reqtype == eLoggerservicelogTypeGrpRelaunch)) {
+ for (it = vect.begin(); it != vect.end() && l_count > 0; it++) {
+ l_count--;
+
+ std::string l_filename = *it;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (unlink(l_tmpstr.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d,msg:%s",
+ l_tmpstr.c_str(), errno, strerror(errno));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " del-file=%s total=%d", l_tmpstr.c_str(),
+ l_totalsize);
+ }
+
+ if (f_reqtype == eLoggerservicelogTypeAbnormal) {
+ removeSameNumFiles(it, f_emmcpath, vect);
+ }
+
+ SyncDir(f_emmcpath);
+ } else {
+ l_totalsize = 0;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ " nothing to delete logs req-type=%d del-logtype=%d total=%d, log_count=%d",
+ f_reqtype, f_deltype, l_totalsize, l_count);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_totalsize;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 4: no space error case
+EFrameworkunifiedStatus forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string l_emmc_path;
+ size_t l_delsize = 0;
+ ELOGGERSERVICELOGTYPE l_logtype = eLoggerservicelogTypeOther;
+
+ size_t l_pos = f_archive_destination.find_last_of('/');
+ if (std::string::npos != l_pos) {
+ l_emmc_path = f_archive_destination.substr(0, l_pos);
+ l_emmc_path.append("/");
+ l_logtype = QueryLoggerservicelogType(
+ f_archive_destination.substr(l_pos + 1,
+ f_archive_destination.size() - l_pos + 1));
+
+ if ((l_logtype == eLoggerservicelogTypeSysAbnormal) || (l_logtype == eLoggerservicelogType_CWORD52_)) {
+ l_logtype = eLoggerservicelogTypeAbnormal;
+ }
+
+ }
+
+ if (l_logtype == eLoggerservicelogTypeOther) {
+ // not found
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Invalid Parameter. dest=%s",
+ f_archive_destination.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ // remove dirty-file if exist
+ if (unlink(f_archive_destination.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d.",
+ f_archive_destination.c_str(), errno);
+ }
+
+ // delete normal log
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, f_req_size,
+ eLoggerservicelogTypeNormal);
+ if (l_delsize >= f_req_size) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete normal logs success: req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (l_logtype == eLoggerservicelogTypeAbnormal) {
+ // delete abnormal log if request type is abnormal
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete abnormal logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeAbnormal);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete abnormal logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " abnormal log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else if (l_logtype == eLoggerservicelogTypeGrpRelaunch) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete group relaunch logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeGrpRelaunch);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete group relaunch logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " group relaunch log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " normal log del not complete. req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function SS_LoggerStoreDebugLogs
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SS_LoggerStoreLogs(SS_STORELOGS_OPE_TYPE type) {
+ if (type < SS_STORELOGS_MAX) {
+ return storeLogs(type);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. Bad enum number %d", type);
+ return eFrameworkunifiedStatusFail;
+ }
+}
+
+
+EFrameworkunifiedStatus SS_LoggerStoreLogs_deleteOldLogAbnrm(const std::string& log_path,
+ std::vector<std::string>& l_vector,
+ const std::string& f_archive_destination,
+ SI_32 max_num,
+ UI_32 abnrm_total) {
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus;
+ l_eFrameworkunifiedStatus = deleteOldLogAbnrm(log_path, l_vector, f_archive_destination, max_num, abnrm_total);
+ return l_eFrameworkunifiedStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsDirectory
+/// Method to check if the entity is a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+static BOOL IsDirectory(std::string &f_cPath) { // NOLINT (runtime/references)
+ BOOL l_bReturn = FALSE;
+ struct stat st_buf;
+
+ if (-1 == stat(f_cPath.c_str(), &st_buf)) { // LCOV_EXCL_BR_LINE 5: stat's error case // NOLINT (runtime/references) // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: stat's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: stat failed for path/file %s, errno %d", f_cPath.c_str(),
+ errno);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ // LCOV_EXCL_STOP
+ } else if (S_ISDIR(st_buf.st_mode)) {
+ l_bReturn = TRUE; // return true if f_cPath is a directory
+ }
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveDirectory
+/// Method to remove a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+static BOOL RemoveDirectory(std::string &f_cPath) { // NOLINT (runtime/references)
+ BOOL l_bReturn = FALSE;
+
+ if (RemoveSubDirectory(f_cPath)) { // LCOV_EXCL_BR_LINE 6: RemoveSubDirectory always return true
+ // delete the parent directory
+ if (0 == rmdir(f_cPath.c_str())) { // LCOV_EXCL_BR_LINE 5: rmdir's error case
+ l_bReturn = TRUE;
+ }
+ }
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveSubDirectory
+/// Method to remove a sub directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+static BOOL RemoveSubDirectory(std::string &f_cPath) { // NOLINT (runtime/references)
+ BOOL l_bReturn = TRUE;
+
+ if (!f_cPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cPath can't be empty
+ std::string l_cFilePath = "";
+ struct dirent l_Dirent;
+ struct dirent* next;
+ DIR *l_pDir = NULL;
+
+ l_pDir = opendir(f_cPath.c_str());
+ if (NULL != l_pDir) { // LCOV_EXCL_BR_LINE 5: opendir's error case
+ if ('/' != f_cPath[f_cPath.length() - 1]) { // LCOV_EXCL_BR_LINE 6: there must be no '/'
+ f_cPath.append("/");
+ }
+
+ while (0 == readdir_r(l_pDir, &l_Dirent, &next) && next != NULL) {
+ if (0 != std::strcmp(l_Dirent.d_name, ".")
+ && 0 != std::strcmp(l_Dirent.d_name, "..")
+ && 0 != std::strcmp(l_Dirent.d_name, "lost+found")) {
+ l_cFilePath.assign(f_cPath);
+ l_cFilePath.append(l_Dirent.d_name); // concatenate the strings to get the complete f_cPath
+ if (TRUE == IsDirectory(l_cFilePath)) {
+ l_bReturn = RemoveDirectory(l_cFilePath);
+ } else {
+ // it's a file, we can use unlink
+ if (unlink(l_cFilePath.c_str()) == -1) { // LCOV_EXCL_BR_LINE 5: unlink's error case
+ // LCOV_EXCL_START 5: unlink's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ closedir(l_pDir); // close the directory
+ SyncDir(f_cPath);
+ } else {
+ // LCOV_EXCL_START 5: opendir's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pDir is NULL");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cPath can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Pathname empty.");
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ return l_bReturn;
+}
+
+static void CreateSaveFinFlag(SS_STORELOGS_OPE_TYPE type) {
+ if (type == SS_STORELOGS_INTERFACEUNIFIEDLOG) {
+ int fd;
+ fd = open(SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG,
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. Create %s. errno %d msg :%s",
+ SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG, errno, strerror(errno));
+ } else {
+ fsync(fd);
+ close(fd);
+ std::string l_flagPath = SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG;
+ size_t l_pos = l_flagPath.find_last_of('/');
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in l_flagPath
+ std::string l_dirPath = l_flagPath.substr(0, l_pos);
+ SyncDir(l_dirPath);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "create saveflag finish.");
+ fprintf(stderr, "%s:Completed\n", __FUNCTION__);
+ }
+ }
+ }
+}
+
+static void deleteAccOffOnUntyped(std::string deletePath)
+{
+ struct stat l_stat;
+ SI_8 l_statRetVal;
+ if (0 != access(deletePath.c_str(), F_OK)) {
+ DEB_LOGGERSERVICELOG(ZONE_WARN, __FUNCTION__, "access error (%s)", deletePath.c_str());
+ } else if (0 != (l_statRetVal = lstat(deletePath.c_str(), &l_stat))) {
+ DEB_LOGGERSERVICELOG(ZONE_WARN, __FUNCTION__, "get stat error (%s)", deletePath.c_str());
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ deleteAccOffOnDir(deletePath);
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ unlink(deletePath.c_str());
+ }
+}
+
+static void deleteAccOffOnDir(std::string deletePath)
+{
+ DIR * l_pDir = opendir(deletePath.c_str());
+ if (l_pDir != NULL) {
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_deletePath = deletePath;
+ l_deletePath.append("/");
+ l_deletePath.append(l_pDirent.d_name);
+ deleteAccOffOnUntyped(l_deletePath);
+ }
+ }
+ closedir (l_pDir);
+ }
+ RemoveDirectory(deletePath);
+}
+
+static EFrameworkunifiedStatus storeLogs(SS_STORELOGS_OPE_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ std::string file_name;
+ std::vector<LogInfo> list;
+ std::vector<LoggerservicelogInfo> loggerservicelogList;
+ TAR* tar_info = NULL;
+ uint32_t time_info;
+ uint8_t status;
+ CfgInfo cfginfo;
+
+ UI_32 l_counter = INVALID_FILENUMBER;
+
+
+ // load ss_logger configuration file.
+ getConfigInfo(cfginfo);
+
+
+ if (type == SS_STORELOGS_SYS_ILLEGAL) {
+ if (getFileNumberFromTempArchive(l_counter) != eFrameworkunifiedStatusOK) {
+ // ------------------------------------ //
+ // no made ILG_RESET.tar.gz //
+ // when is abnormal logging count over. //
+ // ------------------------------------ //
+ return eFrameworkunifiedStatusOK;
+ }
+ }
+
+
+// Clock_getSystemTimeY2K38(&time_info, &status);
+
+// file_name = getFileName(cfginfo.output_path, time_info, type);
+//
+// // prepare log files for collectting
+// for (UI_32 i = 0; i < _countof(GetLogFuncTbl); i++) {
+// GetLogFuncTbl[i](type, list);
+// }
+ file_name = getFileName(cfginfo.output_path, time_info, type, l_counter);
+
+ if (type != SS_STORELOGS_SYS_ILLEGAL) {
+ // prepare log files for collectting
+ for (UI_32 i = 0; i < _countof(GetLogFuncTbl); i++) {
+ GetLogFuncTbl[i](type, list);
+ }
+ }
+
+ if (type == SS_STORELOGS_ACCOFFON) {
+ copyFileToAccOffOnDir(list, type);
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "- : FrameworkunifiedStatus = %d", l_eFrameworkunifiedStatus);
+ return l_eFrameworkunifiedStatus;
+ } else if (type != SS_STORELOGS_ACCOFFON_PRESS) {
+ // loggerservicelogList used with clear buffer
+ getLoggerservicelogFile(type, list, loggerservicelogList);
+ }
+
+ // ---------------------------------------------------------------- //
+ // Warning!!! Logs by using FRAMEWORKUNIFIEDLOG macro, are not saved from here!! //
+ // You can saved logs by FRAMEWORKUNIFIEDLOG after finished to clear buffer. //
+ // ---------------------------------------------------------------- //
+
+ if (list.size() != 0) {
+ // delete old archive before create new one.
+ deleteOldEmmcLog(cfginfo, file_name, type);
+
+ l_eFrameworkunifiedStatus = openArchive(&tar_info, file_name);
+ if (l_eFrameworkunifiedStatus == eFrameworkunifiedStatusOK) {
+ if (type == SS_STORELOGS_ACCOFFON_PRESS) {
+ std::string collectPath;
+ collectPath = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ collectPath.append("/");
+ collectPath.append(ACCOFFON_DIR_NAME);
+ if (0 != access(collectPath.c_str(), F_OK)) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. The specified file path and name does not exist: %s", collectPath.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ return l_eFrameworkunifiedStatus;
+ } else {
+ l_eFrameworkunifiedStatus = addAllFileToArchive(tar_info,collectPath);
+ }
+ } else {
+ for (UI_32 j = 0; j < list.size(); j++) {
+ l_eFrameworkunifiedStatus = addToArchive(tar_info, list.at(j).file_path, list.at(j).dest_name);
+ if(l_eFrameworkunifiedStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Error. File %s failed to archive.", list.at(j).file_path.c_str());
+ }
+ }
+ }
+
+// l_eFrameworkunifiedStatus = closeArchive(tar_info);
+ l_eFrameworkunifiedStatus = closeArchive(tar_info, type);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "finish archiving logs(%d)", type);
+
+ // when finish archiving, clear frameworkunifiedlog buffer.
+ if (type == SS_STORELOGS_ACCOFFON_PRESS) {
+ deleteTmpAccOffOn((std::string)ACCOFFON_DIR_NAME);
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "- : FrameworkunifiedStatus = %d", l_eFrameworkunifiedStatus);
+ return (l_eFrameworkunifiedStatus);
+ } else {
+ ClearLoggerservicelogBuffer(loggerservicelogList);
+ }
+
+ // create flag of archiving completed
+ CreateSaveFinFlag(type);
+
+ // -------------------------------------------- //
+ // You can save logs by FRAMEWORKUNIFIEDLOG macro from here. //
+ // -------------------------------------------- //
+ }
+
+ // remove temporary or unnecessary files.
+ for (UI_32 k = 0; k < list.size(); k++) {
+ if (list.at(k).tmp_file_delete == TRUE) {
+ struct stat l_stat;
+ if (0 != stat(list.at(k).file_path.c_str(), &l_stat)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Error. stat(%s) errno. %d",
+ list.at(k).file_path.c_str(), errno);
+ } else if (S_ISDIR(l_stat.st_mode)) {
+ RemoveDirectory(list.at(k).file_path);
+ } else {
+ if (0 != unlink(list.at(k).file_path.c_str())) { // LCOV_EXCL_BR_LINE 5: unlink's error case
+ // LCOV_EXCL_START 5: unlink's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Error. unlink(%s) errno. %d",
+ list.at(k).file_path.c_str(), errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : FrameworkunifiedStatus = %d", l_eFrameworkunifiedStatus);
+ return (l_eFrameworkunifiedStatus);
+}
+
+static void getCommunicationlogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(COMMUNICATION_DIR_NAME);
+ log_info.dest_name = COMMUNICATION_DIR_NAME;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getExternallogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ExternalLogList ext_log;
+ memset(&ext_log, 0, sizeof(&ext_log));
+
+ CNSConfigReader *l_pReaderCfg = new CNSConfigReader();
+
+ if (NULL == l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Unable to allocate CNSConfigReader object.");
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(LOGGERSERVICELOG_CONFIG_PATH))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_pReaderCfg->Parse(%s) returned: 0x%X", LOGGERSERVICELOG_CONFIG_PATH);
+ } else if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetInt("LOGGING.ExternalLogNum", ext_log.num))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_pReaderCfg->GetInt(LOGGING.ExternalLogNum)");
+ } else if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetInt("LOGGING.ExternalLogMax", ext_log.max))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_pReaderCfg->GetInt(LOGGING.EmmcOutputMax)");
+ } else {
+ if (ext_log.num > 0) {
+ std::string str = "EXTERNAL_";
+ UI_32 num = 0;
+
+ if (ext_log.num <= ext_log.max) {
+ num = ext_log.num;
+ } else {
+ num = ext_log.max;
+ }
+
+ ext_log.p_info = new ExternalLogInfo[num];
+
+ // Load external log info
+ for (UI_32 i = 0; i < num; i++) {
+ std::string query = str + std::to_string(i+1);
+ if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetString((query+".OutputPath"), ext_log.p_info[i].dirname))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_pReaderCfg->GetString(EXTERNAL.OutputPath)");
+ } else if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetString((query+".ExtLogPath"), ext_log.p_info[i].path))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_pReaderCfg->GetString(EXTERNAL.ExtLogPath)");
+ } else if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetBool((query+".Remove"), ext_log.p_info[i].remove))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_pReaderCfg->GetBool(EXTERNAL.Remove)");
+ } else {
+ LogInfo log_info;
+ log_info.file_path = ext_log.p_info[i].path;
+ log_info.dest_name = ext_log.p_info[i].dirname;
+ log_info.tmp_file_delete = ext_log.p_info[i].remove;
+
+ list.push_back(log_info);
+ }
+ }
+
+ delete[] ext_log.p_info;
+
+ } else {
+ // None external log
+ }
+ }
+ delete l_pReaderCfg;
+ }
+}
+
+
+
+
+static void getLoggerservicelogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list, // NOLINT (runtime/references)
+ std::vector<LoggerservicelogInfo>& loggerservicelogList) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+ std::string src_file_path;
+ std::string dst_file_path;
+ PCSTR file_name;
+ UI_32 file_num;
+ LogInfo log_info;
+ LoggerservicelogInfo loggerservicelog_info;
+
+ file_num = NSLogGetFrameworkunifiedlogFileTotalNum();
+ for (UI_32 cont = 0; cont < file_num; cont++) {
+ file_name = NSLogGetFrameworkunifiedlogFileName(cont);
+ if (file_name == NULL) {
+ break;
+ }
+ src_file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ src_file_path.append("/");
+ src_file_path.append(file_name);
+ dst_file_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ dst_file_path.append("/");
+ dst_file_path.append(file_name);
+
+ int index;
+ index = NSLogGetFrameworkunifiedlogIndex(src_file_path.c_str());
+ CNSRingBuffer* l_pLoggerservicelog = new (std::nothrow) CNSRingBuffer(
+ src_file_path, 0, index + LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s",
+ src_file_path.c_str());
+ continue;
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pLoggerservicelog->DumpToFile(dst_file_path.c_str(),
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer DumpToFile failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ } else {
+ log_info.file_path = dst_file_path;
+ log_info.dest_name = file_name;
+ log_info.tmp_file_delete = TRUE;
+ list.push_back(log_info);
+ // save frameworkunifiedlog-info for using clear frameworkunifiedlog buffer
+ loggerservicelog_info.path = src_file_path;
+ loggerservicelog_info.index = index;
+ loggerservicelogList.push_back(loggerservicelog_info);
+ }
+ (void) l_pLoggerservicelog->Close();
+ }
+ delete l_pLoggerservicelog;
+ }
+}
+
+static void copyLoggerservicelogFile(std::string distPath)
+{
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+ std::string src_file_path;
+ std::string dst_file_path;
+ PCSTR file_name;
+ UI_32 file_num;
+
+ file_num = NSLogGetFrameworkunifiedlogFileTotalNum();
+
+ for (UI_32 cont = 0; cont < file_num; cont++) {
+ file_name = NSLogGetFrameworkunifiedlogFileName(cont);
+
+ if (file_name == NULL) {
+ break;
+ }
+
+ src_file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ src_file_path.append("/");
+ src_file_path.append(file_name);
+
+ dst_file_path = distPath;
+ dst_file_path.append("/");
+ dst_file_path.append(file_name);
+
+ int index;
+ index = NSLogGetFrameworkunifiedlogIndex(src_file_path.c_str());
+ CNSRingBuffer* l_pLoggerservicelog = new (std::nothrow)CNSRingBuffer(src_file_path,0,index+LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s", src_file_path.c_str());
+ continue;
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,"Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d", src_file_path.c_str(), l_eStatus);
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->DumpToFile(dst_file_path.c_str(), &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,"Error: FRAMEWORKUNIFIEDLOG RingBuffer DumpToFile failed %s %d", src_file_path.c_str(), l_eStatus);
+ }
+ (void)l_pLoggerservicelog->Close();
+ }
+ delete l_pLoggerservicelog;
+ }
+}
+
+static void deleteTmpAccOffOn(std::string accOffOnDir)
+{
+ std::string l_tmpAccOffOnPath = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ l_tmpAccOffOnPath.append("/");
+ l_tmpAccOffOnPath.append(accOffOnDir.c_str());
+ DIR * l_pDir = opendir(l_tmpAccOffOnPath.c_str());
+ if (l_pDir != NULL) {
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_deletePath = l_tmpAccOffOnPath;
+ l_deletePath.append("/");
+ l_deletePath.append(l_pDirent.d_name);
+ deleteAccOffOnUntyped(l_deletePath);
+ }
+ }
+ closedir (l_pDir);
+ }
+ RemoveDirectory(l_tmpAccOffOnPath);
+}
+
+static void ClearLoggerservicelogBuffer(std::vector<LoggerservicelogInfo> &loggerservicelogList) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::vector<LoggerservicelogInfo>::iterator ite = loggerservicelogList.begin();
+
+ if (ite == loggerservicelogList.end()) {
+ // target not found...
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "nothing to clear");
+ } else {
+ for (ite = loggerservicelogList.begin(); ite != loggerservicelogList.end(); ite++) {
+ CNSRingBuffer* l_pLoggerservicelog = new (std::nothrow) CNSRingBuffer(
+ ite->path.c_str(), 0, ite->index + LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s", ite->path.c_str());
+ continue;
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d", ite->path.c_str(),
+ l_eStatus);
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->ClearBuf())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer ClearBuf failed %s %d",
+ ite->path.c_str(), l_eStatus);
+ }
+ (void) l_pLoggerservicelog->Close();
+ }
+ delete l_pLoggerservicelog;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Completed");
+ fprintf(stderr, "%s:Completed\n", __FUNCTION__);
+}
+
+static void createKernelLog(SS_STORELOGS_KERNEL_LOG_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ int len;
+ int fd;
+ char* buf;
+ ssize_t wr_len;
+
+ len = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
+ if (len < 0) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to get syslog buffer size: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ buf = reinterpret_cast<char*>(malloc(len));
+ if (buf != NULL) { // LCOV_EXCL_BR_LINE 5: malloc's error case
+ len = klogctl(SYSLOG_ACTION_READ_ALL, buf, len);
+ if ((len < 0) || (len == 0)) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to read syslog buffer: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ std::string file_put_path = "";
+
+ switch (type) {
+ case SS_STORELOGS_KERNEL_LOG:
+ file_put_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ file_put_path.append("/");
+ file_put_path.append(KERNEL_LOG_FN);
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ case SS_STORELOGS_KERNEL_BOOT_LOG:
+ file_put_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ file_put_path.append("/");
+ file_put_path.append(KERNEL_BOOT_LOG_FN);
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ default:
+ fd = -1;
+ break;
+ }
+
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to open file: %s: %d, %s",
+ file_put_path.c_str(), errno, strerror(errno));
+ } else {
+ wr_len = write(fd, buf, len);
+ if (wr_len == -1) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. File write failed. errno: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ fsync(fd);
+ close(fd);
+ }
+ }
+ free(buf);
+ } else {
+ // LCOV_EXCL_START 5: malloc's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation Failed %s",
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+static void getKernellogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ getLastKernelLog(list);
+
+ getKernelLog(list);
+
+ if (type != SS_STORELOGS_ACCOFFON) {
+ getKernelBootLog(type, list);
+ }
+}
+
+static void getLastKernelLog(std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ LogInfo log_info;
+
+ log_info.file_path = PSTORE_DIR_PATH;
+ log_info.dest_name = "kernellog";
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getKernelLog(std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ createKernelLog(SS_STORELOGS_KERNEL_LOG);
+
+ LogInfo log_info;
+
+ std::string klog_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ klog_path.append("/");
+ klog_path.append(KERNEL_LOG_FN);
+
+ if (0 == access(klog_path.c_str(), F_OK)) {
+ log_info.file_path = klog_path;
+ log_info.dest_name = KERNEL_LOG_FN;
+ log_info.tmp_file_delete = TRUE;
+ list.push_back(log_info);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Info: %s not found.", klog_path.c_str());
+ }
+}
+
+static void getKernelBootLog(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ createKernelLog(SS_STORELOGS_KERNEL_BOOT_LOG);
+
+ LogInfo log_info;
+
+ std::string klog_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ klog_path.append("/");
+ klog_path.append(KERNEL_BOOT_LOG_FN);
+
+ if (0 == access(klog_path.c_str(), F_OK)) {
+ std::string klog_out_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ klog_out_path.append("/");
+ klog_out_path.append(KERNEL_BOOT_LOG_FN);
+
+ if (eFrameworkunifiedStatusOK == copyFile(klog_path.c_str(), klog_out_path.c_str())) { // LCOV_EXCL_BR_LINE 6: copyFile must return ok // NOLINT[whitespace/line_length]
+ log_info.file_path = klog_out_path;
+ log_info.dest_name = KERNEL_BOOT_LOG_FN;
+ log_info.tmp_file_delete = TRUE;
+ list.push_back(log_info);
+ } else {
+ // LCOV_EXCL_START 6: copyFile must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Info: copyFile src:%s dest:%s failed.",
+ klog_path.c_str(), klog_out_path.c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Info: %s not found.", klog_path.c_str());
+ }
+}
+
+
+//static std::string getFileName(std::string &path, uint32_t f_time, // NOLINT (runtime/references)
+// SS_STORELOGS_OPE_TYPE type) {
+static std::string getFileName(std::string &path, uint32_t f_time,
+ SS_STORELOGS_OPE_TYPE type, UI_32 l_counter) {
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::stringstream l_nameStream;
+
+// UI_32 l_counter = 0;
+ std::string l_time_str = "00000000_000000";
+ std::string l_ret;
+ char buffer[20];
+ struct tm l_time_tmp;
+
+
+// getEmmcCounter(path, l_counter);
+ if (l_counter == INVALID_FILENUMBER) {
+ l_counter = 0;
+ getEmmcCounter(path, l_counter);
+ }
+
+
+// CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_time_tmp);
+// if (clock_ret == CLOCK_OK) {
+// if (0 != strftime(buffer, sizeof(buffer), "%Y%m%d_%H%M%S", &l_time_tmp)) {
+// l_time_str = buffer;
+// }
+// }
+
+// l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec
+// << l_counter << '_';
+ l_nameStream << std::setw(FILENUMBER_DIGIT_NUM) << std::setfill('0') << std::right << std::dec
+ << l_counter << '_';
+
+
+ switch (type) {
+ case SS_STORELOGS_ILLEGAL:
+ l_nameStream << std::setw(15) << l_time_str << "_ILG_RESET.tar.gz";
+ break;
+ case SS_STORELOGS_INTERFACEUNIFIEDLOG:
+ l_nameStream << std::setw(15) << l_time_str << "_ACCOFF.tar.gz";
+ break;
+ case SS_STORELOGS_ACCOFFON:
+ case SS_STORELOGS_ACCOFFON_PRESS:
+ l_nameStream << std::setw(15) << l_time_str << "_ACCOFFON.tar.gz";
+ break;
+
+ case SS_STORELOGS_SYS_ILLEGAL:
+ l_nameStream << std::setw(15) << l_time_str << SS_STORE_FILENAME_SYSILG_TERM;
+ break;
+
+ default:
+ //Set the file name as usual for cases other than the anomaly log specification.
+ l_nameStream << std::setw(15) << l_time_str << ".tar.gz";
+ break;
+ }
+
+ l_ret = path;
+ l_ret.append("/");
+ l_ret.append(l_nameStream.str());
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+static void getEmmcCounter(std::string &path, UI_32& f_counter) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_checkFileName;
+ std::vector<UI_32> l_vector;
+ DIR *l_dirp;
+ struct dirent *l_direntp;
+ size_t l_pos;
+ UI_32 l_count;
+ UI_32 l_maxCount = 0;
+
+ l_dirp = opendir(path.c_str());
+ if (l_dirp != NULL) {
+ for (;;) {
+ l_direntp = readdir(l_dirp);
+ if (l_direntp == NULL) {
+ break;
+ }
+ l_checkFileName = l_direntp->d_name;
+ l_pos = l_checkFileName.find(".tar.gz");
+ if (std::string::npos != l_pos) {
+ l_pos = l_checkFileName.find("_");
+ if (std::string::npos != l_pos) {
+ std::string l_numberString = l_checkFileName.substr(0, l_pos);
+ l_count = static_cast<UI_32>(strtoul(l_numberString.c_str(), NULL, 10));
+ l_vector.push_back(l_count);
+ l_maxCount = std::max(l_count, l_maxCount);
+ }
+ }
+ }
+ closedir(l_dirp);
+ }
+ l_maxCount++;
+
+// if (l_maxCount >= 100000u) {
+// l_maxCount = 1;
+ if (l_maxCount >= FILENUMBER_UPPER_LIMIT_OVER) {
+ l_maxCount = FILENUMBER_LOWER_LIMIT;
+
+ for (;;) {
+ std::vector<UI_32>::iterator find_itr = std::find(l_vector.begin(),
+ l_vector.end(),
+ l_maxCount);
+ if (find_itr == l_vector.end()) {
+ break;
+ }
+ l_maxCount++;
+ }
+ }
+ f_counter = l_maxCount;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+static void getConfigInfo(CfgInfo& f_cfginfo) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ f_cfginfo.output_path = "";
+ f_cfginfo.output_max = 0;
+
+ CNSConfigReader *l_pReaderCfg = new CNSConfigReader();
+
+ if (NULL == l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unable to allocate CNSConfigReader object.");
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(LOGGERSERVICELOG_CONFIG_PATH))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->Parse(%s) returned: 0x%X",
+ LOGGERSERVICELOG_CONFIG_PATH, l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetString("LOGGING.EmmcOutputPath",
+ f_cfginfo.output_path))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetString(LOGGING.EmmcOutputPath)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputMax",
+ f_cfginfo.output_max))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetInt(LOGGING.EmmcOutputMax)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputErrMax",
+ f_cfginfo.output_errmax))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetInt(LOGGING.EmmcOutputErrMax)");
+ }
+ delete l_pReaderCfg;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+static EFrameworkunifiedStatus deleteOldLog(std::string log_path,
+ std::vector<std::string>& l_vector, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ UI_32 max_num) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ size_t l_pos = f_archive_destination.find_last_of('/');
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: '/' must exist in f_archive_destination
+ std::sort(l_vector.begin(), l_vector.end());
+ std::vector<std::string>::iterator itr = l_vector.begin();
+ for (UI_32 i = static_cast<UI_32>(l_vector.size()); (max_num - 1) < i; i--, itr++) {
+ if (itr == l_vector.end()) { // LCOV_EXCL_BR_LINE 6: itr can't be l_vector.end()
+ // LCOV_EXCL_START 6: itr can't be l_vector.end()
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ break;
+ // LCOV_EXCL_STOP
+ }
+ std::string l_FilePath = log_path;
+ std::string l_FileName = *itr;
+ l_FilePath.append("/");
+ l_FilePath.append(l_FileName.c_str());
+ if (0 != unlink(l_FilePath.c_str())) {
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete old log file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ SyncDir(log_path);
+ } else {
+ // LCOV_EXCL_START 6: '/' must exist in f_archive_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete target not found. %s",
+ f_archive_destination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ return l_eStatus;
+}
+
+
+static EFrameworkunifiedStatus getFileNumber(const std::string &filename,UI_32 &number) {
+ char buf[16];
+ size_t pos;
+ size_t offset;
+ size_t length;
+ UI_32 temp_value;
+
+ offset = filename.find_last_of(PATHNAME_SEPARATOR) + 1;
+ pos = filename.find_first_of('_', offset);
+ length = pos-offset;
+ if (std::string::npos == pos) {
+ return eFrameworkunifiedStatusInvldParam;
+ } else if (sizeof(buf) <= length) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ char *endptr;
+ int error_number;
+
+ memcpy(buf, filename.c_str() + offset, length);
+ buf[length] = '\x0';
+
+ errno = EOK;
+ temp_value = strtol(buf, &endptr, 10);
+ error_number = errno;
+ if ((error_number != EOK) || (*endptr != '\x0')) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ number = temp_value;
+ return eFrameworkunifiedStatusOK;
+}
+
+static bool compareFileNumber(UI_32 filename1_number, const std::string &filename2) {
+ EFrameworkunifiedStatus l_eStatus;
+ bool result;
+ UI_32 filename2_number;
+
+ l_eStatus = getFileNumber(filename2, filename2_number);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ return false;
+ }
+ result = (filename1_number == filename2_number);
+ return result;
+}
+
+static EFrameworkunifiedStatus removeFiles(const std::string &log_path, std::vector<std::string> &l_vector,
+ size_t begin_pos, size_t end_pos) {
+ std::string l_FilePath;
+ size_t i;
+ int result;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_ePartStatus = eFrameworkunifiedStatusOK;
+ l_FilePath.reserve(SSLOGGER_PATHNAME);
+ for (i = begin_pos; i < end_pos; i++) {
+ l_FilePath = log_path + PATHNAME_SEPARATOR_STR + l_vector[i];
+ result = unlink(l_FilePath.c_str());
+ if (0 != result) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. unlink() filename = %s ,errno = %d.", l_FilePath.c_str(), errno);
+ l_ePartStatus = eFrameworkunifiedStatusAccessError;
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ }
+ }
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus removeSameNumFiles(std::vector<std::string>::iterator &itr, const std::string &log_path,
+ std::vector<std::string> &l_vector) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (l_vector.begin() == itr) { // LCOV_EXCL_BR_LINE 4: itr is l_vector.begin() only when no space error case
+ // LCOV_EXCL_START 4: itr is l_vector.begin() only when no space error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+ std::string &removed_filename = *(itr - 1);
+ UI_32 removed_filenumber;
+ if (getFileNumber(removed_filename, removed_filenumber) != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 6: double check, must return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: double check, must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning. Type mismatch filename. = %s", removed_filename.c_str());
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+
+ std::string l_FilePath;
+ EFrameworkunifiedStatus l_ePartStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int result;
+ for (;itr < l_vector.end(); itr++) {
+ const std::string &exist_filename = (*itr);
+ if (compareFileNumber(removed_filenumber, exist_filename) == true) {
+ l_FilePath = log_path + PATHNAME_SEPARATOR_STR + exist_filename;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Remove file = %s.", l_FilePath.c_str());
+ result = unlink(l_FilePath.c_str());
+ if (0 != result) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. unlink() filename = %s , errno = %d.", l_FilePath.c_str(), errno);
+ l_ePartStatus = eFrameworkunifiedStatusAccessError;
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ }
+ } else {
+ break;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus deleteOldLogAbnrm(const std::string& log_path, std::vector<std::string>& l_vector,
+ const std::string& f_archive_destination, SI_32 max_num, UI_32 abnrm_total) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ size_t l_pos = f_archive_destination.find_last_of(PATHNAME_SEPARATOR);
+ if (std::string::npos == l_pos) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete target not found. %s", f_archive_destination.c_str());
+ return eFrameworkunifiedStatusFail;
+ }
+ if (l_vector.size() == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. empty array.");
+ return eFrameworkunifiedStatusFail;
+ }
+ //FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " max_num = %d , vect_abnrm.size() = %d", max_num, vect_abnrm.size());
+
+ size_t i;
+ EFrameworkunifiedStatus l_ePartStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t end_pos = l_vector.size();
+ SI_32 abnrm_count = 0;
+ UI_32 exist_filenumber;
+ ELOGGERSERVICELOGTYPE filetype;
+
+ max_num = abnrm_total - max_num + 1;
+ std::sort(l_vector.begin(), l_vector.end());
+ for (i = 0; i < end_pos; i++) {
+ const std::string &exist_filename = l_vector[i];
+ if (getFileNumber(exist_filename, exist_filenumber) != eFrameworkunifiedStatusOK) {
+ continue;
+ }
+ filetype = QueryLoggerservicelogType(exist_filename);
+ if (filetype == eLoggerservicelogTypeAbnormal) {
+ abnrm_count++;
+ if (max_num <= abnrm_count) {
+ end_pos = i + 1;
+ break;
+ }
+ }
+ }
+ l_ePartStatus = removeFiles(log_path, l_vector, 0, end_pos);
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ if (end_pos < l_vector.size()) {
+ std::vector<std::string>::iterator itr = l_vector.begin() + end_pos;
+ l_ePartStatus = removeSameNumFiles(itr, log_path, l_vector);
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ }
+ SyncDir(log_path);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+
+static EFrameworkunifiedStatus deleteOldEmmcLog(CfgInfo& f_cfginfo, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ SS_STORELOGS_OPE_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR *l_dirp = NULL;
+ struct dirent *l_direntp = NULL;
+ std::vector<std::string> vect_abnrm;
+ std::vector<std::string> vect_nrm;
+ std::vector<std::string> vect_rlnc;
+ std::string l_emmc_path = f_cfginfo.output_path;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ UI_32 abnrm_count = 0;
+
+ if (SS_STORELOGS_SYS_ILLEGAL == type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+ }
+
+
+ l_dirp = opendir(l_emmc_path.c_str());
+ if (l_dirp != NULL) {
+ while ((l_direntp = readdir(l_dirp)) != NULL) {
+ std::string l_findFileName = l_direntp->d_name;
+
+// if ((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz"))
+// || (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+ if ((l_findFileName == ".") || (l_findFileName == "..")) {
+ continue;
+ } else if (std::string::npos != l_findFileName.find(SS_STORE_FILENAME_SYSILG_TERM)) {
+ vect_abnrm.push_back(l_findFileName);
+ } else if (std::string::npos != l_findFileName.find(SS_STORE_FILENAME__CWORD52__TERM)) {
+ vect_abnrm.push_back(l_findFileName);
+ } else if((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz")) ||
+ (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+
+ vect_abnrm.push_back(l_findFileName);
+
+ abnrm_count++;
+
+ } else if (std::string::npos
+ != l_findFileName.find("_GRP_RELAUNCH.tar.gz")) {
+ vect_rlnc.push_back(l_findFileName);
+ } else if (std::string::npos != l_findFileName.find(".tar.gz")) {
+ vect_nrm.push_back(l_findFileName);
+ }
+ }
+ closedir(l_dirp);
+ }
+
+ if (SS_STORELOGS_ILLEGAL == type) {
+ if ((UI_32) f_cfginfo.output_errmax <= vect_abnrm.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_abnrm, f_archive_destination,
+ (UI_32) f_cfginfo.output_errmax);
+ }
+ } else {
+ if ((UI_32) f_cfginfo.output_max <= vect_nrm.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_nrm, f_archive_destination,
+ (UI_32) f_cfginfo.output_max);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/systemservice/logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h b/systemservice/logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h
new file mode 100755
index 0000000..31d1caa
--- /dev/null
+++ b/systemservice/logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h
@@ -0,0 +1,96 @@
+/*
+ * @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_SystemServices_Logger
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_LIB_SS_LOGGER_STORE_LOGS_LOGGERSERVICELOG_H_
+#define LOGGER_SERVICE_SERVER_LIB_SS_LOGGER_STORE_LOGS_LOGGERSERVICELOG_H_
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR, ZONE_WARN, ZONE_FUNC
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern const CHAR AppName[];
+
+typedef enum _ELoggerserviceLogType {
+ eLoggerservicelogTypeNormal,
+ eLoggerservicelogTypeAbnormal,
+
+ eLoggerservicelogTypeSysAbnormal,
+ eLoggerservicelogType_CWORD52_,
+
+ eLoggerservicelogTypeGrpRelaunch,
+ eLoggerservicelogTypeOther,
+} ELOGGERSERVICELOGTYPE;
+
+#endif // LOGGER_SERVICE_SERVER_LIB_SS_LOGGER_STORE_LOGS_LOGGERSERVICELOG_H_
diff --git a/systemservice/logger_service/server/realtimeUsbLog/Makefile b/systemservice/logger_service/server/realtimeUsbLog/Makefile
new file mode 100755
index 0000000..420c13e
--- /dev/null
+++ b/systemservice/logger_service/server/realtimeUsbLog/Makefile
@@ -0,0 +1,22 @@
+#
+# @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.
+#
+
+
+SUBDIRS += work
+
+
+
+include ../../../system_service.mk
diff --git a/systemservice/logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin b/systemservice/logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin
new file mode 100755
index 0000000..440d361
--- /dev/null
+++ b/systemservice/logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin
@@ -0,0 +1,4 @@
+/usr/agl/bin|${OSW_reldbg}
+debug|dbg
+release|rel
+product|rel
diff --git a/systemservice/logger_service/server/realtimeUsbLog/src/Makefile b/systemservice/logger_service/server/realtimeUsbLog/src/Makefile
new file mode 100755
index 0000000..c3733b3
--- /dev/null
+++ b/systemservice/logger_service/server/realtimeUsbLog/src/Makefile
@@ -0,0 +1,74 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = realtimeUsbLog
+
+######### installed library(*.a) #############
+
+
+######### installed shared library(*.so) #############
+
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+realtimeUsbLog_SRCS += ss_logger_realtime_usb.cpp
+realtimeUsbLog_SRCS += loggerservice_main.cpp
+######### add source path #############
+VPATH += ../src
+
+######### add include path #############
+CPPFLAGS += -I./
+
+#CPPFLAGS += -I../inc
+#CPPFLAGS += -I../../inc
+CPPFLAGS += -I../../include
+CPPFLAGS += -I../../../../system_manager/server/include
+CPPFLAGS += -I../../../../system_manager/server/include/processlauncher
+
+
+######### add compile option #############
+CPPFLAGS += -DLINUX
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30
+######### linked library #############
+
+
+######### linked library (dynamic) #############
+#LDLIBS += -Wl,-Bdynamic -lxxx
+LDLIBS += -Wl,-Bdynamic -lcommon
+#LDLIBS += -Wl,-Bdynamic -lextension
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+
+LDLIBS += -Wl,-Bdynamic -lsssmcfg
+LDLIBS += -Wl,-Bdynamic -lresm
+LDLIBS += -Wl,-Bdynamic -lssver
+LDLIBS += -Wl,-Bdynamic -lSS_RomAccessIf
+#LDLIBS += -Wl,-Bdynamic -lDiagCodeAPI
+LDLIBS += -Wl,-Bdynamic -ltar -lz
+LDLIBS += -Wl,-Bdynamic -lrt
+
+
+######### add library path #############
+
+LDFLAGS += -g -Wl,--gc-sections
+
+LINK_CXX=Y
+include ../../../../system_service.mk
diff --git a/systemservice/logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp b/systemservice/logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp
new file mode 100755
index 0000000..d5dfd00
--- /dev/null
+++ b/systemservice/logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp
@@ -0,0 +1,103 @@
+/*
+ * @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 Application entry point.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <errno.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <system_service/ss_system_if.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_version.h>
+#include <native_service/ns_version_if.h>
+#include <system_service/ss_system_types.h>
+#include <system_service/ss_logger_store_logs.h>
+#include <fstream>
+#include <cstdlib>
+
+BOOL g_isExec = FALSE;
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnInitialization
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ eStatus = StartRtUsbLogThread(hApp);
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnDestroy
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) {
+ return eFrameworkunifiedStatusOK;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnDummy
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDummy(HANDLE hApp) {
+ return eFrameworkunifiedStatusOK;
+}
+
+//////////////////////////////////////////
+// Function : main
+//////////////////////////////////////////
+int main(int argc, char *argv[]) {
+ HANDLE hApp;
+ int nsFd;
+ char clientName[16] = "realtimeUsbLog";
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+
+ cbFuncs.onInitilization = FrameworkunifiedOnInitialization;
+ cbFuncs.onDestroy = FrameworkunifiedOnDestroy;
+
+ cbFuncs.onStart = FrameworkunifiedOnDummy;
+ cbFuncs.onStop = FrameworkunifiedOnDummy;
+ cbFuncs.onDebugDump = FrameworkunifiedOnDummy;
+ cbFuncs.createStateMachine = FrameworkunifiedOnDummy;
+ cbFuncs.ssFrameworkInterface = FrameworkunifiedOnDummy;
+
+ FrameworkunifiedCreateDispatcherWithoutLoop(clientName, hApp, argc, argv, &cbFuncs, FALSE);
+
+ FrameworkunifiedGetDispatcherFD(hApp, &nsFd);
+
+ g_isExec = TRUE;
+ while (g_isExec) {
+ fd_set fds;
+ int maxFd = 0;
+
+ FD_ZERO(&fds);
+
+ FD_SET(nsFd, &fds);
+ maxFd = nsFd;
+
+ select(maxFd + 1, &fds, NULL, NULL, NULL);
+
+ if (FD_ISSET(nsFd, &fds)) {
+ FrameworkunifiedDispatchProcessWithoutLoop(hApp);
+ }
+ }
+
+ FrameworkunifiedDestroyDispatcherWithoutLoop(hApp);
+ return 0;
+}
diff --git a/systemservice/logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp b/systemservice/logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp
new file mode 100755
index 0000000..c318f1a
--- /dev/null
+++ b/systemservice/logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp
@@ -0,0 +1,722 @@
+/*
+ * @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_NS_InterfaceunifiedLogCapture
+/// \brief This file contains the standard set functions called by the NS
+// dispatcher on application initialization, cleanup and wakeup.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <mqueue.h>
+#include <errno.h>
+#include <string.h>
+#include <dirent.h>
+#include <time.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <native_service/frameworkunified_timer.h>
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service.h>
+#include <system_service/ss_devicedetection_service_protocol.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_types.h>
+#include <queue>
+#include <string>
+
+// System definition
+#ifndef TN_LOGGERRTIME
+#define TN_LOGGERRTIME "LoggerRtime"
+#define PR_LOGGERRTIME_S PR_TSS_S
+#define PR_LOGGERRTIME PR_TSS
+#endif // TN_LOGGERRTIME
+// Queue resource
+#define USB_REALTIME_MSGMAX 256
+#define USB_REALTIME_SIZMAX 4096
+#define USB_REALTIME_QNAME "/PlRtLogger"
+// Folder path
+#define USB_RT_FOLDERPATH_ "/REALTIME_"
+
+// older path
+#define USB_RT_TMP_PATH "/tmp"
+// File name
+#define USB_RT_LOGNAME_TMP "usbrt_tmp.log"
+#define ENC_BUF_MAX_SIZE (1024*8)
+
+#ifdef RELEASE_BUILD
+// encrypt values
+#define DEV_ENC_EXTENSION ".enc1"
+#define REL_ENC_EXTENSION ".enc2"
+#define ALIGNMENT_SIZE 4
+#endif // RELEASE_BUILD
+
+// File path
+#define USB_RT_LOGNAME_ "loggerservice_usb__realtime"
+// Max size of each log file
+#define USB_RT_FILE_SIZE (1024*1024)
+// Num of logs to write in std::queue at one time
+#define QUELOG_WRITE_BLOCK_NUM 300
+// Max of logs to save in std::queue
+#define QUELOG_SAVE_MAX 12000
+#define QUELOG_DELNUM (QUELOG_WRITE_BLOCK_NUM*2) // num of deletion at one time
+// TIMER ID
+#define USB_RT_TIMER_EV 0x89
+#define USB_RT_TIMER_SYNC 1 // kind
+#define USB_RT_TIMER_CYCLE 10000 // cycle of timeout(msec)
+
+static HANDLE g_rt_tid = NULL;
+static int g_wfd = -1;
+static mqd_t g_qid = (mqd_t) - 1;
+static int g_num_of_file = 1;
+static char g_mnt_path[MAXPATHLEN];
+static char g_fld_path[MAXPATHLEN];
+static char g_log_path[MAXPATHLEN];
+static char *g_log_name;
+static bool g_need_sync = false;
+static size_t g_filesize = 0;
+
+//static queue<string> g_saveq;
+static std::queue<std::string> g_saveq;
+
+static DeviceDetectionServiceIf g_devDetect;
+static bool g_usb_available = false;
+
+static char g_log_tmp_path[MAXPATHLEN];
+
+EFrameworkunifiedStatus rtUsbLogThread(HANDLE hApp);
+EFrameworkunifiedStatus rtUsbLogTShutdown(HANDLE hApp);
+EFrameworkunifiedStatus OnPowerOnOffNotification(HANDLE hApp);
+
+EFrameworkunifiedStatus StartTimer(HANDLE hApp, const UI_32 timeout);
+EFrameworkunifiedStatus CancelTimer(void);
+
+// DeviceDetection Related funcs
+EFrameworkunifiedStatus OnDeviceDetectionAvailability(HANDLE hApp);
+EFrameworkunifiedStatus OnDeviceDetectionOpenSessionACK(HANDLE hApp);
+EFrameworkunifiedStatus onDeviceDetectionCloseSessionACK(HANDLE hApp);
+EFrameworkunifiedStatus onUsbDetectCallback(HANDLE hApp);
+
+EFrameworkunifiedStatus EncryptAndCopyFile(void);
+
+EFrameworkunifiedStatus StartRtUsbLogThread(HANDLE hApp) {
+ FrameworkunifiedChildThreadAttr attr;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (g_rt_tid != NULL) {
+ return eFrameworkunifiedStatusOK;
+ }
+
+ // Create Realtime USB Logging Thread and start
+ memset(&attr, 0, sizeof(FrameworkunifiedChildThreadAttr));
+ // One time while to break on Error
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedCreateChildThreadAttrSetSched(&attr,
+ eFrameworkunifiedSchedPolicyTSS,
+ PR_LOGGERRTIME))) {
+ return l_eStatus;
+ }
+ g_rt_tid = FrameworkunifiedCreateChildThreadWithAttribute(hApp, TN_LOGGERRTIME,
+ rtUsbLogThread,
+ rtUsbLogTShutdown, &attr);
+ if (g_rt_tid == NULL) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ l_eStatus = FrameworkunifiedStartChildThread(hApp, g_rt_tid, 0, (PVOID) NULL);
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus StopRtUsbLogThread(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // Close fd to sync
+ if (g_wfd != -1) {
+ if (0 != close(g_wfd)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ EncryptAndCopyFile();
+ }
+ // Close message queue
+ if (g_qid != (mqd_t) - 1) {
+ if (0 != mq_close(g_qid)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ // Terminate Thread
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedStopChildThread(hApp, g_rt_tid, 0, NULL)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedDestroyChildThread(hApp, g_rt_tid)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus OnPowerOnOffNotification(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ T_SS_SM_UserModeOnOffNotification_StructType onoff_mode;
+
+ l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID) &onoff_mode,
+ sizeof(onoff_mode));
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ fprintf(stderr, "%s: Failed to fetch OnOff Mode\n", __FUNCTION__);
+ return l_eStatus;
+ }
+ if (!onoff_mode.isUserModeOn) { // ACC-OFF
+ // Close fd to sync
+ if (g_wfd >= 0) {
+ syncfs(g_wfd);
+ if (0 != close(g_wfd)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ EncryptAndCopyFile();
+ g_wfd = -2; // ACC-OFF detected
+ }
+ }
+ return l_eStatus;
+}
+
+static int getStartFileNum(void) {
+ int start = 0;
+ int num;
+ DIR *dirp;
+ struct dirent entry;
+ struct dirent *next;
+
+ if ((dirp = opendir(g_fld_path)) == NULL) {
+ fprintf(stderr, "%s: Failed in opendir, errno=%d\n", __FUNCTION__, errno);
+ return -1;
+ }
+ for (;;) {
+ if (readdir_r(dirp, &entry, &next) != 0) {
+ fprintf(stderr, "%s: Failed in readdir_r, errno=%d\n", __FUNCTION__,
+ errno);
+ closedir(dirp);
+ return -1;
+ }
+ if (next == NULL) { // NO more
+ break;
+ }
+ if (strncmp(entry.d_name, g_log_name, strlen(g_log_name)) != 0) {
+ continue;
+ }
+ num = atoi(entry.d_name + strlen(g_log_name));
+ if (num > start) {
+ start = num;
+ }
+ }
+ closedir(dirp);
+ start++;
+
+ return start;
+}
+
+EFrameworkunifiedStatus WriteAndSwitchLogFile(const char* data, ssize_t size) {
+ ssize_t wrotelen;
+ char logpath[MAXPATHLEN];
+
+ wrotelen = write(g_wfd, data, size);
+ if (wrotelen != size) {
+ close(g_wfd);
+ g_wfd = -1;
+ g_filesize = 0;
+ EncryptAndCopyFile();
+ fprintf(stderr, "%s: Failed to write, size=%d, wrotelen=%d, errno=%d\n",
+
+// __FUNCTION__, static_cast<int32_t>size, static_cast<int32_t>wrotelen, errno);
+ __FUNCTION__, static_cast<int32_t>(size), static_cast<int32_t>(wrotelen), errno);
+
+ return eFrameworkunifiedStatusFail;
+ } else {
+ g_filesize += wrotelen;
+ g_need_sync = true;
+ if (static_cast<int>(g_filesize) >= USB_RT_FILE_SIZE) {
+ g_filesize = 0;
+ close(g_wfd);
+ EncryptAndCopyFile();
+ g_num_of_file++;
+
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+ if ((g_wfd = open(logpath, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0644))
+ == -1) {
+ fprintf(stderr, "%s: Failed to open file %s, errno=%d\n", __FUNCTION__,
+ logpath, errno);
+ return eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus OnMessageQueueReceived(HANDLE hApp) {
+ ssize_t len, len2;
+ char msg[USB_REALTIME_SIZMAX], msg2[USB_REALTIME_SIZMAX];
+ char logpath[MAXPATHLEN];
+ unsigned int prior;
+ struct stat stbuf;
+
+// string work_str;
+ std::string work_str;
+
+ bool pushed = false;
+ const struct timespec tspec = { 0, 0 };
+
+ // write loop
+ while (1) {
+ pushed = false;
+ if (g_qid == (mqd_t) - 1) { // Already ACC-OFFed
+ return eFrameworkunifiedStatusOK;
+ }
+ len = mq_timedreceive(g_qid, msg, sizeof(msg), &prior, &tspec);
+ if (len == (ssize_t) - 1) { // NO more data
+ if (errno != ETIMEDOUT) {
+ fprintf(stderr, "%s: Unexpected error %d\n", __FUNCTION__, errno);
+ }
+ break;
+ }
+ // Remove overflowed log
+ if (g_saveq.size() > QUELOG_SAVE_MAX) {
+ int delnum = g_saveq.size() - QUELOG_SAVE_MAX + QUELOG_DELNUM;
+ for (int i = 0; i < delnum; i++) {
+ g_saveq.pop();
+ }
+ }
+ // check if file is opened
+ if (g_wfd == -1) {
+ /*
+ * Make folder and open log file
+ */
+ // save dequeued log
+
+// g_saveq.push(string((const char*) msg, len));
+ g_saveq.push(std::string((const char*) msg, len));
+
+ pushed = true; // request pushed or NON-log message -> NO NEED to write this data to log file
+ // Check USB mounted
+ if (!g_usb_available) {
+ // No mount event is received
+ continue;
+ }
+ // Check USB mounted
+ if (stat(g_mnt_path, &stbuf) != 0) {
+ // No mount path found
+ continue;
+ }
+ // Check and make subfolder
+ int mkdres = mkdir(g_fld_path, 0666);
+ if (mkdres == 0) {
+ g_num_of_file = 1;
+ } else if (mkdres == -1 && errno == EEXIST) {
+ // Decide file number to start(Check current log files)
+ g_num_of_file = getStartFileNum();
+ if (g_num_of_file <= 0) {
+ fprintf(stderr, "%s: Failed in getStartFileNum\n", __FUNCTION__);
+ continue;
+ }
+ } else {
+ fprintf(stderr, "%s: Failed to mkdir %s, errno=%d\n", __FUNCTION__,
+ g_fld_path, errno);
+ continue;
+ }
+
+ // Open File
+ g_filesize = 0;
+
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+ if ((g_wfd = open(logpath, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0644))
+ == -1) {
+ fprintf(stderr, "%s: Failed to open file %s, errno=%d\n", __FUNCTION__,
+ logpath, errno);
+ continue;
+ }
+ } else if (g_wfd == -2) {
+ // Already ACC-OFF, Just throw the logs away
+ continue;
+ }
+ // Write out saved log if any
+ int written_once = QUELOG_WRITE_BLOCK_NUM; // num of written at once
+ while (1) {
+ if (g_saveq.empty()) {
+ break;
+ }
+ if (written_once >= QUELOG_WRITE_BLOCK_NUM) {
+ written_once = 0;
+ while (1) {
+ // read request queue
+ len2 = mq_timedreceive(g_qid, msg2, sizeof(msg2), &prior, &tspec);
+ if (len2 == (ssize_t) - 1) { // NO MORE data
+ if (errno != ETIMEDOUT) {
+ fprintf(stderr, "%s: Unexpected error %d\n", __FUNCTION__, errno);
+ }
+ break;
+ }
+
+// g_saveq.push(string((const char*) msg2, len2));
+ g_saveq.push(std::string((const char*) msg2, len2));
+
+ }
+ }
+ work_str = g_saveq.front();
+ if (eFrameworkunifiedStatusOK
+ != WriteAndSwitchLogFile(work_str.data(), work_str.length())) {
+ fprintf(stderr, "%s: Failed in write Saved data, errno=%d\n",
+ __FUNCTION__, errno);
+ break;
+ } else {
+ written_once++;
+ g_saveq.pop();
+ }
+ }
+ if (pushed || g_wfd == -1) {
+ continue;
+ }
+ // write data
+ if (eFrameworkunifiedStatusOK != WriteAndSwitchLogFile(msg, len)) {
+ fprintf(stderr, "%s: Failed in write Saved data-2, errno=%d\n",
+ __FUNCTION__, errno);
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus OnSyncTimeout(HANDLE hApp) {
+ if (g_need_sync) {
+ if (g_wfd != -1 && g_wfd != -2) {
+ char logpath[MAXPATHLEN];
+ fsync(g_wfd);
+ close(g_wfd);
+ g_wfd = -1;
+ EncryptAndCopyFile();
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+ if ((g_wfd = open(logpath, O_RDWR | O_CREAT | O_APPEND | O_CLOEXEC, 0644))
+ == -1) {
+ fprintf(stderr, "%s: Failed to open file %s, errno=%d (%s)\n",
+ __FUNCTION__, logpath, errno, strerror(errno));
+ // because in order to continue to obtain logs.
+ return eFrameworkunifiedStatusOK;
+ }
+ g_need_sync = false;
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus rtUsbLogThread(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ struct mq_attr qattr;
+ const struct timespec idle_time = { 1, 0 }; // 1sec
+ HANDLE timer_handle = NULL;
+
+ // Subscribe Boot Mode Notifcation to SysMgr
+ l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp,
+ NTFY_SSSystemMgrPowerOnOff,
+ OnPowerOnOffNotification);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ fprintf(stderr, "%s: Subscribe PowerOnOff failed, status=%d\n",
+ __FUNCTION__, l_eStatus);
+ }
+ // Subscribe Device Detection Availability
+ while (1) {
+ if (g_devDetect.Initialize(hApp)) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = g_devDetect.NotifyOnDeviceDetectionAvailability(
+ OnDeviceDetectionAvailability))) {
+ fprintf(stderr,
+ "%s: DevDetec AvailabilityCallback registration failed\n",
+ __FUNCTION__);
+ }
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = g_devDetect.NotifyOnOpenSessionAck(
+ OnDeviceDetectionOpenSessionACK))) {
+ fprintf(stderr, "%s: DevDetec OpenSession ACK registration failed\n",
+ __FUNCTION__);
+ }
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = g_devDetect.NotifyOnCloseSessionAck(
+ onDeviceDetectionCloseSessionACK))) {
+ fprintf(stderr, "%s: DevDetec CloseSession ACK registration failed\n",
+ __FUNCTION__);
+ }
+ break;
+ } else {
+ fprintf(stderr, "%s: Device Detection Object Initialization failed\n",
+ __FUNCTION__);
+ nanosleep(&idle_time, NULL);
+ }
+ }
+
+ // open message queue
+ while (1) {
+ qattr.mq_flags = 0;
+ qattr.mq_maxmsg = USB_REALTIME_MSGMAX;
+ qattr.mq_msgsize = USB_REALTIME_SIZMAX;
+ qattr.mq_curmsgs = 0;
+ if ((g_qid = mq_open(USB_REALTIME_QNAME, O_RDWR | O_CREAT, 0666, &qattr))
+ >= (mqd_t) 0) {
+ break;
+ }
+ fprintf(stderr, "%s: Failed in mq_open, errno=%d\n", __FUNCTION__, errno);
+ nanosleep(&idle_time, NULL);
+ }
+
+ // Attach callback func to message queue fd
+ l_eStatus = FrameworkunifiedAttachCallbackToDispatcherWithFd(hApp, static_cast<int>(g_qid),
+ OnMessageQueueReceived);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ fprintf(
+ stderr,
+ "%s: Error in FrameworkunifiedAttachCallbackToDispatcherWithFd with mq_fd, status=%d\n",
+ __FUNCTION__, l_eStatus);
+ return l_eStatus;
+ }
+ // Start Cyclic Timer
+ timer_handle = FrameworkunifiedAttachTimerCallback(hApp, USB_RT_TIMER_CYCLE,
+ USB_RT_TIMER_CYCLE,
+ OnSyncTimeout);
+ if (timer_handle == NULL) {
+ fprintf(stderr, "%s: Error in FrameworkunifiedAttachTimerCallback\n", __FUNCTION__);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ // Enter dispatcher ==> Just return
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus rtUsbLogTShutdown(HANDLE hApp) {
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus OnDeviceDetectionAvailability(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (FrameworkunifiedIsServiceAvailable(hApp)) {
+ if (eFrameworkunifiedStatusOK != (eStatus = g_devDetect.OpenSessionRequest())) {
+ fprintf(stderr, "%s: Open session request failed\n", __FUNCTION__);
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK != (eStatus = g_devDetect.CloseSessionRequest())) {
+ fprintf(stderr, "%s: Close session request failed\n", __FUNCTION__);
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus OnDeviceDetectionOpenSessionACK(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = g_devDetect.DecodeOpenSessionResponse())) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = g_devDetect.RegisterForDeviceDetectionEvent(
+ SS_DEV_DETECT_ANY_USB_EV, onUsbDetectCallback))) {
+ fprintf(stderr, "%s: Registration for SS_DEV_DETECT_ANY_USB_EV failed\n",
+ __FUNCTION__);
+ }
+ } else {
+ fprintf(stderr, "%s: Decode open session response failed\n", __FUNCTION__);
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus onDeviceDetectionCloseSessionACK(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CloseSessionAck tCloseSessionAck;
+
+ if (hApp) {
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tCloseSessionAck,
+ sizeof(tCloseSessionAck)))) {
+ if (eFrameworkunifiedStatusOK != tCloseSessionAck.eStatus) {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus onUsbDetectCallback(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SS_MediaDetectInfo l_tMediaDetectInfo;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_tMediaDetectInfo,
+ sizeof(l_tMediaDetectInfo)))) {
+ fprintf(stderr, "%s: FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x\n",
+ __FUNCTION__, l_eStatus);
+ } else {
+ if (l_tMediaDetectInfo.dev_type != eUSB) { // NOT mass storage device
+ return l_eStatus;
+ }
+ if (l_tMediaDetectInfo.bIsDeviceAvailable) {
+ if (g_usb_available) { // Already mounted
+ return l_eStatus;
+ }
+ // set USB device available
+ g_usb_available = true;
+ // Organize paths to access
+ strncpy(g_mnt_path, l_tMediaDetectInfo.deviceMountpath,
+ sizeof(g_mnt_path));
+
+ snprintf(g_fld_path, MAXPATHLEN, "%s%s", g_mnt_path, USB_RT_FOLDERPATH_);
+ snprintf(g_log_path, MAXPATHLEN, "%s/%s", g_fld_path, USB_RT_LOGNAME_);
+ g_log_name = const_cast<char*>(USB_RT_LOGNAME_);
+
+
+
+// snprintf(g_log_tmp_path, "%s", USB_RT_TMP_PATH);
+ snprintf(g_log_tmp_path, MAXPATHLEN, "%s", USB_RT_TMP_PATH);
+
+
+ } else {
+ // unset USB device available
+ if (strcmp(l_tMediaDetectInfo.deviceMountpath, g_mnt_path) == 0) {
+ g_usb_available = false;
+ g_mnt_path[0] = 0;
+ if (g_wfd != -1 && g_wfd != -2) {
+ close(g_wfd);
+ g_wfd = -1;
+ EncryptAndCopyFile();
+ }
+ }
+ }
+ }
+
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus EncryptAndCopyFile(void) {
+ char usblogpath[MAXPATHLEN];
+ char logpath[MAXPATHLEN];
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int rfd, wfd;
+ int ret;
+ struct stat istat_buf;
+
+
+// snprintf(usblogpath, "%s%05d.log", g_log_path, g_num_of_file);
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(usblogpath, MAXPATHLEN, "%s%05d.log", g_log_path, g_num_of_file);
+
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+
+ rfd = open(logpath, O_RDWR | O_CLOEXEC);
+ if (rfd == -1) {
+ fprintf(stderr, "%s: Error. Failed to open file: %s for reading.\n",
+ __FUNCTION__, logpath);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ ret = fstat(rfd, &istat_buf);
+ if (ret < 0) {
+ fprintf(stderr, "%s: Error. stat(%s). errno: %d, %s \n", __FUNCTION__,
+ logpath, errno, strerror(errno));
+ close(rfd);
+ return eFrameworkunifiedStatusFail;
+ } else {
+ BYTE *pData;
+ int total_len;
+ int read_len;
+ off_t total_size = istat_buf.st_size;
+
+ wfd = open(usblogpath, O_RDWR | O_APPEND | O_TRUNC | O_CREAT | O_CLOEXEC,
+ 0644);
+ if (wfd == -1) {
+ fprintf(stderr, "%s: Error. Failed to open file: %s for reading.\n",
+ __FUNCTION__, usblogpath);
+ close(rfd);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ pData = reinterpret_cast<BYTE*>(malloc(ENC_BUF_MAX_SIZE));
+ if (pData == NULL) {
+ fprintf(stderr, "%s: Error. Failed to malloc %d byte for dst \n",
+ __FUNCTION__, ENC_BUF_MAX_SIZE);
+ close(rfd);
+ close(wfd);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ total_len = static_cast<int>(total_size);
+ do {
+ read_len = read(rfd, pData, ENC_BUF_MAX_SIZE);
+ if (read_len == -1) {
+ fprintf(stderr, "%s: Error. File read failed. errno: %d, %s \n",
+ __FUNCTION__, errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ ret = write(wfd, pData, read_len);
+ if (ret == -1) {
+ fprintf(stderr, "%s: Error. length(%d) no space to write: %d, %s \n",
+ __FUNCTION__, ret, errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ total_len -= read_len;
+ } while (total_len > 0);
+
+ fsync(wfd);
+ free(pData);
+ close(wfd);
+ close(rfd);
+
+ if (l_eStatus == eFrameworkunifiedStatusFail) {
+ return l_eStatus;
+ }
+ {
+ // Synchronization security
+ struct stat ostat_buf;
+ while (1) {
+ ret = stat(usblogpath, &ostat_buf);
+ if (ret < 0) {
+ fprintf(stderr, "%s: Error. stat(%s). errno: %d, %s", __FUNCTION__,
+ usblogpath, errno, strerror(errno));
+ break;
+ }
+ if (ostat_buf.st_size >= total_size) {
+ break;
+ }
+ usleep(1000); // interval
+ }
+ }
+ }
+ return l_eStatus;
+}
diff --git a/systemservice/logger_service/server/realtimeUsbLog/work/Makefile b/systemservice/logger_service/server/realtimeUsbLog/work/Makefile
new file mode 100755
index 0000000..ee9c7e8
--- /dev/null
+++ b/systemservice/logger_service/server/realtimeUsbLog/work/Makefile
@@ -0,0 +1,23 @@
+#
+# @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.
+#
+
+#ADD_EXT:=rel
+
+
+LDLIBS += -Wl,-Bdynamic -lcrypto
+CPPFLAGS += -DRELEASE_BUILD
+
+include ../src/Makefile
diff --git a/systemservice/logger_service/server/realtimeUsbLog/work_debug/Makefile b/systemservice/logger_service/server/realtimeUsbLog/work_debug/Makefile
new file mode 100755
index 0000000..8ad806a
--- /dev/null
+++ b/systemservice/logger_service/server/realtimeUsbLog/work_debug/Makefile
@@ -0,0 +1,19 @@
+#
+# @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.
+#
+
+ADD_EXT:=dbg
+
+include ../src/Makefile
diff --git a/systemservice/logger_service/server/screenShot/Makefile b/systemservice/logger_service/server/screenShot/Makefile
new file mode 100755
index 0000000..f52e40c
--- /dev/null
+++ b/systemservice/logger_service/server/screenShot/Makefile
@@ -0,0 +1,52 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = SS_ScrShot
+
+######### installed library(*.a) #############
+
+
+######### installed shared library(*.so) #############
+
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+SS_ScrShot_SRCS = ss_logger_scrshot.cpp
+
+######### add source path #############
+
+
+######### add compile option #############
+CPPFLAGS += -DLINUX
+CPPFLAGS += -fno-exceptions
+
+######### linked library #############
+
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -ldu
+LDLIBS += -Wl,-Bdynamic -ljpeg
+#LDLIBS += -Wl,-Bdynamic -lextension
+LDLIBS += -Wl,-Bdynamic -ldrm
+
+######### add library path #############
+LDFLAGS += -Wl,--gc-sections
+
+LINK_CXX=Y
+include ../../../system_service.mk
diff --git a/systemservice/logger_service/server/screenShot/ss_logger_scrshot.cpp b/systemservice/logger_service/server/screenShot/ss_logger_scrshot.cpp
new file mode 100755
index 0000000..db5bcba
--- /dev/null
+++ b/systemservice/logger_service/server/screenShot/ss_logger_scrshot.cpp
@@ -0,0 +1,89 @@
+/*
+ * @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_SS_LoggerService
+/// \brief
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <jpeglib.h>
+#include <du.h>
+
+#define MAX_IMAGE_WIDTH 1280
+#define MAX_IMAGE_HEIGHT 480
+#define COLOR_COMPONENT 4
+
+int SS_Logger_SaveScreenShot(const char* filename, int type) {
+ FILE *outfile;
+ struct SCRSHOT_capture_arg stSCR;
+ struct jpeg_compress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+ unsigned char *work_buf;
+
+ stSCR.du = type; // 0:E2 1:M2
+ stSCR.fmt = SCRSHOT_FMT_ARGB8888;
+ stSCR.buff = malloc(MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT * COLOR_COMPONENT);
+ stSCR.buff_len = MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT * COLOR_COMPONENT;
+ stSCR.ev_handler = NULL; // sync mode
+
+ if (stSCR.buff == NULL) {
+ exit(1);
+ }
+
+ if (SCRSHOT_RET_SUCCESS != SCRSHOT_capture(&stSCR)) {
+ exit(1);
+ }
+
+ cinfo.err = jpeg_std_error(&jerr);
+ jpeg_create_compress(&cinfo);
+
+ if ((outfile = fopen(filename, "wb")) == NULL) {
+ exit(1);
+ }
+ jpeg_stdio_dest(&cinfo, outfile);
+ cinfo.image_width = stSCR.width;
+ cinfo.image_height = stSCR.height;
+ cinfo.input_components = COLOR_COMPONENT;
+ cinfo.in_color_space = JCS_EXT_BGRA;
+ jpeg_set_defaults(&cinfo);
+ jpeg_start_compress(&cinfo, TRUE);
+
+ work_buf = (unsigned char*) stSCR.buff;
+ for (unsigned int i = 0; i < stSCR.height; i++) {
+ jpeg_write_scanlines(&cinfo, (JSAMPARRAY) & (work_buf), 1);
+ work_buf += stSCR.width * COLOR_COMPONENT;
+ }
+
+ jpeg_finish_compress(&cinfo);
+ jpeg_destroy_compress(&cinfo);
+ free(stSCR.buff);
+ fclose(outfile);
+ exit(0);
+}
+
+int main(int argc, char *argv[]) {
+ if (argc < 3) {
+ exit(1);
+ }
+ int chType = atoi(argv[2]);
+ SS_Logger_SaveScreenShot(argv[1], chType);
+
+ return 0;
+}
diff --git a/systemservice/logger_service/server/src/cached_file_writer.cpp b/systemservice/logger_service/server/src/cached_file_writer.cpp
new file mode 100755
index 0000000..92c02f5
--- /dev/null
+++ b/systemservice/logger_service/server/src/cached_file_writer.cpp
@@ -0,0 +1,79 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/cached_file_writer.h"
+#include <native_service/frameworkunified_types.h>
+
+namespace ReaderWriter {
+
+CCachedFileWriter::CCachedFileWriter() {
+ std::memset(this->m_buffer, 0, CACHED_BLOCK_SIZE);
+ m_index = 0u;
+}
+
+CCachedFileWriter::~CCachedFileWriter() {
+}
+
+EFrameworkunifiedStatus CCachedFileWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // length check
+ if (f_data != NULL) { // LCOV_EXCL_BR_LINE 200: f_data can not be null
+ if ((this->m_index + f_length) > CACHED_BLOCK_SIZE) { // LCOV_EXCL_BR_LINE 200: data size can not over 4*1024
+ l_eStatus = this->FlushCache();
+ }
+ if (f_length > CACHED_BLOCK_SIZE) { // LCOV_EXCL_BR_LINE 200: data size can not over 4*1024
+ // LCOV_EXCL_START 200: data size can not over 4*1024
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Possible memory corruption.");
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Length(%d) bigger than cache. Will dump memory to core and ignore data. ",
+ f_length);
+ // LCOV_EXCL_STOP
+ } else {
+ (void) std::memcpy(&this->m_buffer[this->m_index], f_data, f_length);
+ this->m_index += f_length;
+ f_bytesWritten = f_length;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CCachedFileWriter::FlushCache(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SI_32 l_written = 0;
+ SI_32 l_writtenTotal = 0;
+ while (((l_writtenTotal >= 0) && ((UI_32) l_writtenTotal < this->m_index))
+ && (eFrameworkunifiedStatusOK == l_eStatus)) {
+ l_eStatus = this->WriteData(&this->m_buffer[l_writtenTotal],
+ this->m_index - l_writtenTotal, l_written);
+ l_writtenTotal += l_written;
+ l_written = 0;
+ }
+ this->m_index = 0;
+ return l_eStatus;
+}
+} // namespace ReaderWriter
diff --git a/systemservice/logger_service/server/src/file_writer.cpp b/systemservice/logger_service/server/src/file_writer.cpp
new file mode 100755
index 0000000..221a1d4
--- /dev/null
+++ b/systemservice/logger_service/server/src/file_writer.cpp
@@ -0,0 +1,122 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/file_writer.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string>
+
+namespace ReaderWriter {
+CFileWriter::CFileWriter()
+ : m_FileHandle(-1),
+ m_fileposn(-1),
+ m_maxFileSize(0) {
+}
+
+CFileWriter::~CFileWriter() {
+ if (this->m_FileHandle != -1) { // LCOV_EXCL_BR_LINE 200: it aways open, so m_FileHandle can not be -1
+ this->Close();
+ this->m_FileHandle = -1;
+ }
+}
+
+EFrameworkunifiedStatus CFileWriter::Initialize(CLoggerCfg* f_pLoggerCfg,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ this->m_maxFileSize = f_size1;
+ if ((f_Name1.length() != 0) && (this->m_FileHandle == -1)) { // LCOV_EXCL_BR_LINE 6:Due to the initial status
+ m_filename = f_Name1;
+ l_eStatus = this->Open();
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CFileWriter::Open(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if (this->m_FileHandle != -1) { // LCOV_EXCL_BR_LINE 6:Due to the initial status
+ // File already opened, no action required.
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (m_filename.length() != 0) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ this->m_FileHandle = open(m_filename.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC,
+ 0644);
+ if (-1 != this->m_FileHandle) { // LCOV_EXCL_BR_LINE 5:The open cannot pass because it cannot be mock
+ l_eStatus = eFrameworkunifiedStatusOK;
+ m_fileposn = lseek(m_FileHandle, 0L, SEEK_CUR);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+BOOL CFileWriter::IsOpen(void) {
+ return (-1 == m_FileHandle) ? FALSE : TRUE;
+}
+
+EFrameworkunifiedStatus CFileWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ return (this->WriteData(f_data, f_length, f_bytesWritten));
+}
+
+EFrameworkunifiedStatus CFileWriter::WriteData(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_bytesWritten = 0;
+ if (-1 == m_FileHandle) { // LCOV_EXCL_BR_LINE 200: m_FileHandle can not be null
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ while ((eFrameworkunifiedStatusOK == l_eStatus)
+ && ((f_bytesWritten >= 0) && ((UI_32) f_bytesWritten < f_length))) {
+ SI_32 l_bytesWritten = -1;
+ m_fileposn = lseek(m_FileHandle, 0L, SEEK_CUR);
+ if ((m_fileposn + (UI_32) f_length) >= this->m_maxFileSize) {
+ SI_32 l_deltaLength = static_cast<SI_32>(this->m_maxFileSize - m_fileposn);
+ l_bytesWritten = static_cast<SI_32>(write(m_FileHandle, &f_data[f_bytesWritten],
+ l_deltaLength));
+ f_bytesWritten += l_bytesWritten;
+ if ((l_bytesWritten >= 0) && (l_deltaLength == l_bytesWritten)) {
+ m_fileposn = lseek(m_FileHandle, 0L, SEEK_SET);
+ }
+ } else {
+ l_bytesWritten = static_cast<SI_32>(write(m_FileHandle, &f_data[f_bytesWritten],
+ f_length - f_bytesWritten));
+ f_bytesWritten += l_bytesWritten;
+ }
+ l_eStatus = (l_bytesWritten > -1) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ }
+
+ return (l_eStatus);
+}
+
+void CFileWriter::Close() { // LCOV_EXCL_START 6:Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (this->m_FileHandle != -1) {
+ (void) close(this->m_FileHandle);
+ this->m_FileHandle = -1;
+ }
+}
+// LCOV_EXCL_STOP
+} // namespace ReaderWriter
diff --git a/systemservice/logger_service/server/src/loggerservice_application.cpp b/systemservice/logger_service/server/src/loggerservice_application.cpp
new file mode 100755
index 0000000..2d39fb2
--- /dev/null
+++ b/systemservice/logger_service/server/src/loggerservice_application.cpp
@@ -0,0 +1,952 @@
+/*
+ * @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_NS_InterfaceunifiedLogCapture
+/// \brief This file contains the standard set functions called by the NS
+// dispatcher on application initialization, cleanup and wakeup.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/cl_process.h>
+
+#include <native_service/nslogutil_cmd_if.h>
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_np_service_protocol.h>
+
+#include <loggerservicedebug_loggerservicelog.h>
+#include <loggerservicedebug_thread_if.h>
+#include <loggerservicedebug_writer_Evntworker.h>
+
+#include <native_service/frameworkunified_timer.h>
+#include <ss_logger_device_detection.h>
+
+#include <ss_logger_cfg.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <system_service/ss_logger_service.h>
+#include <ss_logger_service_callbacks.h>
+
+#include <system_service/ss_sm_client_if.h>
+
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_system_manager_notifications.h>
+
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <system_service/ss_services.h>
+#include <ss_logger_error_event.h>
+#include <ss_logger_reader_writer_control.h>
+#include <ss_logger_common.h>
+#include <stub/pfdrec_thread_ifc.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_logger_store_logs.h>
+#include <queue>
+#include <string>
+
+// const definitions
+#define TMPFS_PATH "/tmp"
+
+#define SYS_ILLEGAL_LOG_DELAY_TIME ( 20 * 1000 )
+const CHAR LOGGERSERVICELOGGER_SETPARAMS[] = TMPFS_PATH "/loggerservicelogger_setparams.log";
+const CHAR Counter_LOG_PATH_FN[] = TMPFS_PATH "/loggerservice_counter.log";
+const CHAR Mileage_LOG_PATH_FN[] = TMPFS_PATH "/loggerservice_mileage.log";
+
+const CHAR g_strLogQueWriterWorkerName[] = "pdg.LogQueWriter";
+const CHAR g_strTransmitQueWriterWorkerName[] = "pdg.TransmitQueWriter";
+const CHAR g_strUdpQueWriterWorkerName[] = "pdg.UdpQueWriter";
+const CHAR g_strEvntLogQueWorkerName[] = "pdg.EvntLogQue";
+
+// handles to writer threads
+static HANDLE g_thrdLogWriter = NULL; // Var. that holds the child handle to the Log Writer thread
+static HANDLE g_thrdTxWriter = NULL; // Var. that holds the child handle to the Tx Writer thread
+
+/// Event_logger
+HANDLE g_thrdEvntLogWriter = NULL; // Var. that holds the child handle to the EVNTLOGGER Writer thread
+static TEvntWriterInfo Evntlog_wi = { };
+TUploadEventLogResp g_stUploadEventLogResp;
+
+// global variable to store the service status
+ELOGGERSERVICESTATUS g_eLoggerServiceStatus = eLSInit;
+
+// class to usb and reader threads
+LoggerserviceDebugChildThread g_loggerservicedebug_threads;
+
+/// Device Detection Class Instance
+DeviceDetectionServiceIf g_devDetect_t;
+
+CLoggerCfg g_loggerCfg;
+CErrorEvent g_errorEventHandler;
+CLoggerServiceCallbacks g_serviceCallbacks;
+CLoggerDeviceDetection g_deviceDetection;
+CReaderWriterControl g_ReaderWriterControl;
+CPFDRECThread g_PFDRECThread;
+
+/// Decide the function NormalStartupProcess execution
+static bool g_normal_startup_status = false;
+
+/// Callbacks for messages that will be received and processed by this module
+static EFrameworkunifiedStatus OnUsbEject(HANDLE hApp);
+
+static EFrameworkunifiedStatus OnUsbStoreLogs(HANDLE hApp);
+
+static EFrameworkunifiedStatus SMSessionAckCb(HANDLE hApp);
+
+/// Positive Response Call backs from child thread for statistical counter read
+static EFrameworkunifiedStatus cbStatisticalCounterSuccessResp(HANDLE hApp);
+
+/// Error Response Call backs from child thread for statistical counter read
+static EFrameworkunifiedStatus cbStatisticalCounterErrorResp(HANDLE hApp);
+
+/// Response Call backs from child thread for clear event logs
+static EFrameworkunifiedStatus cbClearEventLogsResponse(HANDLE hApp);
+
+/// Response Call backs from child thread for copying event logs to USB
+static EFrameworkunifiedStatus cbCopyEventLogsUSBResponse(HANDLE hApp);
+
+/// Response Call backs from child thread for Reading number of events logged
+static EFrameworkunifiedStatus cbReadNumbOfEventsResponse(HANDLE hApp);
+
+/// Response Call backs from child thread for Upload eventlog
+static EFrameworkunifiedStatus cbUploadEventLogResponse(HANDLE hApp);
+
+/// Notificatin from SystemManager when All Services wakeup completed
+static EFrameworkunifiedStatus cbServiceWakeupStatus(HANDLE hApp);
+
+
+/// generate SYS_ILG_LOG
+static EFrameworkunifiedStatus SysIllegalLogTimer_OnInterval(HANDLE hApp);
+
+
+/// Call back tables for response from event logger child thread
+FrameworkunifiedProtocolCallbackHandler evtLogChildThread_handler[] = { { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ eThrdCmdStatisticalCounterSuccessResp, cbStatisticalCounterSuccessResp }, {
+ eThrdCmdStatisticalCounterErrorResp, cbStatisticalCounterErrorResp }, {
+ eThrdCmdCopyEventLogUSBResponse, cbCopyEventLogsUSBResponse }, {
+ eThrdCmdClearEventLogResponse, cbClearEventLogsResponse }, {
+ eThrdCmdNumberOfEventsLoggedResponse, cbReadNumbOfEventsResponse }, {
+ eThrdCmdUploadEventLogResponse, cbUploadEventLogResponse } };
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnInitialization
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // 1. Register Srv Availability Notification
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hApp, NTFY_SS_LoggerService_Availability))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ // 2. Publish Service not available
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:%d ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = g_loggerCfg.Initialize(hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_loggerCfg.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ std::string l_cfgFilePathAndName =
+ "/usr/agl/conf/BS/ss/logger_service/rodata/ss_logger.cfg";
+ if (eFrameworkunifiedStatusOK != (l_eStatus = g_loggerCfg.Load(l_cfgFilePathAndName))) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. Failed to load SS_Logger configuration from %s with error: %d",
+ l_cfgFilePathAndName.c_str(), l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = g_loggerCfg.Validate())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Configuration validation failed with error: %d.",
+ l_eStatus);
+ }
+
+ g_loggerCfg.Print(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ l_eStatus = g_deviceDetection.Initialize(hApp, &g_loggerCfg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_deviceDetection.Initialize"); // LCOV_EXCL_BR_LINE 15: macro
+
+ l_eStatus = g_ReaderWriterControl.Initialize(&g_loggerCfg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_ReaderWriterControl.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ if (NULL == (g_thrdEvntLogWriter = FrameworkunifiedCreateChildThreadWithPriority( hApp, g_strEvntLogQueWorkerName, EvntWriterWorkerOnStart, EvntWriterWorkerOnStop, frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(std::string(g_strEvntLogQueWorkerName))))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedCreateChildThreadWithPriority Failed Status:0x%x for thread create of %s",
+ l_eStatus, g_strEvntLogQueWorkerName);
+ return (l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG( // LCOV_EXCL_BR_LINE 15: macro
+ ZONE_INFO,
+ __FUNCTION__,
+ "FrameworkunifiedCreateChildThreadWithPriority Success Status: for thread create of %s",
+ g_strEvntLogQueWorkerName); // LCOV_EXCL_BR_LINE 15: macro
+ }
+
+ l_eStatus = g_errorEventHandler.Initialize(hApp, &g_loggerCfg, // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ &g_ReaderWriterControl,
+ g_thrdEvntLogWriter,
+ g_strEvntLogQueWorkerName); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. g_errorEventHandler.Initialize() returned: %d.", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+ l_eStatus = g_serviceCallbacks.Initialize(hApp, &g_loggerCfg,
+ &g_errorEventHandler); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_serviceCallbacks.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ // Callback to Event log child Thread
+ l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hApp, g_strEvntLogQueWorkerName, evtLogChildThread_handler,
+ _countof(evtLogChildThread_handler)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: macro
+ "Status of callback for child thread attach:%X", l_eStatus); // LCOV_EXCL_BR_LINE 15: macro
+
+ // setup call backs for my children
+ FrameworkunifiedAttachCallbackToDispatcher(hApp, AppName, eThrdCmdUsbEject, OnUsbEject); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FrameworkunifiedAttachCallbackToDispatcher(hApp, AppName, eThrdCmdUsbStoreLogs,
+ OnUsbStoreLogs);
+
+ // Publications
+ FrameworkunifiedNotificationsList publish_notifs[] = {
+ // Notifications name,length, state
+ { NTFY_LOGGER_SETCONTROLMASK, sizeof(CHANGELOGPARAMS), eFrameworkunifiedStateVar } };
+
+ // Indicate to Notification Service what I will be Publishing!
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp, publish_notifs, _countof(publish_notifs)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedNPRegisterNotifications Failed Status:0x%x ", l_eStatus);
+ return (l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ /// Start the Writer threads
+ strncpy(Evntlog_wi.mileage_filename, Mileage_LOG_PATH_FN,
+ Evntlog_wi.FN_LEN - 1);
+ Evntlog_wi.mileage_filename[Evntlog_wi.FN_LEN - 1] = '\0';
+ strncpy(Evntlog_wi.base_cnt_filename, Counter_LOG_PATH_FN,
+ Evntlog_wi.FN_LEN - 1);
+ Evntlog_wi.base_cnt_filename[Evntlog_wi.FN_LEN - 1] = '\0';
+ Evntlog_wi.max_filelen = g_loggerCfg.m_logMaxFileSize;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp, g_thrdEvntLogWriter, sizeof(Evntlog_wi), &Evntlog_wi))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = RegisterSMSessionAckCallback(SMSessionAckCb); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "RegisterSMSessionAckCallback()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ l_eStatus = g_PFDRECThread.Initialize(hApp); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_PFDRECThread.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_SSServiceWakeupStatus, cbServiceWakeupStatus); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSubscribeNotificationWithCallback()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ // Set Service status to init
+ g_eLoggerServiceStatus = eLSInit;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+static void *accOffOnCollect(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SS_LoggerStoreLogs(SS_STORELOGS_ACCOFFON_PRESS);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return NULL;
+}
+
+// Normal startup process
+static EFrameworkunifiedStatus NormalStartupProcess(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (false == g_normal_startup_status) {
+ T_SS_SM_START_DataStructType prm;
+
+ l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &prm, sizeof(T_SS_SM_START_DataStructType), eSMRRetain);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Failed PasGetMsgDataOfSize() [%d]", l_eStatus);
+ }
+
+ if (prm.resetStatus == e_SS_SM_RESET_STATUS_NG) {
+ HANDLE timer =
+ FrameworkunifiedAttachTimerCallback(hApp, SYS_ILLEGAL_LOG_DELAY_TIME, 0, SysIllegalLogTimer_OnInterval);
+ if (timer == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, " Failed to register timer.");
+ }
+ }
+
+ if (0 == access("/tmp/accoffon", F_OK)) {
+ pthread_t threadAccOffOn;
+ pthread_create( &threadAccOffOn, NULL, accOffOnCollect, NULL);
+ }
+
+ if (g_eLoggerServiceStatus == eLSStop) {
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ",
+ l_eStatus);
+ }
+
+ // Start the Writer threads
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedStartChildThread(hApp, g_thrdEvntLogWriter,
+ sizeof(Evntlog_wi), &Evntlog_wi))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
+ }
+ }
+ // Set Service status to init
+ g_eLoggerServiceStatus = eLSStart;
+
+ // Set normal_startup_status flag (true)
+ g_normal_startup_status = true;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus SysIllegalLogTimer_OnInterval(HANDLE hApp) { // LCOV_EXCL_START 200: There is no SUBCP_STS_COMNG case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = SS_LoggerStoreLogs(SS_STORELOGS_SYS_ILLEGAL);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, " Failed SS_LoggerStoreLogs()");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ /*Get stop factor form hApp*/
+ T_SS_SM_STOP_DataStructType errorType;
+
+ // LCOV_EXCL_BR_START 4: NSFW error
+ if (eFrameworkunifiedStatusOK
+ != FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID) &errorType, sizeof(errorType),
+ eSMRRelease)) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: NSFW error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ " FrameworkunifiedGetMsgDataOfSize failed with error");
+ // LCOV_EXCL_STOP
+ } else {
+ EFrameworkunifiedStatus loggerserviceRet = SS_LoggerStoreLogs(SS_STORELOGS_INTERFACEUNIFIEDLOG);
+ LOG_STATUS_IF_ERRORED(loggerserviceRet, "Fail to save Loggerservice Log");
+ EFrameworkunifiedStatus naviLog_status = g_errorEventHandler.SaveNaviLog(
+ errorType.shutdownTrigger);
+ LOG_STATUS_IF_ERRORED(naviLog_status, "Fail to save Navi Log");
+ }
+ StopLoggingFunction(hApp);
+
+ if (g_eLoggerServiceStatus == eLSStart) { // LCOV_EXCL_BR_LINE 200: g_eLoggerServiceStatus must be eLSStart on ACC-OFF
+ LoggerService_OnStop(hApp);
+ }
+
+ // Set normal_startup_status flag (false)
+ g_normal_startup_status = false;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+/**
+ * EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp)
+ * @brief Logger Stop is called on Shutdown complete cmd
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Set Service status to init
+ g_eLoggerServiceStatus = eLSStop;
+
+ /// Start the Writer threads
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStopChildThread(hApp, g_thrdEvntLogWriter, sizeof(Evntlog_wi), &Evntlog_wi))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "Successful in Sending Stop to ChildThread");
+ }
+
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus SMSessionAckCb(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hSession;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: macro
+
+ l_hSession = FrameworkunifiedGetOpenSessionHandle(hApp);
+
+ if (NULL == l_hSession) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. FrameworkunifiedGetSessionHandle() returned a NULL session handle. "
+ "Error events originating from System Manager will not be detected.");
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = FrameworkunifiedSetSessionHandle(hApp, FrameworkunifiedGetMsgSrc(hApp), l_hSession);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSessionHandle()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ l_eStatus = g_errorEventHandler.RegisterSessionErrorEvent(l_hSession);
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: macro
+ "g_errorEventHandler.RegisterSessionErrorEvent()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnShutdown
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnEShutdown
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnDebugDump
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// HACK! mb20100701
+/// \todo Add behavior to this function
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) { // LCOV_EXCL_START 14:For process termination processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusNotImplemented;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus OnUsbEject(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ if (g_loggerservicedebug_threads.Running(
+ LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript)) {
+ g_loggerservicedebug_threads.Stop(LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript);
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Stopped Thread: %s",
+ g_loggerservicedebug_threads.Name(
+ LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus OnUsbStoreLogs(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ TThrdCaptureLogsEvt evt = { };
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &evt, sizeof(evt)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x ",
+ l_eStatus);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return l_eStatus;
+ }
+
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriterStop, 0, NULL);
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriterStop, 0, NULL);
+
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriteFilesToUsb,
+ sizeof(evt), &evt);
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriteFilesToUsb,
+ sizeof(evt), &evt);
+
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriterResume, 0,
+ NULL);
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriterResume, 0, NULL);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbStatisticalCounterPosResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbStatisticalCounterSuccessResp(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TStatisticalCntCmdSuccessResp l_stCmdSuccessResp;
+ SS_loggerserviceprotocol l_eResponseCmd;
+ HANDLE l_hSession = NULL;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TStatisticalCntCmdSuccessResp>(hApp,
+ l_stCmdSuccessResp))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stCmdSuccessResp.stSessiondata.strSrcName.c_str(),
+ l_stCmdSuccessResp.stSessiondata.session_id))) {
+ l_eResponseCmd = SS_LOGGER_READ_STATL_COUNTER_SUCCESS_RESP;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd,
+ sizeof(SStatisticalCounter),
+ &l_stCmdSuccessResp.stBuffer))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbStatisticalCounterErrResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbStatisticalCounterErrorResp(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TSessionData l_stSessiondata;
+ SS_loggerserviceprotocol l_eResponseCmd;
+ HANDLE l_hSession = NULL;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(hApp, l_stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(hApp,
+ l_stSessiondata.strSrcName.c_str(),
+ l_stSessiondata.session_id))) {
+ l_eResponseCmd = SS_LOGGER_READ_STATL_COUNTER_ERROR_RESP;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd, 0x00, NULL))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbClearEventLogsResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbClearEventLogsResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TClearEvntLogCmdResponse l_stCmdResponse;
+ HANDLE l_hSession = NULL;
+ SS_loggerserviceprotocol l_eResponseCmd;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TClearEvntLogCmdResponse>(hApp, l_stCmdResponse))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stCmdResponse.stSessiondata.strSrcName.c_str(),
+ l_stCmdResponse.stSessiondata.session_id))) {
+ if (l_stCmdResponse.u8Response == (UI_8) CLEAR_EVENT_LOG_SUCCESS) {
+ l_eResponseCmd = SS_LOGGERCLEAREVENT_SUCCESS_RESP;
+ } else {
+ l_eResponseCmd = SS_LOGGERCLEAREVENT_ERROR_RESP;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd, 0x00, NULL))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbCopyEventLogsUSBResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbCopyEventLogsUSBResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TWriteFilesToUsbCmdResponse l_stCmdResponse;
+ HANDLE l_hSession = NULL;
+ SS_loggerserviceprotocol l_eResponseCmd;
+ EEvtLoggerErrorCode l_eResponseCode;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TWriteFilesToUsbCmdResponse>(hApp,
+ l_stCmdResponse))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stCmdResponse.stSessiondata.strSrcName.c_str(),
+ l_stCmdResponse.stSessiondata.session_id))) {
+ if (l_stCmdResponse.u8Response == (UI_8) COPY_EVT_USB_SUCCESS) {
+ l_eResponseCmd = SS_LOGGERCOPYEVENTUSB_SUCCESS_RESP;
+ l_eResponseCode = NO_ERROR_INFO;
+ } else {
+ l_eResponseCmd = SS_LOGGERCOPYEVENTUSB_ERROR_RESP;
+ l_eResponseCode = (EEvtLoggerErrorCode) l_stCmdResponse.u8Response;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd,
+ sizeof(EEvtLoggerErrorCode),
+ &l_eResponseCode))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbReadNumbOfEventsResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_16 l_NumOfEvents = 0;
+ TEvntsLogged l_stNumberOfEvtsLogged;
+ HANDLE l_hsession = NULL;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TEvntsLogged>(hApp, l_stNumberOfEvtsLogged))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ l_NumOfEvents = l_stNumberOfEvtsLogged.u16numberofeventslogged;
+ if (NULL
+ != (l_hsession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stNumberOfEvtsLogged.stSessiondata.strSrcName.c_str(),
+ l_stNumberOfEvtsLogged.stSessiondata.session_id))) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hsession,
+ SS_LOGGER_ENG_READ_NUMOFEVENTS_RESP,
+ sizeof(UI_16), &l_NumOfEvents))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbUploadEventLogResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hsession = NULL;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "UploadEventLog Response Msg Len = %d",
+ FrameworkunifiedGetMsgLength(hApp));
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TUploadEventLogResp>(hApp, g_stUploadEventLogResp))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hsession = FrameworkunifiedGetSessionHandle(
+ hApp, g_stUploadEventLogResp.stSessiondata.strSrcName.c_str(),
+ g_stUploadEventLogResp.stSessiondata.session_id))) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hsession, SS_LOGGER_UPLOAD_EVENTLOG_RESP,
+ sizeof(STEventLogPersistBuffer),
+ &g_stUploadEventLogResp.stEventLogBuffer))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus cbServiceWakeupStatus(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = g_errorEventHandler.CreateKernelLog(hApp,
+ SS_LOGGER_KBOOTLOG_CREATE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "CreateKernelLog(SS_LOGGER_KBOOTLOG_CREATE)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+void StopLoggingFunction(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // PFDRECThread Stop
+ EFrameworkunifiedStatus l_eStatus = g_PFDRECThread.Finalize(hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_PFDRECThread.Finalize()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
diff --git a/systemservice/logger_service/server/src/loggerservice_main.cpp b/systemservice/logger_service/server/src/loggerservice_main.cpp
new file mode 100755
index 0000000..a7ee212
--- /dev/null
+++ b/systemservice/logger_service/server/src/loggerservice_main.cpp
@@ -0,0 +1,59 @@
+/*
+ * @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_NS_InterfaceunifiedLogCapture
+/// \brief Application entry point.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <pthread.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_application.h>
+#include <system_service/ss_system_if.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <system_service/ss_version.h>
+#include <native_service/ns_version_if.h>
+#include <system_service/ss_services.h>
+#include <cstdlib>
+#include <iostream>
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
+
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { FRAMEWORKUNIFIEDLOGOPTIONS, {
+ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ZONE_TEXT_31 }, FRAMEWORKUNIFIEDLOGZONES };
+
+const CHAR AppName[] = SERVICE_LOGGER;
+
+//////////////////////////////////////////
+// Function : main
+//////////////////////////////////////////
+int main(int argc, char *argv[]) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cbFuncs); // LCOV_EXCL_BR_LINE 15: macro
+ FRAMEWORKUNIFIED_SET_ZONES(); // LCOV_EXCL_BR_LINE 15: macro
+
+ eStatus = FrameworkunifiedDispatcherWithArguments(AppName, argc, argv, &cbFuncs); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ return eStatus;
+} // LCOV_EXCL_BR_LINE 10:the last line
diff --git a/systemservice/logger_service/server/src/loggerservicedebug_child_thread.cpp b/systemservice/logger_service/server/src/loggerservicedebug_child_thread.cpp
new file mode 100755
index 0000000..4a8668f
--- /dev/null
+++ b/systemservice/logger_service/server/src/loggerservicedebug_child_thread.cpp
@@ -0,0 +1,134 @@
+/*
+ * @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_NS_InterfaceunifiedLogCapture
+/// \brief Class that threads for usb, and readers use to AGL and get
+/// information from the parent.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <loggerservicedebug_thread_if.h>
+#include <new>
+
+const CHAR g_strLogQueReaderWorkerName[] = "pdg.LogQueR";
+const CHAR g_strTransmitQueReaderWorkerName[] = "pdg.TransQueR";
+const CHAR g_strPerformanceQueReaderWorkerName[] = "pdg.PerformQueR";
+const CHAR g_strUsbEjectWorkerName[] = "pdg.UsbEject";
+const CHAR g_strUsbLogCaptureWorkerName[] = "pdg.UsbLogCapt";
+const CHAR g_strCaptureLogScriptExeName[] = "pdg.CaptLogScri";
+
+LoggerserviceDebugChildThread::LoggerserviceDebugChildThread() {
+ names[LoggerserviceDebugChildThread::kLoggerserviceDebugLogQueReader] =
+ g_strLogQueReaderWorkerName;
+ names[LoggerserviceDebugChildThread::kLoggerserviceDebugTransmitQueReader] =
+ g_strTransmitQueReaderWorkerName;
+ names[LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript] =
+ g_strCaptureLogScriptExeName;
+ names[LoggerserviceDebugChildThread::kLoggerservicePerformanceLogQueReader] =
+ g_strPerformanceQueReaderWorkerName;
+
+ threads[LoggerserviceDebugChildThread::kLoggerserviceDebugLogQueReader] = NULL;
+ threads[LoggerserviceDebugChildThread::kLoggerserviceDebugTransmitQueReader] = NULL;
+ threads[LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript] = NULL;
+ threads[LoggerserviceDebugChildThread::kLoggerservicePerformanceLogQueReader] = NULL;
+} // LCOV_EXCL_BR_LINE 10:the last line
+
+LoggerserviceDebugChildThread::~LoggerserviceDebugChildThread() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+BOOL LoggerserviceDebugChildThread::Start(ELoggerserviceDebugThreads id, const char* parentsName,
+ const char * sendDataToQue,
+ void* (*routine)(void*),
+ const char * sendToUdpQue) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL rtn = FALSE;
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] == NULL) {
+ if ( NULL
+ != (threads[id] = new (std::nothrow) CChild(parentsName,
+ sendDataToQue,
+ names[id].c_str(),
+ routine, sendToUdpQue))) {
+ rtn = TRUE;
+ }
+ } else {
+ rtn = TRUE;
+ }
+ }
+
+ return rtn;
+}
+// LCOV_EXCL_STOP
+
+void LoggerserviceDebugChildThread::Stop(ELoggerserviceDebugThreads id) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] != NULL) {
+ delete threads[id];
+ threads[id] = NULL;
+ }
+ }
+}
+// LCOV_EXCL_STOP
+
+BOOL LoggerserviceDebugChildThread::Running(ELoggerserviceDebugThreads id) const { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL rtn = FALSE;
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] != NULL) {
+ rtn = TRUE;
+ }
+ }
+
+ return rtn;
+}
+// LCOV_EXCL_STOP
+
+void LoggerserviceDebugChildThread::StopAll() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ for (int id = kLoggerserviceDebugLogQueReader; id < kLoggerserviceDebugMax; id++) {
+ if (threads[id] != NULL) {
+ threads[id]->Join();
+ delete threads[id];
+ threads[id] = NULL;
+ }
+ }
+}
+// LCOV_EXCL_STOP
+
+const char * LoggerserviceDebugChildThread::Name(ELoggerserviceDebugThreads id) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ return names[id].c_str();
+ }
+
+ return NULL;
+}
+// LCOV_EXCL_STOP
+
+void LoggerserviceDebugChildThread::LiftWaitBarrier(ELoggerserviceDebugThreads id) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] != NULL) {
+ threads[id]->IsValidWaitBarrier();
+ }
+ }
+}
+// LCOV_EXCL_STOP
+
diff --git a/systemservice/logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp b/systemservice/logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp
new file mode 100755
index 0000000..5d29a58
--- /dev/null
+++ b/systemservice/logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp
@@ -0,0 +1,1362 @@
+/*
+ * @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_NS_LogTraceSender
+/// \brief frameworkunifieddebug writer thread class, handles writing a log file
+/// all really done by my_writer class.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include "loggerservicedebug_writer_Evntworker.h"
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <sys/timeb.h>
+#include <boost/bind.hpp>
+#include <errno.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_timer.h>
+#include <loggerservicedebug_thread_if.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_templates.h>
+#include <stub/Clock_API.h>
+#include <new>
+#include <utility>
+#include <string>
+
+/// Macros definition for the constants
+#define SIZE_0 (size_t)0
+#define SIZE_1 (size_t)1
+#define COUNTER_SIZE 6 ///< Counter ID 2 bytes and Counter Value is 4 bytes
+#define SINGLE_EVENT_INFO_SIZE 10 ///< Event log size
+#define INITIAL_CNT_VALUE 0x00000001 ///< Init count value for counter logging
+#define MAX_CNT_VALUE 0xFFFFFFFF ///< Max count calue for counter logging
+#define MAX_USB_DEVICE 2 ///< Max USB devices
+
+// Temp path for event logs that used for copying to USB
+const CHAR TMP_DEBUG_EVNTLOG_PATH_FN[] = "/tmp/loggerservice_Evntdebug.dat";
+
+// Structure to hold the USB device information
+TThrdEvtLogStore gSUSBDevInfo[MAX_USB_DEVICE] = { };
+
+// Structure to hold the SD card device information
+TThrdEvtLogStore gSSDCardevInfo = { };
+
+// Object for device detection class
+DeviceDetectionServiceIf m_device_detector_obj;
+
+// Map container for startup phase counter
+CounterInformation CEvntWriterWorker::counter;
+
+// Deque container for event logging
+DEQUE_Event_Type CEvntWriterWorker::deque_event_info;
+
+static CEvntWriterWorker * pObj = new (std::nothrow) CEvntWriterWorker(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+static TEvntWriterInfo wi = { };
+
+// Event Common Info global structure
+extern UEvtLoggerCommonInfo g_uEvtLoggerCommonInfo;
+extern UI_16 g_u16DiagId;
+static EFrameworkunifiedStatus ReadEventLogQueue(HANDLE hThread);
+// created global variables as they are used in non member function
+HANDLE g_hReceive = NULL;
+HANDLE g_hEvtLogTimer = NULL;
+
+CEvntWriterWorker::CEvntWriterWorker()
+ : m_u32MileageData(0),
+ m_u32NumberEventsLogged(0) {
+ memset(m_stVINnumber.VINstr, 0, m_stVINnumber.VIN_LEN);
+}
+
+CEvntWriterWorker::~CEvntWriterWorker() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::Initialize(HANDLE hThread) {
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :EventLogRegisterCbHandlers
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::EventLogRegisterCbHandlers(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FrameworkunifiedProtocolCallbackHandler aParentHandlers[] = { {
+ eThrdCmdWriteEvntFilesToUsb, boost::bind(
+ &CEvntWriterWorker::OnCmdWriteEventFilesToUsb, this, _1) }, {
+ eThrdCmdClearEvntLogs, boost::bind(
+ &CEvntWriterWorker::OnCmdClearEventLogs, this, _1) }, {
+ eThrdCmdStatisticalCounter, boost::bind(
+ &CEvntWriterWorker::OnCmdReadStatisticalCounter, this, _1) }, {
+ eThrdCmdResetStatisticalCntrs, boost::bind(
+ &CEvntWriterWorker::OnCmdResetStatisticalCounter, this, _1) }, {
+ eThrdCmdSetVINnumber, boost::bind(&CEvntWriterWorker::OnCmdSetVIN, this,
+ _1) }, { eThrdCmdImmPersistEvtLog,
+ boost::bind(&CEvntWriterWorker::immediate_persist_event_log, this, _1) },
+ { eThrdCmdMileageData, boost::bind(&CEvntWriterWorker::EvtThd_SetMileage,
+ this, _1) }, {
+ eThrdCmdGetNumberOfEventsLogged, boost::bind(
+ &CEvntWriterWorker::OnCmdReadNumberOfEventsLogged, this, _1) }, {
+ eThrdCmdUploadEventLog, boost::bind(
+ &CEvntWriterWorker::OnCmdUploadEventLog, this, _1) } };
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedAttachParentCallbacksToDispatcher(
+ hThread, aParentHandlers, _countof(aParentHandlers)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: parent call backs attach failed , err code: %d", l_eStatus);
+ }
+
+ // TO DO replace the queue name with macro EVENTLOG_MSGQ_NAME, after NS delivers it.
+ if (NULL != (g_hReceive = McOpenReceiverNotBlocked("/EvntLogQue"))) {
+ if (NULL
+ == (g_hEvtLogTimer = FrameworkunifiedAttachTimerCallback(hThread, 100, 1000,
+ ReadEventLogQueue))) {
+ LOG_ERROR("FrameworkunifiedAttachTimerCallback()");
+ }
+ } else {
+ LOG_ERROR("McOpenReceiverNotBlocked");
+ }
+
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus ReadEventLogQueue(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ CHAR source[MAX_QUEUE_NAME_SIZE];
+ UI_32 l_cmd = 0;
+ UI_8 pbuf[MAX_QUEUE_MSG_SIZE];
+
+ if (NULL != g_hReceive) { // LCOV_EXCL_BR_LINE 6: g_hReceive is always null
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ while (1) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = McReceive(g_hReceive, source, &l_cmd,
+ MAX_QUEUE_MSG_SIZE,
+ pbuf))) {
+ break;
+ } else {
+ switch (l_cmd) {
+ case SS_MSG_EVTLOG:
+ if (pObj) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->OnCmdEventLog(pbuf))) {
+ LOG_ERROR("OnCmdEventLog()");
+ }
+ } else {
+ LOG_ERROR("pObj NULL");
+ }
+ break;
+
+ case SS_MSG_LOGGERCNT:
+ if (pObj) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->OnCmdIncrcount(pbuf))) {
+ LOG_ERROR("OnCmdIncrcount()");
+ }
+ } else {
+ LOG_ERROR("pObj NULL");
+ }
+ break;
+
+ case SS_MSG_LOGGER_CNT_EVTLOG:
+ if (pObj) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = pObj->OnCmdIncrwriteevent(pbuf))) {
+ LOG_ERROR("OnCmdIncrwriteevent()");
+ }
+ } else {
+ LOG_ERROR("pObj NULL");
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ LOG_ERROR("Receive Handle NULL"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+
+ if (eFrameworkunifiedStatusErrNoEAGAIN == l_eStatus) { // LCOV_EXCL_BR_LINE 6: l_eStatus is always eFrameworkunifiedStatusOK
+ l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_LINE 6: l_eStatus is always eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////
+/// Function :EvntWriterWorkerOnStart
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus EvntWriterWorkerOnStart(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hThread, (PVOID) &wi, sizeof(wi), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Unable to read handle from FrameWork Thread.%d", eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Successfully read handle from FrameWork Thread.\n"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+
+ // Device Detection Obj initialization
+ if (m_device_detector_obj.Initialize(hThread)) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ memset(&gSUSBDevInfo, 0, sizeof(gSUSBDevInfo));
+ memset(&gSSDCardevInfo, 0, sizeof(gSSDCardevInfo));
+
+ if (eFrameworkunifiedStatusOK != (eStatus = m_device_detector_obj.NotifyOnDeviceDetectionAvailability( DD_USBServiceAvailabilityCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: ServiceAvailabilityCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = m_device_detector_obj.NotifyOnOpenSessionAck( DD_USBOpenSessionAckCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: OpenSessionAckCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = m_device_detector_obj.NotifyOnCloseSessionAck( DD_USBCloseSessionAckCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CloseSessionCallback registration failed");
+ }
+ } else {
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Device Detection Object Initialization failed!");
+ // LCOV_EXCL_STOP
+ }
+
+ if (pObj) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ FrameworkunifiedSetThreadSpecificData(hThread, pObj);
+ if (eFrameworkunifiedStatusOK != (eStatus = pObj->Initialize(hThread))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CEvntWriterWorker Initialize Failed");
+ }
+ } else {
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "pObj is NULL");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :EvntWriterWorkerOnStop
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus EvntWriterWorkerOnStop(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ if (pObj) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ if (NULL != g_hEvtLogTimer) { // LCOV_EXCL_BR_LINE 200:As it is always NULL
+ // LCOV_EXCL_START 200:As it is always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CALL_AND_LOG_STATUS(FrameworkunifiedDetachTimerCallback(hThread, g_hEvtLogTimer));
+ g_hEvtLogTimer = NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ /// To Read all msgs of EventLog queue on shutdown
+ CALL_AND_LOG_STATUS(ReadEventLogQueue(hThread)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ /// Close ReadEventLog Queue receive handle
+ if (NULL != g_hReceive) { // LCOV_EXCL_BR_LINE 200:As it is always NULL
+ // LCOV_EXCL_START 200:As it is always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CALL_AND_LOG_STATUS(McClose(g_hReceive));
+ g_hReceive = NULL;
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdIncrcount_phase
+///////////////////////////////////////////////////////////////////////
+VOID CEvntWriterWorker::OnCmdIncrcount_phase(st_LogCount *cnt) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ if (NULL != cnt) {
+ EStatCounterGroupID group;
+ UI_16 counterID = ((*cnt).cnt_id);
+ group = static_cast<EStatCounterGroupID>((counterID >> 8) & 0x00FF);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "Increment counter(%04X) for group(%02X) by one", counterID, group);
+ counterIncrementByValue(group, counterID, 0x01u);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Function call without parameter");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdIncrcount
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdIncrcount(UI_8 *pbuf) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ st_LogCount cnt;
+
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = McGetDataOfSize(pbuf, (PVOID) &cnt, sizeof(cnt)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "call increment function cnt.phase=%x,cnt.ID=%x", cnt.phase,
+ cnt.cnt_id);
+ OnCmdIncrcount_phase(&cnt);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Not recieved data from q");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdIncrwriteevent
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdIncrwriteevent(UI_8* pbuf) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ st_LogEvent EC;
+ st_LogEvent_ss ev = { };
+ st_LogCount C;
+
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = McGetDataOfSize(pbuf, (PVOID) &EC, sizeof(EC)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Successful increment");
+ ev.event_id = EC.event_id;
+ ev.data[0] = EC.data[0];
+ ev.data[1] = EC.data[1];
+ ev.data[2] = EC.data[2];
+ ev.data[3] = EC.data[3];
+ OnCmdWriteEventLogs(&ev);
+ C.phase = (SystemPhase) (EC.phase);
+ C.cnt_id = EC.cnt_ID;
+ OnCmdIncrcount_phase(&C);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Not recieved data from q");
+ }
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdWriteEventLogs
+///////////////////////////////////////////////////////////////////////
+VOID CEvntWriterWorker::OnCmdWriteEventLogs(st_LogEvent_ss *ev) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ UI_32 u32deque_size = 0;
+ u32deque_size = static_cast<UI_32>(deque_event_info.size());
+ u32deque_size = u32deque_size * SINGLE_EVENT_INFO_SIZE; // Existing Event Info size
+ u32deque_size += SINGLE_EVENT_INFO_SIZE;
+ // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size before write:%X ",u32deque_size);
+
+ if (u32deque_size > MAX_EVENTLOG_SIZE) {
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size will be exceeded after new event:%X ",u32deque_size);
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Removed the oldest event and add latest event in the the end");
+ deque_event_info.pop_front();
+ u32deque_size = static_cast<UI_32>(deque_event_info.size());
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size after pop:%X ",(u32deque_size*SINGLE_EVENT_INFO_SIZE));
+ }
+ deque_event_info.push_back(*ev);
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size after write:%X ",
+// (deque_event_info.size()*SINGLE_EVENT_INFO_SIZE));
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+UI_32 LS_ConvertEndian(UI_32 * pvar) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ UI_32 retVal = (UI_32) 0;
+ UI_32 var = *pvar;
+ retVal = (((var & 0xFF000000) >> 24) | ((var & 0x00FF0000) >> 8)
+ | ((var & 0x0000FF00) << 8) | ((var & 0x000000FF) << 24));
+ return (retVal);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdEventLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdEventLog(UI_8* pbuf) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ st_LogEvent_ss ev = { };
+ st_LogEvent_full ev_full = { };
+ UI_32 l_mileage;
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = McGetDataOfSize(pbuf, &ev_full, sizeof(ev_full)))) {
+ if (0 != ev_full.grp_ID) {
+ if (0x01 == ev_full.grp_ID) {
+ // copied to local var as m_u32MileageData value is persisted
+ l_mileage = m_u32MileageData;
+ ev.ts = LS_ConvertEndian(&l_mileage);
+ } else {
+ ev.ts = ev_full.ts;
+ }
+ ev.grp_ID = ev_full.grp_ID;
+ ev.event_id = ev_full.event_id;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "TS %u, GRPID %d, EVTID %d", ev.ts,
+ ev.grp_ID, ev.event_id);
+ // FRAMEWORKUNIFIEDLOG_EVT(Zone,EventId,4,data0,data1,data2,data3)
+ // Data in tool should be represented in Little Endian format means data3(MSB)..data0(LSB)
+ // In the COMMON_DATA, 1st element of structure u_stEvtLoggerCommonInfo is stored in the CommonData[0],
+ // ie BodayCAN_Stat,
+ // in the data array, byte0=>MSB, byte3=>LSB in the tool
+ if (ev_full.typeofdata == COMMON_DATA) {
+ for (UI_8 j = 0; j < 3; j++) {
+ ev.data[j] = g_uEvtLoggerCommonInfo.CommonData[j];
+ }
+ // byte0 param
+ ev.data[3] = ev_full.data[0];
+ } else {
+ // in array data[0] => MSB in tool, data[3] => LSB in the tool
+ for (UI_8 i = 4, j = 0; i > 0 && j < 4; i--, j++) {
+ ev.data[i - 1] = ev_full.data[j];
+ }
+ }
+ OnCmdWriteEventLogs(&ev);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Invalid event");
+ }
+ }
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdStop
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdStop(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdStart(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :read_count_from_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::readCountFromFile(PCSTR filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 counter_ID = 0;
+ UI_32 counter_val = 0;
+ FILE* fp;
+ if (filename != NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Open counter file:%s", filename);
+ if (NULL != (fp = ::fopen(filename, "r"))) {
+ while (!feof(fp)) {
+ EStatCounterGroupID group;
+ UI_8 groupID;
+ UI_8 count = static_cast<UI_8>(::fscanf(fp, "%04X%08X", &counter_ID, &counter_val));
+ groupID = (counter_ID >> 8) & 0xFF;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Read: 0x%04X 0x%08X", counter_ID,
+ counter_val);
+ if ((count == 2u)
+ && (groupID >= static_cast<UI_8>(STARTUP_SHUTDOWN_COUNTER_GROUP))
+ && (groupID <= static_cast<UI_8>(APP_USAGE_COUNTER_GROUP))) {
+ // Check if group is valid before casting it o EStatCounterGroup
+ group = static_cast<EStatCounterGroupID>(groupID);
+ counterIncrementByValue(group, static_cast<UI_16>(counter_ID), counter_val);
+ }
+ }
+ ::fclose(fp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Normal File failed to open");
+ eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Filename is NULL-pointer");
+ eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::writeGroupToFile(FILE *fp,
+ EStatCounterGroupID group) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (fp != NULL) {
+ CounterInformation::iterator countInfIt = counter.find(group);
+ if (countInfIt != counter.end()) {
+ Counter count = countInfIt->second;
+ if (!count.empty()) {
+ Counter::iterator countIt;
+ for (countIt = count.begin(); countIt != count.end(); ++countIt) {
+ ::fprintf(fp, "%04X%08X\n", countIt->first, countIt->second);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Written %d entries for Group 0x%02X",
+ (UI_8)count.size(), (UI_8)group);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Group 0x%02X is empty", (UI_8)group);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Group not found in map");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Parameter fp is NULL-pointer");
+ eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :writeCountToFile
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::writeCountToFile(PCSTR filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FILE *fp;
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CounterInformation::iterator countInfIt;
+ if (0 == strcmp(filename, Counter_LOG_PATH_FN)) {
+ if (NULL != (fp = ::fopen(filename, "w"))) {
+ for (countInfIt = counter.begin(); countInfIt != counter.end();
+ ++countInfIt) {
+ (void) writeGroupToFile(fp, countInfIt->first);
+ }
+ ::fclose(fp);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Not valid file");
+ eStatus = eFrameworkunifiedStatusErrNoEBADF;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :read_events_from_buffer
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+VOID CEvntWriterWorker::read_events_from_buffer(
+ STEventLogPersistBuffer* f_pstEvtLogBuf) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ deque_event_info.clear();
+ for (int i = 0; i < (f_pstEvtLogBuf->Current_Log_Size); i++) {
+ if (i < f_pstEvtLogBuf->EVT_BUFMAXSIZE) {
+ deque_event_info.push_back(f_pstEvtLogBuf->EvtLog_Buffer[i]);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: EventLog buffer size greater than EVT_BUFMAXSIZE");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Size of DEQUE event is :%d",
+ static_cast<int>(deque_event_info.size()));
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :write_events_to_buffer
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+VOID CEvntWriterWorker::write_events_to_buffer(
+ STEventLogPersistBuffer* f_pstEvtLogBuf) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ st_LogEvent_ss l_event_info;
+ DEQUE_Event_Type::iterator deque_it;
+ deque_it = deque_event_info.begin();
+ int i = 0;
+
+ memset(f_pstEvtLogBuf, 0x00, sizeof(STEventLogPersistBuffer));
+ while (deque_it != deque_event_info.end()) {
+ if (0x00 != deque_it->grp_ID) {
+ l_event_info.ts = deque_it->ts;
+ l_event_info.grp_ID = deque_it->grp_ID;
+ l_event_info.event_id = deque_it->event_id;
+ memcpy(l_event_info.data, deque_it->data, sizeof(l_event_info.data));
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Event record is:%X ",++EventRecordCnt);
+ if (i < f_pstEvtLogBuf->EVT_BUFMAXSIZE) {
+ memcpy(&f_pstEvtLogBuf->EvtLog_Buffer[i], &l_event_info,
+ sizeof(l_event_info));
+ }
+ }
+ deque_it++;
+ i++;
+ }
+ f_pstEvtLogBuf->Current_Log_Size = static_cast<UI_16>(deque_event_info.size());
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Size of DEQUE event is :%d",
+ static_cast<int>(deque_event_info.size()));
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :write_event_to_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::write_event_to_file(const CHAR* filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 u32File_Size;
+ st_LogEvent_ss Sevent_Info;
+ DEQUE_Event_Type::iterator deque_it;
+ FILE *fp;
+
+ if (NULL != (fp = ::fopen(filename, "wb"))) {
+ deque_it = deque_event_info.begin();
+ while (deque_it != deque_event_info.end()) {
+ Sevent_Info.ts = deque_it->ts;
+ Sevent_Info.grp_ID = deque_it->grp_ID;
+ Sevent_Info.event_id = deque_it->event_id;
+ memcpy(Sevent_Info.data, deque_it->data, sizeof(Sevent_Info.data));
+
+ if (0x00 != deque_it->grp_ID) {
+ if (SIZE_1
+ != (u32File_Size = static_cast<UI_32>(::fwrite(&Sevent_Info, sizeof(Sevent_Info), 1,
+ fp)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Writing in to file is failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ }
+ deque_it++;
+ }
+ ::fclose(fp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: File failed to open");
+ eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdClearEventLogs
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdClearEventLogs(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSessionData l_stSessionData;
+ TClearEvntLogCmdResponse l_stCmdResponse;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(hThread,
+ l_stCmdResponse.stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ deque_event_info.clear();
+ if (eFrameworkunifiedStatusOK != (l_eStatus = immediate_persist_event_log(hThread))) {
+ l_stCmdResponse.u8Response = (UI_8) CLEAR_EVENT_LOG_FAILED;
+ } else {
+ l_stCmdResponse.u8Response = (UI_8) CLEAR_EVENT_LOG_SUCCESS;
+ }
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread, eThrdCmdClearEventLogResponse,
+ sizeof(TClearEvntLogCmdResponse),
+ &l_stCmdResponse))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP 8
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdSetVIN
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdSetVIN(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STVIN_NUMBER l_stVIN_Number;
+
+ if (eFrameworkunifiedStatusOK
+ == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hThread, &l_stVIN_Number,
+ sizeof(l_stVIN_Number), eSMRRelease))) {
+ memcpy(&m_stVINnumber, &l_stVIN_Number, sizeof(STVIN_NUMBER));
+ }
+
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdGetVIN
+///////////////////////////////////////////////////////////////////////
+VOID CEvntWriterWorker::OnCmdGetVIN(STVIN_NUMBER& f_stVIN_Number) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ memcpy(&f_stVIN_Number, &m_stVINnumber, sizeof(STVIN_NUMBER));
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdWriteEventFilesToUsb
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdWriteEventFilesToUsb(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TWriteFilesToUsbCmdData l_stCmdData;
+ TWriteFilesToUsbCmdResponse l_stCmdResponse;
+
+ TThrdEvtLogStore evt = { };
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TWriteFilesToUsbCmdData>(hThread, l_stCmdData))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if ((USB0 == l_stCmdData.eDevId) || (USB1 == l_stCmdData.eDevId)) {
+ memcpy(&evt, &gSUSBDevInfo[l_stCmdData.eDevId], sizeof(TThrdEvtLogStore));
+ } else if (SD == l_stCmdData.eDevId) {
+ memcpy(&evt, &gSSDCardevInfo, sizeof(TThrdEvtLogStore));
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ LOG_ERROR("Invalid DeviceId()");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "USB dev info:Available %d, Location %s, Parse %s ",
+ evt.IsDeviceAvailable, evt.parse_fn, evt.location);
+ l_stCmdResponse.u8Response = copy_event_files_to_usb(&evt);
+ l_stCmdResponse.stSessiondata.strSrcName = l_stCmdData.stSessiondata.strSrcName;
+ l_stCmdResponse.stSessiondata.session_id = l_stCmdData.stSessiondata.session_id;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread, eThrdCmdCopyEventLogUSBResponse,
+ sizeof(TWriteFilesToUsbCmdResponse),
+ &l_stCmdResponse))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdReadStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdReadStatisticalCounter(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SStatisticalCounter buffer = { 0 };
+ TStatisticalCntCmdSuccessResp l_stCmdSuccessResp;
+
+ if (hThread != NULL) {
+ TStatisticalCountersCmd l_stCmdData;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TStatisticalCountersCmd>(hThread, l_stCmdData))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadStatisticalCounter(l_stCmdData.eGroupId, buffer))) {
+ LOG_ERROR("ReadStatisticalCounter()");
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread,
+ eThrdCmdStatisticalCounterErrorResp,
+ sizeof(TSessionData),
+ &l_stCmdData.stSessiondata))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ } else {
+ (VOID) memcpy(&l_stCmdSuccessResp.stBuffer, &buffer,
+ sizeof(SStatisticalCounter));
+ (VOID) memcpy(&l_stCmdSuccessResp.stSessiondata,
+ &l_stCmdData.stSessiondata, sizeof(TSessionData));
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread,
+ eThrdCmdStatisticalCounterSuccessResp,
+ sizeof(TStatisticalCntCmdSuccessResp),
+ &l_stCmdSuccessResp))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :ReadStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::ReadStatisticalCounter(
+ EStatCounterGroupID eCounterGroup, SStatisticalCounter& buffer) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 size = 0u;
+
+ CounterInformation::iterator countInfIt = counter.find(eCounterGroup);
+ if (counter.end() != countInfIt) {
+ Counter count = countInfIt->second;
+ Counter::iterator countIt;
+ if (((UI_16) count.size()) <= 40) {
+ for (countIt = count.begin(); countIt != count.end(); ++countIt) {
+ UI_16 counterID = countIt->first;
+ UI_32 counterVal = countIt->second;
+ u16copy(&buffer.StatisticalCountBuffer[size], counterID);
+ size += static_cast<UI_16>( sizeof(counterID));
+
+ counterVal = countIt->second;
+ u32copy(&buffer.StatisticalCountBuffer[size], counterVal);
+ size += static_cast<UI_16>( sizeof(counterVal));
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldBuf;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Too many counter elements %02d > 42 ", static_cast<int>(count.size()));
+ }
+ } else {
+ /*OK, here: empty buffer will be returned*/
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdResetStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdResetStatisticalCounter(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TStatisticalCountersCmd l_stCmdData;
+
+ if (hThread != NULL) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TStatisticalCountersCmd>(hThread, l_stCmdData))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ResetStatisticalCounter(l_stCmdData.eGroupId))) {
+ LOG_ERROR("ResetStatisticalCounter()");
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+///////////////////////////////////////////////////////////////////////
+/// Function :ResetStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::ResetStatisticalCounter(
+ EStatCounterGroupID eCounterGroup) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ CounterInformation::iterator countInfIt;
+ countInfIt = counter.find(eCounterGroup);
+ if (counter.end() != countInfIt) {
+ countInfIt->second.clear();
+ counter.erase(countInfIt->first);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Erased group: 0x%02X from map",
+ (UI_8)eCounterGroup);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :_GetCurrentTimeString
+///////////////////////////////////////////////////////////////////////
+PSTR _GetCurrentTimeString(PCHAR TempFileName, PSTR f_pstrVIN) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ uint32_t rawtime;
+ uint8_t status;
+ struct tm local_time;
+ CHAR tbuf[30];
+ UI_8 l_len = 0;
+ std::string l_strVIN = f_pstrVIN;
+
+ // Time string is based on current date and time. Time string format is <year-mon-dayThhmm>.
+ Clock_getSystemTimeY2K38(&rawtime, &status);
+ Clock_getLocalTimeY2K38(&rawtime, &local_time);
+ if (0
+ != (l_len = static_cast<UI_8>(strftime(tbuf, sizeof(tbuf), "%Y-%m-%dT%H%M",
+ &local_time)))) {
+ sprintf(TempFileName, "%s_%s_%04X.dat", l_strVIN.c_str(), tbuf, // NOLINT (runtime/printf)
+ g_u16DiagId);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "EventLog File Name :%s, tbuf_len = %d",
+ TempFileName, l_len);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return TempFileName;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :copy_event_files_to_usb
+///////////////////////////////////////////////////////////////////////
+UI_8 CEvntWriterWorker::copy_event_files_to_usb(TThrdEvtLogStore *pStUSBIndo) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ CHAR buffer[10];
+ CHAR TempFileName[MAX_SYS_INFO_SIZE];
+ STVIN_NUMBER l_stVIN_Number;
+ std::string _filename("");
+ UI_8 u8Result = COPY_EVT_USB_SUCCESS;
+
+ // Initializing all Char arrays.
+ memset(buffer, 0, 10);
+ memset(TempFileName, 0, MAX_SYS_INFO_SIZE);
+
+ if (pStUSBIndo->IsDeviceAvailable == TRUE) {
+ _filename = pStUSBIndo->location;
+ OnCmdGetVIN(l_stVIN_Number);
+ _filename += _GetCurrentTimeString(TempFileName, l_stVIN_Number.VINstr);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = write_event_to_file(_filename.c_str()))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Write to file failed:%d",
+ l_eStatus);
+ u8Result = (UI_8) USB_DEVICE_WRITE_ERROR;
+ }
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Device not available, so event logs can not be copied");
+ u8Result = (UI_8) USB_DEVICE_NOT_AVAILABLE;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return u8Result;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :DD_USBSrvDetectionCallBack
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBSrvDetectionCallBack(HANDLE hApp) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ SS_MediaDetectInfo tMediaDetectInfo = { };
+ std::string FilePathStr;
+ UI_8 u8Pos = 0;
+
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tMediaDetectInfo,
+ sizeof(tMediaDetectInfo)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "MediaDetectCallBack FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x ",
+ eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Device = %d", tMediaDetectInfo.dev_type);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Availability = %d",
+ tMediaDetectInfo.bIsDeviceAvailable);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " device path = %s",
+ tMediaDetectInfo.deviceMountpath);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " File path = %s",
+ tMediaDetectInfo.filepathName);
+
+ FilePathStr.append(tMediaDetectInfo.deviceMountpath);
+
+ if (tMediaDetectInfo.dev_type == eUSB) {
+ if (tMediaDetectInfo.bIsDeviceAvailable == TRUE) {
+ u8Pos = static_cast<UI_8>(FilePathStr.find_last_of("/\\"));
+
+ if (FilePathStr.compare(u8Pos + 1, 12, "usb-00-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB1 Detected ");
+ gSUSBDevInfo[0].IsDeviceAvailable = TRUE;
+ snprintf(gSUSBDevInfo[0].parse_fn, gSUSBDevInfo[0].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ snprintf(gSUSBDevInfo[0].location, gSUSBDevInfo[0].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ } else if (FilePathStr.compare(u8Pos + 1, 12, "usb-01-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB2 Detected ");
+ gSUSBDevInfo[1].IsDeviceAvailable = TRUE;
+ snprintf(gSUSBDevInfo[1].parse_fn, gSUSBDevInfo[1].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ snprintf(gSUSBDevInfo[1].location, gSUSBDevInfo[1].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB Detected :%s", FilePathStr.c_str());
+ }
+ } else {
+ u8Pos = static_cast<UI_8>(FilePathStr.find_last_of("/\\"));
+
+ if (FilePathStr.compare(u8Pos + 1, 12, "usb-00-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB1 Ejected ");
+ gSUSBDevInfo[0].IsDeviceAvailable = FALSE;
+ } else if (FilePathStr.compare(u8Pos + 1, 12, "usb-01-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB2 Ejected ");
+ gSUSBDevInfo[1].IsDeviceAvailable = FALSE;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB Ejected :%s", FilePathStr.c_str());
+ }
+ }
+
+ } else if (tMediaDetectInfo.dev_type == eSD) {
+ if (tMediaDetectInfo.bIsDeviceAvailable == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SD card Detected ");
+ gSSDCardevInfo.IsDeviceAvailable = TRUE;
+ snprintf(gSSDCardevInfo.parse_fn, gSSDCardevInfo.FN_LEN, "%s/",
+ FilePathStr.c_str());
+ snprintf(gSSDCardevInfo.location, gSSDCardevInfo.FN_LEN, "%s/",
+ FilePathStr.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SD card Ejected ");
+ gSSDCardevInfo.IsDeviceAvailable = FALSE;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : DD_USBServiceAvailabilityCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBServiceAvailabilityCallBack(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (FrameworkunifiedIsServiceAvailable(hThread)) {
+ if (eFrameworkunifiedStatusOK // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful
+ != (eStatus = m_device_detector_obj.OpenSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Open session request failed");
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful
+ != (eStatus = m_device_detector_obj.CloseSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Close session request failed");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : DD_USBOpenSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBOpenSessionAckCallBack(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful
+ m_device_detector_obj.DecodeOpenSessionResponse())) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = m_device_detector_obj.RegisterForDeviceDetectionEvent( // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful // NOLINT[whitespace/line_length]
+ SS_DEV_DETECT_ANY_USB_EV, DD_USBSrvDetectionCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Registration for SS_DEV_DETECT_ANY_USB_EV failed");
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = m_device_detector_obj.RegisterForDeviceDetectionEvent( // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful // NOLINT[whitespace/line_length]
+ SS_DEV_DETECT_ANY_SD_EV, DD_USBSrvDetectionCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Registration for SS_DEV_DETECT_ANY_SD_EV failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Decode open session response failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+//////////////////////////////////////////
+// Function : DD_USBCloseSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBCloseSessionAckCallBack(HANDLE hApp) { // LCOV_EXCL_START 200: CloseSessionRequest can not be called // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CloseSessionAck tCloseSessionAck = { };
+
+ if (hApp) {
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tCloseSessionAck,
+ sizeof(tCloseSessionAck)))) {
+ if (eFrameworkunifiedStatusOK == tCloseSessionAck.eStatus) {
+ UI_32 l_uiSessionId = tCloseSessionAck.sessionId;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "session %d closed successfully",
+ l_uiSessionId);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::counterIncrementByValue(EStatCounterGroupID group,
+ UI_16 id, UI_32 value) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus result = eFrameworkunifiedStatusFail;
+ CounterInformation::iterator count_inf_it;
+ count_inf_it = counter.find(group);
+ if (counter.end() == count_inf_it) {
+ Counter newCounter;
+ newCounter.insert(std::pair<UI_16, UI_32>(id, value));
+ counter.insert(std::pair<EStatCounterGroupID, Counter>(group, newCounter));
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "Added new Counter for group %d, id: 0x%04X, value: 0x%08X",
+ (UI_8)group, id, value);
+ } else {
+ Counter::iterator count_it;
+ count_it = count_inf_it->second.find(id);
+ if (count_inf_it->second.end() == count_it) {
+ count_inf_it->second.insert(std::pair<UI_16, UI_32>(id, value));
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "Added new Entry for group %d, id: 0x%04X, value: 0x%08X",
+ (UI_8)group, id, value);
+ } else {
+ if (count_it->second != MAX_CNT_VALUE) {
+ count_it->second += value;
+ }
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_FUNC,
+ __FUNCTION__,
+ "Modified Entry for group %d, id: 0x%04X, by value: 0x%08X, new value: 0x%08X",
+ (UI_8)group, id, value, count_it->second);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return result;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::immediate_persist_event_log(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ STEventLogPersistBuffer* l_evtlogbuf;
+ l_evtlogbuf = new (std::nothrow) STEventLogPersistBuffer;
+
+ if (NULL != l_evtlogbuf) {
+ if (pObj) {
+ pObj->write_events_to_buffer(l_evtlogbuf);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CEvntWriterWorker Object handle is NULL");
+ }
+ delete l_evtlogbuf;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: New failed to allocate memory, err: %s", strerror(errno));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::EvtThd_SetMileage(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_u32mileage;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hThread, &l_u32mileage,
+ sizeof(l_u32mileage)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Failed Status:%d ",
+ l_eStatus);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ m_u32MileageData = l_u32mileage;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :write_mileage_to_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::write_mileage_to_file(const CHAR* filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 u32File_Size;
+ SI_32 fd = -1;
+
+ if (-1 != (fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))) {
+ if (SIZE_0
+ >= (u32File_Size = static_cast<UI_32>(::write(fd, &m_u32MileageData, sizeof(UI_32))))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Writing in to file is failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ ::close(fd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: File failed to open");
+ eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :read_mileage_from_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::read_mileage_from_file(const CHAR* filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+// UI_32 u32File_Size;
+ SI_32 fd = -1;
+
+ if (NULL != filename) {
+ if (-1 != (fd = ::open(filename, O_RDONLY, S_IRUSR))) {
+ if (-1 == ::read(fd, &m_u32MileageData, sizeof(UI_32))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Reading file failed, %s",
+ strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "m_u32MileageData = %d",
+ m_u32MileageData);
+ }
+ ::close(fd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: File failed to open");
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Filename is NULL");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdReadNumberOfEventsLogged
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdReadNumberOfEventsLogged(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TEvntsLogged l_stEventsLogged;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(hThread,
+ l_stEventsLogged.stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ l_stEventsLogged.u16numberofeventslogged = (UI_16) deque_event_info.size();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Number of Events Read: %d",
+ l_stEventsLogged.u16numberofeventslogged);
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread,
+ eThrdCmdNumberOfEventsLoggedResponse,
+ sizeof(TEvntsLogged), &l_stEventsLogged))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Error: FrameworkunifiedSendMsg failed %d", l_eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdUploadEventLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdUploadEventLog(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(
+ hThread, m_stUploadEventLogResp.stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (pObj) {
+ pObj->write_events_to_buffer(&m_stUploadEventLogResp.stEventLogBuffer);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread, eThrdCmdUploadEventLogResponse,
+ sizeof(TUploadEventLogResp),
+ &m_stUploadEventLogResp))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CEvntWriterWorker Object handle is NULL");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdCopyEvntLogToTmp
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdCopyEvntLogToTmp(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
diff --git a/systemservice/logger_service/server/src/mem_reader.cpp b/systemservice/logger_service/server/src/mem_reader.cpp
new file mode 100755
index 0000000..5ad6a6c
--- /dev/null
+++ b/systemservice/logger_service/server/src/mem_reader.cpp
@@ -0,0 +1,125 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports reading from a shared mem area.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader/mem_reader.h"
+#include <string>
+
+namespace ReaderWriter {
+
+CMemReader::CMemReader()
+ : m_pSharedBuf(NULL),
+ m_sharedBufSize(0) {
+}
+
+CMemReader::~CMemReader() {
+ this->Close();
+}
+
+EFrameworkunifiedStatus CMemReader::Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ m_sharedBufSize = f_maxSize;
+ m_pSharedBuf = new (std::nothrow) CNSSharedMemReader(f_name, TRUE); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ l_eStatus = this->Open();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CMemReader::Open(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_pSharedBuf will noe be null
+ if (!m_pSharedBuf->IsOpen()) {
+ // maps the shared memory buffer
+ l_eStatus = m_pSharedBuf->Open();
+ } else {
+ // Already opened no action required
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+BOOL CMemReader::IsOpen(void) {
+ return this->m_pSharedBuf->IsOpen();
+}
+
+EFrameworkunifiedStatus CMemReader::Read(UI_8* f_data, UI_32 f_length, SI_32& f_bytesRead) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (this->m_pSharedBuf != NULL) {
+ if (TRUE != this->m_pSharedBuf->IsOpen()) {
+ l_eStatus = m_pSharedBuf->Open();
+ }
+ if (l_eStatus == eFrameworkunifiedStatusOK) {
+ f_bytesRead = m_pSharedBuf->Read(reinterpret_cast<char *>(f_data), f_length);
+ if (NS_SHM_ERROR != f_bytesRead) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CMemReader::ReadToFile(std::string f_fileName, UI_32& f_Written) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ if ((NULL != m_pSharedBuf) && // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_pSharedBuf will noe be null
+ (f_fileName.length() != 0)) {
+ l_eStatus = m_pSharedBuf->DumpToFile(f_fileName.c_str(), &f_Written);
+ }
+
+ return l_eStatus;
+}
+
+void CMemReader::Close(void) {
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 6: m_pSharedBuf can not be null
+ // un-map the shared memory object
+ (void) m_pSharedBuf->Close();
+
+ delete m_pSharedBuf;
+ m_pSharedBuf = NULL;
+ }
+}
+
+EFrameworkunifiedStatus CMemReader::ResetPosition(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 6:Because m_pSharedBuf is always NULL
+ // un-map the shared memory object
+ l_eStatus = m_pSharedBuf->SetReadPtrToWritePtr();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pSharedBuf->SetReadPtrToWritePtr();"); // LCOV_EXCL_BR_LINE 15:Macro
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+} // namespace ReaderWriter
diff --git a/systemservice/logger_service/server/src/mod_version.c b/systemservice/logger_service/server/src/mod_version.c
new file mode 100755
index 0000000..0594b74
--- /dev/null
+++ b/systemservice/logger_service/server/src/mod_version.c
@@ -0,0 +1,49 @@
+/*
+ * @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_NS_LogTraceSender
+/// \brief This file supports logging module version identification.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <native_service/frameworkunified_types.h>
+
+#define MOD_VERSION_LENGTH 12
+
+static CHAR s_ModVersion[MOD_VERSION_LENGTH + 1] = "0.0.0";
+
+SI_8 GetModuleVersion (CHAR* pRetBuf, UI_8 nBufLen)
+{ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ UI_8 CopyLen = 0;
+ SI_8 RetVal = -1;
+
+ if (NULL != pRetBuf)
+ {
+ CopyLen = MIN_VAL(nBufLen, MOD_VERSION_LENGTH);
+ strncpy(pRetBuf, s_ModVersion, CopyLen);
+ pRetBuf[CopyLen] = '\0';
+ RetVal = 0;
+ }
+ return RetVal;
+}
+// LCOV_EXCL_STOP 8: dead code
+
diff --git a/systemservice/logger_service/server/src/queue_reader.cpp b/systemservice/logger_service/server/src/queue_reader.cpp
new file mode 100755
index 0000000..6c056c3
--- /dev/null
+++ b/systemservice/logger_service/server/src/queue_reader.cpp
@@ -0,0 +1,101 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader/queue_reader.h"
+#include <string>
+
+namespace ReaderWriter {
+CQueueReader::CQueueReader()
+ : m_handle(-1),
+ m_queName("") { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+}
+
+CQueueReader::~CQueueReader() {
+ if (this->IsOpen()) {
+ this->Close();
+ }
+}
+
+EFrameworkunifiedStatus CQueueReader::Initialize(CLoggerCfg* f_pLoggerCfg,
+ std::string f_name, UI_32 f_maxSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ if (f_pLoggerCfg != NULL) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ // Check for invalid name
+ if (f_name.length() != 0) { // LCOV_EXCL_BR_LINE 6:it can not be 0
+ m_queName = f_name;
+ l_eStatus = this->Open();
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CQueueReader::Open(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+
+ if (-1 != m_handle) { // LCOV_EXCL_BR_LINE 6:Because m_handle is always -1
+ // Queue already opened, no action required.
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (m_queName.length() != 0) { // LCOV_EXCL_BR_LINE 6:Because m_queName is not always an empty string
+ const UI_32 MAX_MESSAGES_STORED_IN_QUEUE = 512;
+ struct mq_attr mqattr;
+ mqattr.mq_flags = 0;
+ mqattr.mq_maxmsg = MAX_MESSAGES_STORED_IN_QUEUE;
+ mqattr.mq_msgsize = MAX_QUEUE_MSG_SIZE;
+
+ this->m_handle = mq_open(m_queName.c_str(), O_RDONLY | O_CREAT, 0666,
+ &mqattr);
+ if (-1 != m_handle) { // LCOV_EXCL_BR_LINE 5:mq_open cannot be passed because it cannot be turned mock
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+BOOL CQueueReader::IsOpen(void) {
+ return (-1 != m_handle) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 6:Because the condition cannot be set
+}
+
+EFrameworkunifiedStatus CQueueReader::Read(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesRead) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ if (this->m_handle != -1) { // LCOV_EXCL_BR_LINE 6:Because the condition cannot be set
+ if (f_length <= MAX_QUEUE_MSG_SIZE) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ f_bytesRead = static_cast<SI_32>(mq_receive(this->m_handle, reinterpret_cast<char *>(f_data),
+ (size_t) MAX_QUEUE_MSG_SIZE, NULL));
+
+ if ((0 <= f_bytesRead) && ((UI_32) f_bytesRead <= f_length)) { // LCOV_EXCL_BR_LINE 6:Because the condition cannot be set
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ return (l_eStatus);
+}
+
+void CQueueReader::Close(void) {
+ if (this->m_handle != -1) { // LCOV_EXCL_BR_LINE 200: m_handle is aways not -1
+ (void) mq_close(this->m_handle);
+ }
+}
+} // namespace ReaderWriter
diff --git a/systemservice/logger_service/server/src/reader.cpp b/systemservice/logger_service/server/src/reader.cpp
new file mode 100755
index 0000000..04880f0
--- /dev/null
+++ b/systemservice/logger_service/server/src/reader.cpp
@@ -0,0 +1,86 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader/reader.h"
+#include <string>
+#include <new>
+#include <iostream>
+#include "readerWriter/reader/queue_reader.h"
+#include "readerWriter/reader/mem_reader.h"
+#include "ss_logger_cfg.h"
+namespace ReaderWriter {
+CReader::CReader()
+ : m_pLoggerCfg(NULL) {
+}
+
+CReader::~CReader() {
+}
+
+CReader* CReader::OpenReader(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_name, UI_32 f_maxSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CReader* l_ret = NULL;
+ if (f_pLoggerCfg != NULL) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ if (f_name.length() != 0) { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ switch (f_type) { // LCOV_EXCL_BR_LINE 200:As it must be eReaderWriterTypeQueue or eReaderWriterTypeMem
+ case eReaderWriterTypeFile:
+ break;
+
+ case eReaderWriterTypeQueue:
+ l_ret = new (std::nothrow) CQueueReader(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+
+ case eReaderWriterTypeMem:
+ l_ret = new (std::nothrow) CMemReader(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (NULL != l_ret) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ if (eFrameworkunifiedStatusOK != l_ret->Initialize(f_pLoggerCfg, f_name, f_maxSize)) {
+ delete (l_ret);
+ l_ret = NULL;
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_ret;
+}
+
+
+EFrameworkunifiedStatus CReader::ReadToFile(std::string f_fileName, UI_32& f_Written) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNotImplemented;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CReader::ResetPosition(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNotImplemented;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+} // namespace ReaderWriter
diff --git a/systemservice/logger_service/server/src/reader_writer.cpp b/systemservice/logger_service/server/src/reader_writer.cpp
new file mode 100755
index 0000000..ef32384
--- /dev/null
+++ b/systemservice/logger_service/server/src/reader_writer.cpp
@@ -0,0 +1,282 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader_writer.h"
+#include <errno.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <system_service/ss_templates.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <string>
+
+namespace ReaderWriter {
+
+CReaderWriter::CReaderWriter()
+ : m_pLoggerCfg(NULL),
+ m_reader(NULL),
+ m_writer(NULL),
+ m_running(FALSE),
+ m_thread(-1),
+ m_readerName(""),
+ m_paused(FALSE) {
+
+ pthread_cond_init(&m_condVariable, NULL);
+}
+
+CReaderWriter::~CReaderWriter() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (NULL != this->m_reader) {
+ delete (this->m_reader);
+ this->m_reader = NULL;
+ }
+
+ if (NULL != this->m_writer) {
+ delete (this->m_writer);
+ this->m_writer = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CReaderWriter::Initialize(CLoggerCfg* f_pLoggerCfg,
+ EReaderType f_readerType,
+ std::string f_readerName,
+ UI_32 f_readerMaxSize,
+ EWriterType f_writerType,
+ std::string f_writer1Name,
+ UI_32 f_writer1MaxSize,
+ std::string f_writer2Name,
+ UI_32 f_writer2MaxSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (NULL == (this->m_pLoggerCfg = f_pLoggerCfg)) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ // FRAMEWORKUNIFIEDLOG not needed... If this starts we won't be able to print loggerservicelogs anyways.
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ } else {
+ this->m_reader = CReader::OpenReader(f_pLoggerCfg, f_readerType, // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ f_readerName, f_readerMaxSize);
+ this->m_writer = CWriter::OpenWriter(f_pLoggerCfg, f_writerType, // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ f_writer1Name, f_writer1MaxSize,
+ f_writer2Name, f_writer2MaxSize);
+
+ if ((NULL == this->m_reader) || (NULL == this->m_writer)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+
+ this->Cleanup(this);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriter::Start(std::string f_readerName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
+ if (this->m_running == FALSE) { // LCOV_EXCL_BR_LINE 6:Because m_running is always FALSE
+ this->m_readerName = f_readerName;
+ BOOL l_barInit =
+ // LCOV_EXCL_BR_START 5:pthread cannot be passed because it cannot be turned mock
+ (EOK == pthread_barrier_init(&m_barrier, NULL, 2)) ? TRUE : FALSE;
+ if (l_barInit) {
+ // LCOV_EXCL_BR_STOP
+ pthread_attr_t attr;
+ struct sched_param params;
+ pthread_attr_init(&attr);
+ pthread_attr_getschedparam(&attr, &params);
+ SI_32 prio = frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(
+ f_readerName);
+ if (-1 != prio) { // LCOV_EXCL_BR_LINE 6:Because prio is always -1
+ // LCOV_EXCL_START 6:Because the prio is not always -1
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ params.sched_priority = prio;
+ pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+ pthread_attr_setschedparam(&attr, &params);
+ // LCOV_EXCL_STOP
+ }
+
+ if (EOK == pthread_create(&m_thread, &attr, &CReaderWriter::ThreadFunctionWrapper, this)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock // NOLINT[whitespace/line_length]
+ this->m_running = TRUE;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ pthread_barrier_wait(&this->m_barrier); /* Wait for thread to take off*/
+ }
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+void* CReaderWriter::ThreadFunctionWrapper(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CReaderWriter* l_pObj = reinterpret_cast<CReaderWriter *>(param);
+
+ l_pObj->ThreadFunction(l_pObj);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. ThreadFunction has exited");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return NULL;
+}
+
+void CReaderWriter::ThreadFunction(CReaderWriter* l_pObj) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int l_oldState;
+
+ pthread_setname_np(pthread_self(), this->m_readerName.c_str());
+ pthread_cleanup_push(&CReaderWriter::CleanupWrapper, this);
+ pthread_mutex_init(&m_writeMutex, NULL);
+ pthread_mutex_init(&m_pauseMutex, NULL);
+ int l_wait = pthread_barrier_wait(&m_barrier);
+
+ if ((eFrameworkunifiedStatusOK == l_eStatus)
+ // LCOV_EXCL_BR_START 5:pthread cannot be passed because it cannot be turned mock
+ && (((PTHREAD_BARRIER_SERIAL_THREAD == l_wait) || (0 == l_wait)))) {
+ // LCOV_EXCL_BR_STOP
+ UI_8 data[MAX_QUEUE_MSG_SIZE + 1];
+ while (TRUE) {
+ if (TRUE == this->m_paused) {
+ if (EOK == pthread_mutex_lock(&this->m_pauseMutex)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ (void)pthread_cond_wait(&m_condVariable, &m_pauseMutex); // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ (void) pthread_mutex_unlock(&this->m_pauseMutex); // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ }
+ }
+ if (!this->m_reader->IsOpen() || !this->m_writer->IsOpen()) { // LCOV_EXCL_BR_LINE 6:As it is not always open
+ (void)this->m_reader->Open(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ (void)this->m_writer->Open(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+
+ if (!this->m_reader->IsOpen() || !this->m_writer->IsOpen()) {
+
+// ->Reduced frequency of accesses to IsOpen()
+ usleep(1000*1000); // LCOV_EXCL_BR_LINE 5:C function
+ } else {
+ while ((eFrameworkunifiedStatusOK == l_eStatus) && (FALSE == this->m_paused)) {
+ SI_32 l_bytesRead = -1;
+ SI_32 l_bytesWritten = -1;
+ l_eStatus = this->m_reader->Read(data,
+ MAX_QUEUE_MSG_SIZE,
+ l_bytesRead); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,
+ &l_oldState);
+ if (EOK == pthread_mutex_lock(&this->m_writeMutex)) { // LCOV_EXCL_BR_LINE 5: c code error case
+ l_eStatus = this->m_writer->Write(data,
+ (UI_32) l_bytesRead,
+ l_bytesWritten);
+ (void) pthread_mutex_unlock(&this->m_writeMutex);
+ }
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,
+ &l_oldState);
+ }
+ }
+ l_eStatus = eFrameworkunifiedStatusOK; // Reset l_eStatus
+ }
+ }
+ }
+
+ pthread_cleanup_pop(1);
+}
+
+
+void CReaderWriter::CleanupWrapper(void* param) {
+ CReaderWriter* l_pObj = reinterpret_cast<CReaderWriter *>(param);
+
+ l_pObj->Cleanup(l_pObj);
+}
+
+void CReaderWriter::Cleanup(CReaderWriter* l_pObj) {
+
+// (void) pthread_mutex_unlock(&this->m_pauseMutex);
+// (void) pthread_mutex_unlock(&this->m_writeMutex);
+
+
+ if (this->m_reader != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_reader can not be null
+ delete (this->m_reader);
+ this->m_reader = NULL;
+ }
+ if (this->m_writer != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_writer can not be null
+ delete (this->m_writer);
+ this->m_writer = NULL;
+ }
+ this->m_running = FALSE;
+}
+
+EFrameworkunifiedStatus CReaderWriter::FlushCache(std::string f_filename) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == this->m_pLoggerCfg->IsLoggingEnabled()) { // LCOV_EXCL_BR_LINE 6: it can not be false
+ if (EOK == pthread_mutex_lock(&this->m_writeMutex)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ if (this->m_writer != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_writer can not be null
+ l_eStatus = this->m_writer->FlushCache();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "this->m_writer->FlushCache()")
+ }
+ (void) pthread_mutex_unlock(&this->m_writeMutex);
+ }
+
+ UI_32 l_written;
+ if (NULL != this->m_reader) { // LCOV_EXCL_BR_LINE 6:Because it depends on the startup process
+ l_eStatus = this->m_reader->ReadToFile(f_filename, l_written);
+ /*Don't output error, if function not implemented*/
+ l_eStatus =
+ (l_eStatus == eFrameworkunifiedStatusNotImplemented) ? eFrameworkunifiedStatusOK : l_eStatus;
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "this->m_reader->ReadToFile(f_filename, l_written)");
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriter::UpdateLoggingParameters(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (EOK == pthread_mutex_lock(&this->m_writeMutex)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ if (this->m_writer != NULL) {
+ l_eStatus = this->m_writer->UpdateLoggingParameters();
+ }
+ (void) pthread_mutex_unlock(&this->m_writeMutex);
+ }
+ BOOL l_enabled = this->m_pLoggerCfg->IsLoggingEnabled();
+ if ((this->m_paused == FALSE) && (FALSE == l_enabled)) {
+ this->Pause();
+ } else if ((this->m_paused == TRUE) && (TRUE == l_enabled)) {
+ this->Resume();
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
+void CReaderWriter::Pause(void) {
+ (void) pthread_mutex_lock(&this->m_pauseMutex);
+ this->m_paused = TRUE;
+
+ (void) pthread_mutex_unlock(&this->m_pauseMutex);
+}
+
+void CReaderWriter::Resume(void) {
+ (void) pthread_mutex_lock(&this->m_pauseMutex);
+ if (this->m_reader != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_reader can not be null
+ (void) this->m_reader->ResetPosition();
+ }
+ pthread_cond_signal(&m_condVariable);
+ this->m_paused = FALSE;
+ (void) pthread_mutex_unlock(&this->m_pauseMutex);
+}
+} // namespace ReaderWriter
diff --git a/systemservice/logger_service/server/src/ss_logger_cfg.cpp b/systemservice/logger_service/server/src/ss_logger_cfg.cpp
new file mode 100755
index 0000000..b353bbe
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_cfg.cpp
@@ -0,0 +1,754 @@
+/*
+ * @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_SS_LoggerService
+/// \brief Provide support for CPU high load monitor configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_cfg.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <boost/bind.hpp>
+#include <native_service/nslogutil_cmd_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <algorithm>
+#include <vector>
+
+const static UI_32 cMAX_EMMC_COUNTER_VALUE = 100000u; // NOLINT (build/storage_class)
+///////////////////////////////////////////////////////////////////////////////
+// CLASS METHODS
+///////////////////////////////////////////////////////////////////////////////
+
+CLoggerCfg::CLoggerCfg()
+ : m_logMaxFileSize(0),
+ m_performanceLogMaxFileSize(0),
+ m_emmcOutputMax(0),
+ m_emmcOutputErrMax(0),
+ m_emmcOutputGrpRelaunchMax(0),
+ m_emmcOutputNaviLogMax(0),
+ m_emmcOutputNaviLogNmlMax(0),
+ m_emmcOutputNaviLogErrMax(0),
+ m_emmcOutputPath(""),
+ m_emmcOutputNaviLogPath(""),
+ m_usb0MountPath(""),
+ m_usb1MountPath(""),
+ m_sdMountPath(""),
+ m_eDevType(eDevUSB1),
+ m_UserInvokedLoggingNumber(1u),
+ m_EmmcCounter(0u),
+ m_eLoggerUDPLoggingStatus(eDeactivate),
+ m_eLoggerStatus(SS_LOGGER_DEFAULT_VALUE) {
+ m_udpEnvFlag = FALSE;
+ std::memset(m_logMask, 0, sizeof(m_logMask));
+ std::memset(&m_ExternalLogList, 0, sizeof(&m_ExternalLogList));
+ }
+
+CLoggerCfg::~CLoggerCfg(void) { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ if (m_ExternalLogList.p_info != NULL) {
+ delete[] m_ExternalLogList.p_info;
+ m_ExternalLogList.p_info = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerCfg::Initialize(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ char* l_udp_env = getenv("UDPLOGS_ON");
+ m_udpEnvFlag = (
+ l_udp_env == NULL ?
+ FALSE : (strcmp("TRUE", l_udp_env) == 0 ? TRUE : FALSE));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+EFrameworkunifiedStatus CLoggerCfg::SetandPersistLoggingParams(HANDLE f_hApp,
+ STLoggerSetAllParams f_Params,
+ BOOL f_InitCall) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_paramChanged = f_InitCall;
+ BOOL l_updateLoggerState = f_InitCall;
+
+ if ((TRUE == l_paramChanged) // LCOV_EXCL_BR_LINE 200:l_paramChanged is never TRUE
+ ||
+ (m_eLoggerStatus != f_Params.Logger_State)
+ || // LCOV_EXCL_BR_LINE 200:Because m_UserInvokedLoggingNumber != f_Params.Log_FolderCnt is never false
+ (m_UserInvokedLoggingNumber != f_Params.Log_FolderCnt)
+ || (m_eLoggerUDPLoggingStatus != f_Params.Logger_UDPState)
+ || (m_eDevType != f_Params.Device_Type)) {
+ l_paramChanged = TRUE;
+ } else {
+ l_paramChanged = FALSE;
+ }
+
+ l_updateLoggerState =
+ ((l_updateLoggerState == TRUE)
+ || (m_eLoggerStatus != f_Params.Logger_State)) ? TRUE : FALSE;
+
+ // After startup Logging will be set to default value
+ if (TRUE == f_InitCall) { // LCOV_EXCL_BR_LINE 200:f_InitCall is never TRUE
+ // LCOV_EXCL_START 200:f_InitCall is never TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ m_eLoggerStatus = SS_LOGGER_DEFAULT_VALUE;
+ // LCOV_EXCL_STOP
+ } else {
+ m_eLoggerStatus = f_Params.Logger_State;
+ }
+ m_eLoggerUDPLoggingStatus = f_Params.Logger_UDPState;
+ m_UserInvokedLoggingNumber = f_Params.Log_FolderCnt;
+ m_eDevType = f_Params.Device_Type;
+
+ if (TRUE == l_paramChanged) {
+ l_eStatus = PersistLoggingParam(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: macro
+ "PersistLoggingParam()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::SetLoggingParams(HANDLE f_hApp,
+ const STLoggerSetParams f_stLoggerSetParams) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STLoggerSetAllParams l_Params;
+
+ l_Params.Logger_UDPState = m_eLoggerUDPLoggingStatus;
+ l_Params.Log_FolderCnt = m_UserInvokedLoggingNumber;
+ l_Params.Logger_State = f_stLoggerSetParams.Logger_State;
+ l_Params.Device_Type = f_stLoggerSetParams.Device_Type;
+
+ l_eStatus = SetandPersistLoggingParams(f_hApp, l_Params, FALSE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SetandPersistLoggingParams()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::SetUDPLogging(HANDLE f_hApp,
+ const ELOGGER_STAT f_eUDPLoggingStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STLoggerSetAllParams l_Params;
+
+ l_Params.Logger_UDPState = f_eUDPLoggingStatus;
+ l_Params.Log_FolderCnt = m_UserInvokedLoggingNumber;
+ l_Params.Logger_State = m_eLoggerStatus;
+ l_Params.Device_Type = m_eDevType;
+
+ l_eStatus = SetandPersistLoggingParams(f_hApp, l_Params, FALSE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SetandPersistLoggingParams()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::PersistLoggingParam(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO, __FUNCTION__,
+ "LoggerState = %d, Device_Type = %d,UDPLogging = %d, TriggerNumber = %d",
+ m_eLoggerStatus, m_eDevType, m_eLoggerUDPLoggingStatus,
+ m_UserInvokedLoggingNumber); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ this->UpdateLoggingStatus();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+void CLoggerCfg::RemoveCarriageReturn(std::string &f_str) {
+ if (f_str.empty()) { // LCOV_EXCL_BR_LINE 8: Because there is no empty string case
+ return;
+ }
+
+ if ('\r' == f_str.at(f_str.size() - 1)) {
+ f_str.erase(f_str.size() - 1, 1);
+ }
+}
+EFrameworkunifiedStatus CLoggerCfg::Load(const std::string &f_filePathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+
+ if ("" == f_filePathAndName) { // LCOV_EXCL_BR_LINE 200: Because there is no empty string case
+ // LCOV_EXCL_START 200: Because there is no empty string case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Invalid configuration file name detected.");
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Reading Configuration Data from %s", f_filePathAndName.c_str());
+
+ CNSConfigReader *l_pReaderCfg = new CNSConfigReader(); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (NULL == l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5:new error
+ // LCOV_EXCL_START 5:new error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unable to allocate CNSConfigReader object.");
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(f_filePathAndName))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->Parse(%s) returned: 0x%X",
+ f_filePathAndName.c_str(), l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.LogMaxFileSize", m_logMaxFileSize))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(LOGGING.LogMaxFileSize)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.PerformanceLogSize", m_performanceLogMaxFileSize))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(LOGGING.LogMaxFileSize)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.EmmcOutputPath", m_emmcOutputPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.EmmcOutputPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.EmmcOutputNaviLogPath", m_emmcOutputNaviLogPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.Usb0MountPath", m_usb0MountPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.Usb0MountPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.Usb1MountPath", m_usb1MountPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.Usb1MountPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.SdMountPath", m_sdMountPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.SdMountPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputMax", m_emmcOutputMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.EmmcOutputMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputErrMax", m_emmcOutputErrMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputErrMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputGrpRelaunchMax", m_emmcOutputGrpRelaunchMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputGrpRelaunchMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputNaviLogMax", m_emmcOutputNaviLogMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputNaviLogNmlMax", m_emmcOutputNaviLogNmlMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogNmlMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputNaviLogErrMax", m_emmcOutputNaviLogErrMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogErrMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("STORAGE.ThreadName", m_loggerStorageInfo.Name))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(STORAGE.ThreadName)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("STORAGE.Priority", m_loggerStorageInfo.Priority))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(STORAGE.Priority)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("STORAGE.Timeout", m_loggerStorageInfo.Timeout))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(STORAGE.Timeout)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("STORAGE.TimeoutAfter", m_loggerStorageInfo.TimeoutAfter))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(STORAGE.TimeoutAfter)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.ExternalLogNum", m_ExternalLogList.num))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.ExternalLogNum)"); // LCOV_EXCL_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.ExternalLogMax", m_ExternalLogList.max))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.ExternalLogMax)"); // LCOV_EXCL_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ } else {
+ RemoveCarriageReturn(m_emmcOutputPath);
+ RemoveCarriageReturn(m_emmcOutputNaviLogPath);
+ RemoveCarriageReturn(m_usb0MountPath);
+ RemoveCarriageReturn(m_usb1MountPath);
+ RemoveCarriageReturn(m_sdMountPath);
+ RemoveCarriageReturn(m_loggerStorageInfo.Name);
+
+ for (UI_32 i = 0; i < ZONE_MASK_ARRAY_ELTS; i++) {
+ SI_32 l_logMaskTemp;
+ std::stringstream l_cfgParamName;
+
+ l_cfgParamName << "SETLOGMASK.MASK" << i;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt(l_cfgParamName.str(), l_logMaskTemp))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetInt(%s) failed with error: %d.",
+ l_cfgParamName.str().c_str(), l_eStatus);
+
+ break;
+ // LCOV_EXCL_STOP
+ } else {
+ m_logMask[i] = (UI_32) l_logMaskTemp;
+ }
+ }
+
+ m_EELStorageRelPath = "/EEL_export";
+ m_EELActivateRelPath = "/EEL_activate";
+ m_LoggerserviceEmmcLogsRelPath = "/LOGGERSERVICE_EMMC_LOGS";
+
+ if (m_ExternalLogList.num > 0) {
+ std::string str = "EXTERNAL_"; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ UI_32 num = 0;
+
+ if (m_ExternalLogList.num <= m_ExternalLogList.max) {
+ num = m_ExternalLogList.num;
+ } else {
+ num = m_ExternalLogList.max;
+ }
+
+ // LCOV_EXCL_BR_START 11:Excluded due to gcov constraints (others)
+ m_ExternalLogList.p_info = new ExternalLogInfo[num];
+
+ // Load external log info
+ for (UI_32 i = 0; i < num; i++) {
+ std::string query = str + std::to_string(i+1);
+ if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetString((query+".OutputPath"), m_ExternalLogList.p_info[i].dirname))) {
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(EXTERNAL.OutputPath)"); // LCOV_EXCL_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ } else if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetString((query+".ExtLogPath"), m_ExternalLogList.p_info[i].path))) {
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(EXTERNAL.ExtLogPath)"); // LCOV_EXCL_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ } else if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = l_pReaderCfg->GetBool((query+".Remove"), m_ExternalLogList.p_info[i].remove))) {
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetBool(EXTERNAL.Remove)"); // LCOV_EXCL_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ } else {
+ RemoveCarriageReturn(m_ExternalLogList.p_info[i].dirname);
+ RemoveCarriageReturn(m_ExternalLogList.p_info[i].path);
+ }
+ }
+ // LCOV_EXCL_BR_STOP 11:Excluded due to gcov constraints (others)
+ } else {
+ // None external log
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Configuration successfully loaded."); // LCOV_EXCL_BR_LINE 15: macro
+ }
+ }
+
+ delete l_pReaderCfg; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::Validate(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+
+ if (m_logMaxFileSize == 0) { // LCOV_EXCL_BR_LINE 200:Because the size is never 0
+ // LCOV_EXCL_START 200:Because the size is never 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected. LogMaxFileSize: %d Must be > 0.",
+ m_logMaxFileSize);
+ // LCOV_EXCL_STOP
+ } else if (m_emmcOutputPath == "") {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " EmmcOutputPath: %s Must be a valid path containing a trailing backslash.",
+ m_emmcOutputPath.c_str());
+ } else if (m_emmcOutputNaviLogPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " EmmcOutputNaviLogPath: %s Must be a valid path containing a trailing backslash.",
+ m_emmcOutputNaviLogPath.c_str());
+ // LCOV_EXCL_STOP
+ } else if (m_usb0MountPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " Usb0MountPath: %s Must be a valid path containing a trailing backslash.",
+ m_usb0MountPath.c_str());
+ // LCOV_EXCL_STOP
+ } else if (m_usb1MountPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " Usb1MountPath: %s Must be a valid path containing a trailing backslash.",
+ m_usb1MountPath.c_str());
+ // LCOV_EXCL_STOP
+ } else if (m_sdMountPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected. SdMountPath: %s Must be a valid path containing a trailing backslash.",
+ m_sdMountPath.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+void CLoggerCfg::Print(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+std::string CLoggerCfg::getEmmcOutputPath(void) {
+ return (m_emmcOutputPath);
+}
+
+std::string CLoggerCfg::getEmmcOutputNaviLogPath(void) {
+ return (m_emmcOutputNaviLogPath);
+}
+
+std::string CLoggerCfg::getUsb0MountPath(void) {
+ return (m_usb0MountPath);
+}
+void CLoggerCfg::setUsb0MountPath(std::string& f_deviceMountpath) {
+ m_usb0MountPath = f_deviceMountpath;
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetUserInvokedDestination(std::string& f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_dest = "";
+ switch (m_eDevType) {
+ case eDevUSB1:
+ f_dest = m_usb0MountPath;
+ break;
+
+ case eDevUSB2:
+ f_dest = m_usb1MountPath;
+ break;
+
+ case eDevSD:
+ f_dest = m_sdMountPath;
+ break;
+
+ case eTotalDevicesTypes:
+ case eInvalid_DevType:
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Unknown device type: %d",
+ m_eDevType);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetEmmcDestination(std::string& f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_dest = m_emmcOutputPath;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetEmmcNaviLogDestination(std::string& f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_dest = m_emmcOutputNaviLogPath;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+UI_32 CLoggerCfg::GetUserInvokedCounter(void) {
+ return m_UserInvokedLoggingNumber;
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetIncrementAndPersistUserInvokedCounter(
+ HANDLE f_hApp, UI_32 &f_counter) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_counter = m_UserInvokedLoggingNumber;
+ m_UserInvokedLoggingNumber++;
+ l_eStatus = PersistLoggingParam(f_hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetAndIncrementEmmcCounter(UI_32 &f_counter) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_checkFileName;
+ std::vector<UI_32> l_vector;
+ DIR *l_dirp;
+ struct dirent l_dirent;
+ struct dirent* next = NULL;
+ size_t l_pos;
+ UI_32 l_count;
+ UI_32 l_maxCount;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (m_EmmcCounter == 0u) {
+ l_maxCount = 0;
+ l_dirp = opendir(m_emmcOutputPath.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ for (;;) {
+ int l_ret = readdir_r(l_dirp, &l_dirent, &next);
+ if (((l_ret == 0) && (next == NULL))
+ || (l_ret > 0)) {
+ break;
+ }
+ l_checkFileName = l_dirent.d_name;
+ l_pos = l_checkFileName.find(".tar.gz");
+ if (std::string::npos != l_pos) {
+ l_pos = l_checkFileName.find("_");
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 200: tar.gz file is aways has "_"
+ std::string l_numberString = l_checkFileName.substr(0, l_pos);
+ l_count = static_cast<UI_32>(strtoul(l_numberString.c_str(), NULL, 10));
+ l_vector.push_back(l_count);
+ l_maxCount = std::max(l_count, l_maxCount);
+ }
+ }
+ }
+ closedir(l_dirp);
+ } else {
+ // LCOV_EXCL_START 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_counter = 1;
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+
+ // reach at max number
+ if (l_maxCount >= LOGGERSERVICELOG_EMMC_COUNTER_MAX) {
+ RefreshEmmcCounter(m_EmmcCounter);
+ } else {
+ m_EmmcCounter = l_maxCount + 1;
+ }
+ } else if (m_EmmcCounter >= LOGGERSERVICELOG_EMMC_COUNTER_MAX) {
+ // reach at max number
+ RefreshEmmcCounter(m_EmmcCounter);
+ } else {
+ m_EmmcCounter++;
+ }
+
+ f_counter = m_EmmcCounter;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::RefreshEmmcCounter(UI_32& f_counter) const {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_checkFileName;
+ std::vector<std::string> l_vector;
+ DIR *l_dirp;
+ struct dirent l_dirent;
+ struct dirent* next = NULL;
+ size_t l_pos;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // get filename saved frameworkunifiedlog on eMMC Device
+ l_dirp = opendir(m_emmcOutputPath.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ for (;;) {
+ int l_ret = readdir_r(l_dirp, &l_dirent, &next);
+ if (((l_ret == 0) && (next == NULL)) || (l_ret > 0)) {
+ break;
+ }
+ l_checkFileName = l_dirent.d_name;
+ l_pos = l_checkFileName.find(".tar.gz");
+ if (std::string::npos != l_pos) {
+ l_pos = l_checkFileName.find("_");
+ if (std::string::npos != l_pos) {
+ l_vector.push_back(l_checkFileName);
+ }
+ }
+ }
+ closedir(l_dirp);
+ } else {
+ // LCOV_EXCL_START 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // ignore opendir failure. this means saved frameworkunifiedlog is nothing on eMMC Device
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "open dir error path=%s errno=%s.",
+ m_emmcOutputPath.c_str(), strerror(errno));
+ f_counter = 1;
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+
+ // sort at log count
+ std::sort(l_vector.begin(), l_vector.end());
+
+ std::vector<std::string>::iterator it;
+ std::string l_orgFilePath;
+ std::string l_renameFilePath;
+ UI_32 l_wpt = 0;
+ UI_32 l_count;
+
+ it = l_vector.begin();
+ while (it != l_vector.end()) {
+ std::stringstream l_nameStream;
+ // get log counter parts
+ l_wpt++;
+ l_checkFileName = *it;
+ l_pos = l_checkFileName.find("_");
+ std::string l_numberString = l_checkFileName.substr(0, l_pos);
+ l_count = static_cast<UI_32>(strtoul(l_numberString.c_str(), NULL, 10));
+
+ // rename file if necessary
+ if (l_count != l_wpt) {
+ l_renameFilePath = l_orgFilePath = m_emmcOutputPath.c_str();
+ l_renameFilePath.append("/");
+ l_orgFilePath.append("/");
+ l_orgFilePath.append(l_checkFileName);
+
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right
+ << std::dec << l_wpt;
+ l_checkFileName.replace(0, l_pos, l_nameStream.str());
+
+ l_renameFilePath.append(l_checkFileName);
+
+ if (rename(l_orgFilePath.c_str(), l_renameFilePath.c_str()) != 0) { // LCOV_EXCL_BR_LINE 5: rename is C code
+ // LCOV_EXCL_START 5: rename is C code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // rename failed but continue reamin log rename because new log need to be saved.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "log file[%s]->[%s] rename failed: err=%s.",
+ l_orgFilePath.c_str(), l_renameFilePath.c_str(), strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+ it++;
+ }
+
+ f_counter = l_wpt + 1;
+
+ // set return value as next log counter
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+BOOL CLoggerCfg::IsUDPLoggingEnabled(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret =
+ ((this->m_eLoggerUDPLoggingStatus == eActivate)
+ || (this->m_udpEnvFlag == TRUE)) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %s", (TRUE == l_ret)?"TRUE":"FALSE");
+ return (l_ret);
+}
+
+void CLoggerCfg::AddLoggingParamCB(CbFuncPtr f_fp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (f_fp != NULL) { // LCOV_EXCL_BR_LINE 6: it aways not be null
+ this->m_LoggingCallBack.push_back(f_fp);
+ (void) f_fp(NULL);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void CLoggerCfg::UpdateLoggingStatus(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::vector<CbFuncPtr>::iterator l_iter;
+ for (l_iter = m_LoggingCallBack.begin(); l_iter != m_LoggingCallBack.end(); l_iter++) { // LCOV_EXCL_BR_LINE 11:Unexpected branch // NOLINT[whitespace/line_length]
+ (void) (*l_iter)(NULL);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetLoggerStorageInfo(SLoggerStorageInfo &f_info) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_info = m_loggerStorageInfo;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+BOOL CLoggerCfg::IsLoggingEnabled(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ return (this->m_eLoggerStatus == eActivate) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+ExternalLogList CLoggerCfg::GetExternalLogList(void) {
+ return (m_ExternalLogList);
+} // LCOV_EXCL_BR_LINE 10:the last line
diff --git a/systemservice/logger_service/server/src/ss_logger_device_detection.cpp b/systemservice/logger_service/server/src/ss_logger_device_detection.cpp
new file mode 100755
index 0000000..04bc4b5
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_device_detection.cpp
@@ -0,0 +1,209 @@
+/*
+ * @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_NS_InterfaceunifiedLogCapture
+/// \brief This file supports USB logging threads.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+// System Headers
+#include <errno.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#ifdef AGL_STUB
+#else
+#include <sys/usbdi.h>
+#endif
+#include <limits.h>
+#include <string.h>
+#include <native_service/ns_message_center_if.h>
+#include <ss_logger_fs_directory.h>
+#include <boost/bind.hpp>
+
+// Pasa Logs
+#include <loggerservicedebug_loggerservicelog.h>
+#include <ss_logger_device_detection.h>
+#include <loggerservicedebug_thread_if.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <system_service/ss_sm_client_if.h>
+#include <string>
+#include "ss_logger_common.h"
+
+//
+const SI_32 INVALID_FD = -1;
+
+// Max command line length
+const UI_32 MAX_SYS_CMD_LN_LENGTH = 120;
+
+CLoggerDeviceDetection::CLoggerDeviceDetection() :
+ m_pLoggerCfg(NULL),
+ m_loggerUtil(NULL) {
+}
+
+CLoggerDeviceDetection::~CLoggerDeviceDetection() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerDeviceDetection::Initialize(HANDLE f_hApp, CLoggerCfg * f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ m_pLoggerCfg = f_pLoggerCfg;
+ // Device Detection Obj initialization
+ if (m_devDetect.Initialize(f_hApp)) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ if (eFrameworkunifiedStatusOK != (l_eStatus = m_devDetect.NotifyOnDeviceDetectionAvailability(
+ boost::bind(&CLoggerDeviceDetection::DD_ServiceAvailabilityCallBack, this, _1) ))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "ServiceAvailabilityCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = m_devDetect.NotifyOnOpenSessionAck(
+ boost::bind(&CLoggerDeviceDetection::DD_OpenSessionAckCallBack, this, _1) ))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "OpenSessionAckCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = m_devDetect.NotifyOnCloseSessionAck(
+ boost::bind(&CLoggerDeviceDetection::DD_CloseSessionAckCallBack, this, _1) ))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CloseSessionCallback registration failed");
+ }
+ } else {
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Device Detection Object Initialization failed!");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+// Function : ServiceAvailabilityCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_ServiceAvailabilityCallBack(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (FrameworkunifiedIsServiceAvailable(hApp)) {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.OpenSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Open session request failed");
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.CloseSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Close session request failed");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : OpenSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_OpenSessionAckCallBack(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = m_devDetect.DecodeOpenSessionResponse())) {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.RegisterForDeviceDetectionEvent(SS_DEV_DETECT_ANY_USB_EV,
+ boost::bind(&CLoggerDeviceDetection::DD_MediaDetectCallBack, this, _1)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Registration for SS_DEV_DETECT_ANY_USB_EV failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Decode open session response failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+//////////////////////////////////////////
+// Function : OpenSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_CloseSessionAckCallBack(HANDLE hApp) { // LCOV_EXCL_START 200: can not called from devicedetection_service // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CloseSessionAck tCloseSessionAck;
+
+ if (hApp) {
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tCloseSessionAck, sizeof (tCloseSessionAck)))) {
+ if (eFrameworkunifiedStatusOK == tCloseSessionAck.eStatus) {
+ UI_32 l_uiSessionId = tCloseSessionAck.sessionId;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "session %d closed successfully", l_uiSessionId);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_CloseSessionWithDevDetectionSrv(HANDLE hApp) { // LCOV_EXCL_START 200: can not called from devicedetection_service // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = m_devDetect.
+ NotifyOnCloseSessionAck(boost::bind(&CLoggerDeviceDetection::DD_CloseSessionAckCallBack, this, _1)))) {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.CloseSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to send CloseSessionRequest");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to register closeSessionAckCallback");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_MediaDetectCallBack(HANDLE hApp) { // LCOV_EXCL_START 200: can not called from devicedetection_service // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_devstr;
+ std::string l_filePathStr;
+ SS_MediaDetectInfo l_tMediaDetectInfo;
+
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_tMediaDetectInfo, sizeof (l_tMediaDetectInfo)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x ", l_eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Device = %d", l_tMediaDetectInfo.dev_type);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Availability = %d", l_tMediaDetectInfo.bIsDeviceAvailable);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " device path = %s", l_tMediaDetectInfo.deviceMountpath);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " File path = %s", l_tMediaDetectInfo.filepathName);
+
+ if (l_tMediaDetectInfo.dev_type == eUSB) {
+ if (l_tMediaDetectInfo.bIsDeviceAvailable == TRUE && m_pLoggerCfg != NULL) {
+ std::string l_usbMountPath;
+ l_usbMountPath = l_tMediaDetectInfo.deviceMountpath;
+ m_pLoggerCfg->setUsb0MountPath(l_usbMountPath);
+ m_loggerUtil->SetUsbMountPath(l_usbMountPath);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
diff --git a/systemservice/logger_service/server/src/ss_logger_error_event.cpp b/systemservice/logger_service/server/src/ss_logger_error_event.cpp
new file mode 100755
index 0000000..6e82da7
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_error_event.cpp
@@ -0,0 +1,1047 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_error_event.h"
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <boost/bind.hpp>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_client_names.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <stub/el_mem.h>
+#include <native_service/cl_process.h>
+#include <stub/Clock_API.h>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "loggerservicedebug_thread_if.h"
+#include "ss_logger_service_callbacks.h"
+#include "ss_logger_error_event_archive.h"
+#include "ss_logger_common.h"
+#include "ss_logger_types.h"
+#include "ss_logger_fs_directory.h"
+
+CErrorEvent::CErrorEvent()
+ : m_hApp(NULL),
+ m_bIsPrevEventCompleted(true),
+ m_errorEventNtfData(),
+ m_pLoggerCfg(NULL),
+ m_pReaderWriterControl(NULL),
+ m_ServiceName(""),
+ m_time(0),
+ m_currentEventTriggerNumber(0),
+ m_diagsessionhandle(NULL),
+ m_thrdEvntLogWriter(NULL),
+ m_sfd(-1) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+} // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+CErrorEvent::~CErrorEvent() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEvent::Initialize(HANDLE f_hApp, CLoggerCfg *f_pLoggerCfg,
+ CReaderWriterControl *f_pReaderWriterControl,
+ HANDLE f_thrdEvntLogWriter,
+ std::string f_strEvntLogQueWorkerName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ Timer *l_pTimer;
+
+ m_sfd = CL_ProcessInit();
+ if (m_sfd == -1) { // LCOV_EXCL_BR_LINE 8:Because the process initialization is guaranteed to be successful
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. m_sfd CL_ProcessInit() failed \n."); // LCOV_EXCL_LINE 8:Because the process initialization is guaranteed to be successful
+ }
+
+ SS_LoggerServerEvents l_errorEventStateEvents[] = {
+ SS_LOGGER_SCREENCAPTURE_EVT };
+
+ FrameworkunifiedProtocolCallbackHandler l_smCallbacks[] = {
+ // Logging Protocol Callbacks
+ { SS_SM_EVENT_ERROR_TO_SSL, boost::bind(&CErrorEvent::OnStartLogging,
+ this, _1) }, {
+ SS_SM_ERROR_EVENT_LOGGING_START_RSPN, boost::bind(
+ &CErrorEvent::OnLogStartResponse, this, _1) }, {
+ SS_SM_ERROR_EVENT_ARTIFACT_RSPN, boost::bind(
+ &CErrorEvent::OnArtifactResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ FrameworkunifiedProtocolCallbackHandler l_selfCallbacks[] = {
+ // Logging Protocol Callbacks
+ { SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ, boost::bind(
+ &CErrorEvent::OnArtifactRequest, this, _1) }, {
+ SS_SM_ERROR_EVENT_ARTIFACT_RSPN, boost::bind(
+ &CErrorEvent::OnArtifactResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ FrameworkunifiedProtocolCallbackHandler l_requesterCallbacks[] = { {
+ SS_LOGGER_SCREENCAPTURE_EVT_ACK, boost::bind(
+ &CErrorEvent::OnObtainScreenShotResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ FrameworkunifiedProtocolCallbackHandler l_storageThreadCallbacks[] = { {
+ eLoggerStorageThreadCmdOK, boost::bind(&CErrorEvent::OnStorageResponseOk,
+ this, _1) }, {
+ eLoggerStorageThreadCmdWriteFailed, boost::bind(
+ &CErrorEvent::OnStorageResponseWriteFailed, this, _1) }, {
+ eLoggerStorageThreadCmdNotFound, boost::bind(
+ &CErrorEvent::OnStorageResponseNotFound, this, _1) }, {
+ eLoggerStorageThreadCmdNoWritten, boost::bind(
+ &CErrorEvent::OnStorageResponseNoWritten, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ for (UI_32 i = 0; i < _countof(l_requesterCallbacks); i++) {
+ m_requesterCallbacksVec.push_back(l_requesterCallbacks[i]); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+
+ if (NULL == f_hApp) { // LCOV_EXCL_BR_LINE 6:As it is not always NULL
+ // LCOV_EXCL_START 6:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. Argument f_hApp passed NULL pointer. Initialization failed.");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (m_thrdEvntLogWriter = f_thrdEvntLogWriter)) { // LCOV_EXCL_BR_LINE 6:As it is not always NULL
+ // LCOV_EXCL_START 6:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. Argument f_hApp passed NULL pointer. Initialization failed.");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_errorEventCfg.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_errorEventCfg.Initialize() returned: %d.", l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(f_hApp, SERVICE_LOGGER, l_selfCallbacks, _countof(l_selfCallbacks)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedAttachCallbacksToDispatcher(SERVICE_SYSMANAGER) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(f_hApp, SERVICE_SYSMANAGER, l_smCallbacks, _countof(l_smCallbacks)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedAttachCallbacksToDispatcher(SERVICE_SYSMANAGER) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDefineStateEvents(f_hApp, &l_errorEventStateEvents, static_cast<UI_32>(_countof(l_errorEventStateEvents))))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedDefineStateEvents(SS_LOGGER_SCREENCAPTURE_EVT) returned: %d",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (NULL == f_pLoggerCfg) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ // LCOV_EXCL_START 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. f_pLoggerCfg passed NULL pointer.");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerPopups.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerPopups.Initialize(f_pLoggerCfg) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (NULL == f_pReaderWriterControl) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ // LCOV_EXCL_START 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Argument f_pReaderWriterControl passed NULL pointer.");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerStorage.Initialize(f_hApp, AppName, f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerPopups.Initialize(f_pLoggerCfg) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher( f_hApp, ERROR_EVENT_STORAGE_QUEUE_NAME, l_storageThreadCallbacks, _countof(l_storageThreadCallbacks)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedAttachCallbacksToDispatcher(ERROR_EVENT_STORAGE_QUEUE_NAME) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerCanEvent.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerCanEvent.Initialize() returned: %d.", l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ m_hApp = f_hApp;
+ m_pLoggerCfg = f_pLoggerCfg;
+ m_pReaderWriterControl = f_pReaderWriterControl;
+ l_eStatus = m_loggerUtil.Initialize(m_pLoggerCfg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 5:macro
+ "CLoggerUtil::m_loggerUtil.Initialize(m_pLoggerCfg)");
+
+ l_pTimer = &m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN];
+ l_pTimer->Initialize(
+ f_hApp, SS_LOGGER_ERROR_EVENT_TIMER_ID_LOGGING_START_RSPN,
+ boost::bind(&CErrorEvent::OnLogStartResponseTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ l_pTimer = &m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN];
+ l_pTimer->Initialize(
+ f_hApp, SS_LOGGER_ERROR_EVENT_TIMER_ID_ARTIFACT_RESPONSE,
+ boost::bind(&CErrorEvent::OnArtifactResponseTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ m_ServiceName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : RegisterSessionErrorEvent
+// brief : Register session event. This function is called within the
+// context of the System Manager session acknowledgment handler.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::RegisterSessionErrorEvent(HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = FrameworkunifiedRegisterEvent(f_hSession, SS_SM_EVENT_ERROR_TO_SSL);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedRegisterEvent(SS_SM_EVENT_ERROR_TO_SSL)"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnOpenSession
+// brief : Called when a requester opens a session with SS_Logger
+// service. This function attaches error event callbacks
+// to the dispatcher with the source set to the requester.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnOpenSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(f_hApp, f_pRequesterName,
+ &m_requesterCallbacksVec[0],
+ static_cast<UI_32>(m_requesterCallbacksVec.size()),
+ f_hSession);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedAttachCallbacksToDispatcher(f_hSession)"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnOpenSession
+// brief : Called when a requester opens a session with SS_Logger
+// service. This function attaches error event callbacks
+// to the dispatcher with the source set to the requester.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnCloseSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_cmdIdArr[m_requesterCallbacksVec.size()]; // NOLINT (runtime/arrays)
+
+ for (UI_32 i = 0; i < m_requesterCallbacksVec.size(); i++) {
+ l_cmdIdArr[i] = m_requesterCallbacksVec[i].iCmd;
+ }
+
+ l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(f_hApp, f_pRequesterName,
+ l_cmdIdArr,
+ static_cast<UI_32>(m_requesterCallbacksVec.size()),
+ f_hSession);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedAttachCallbacksToDispatcher()"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStartLogging
+// brief : Called by SS_Logger and external services to begin logging
+// artifact collection. This function sends a logging request
+// to System Manager. See SS_SM_EVENT_ERROR_TO_SSL.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStartLogging(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SMErrorEventNtfData l_eventErrorNtfData;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 5:macro
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<SMErrorEventNtfData>(f_hApp, l_eventErrorNtfData))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // when failed to ReadMsg, we can't know event-type for action, so nothing is able to do.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 200:To ensure success
+ } else {
+ if (TRUE == this->m_pLoggerCfg->IsLoggingEnabled()) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ if (TRUE == m_bIsPrevEventCompleted) {
+ TLoggerErrorEvent l_eventData = l_eventErrorNtfData;
+
+ if (IsNeedVerify(l_eventData.EventType)) {
+ // if need output log to external storage, check whether device is authenticated or not.
+ VerifyExtStorage(l_eventData);
+ }
+
+ uint8_t status;
+ Clock_getSystemTimeY2K38(&m_time, &status);
+ m_currentEventTriggerNumber = m_pLoggerCfg->GetUserInvokedCounter();
+ l_eStatus = m_loggerUtil.checkDestinationAvailable(l_eventData);
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ m_bIsPrevEventCompleted = false; /* See timer start / timeout handler below. */
+
+ m_artifactResponseVec.clear();
+
+ m_errorEventNtfData = l_eventErrorNtfData; /* Overwrite m_eventErrorNtfData when logging complete. */
+ m_errorEventNtfData.EventBitMask = m_errorEventCfg
+ .GetEventsForErrorEvent(l_eventErrorNtfData.EventType);
+ l_eStatus = SendLogStartRequestToSystemManager(
+ m_errorEventNtfData.EventType);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogStartRequestToSystemManager()");
+ l_eStatus = m_loggerCanEvent.PublishStartEvent(f_hApp,
+ m_errorEventNtfData);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerCanEvent.PublishStartEvent(f_hApp,m_errorEventNtfData);");
+
+ bool result =
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN]
+ .Start(m_loggingStartRspnToSec, 0, 0, 0);
+ if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Failed to start timer kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN.");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. Destination not available. ");
+ m_errorEventNtfData = l_eventErrorNtfData; /* Overwrite m_eventErrorNtfData when logging complete. */
+ m_errorEventNtfData.EventBitMask = m_errorEventCfg
+ .GetEventsForErrorEvent(l_eventErrorNtfData.EventType);
+ l_eStatus = OnStorageResponseNotFound(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnStorageResponseNotFound(f_hApp)");
+ }
+ } else {
+ // Not-Need Resp to SM, because of keep logging sequance.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Logging already in progress. Event dropped.");
+ }
+ } else {
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (l_eventErrorNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Logging is disabled! Dropping Event. Sending Complete to SS_SystemManager");
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogCompleteRequestToSystemManager()");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnLogStartResponse
+// brief : Called by System Manager after the acknowledgment of the
+// logging session start request. This function starts the
+// artifact collection process. See
+// SS_SM_ERROR_EVENT_LOGGING_START_RSPN.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnLogStartResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN].Stop();
+ m_errorEventCfg.GetArtifactRequestVec(m_errorEventNtfData.EventType,
+ m_artifactRequestVec);
+
+ l_eStatus = RequestNextArtifact(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "RequestNextArtifact()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnLogStartResponseTimeout
+// brief : Called when / if SM fails to respond to a logging start
+// request and the logging star response timer expires.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnLogStartResponseTimeout(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. SM failed to respond to a logging start request in the required amount of time.");
+
+ m_bIsPrevEventCompleted = TRUE;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : RequestNextArtifact
+// brief : This function requests the next artifact from the service
+// that owns the artifact. If no artifacts remain, this
+// function performs initiates artifact post processing.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::RequestNextArtifact(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_timeoutSec;
+ UI_32 l_timeoutMs;
+
+ if (0 != m_artifactRequestVec.size()) {
+ TLoggingArtifact &l_nextArtifact = m_artifactRequestVec.back();
+ l_eStatus = m_loggerPopups.ShowStartPopup(
+ f_hApp, m_errorEventNtfData, &m_artifactRequestVec,
+ m_loggerUtil.getDestination(m_errorEventNtfData));
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerPopups.ShowStartPopup(f_hApp,m_errorEventNtfData,&m_artifactRequestVec )");
+
+ TEXT(__FUNCTION__,
+ "Requesting next artifact ID:%d from:%s, with timeout:%d ms.",
+ l_nextArtifact.ArtifactId,
+ l_nextArtifact.Information.OwnerServiceName.c_str(),
+ l_nextArtifact.Information.RequestTimeoutMs);
+
+ l_timeoutSec = l_nextArtifact.Information.RequestTimeoutMs / 1000;
+ l_timeoutMs = l_nextArtifact.Information.RequestTimeoutMs % 1000;
+ bool result =
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN].Start(
+ l_timeoutSec, l_timeoutMs, 0, 0);
+ if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to start timer kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN.");
+ // LCOV_EXCL_STOP
+ }
+ switch (l_nextArtifact.Information.Cb.Type) {
+ case eCbTypePath: {
+ l_eStatus = CheckPathForArtifact(f_hApp, l_nextArtifact);
+ }
+ break;
+
+ case eCbTypeFunction: {
+ if (l_nextArtifact.Information.Cb.Function == NULL) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 200:As it is not always NULL
+ } else {
+ l_eStatus = l_nextArtifact.Information.Cb.Function(f_hApp,
+ l_nextArtifact);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "l_nextArtifact.Information.Cb.Function(f_hApp, l_nextArtifact)");
+ }
+ }
+ break;
+
+ case eCbTypeInvalid:
+ default:
+ {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Unknown artifact or artifact owner for artifact ID:"
+ " %d. Invalid logging artifact configuration likely.",
+ l_nextArtifact.ArtifactId);
+ }
+ break;
+ }
+ } else {
+ if ((m_errorEventNtfData.EventType == eErrorEventTypeUserInvokedClearLogs)
+ || (m_errorEventNtfData.EventType
+ == eErrorEventTypeUserInvokedCollectNaviLog)) {
+ l_eStatus = this->OnStorageResponseOk(f_hApp);
+ return (l_eStatus);
+ }
+ uint8_t status;
+ Clock_getSystemTimeY2K38(&m_time, &status);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. All logging error event artifacts have been collected.");
+ l_eStatus = m_loggerUtil.checkDestinationAvailable(m_errorEventNtfData);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerUtil.checkDestinationAvailable(m_errorEventNtfData)");
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ /* Check one last time after all logs have been collected */
+ /* if we should show popup for archiving and writing to USB */
+ l_eStatus = m_loggerPopups.ShowStartPopup(
+ f_hApp, m_errorEventNtfData, &m_artifactRequestVec,
+ m_loggerUtil.getDestination(m_errorEventNtfData));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerPopups.ShowStartPopup(f_hApp,m_errorEventNtfData,&m_artifactRequestVec )");
+
+ l_eStatus = m_loggerUtil.getFilePathAndName(f_hApp, m_errorEventNtfData,
+ m_time, m_archiveDestination);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerUtil.getFilePathAndName()");
+
+ std::string destination_path = m_loggerUtil.getDestination(
+ m_errorEventNtfData);
+ if (destination_path.compare(m_pLoggerCfg->m_emmcOutputPath) == 0) {
+ if (eFrameworkunifiedStatusOK
+ != m_loggerUtil.deleteOldEmmcLog(m_archiveDestination,
+ m_errorEventNtfData.EventType)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerUtil.deleteOldEmmcLog()");
+ }
+ }
+
+ l_eStatus = this->m_loggerStorage.Start(m_archiveDestination,
+ this->m_artifactResponseVec,
+ m_time);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerStorage.Start()");
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = this->OnStorageResponseWriteFailed(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "this->OnStorageResponseWriteFailed(f_hApp)");
+ }
+ } else {
+ l_eStatus = this->OnStorageResponseNotFound(f_hApp);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->OnStorageResponseNotFound(f_hApp)");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnArtifactResponse
+// brief : This function is called when an artifact has been made ready
+// by the owning service.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnArtifactResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ARTIFACT_RESPONSE l_artifactResponse;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<ARTIFACT_RESPONSE>(f_hApp, l_artifactResponse))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 200:To ensure success
+ } else {
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN].Stop();
+
+ // Prevent processing of artifacts that arrive after the error event logging session has completed.
+ if (m_artifactRequestVec.size() > 0) {
+ TEXT(__FUNCTION__, "Artifact ID:%d received.",
+ l_artifactResponse.ArtifactId);
+
+ TLoggingArtifact &l_artifactCurr = m_artifactRequestVec.back();
+ if (l_artifactCurr.ArtifactId != l_artifactResponse.ArtifactId) {
+ TEXT(
+ __FUNCTION__,
+ "Failure collecting current artifact. Expected artifact ID:%d, received artifact ID:%d."
+ " Ignoring received artifact.",
+ l_artifactCurr.ArtifactId, l_artifactResponse.ArtifactId);
+ } else {
+ TLoggingArtifactResponse l_response;
+ l_response.ArtifactId = l_artifactResponse.ArtifactId;
+ l_response.Filepath = l_artifactResponse.FilePathAndName;
+ l_response.Remove = l_artifactCurr.Information.Remove;
+ m_artifactResponseVec.push_back(l_response);
+ m_artifactRequestVec.pop_back(); // Remove received artifact from request vector.
+ l_eStatus = RequestNextArtifact(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "RequestNextArtifact()");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Received spurious artifact ID: %d. No error event logging session active.",
+ l_artifactResponse.ArtifactId); // LCOV_EXCL_BR_LINE 5:macro
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnArtifactResponseTimeout
+// brief : This function is called when a requested artifact response
+// fails to arrive in the required amount of time.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnArtifactResponseTimeout(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (m_artifactRequestVec.size() > 0) { // LCOV_EXCL_BR_LINE 200:As it cannot always be 0
+ TLoggingArtifact &l_artifactCurr = m_artifactRequestVec.back();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Artifact response timer expired for artifact ID: %d.",
+ l_artifactCurr.ArtifactId);
+
+ // Remove artifact from request vector.
+ m_artifactRequestVec.pop_back();
+
+ RequestNextArtifact(f_hApp);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnArtifactRequest
+// brief : This function services an artifact request generated by
+// the error event sub system. The requested artifact will
+// be one of the artifacts owned by SSL.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnArtifactRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EArtifactId l_requestedArtifactId;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EArtifactId>(f_hApp, l_requestedArtifactId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ switch (l_requestedArtifactId) {
+ case eArtifactIdInterfaceunifiedDebugLog:
+ l_eStatus = OnObtainLoggerserviceLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainLoggerserviceLogRequest()");
+ break;
+
+ case eArtifactIdTransmitLog:
+ l_eStatus = OnObtainTransmitLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainTransmitLogRequest()");
+ break;
+
+ case eArtifactIdPerformanceLog:
+ l_eStatus = OnObtainPerformanceLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainPerformanceLogRequest()");
+ break;
+
+ case eArtifactIdScreenShot:
+ l_eStatus = OnObtainScreenShotRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainScreenShotRequest()");
+ break;
+
+ case eArtifactIdKernelLog:
+ l_eStatus = OnObtainKernelLogInfoRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainKernelLogInfoRequest()");
+ break;
+
+ case eArtifactIdDRInitialLog:
+ l_eStatus = OnObtainDRInitialLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainDRInitialLogRequest()");
+ break;
+
+ case eArtifactIdDRLocationLog:
+ l_eStatus = OnObtainDRLocationLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainDRLocationLogRequest()");
+ break;
+
+ case eArtifactIdClearAllLog:
+ l_eStatus = OnClearAllLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnClearAllLogRequest()");
+ break;
+
+ case eArtifactIdNaviLog:
+ l_eStatus = OnNaviLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnNaviLogRequest()");
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unsupported logging artifact requested: %d.",
+ l_requestedArtifactId);
+ break;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseOk
+// brief : This function services response from the storage thread. It
+// is called when the logs have been stored successfully.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseOk(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = this->m_loggerPopups.ShowEndPopup(f_hApp, m_errorEventNtfData,
+ m_archiveDestination);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->m_loggerPopups.ShowEndPopup(f_hApp,m_errorEventNtfData,m_archiveDestination)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ l_eStatus = sendDiagEventResponse();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventResponse()");
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusOK);
+
+ l_eStatus = m_loggerCanEvent.PublishEndEvent(f_hApp, m_errorEventNtfData,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishEndEvent();");
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseWriteFailed
+// brief : This function services response from the storage thread. It
+// is called when the logs failed to be written to the target
+// destination.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseWriteFailed(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
+ (UI_16) eWriteToDeviceFailed);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "m_loggerPopups.ShowErrorPopup(f_hApp, eWriteToDeviceFailed)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ sendDiagEventErrorResponse(eDEVICE_WRITE_ERROR);
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
+
+ l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
+ TRUE,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseNotFound
+// brief : This function services response from the storage thread. It
+// is called when the logs failed to be written to the target
+// destination because the target was not found
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseNotFound(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
+ (UI_16) eSelectedDeviceNotFound);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerPopups.ShowErrorPopup(f_hApp, eSelectedDeviceNotFound)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ l_eStatus = sendDiagEventErrorResponse(eDEVICE_NOT_AVAILABLE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventErrorResponse(eDEVICE_NOT_AVAILABLE)");
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
+
+ l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
+ TRUE,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseNoWritten
+// brief : This function services response from the storage thread. It
+// is called when no logs where found.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseNoWritten(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
+ (UI_16) eNoLogToStore);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "m_loggerPopups.ShowErrorPopup(f_hApp, eNoLogToStore)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ l_eStatus = sendDiagEventErrorResponse(eNO_ERROR_INFO);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventErrorResponse(eNO_ERROR_INFO)");
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusOK);
+
+ l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
+ TRUE,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::sendDiagEventErrorResponse(EELL_ErrorCode f_errCode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (this->m_ServiceName.length() > 0) {
+ l_eStatus = sendDiagEventErrorResponse(f_errCode, this->m_ServiceName);
+ this->m_ServiceName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::sendDiagEventErrorResponse(EELL_ErrorCode f_errCode,
+ std::string f_destName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(m_diagsessionhandle, SS_LOGGERCOPYEMERGENCYLOGS_ERROR_RESP, sizeof(EELL_ErrorCode), &f_errCode))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_LOGGERCOPYEMERGENCYLOGS_ERROR_RESP Msg send failed = %x",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::sendDiagEventResponse(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(m_diagsessionhandle, SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP, 0, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP Msg send failed = %x",
+ l_eStatus);
+ }
+
+ m_ServiceName = "";
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::SetDiagEventSourceName(std::string f_serviceName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((f_serviceName.length() > 0)
+ && (this->m_ServiceName.length() == 0)) {
+ this->m_ServiceName = f_serviceName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. f_serviceName(%s), m_serviceName(%s)",
+ f_serviceName.c_str(), m_ServiceName.c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+void CErrorEvent::SetDiagSessionHandle(HANDLE f_sessionhandle) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_diagsessionhandle = f_sessionhandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void CErrorEvent::SetMileage(UI_32 f_mileage) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ this->m_loggerUtil.SetMilage(f_mileage);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+// LCOV_EXCL_START 200:
+EFrameworkunifiedStatus CErrorEvent::SaveNaviLog(EPWR_SHUTDOWN_TRIGGER_TYPE errType) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_logMaxNum = 0;
+ std::string l_Filename = "";
+
+ uint32_t l_time;
+ uint8_t status;
+ Clock_getSystemTimeY2K38(&l_time, &status);
+ l_eStatus = m_loggerUtil.getEmmcNaviLogParams(l_time, errType, l_Filename,
+ l_logMaxNum);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: getEmmcNaviLogParams NaviLog update failed %d", l_eStatus);
+ } else {
+ if (l_logMaxNum == 0) {
+ /*OutputNaviLogNmlMax or OutputNaviLogErrMax = 0. */
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN,
+ __FUNCTION__,
+ " Warning: Not update NaviLog. OutputNaviLogNmlMax or OutputNaviLogErrMax = 0");
+ } else {
+ FILE *fp;
+ void *p;
+ p = EL_mem_exram_mmap_simple(EL_MEM_ID_NAVI_LOG, PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ EL_MEM_CACHE_INVALID);
+ if (p == MAP_FAILED) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error : EL_mem_exram_mmap_simple MAP_FAILD");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ fp = fopen(l_Filename.c_str(), "wb");
+ if (fp == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open file %s",
+ l_Filename.c_str());
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ } else {
+ fwrite(p, sizeof(unsigned char), EL_mem_getLength(EL_MEM_ID_NAVI_LOG),
+ fp);
+ fclose(fp);
+ }
+ if (0 != EL_mem_exram_munmap(p, EL_mem_getLength(EL_MEM_ID_NAVI_LOG))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : EL_mem_exram_munmap");
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEvent::VerifyExtStorage(TLoggerErrorEvent event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string f_path;
+
+ f_path = m_pLoggerCfg->getUsb0MountPath();
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+
+ if (eFrameworkunifiedStatusFail == l_eStatus) {
+ // timeout or error
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : get secure log failed or timeout");
+ }
+ } else {
+ // timeout
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : ticket verify timeout.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+bool CErrorEvent::IsNeedVerify(EErrorEventType type) {
+ bool ret = false;
+ switch (type) {
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeInterfaceunifiedEmmcLogs:
+ case eErrorEventTypeEelExport:
+ case eErrorEventTypeDiagEvent:
+ case eErrorEventTypeCanEvent:
+ ret = true;
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
diff --git a/systemservice/logger_service/server/src/ss_logger_error_event_archive.cpp b/systemservice/logger_service/server/src/ss_logger_error_event_archive.cpp
new file mode 100755
index 0000000..b718705
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_error_event_archive.cpp
@@ -0,0 +1,413 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_error_event_archive.h"
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <libtar_listhash.h>
+#include <libtar.h>
+#include <zlib.h>
+#include <stdio.h>
+#include <boost/bind.hpp>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <vector>
+#include "ss_logger_util.h"
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_fs_directory.h"
+
+// GZF save variables
+static gzFile g_gzFile;
+
+CErrorEventArchive::CErrorEventArchive(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_pTarInfo = NULL;
+ g_gzFile = NULL;
+ m_gztype.openfunc = (openfunc_t) &CErrorEventArchive::gzOpenArchive;
+ m_gztype.closefunc = (closefunc_t) &CErrorEventArchive::gzCloseArchive;
+ m_gztype.readfunc = (readfunc_t) &CErrorEventArchive::gzReadArchive;
+ m_gztype.writefunc = (writefunc_t) &CErrorEventArchive::gzWriteArchive;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CErrorEventArchive::~CErrorEventArchive(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (NULL != m_pTarInfo) { // LCOV_EXCL_BR_LINE 6: it will close after close
+ // LCOV_EXCL_START 6: it will close after close
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ (void) closeArchive();
+ m_pTarInfo = NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::openArchive(std::string f_pathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == m_pTarInfo) { // LCOV_EXCL_BR_LINE 6: closeArchive will be set to null
+ m_pathAndName = f_pathAndName;
+
+ /* check if directory exists */
+ size_t l_found = f_pathAndName.find_last_of('/');
+ std::string l_path = f_pathAndName.substr(0, l_found);
+
+ if (0 != access(l_path.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Directory does not exist. Creating...");
+ l_eFrameworkunifiedStatus = CFSDirectory::CreateDirectory(l_path);
+ }
+
+ /* create archive in tmp */
+ m_tmpName = "/tmp/log.tar.gz";
+
+ int l_tarRetVal = tar_open(&m_pTarInfo, const_cast<char*>(m_tmpName.c_str()),
+ &m_gztype,
+ O_WRONLY | O_CREAT,
+ TARMODE,
+ TAR_GNU);
+
+ if ((l_tarRetVal != 0) || (m_pTarInfo == NULL) || (g_gzFile == NULL)) { // LCOV_EXCL_BR_LINE 5: tar_open's error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: tar_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open TAR-Archive!");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: closeArchive will be set to null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Tar is still open");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::addToArchive(std::string f_filePathAndName,
+ std::string f_destinationName,
+ UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFileLoadError;
+ struct stat l_stat;
+ int l_statRetVal;
+
+ if (0 != access(f_filePathAndName.c_str(), F_OK)) { // LCOV_EXCL_BR_LINE 200: file is aways exist
+ // LCOV_EXCL_START 200: file is aways exist
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_filePathAndName.c_str());
+ // LCOV_EXCL_STOP
+ } else if (0 != (l_statRetVal = stat(f_filePathAndName.c_str(), &l_stat))) { // LCOV_EXCL_BR_LINE 5: stat's error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: stat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_filePathAndName.c_str(), l_statRetVal);
+ // LCOV_EXCL_STOP
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ if (0 < f_depth) { // LCOV_EXCL_BR_LINE 6: it aways 4
+ l_eFrameworkunifiedStatus = addDirectoryToArchive(f_filePathAndName, f_destinationName,
+ f_depth);
+ } else {
+ // LCOV_EXCL_START 6: it aways 4
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Maximum recursive depth reached! File %s not added to archive.",
+ f_filePathAndName.c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else if (0 != S_ISREG(l_stat.st_mode)) { // LCOV_EXCL_BR_LINE 200: it can not be a symbolic link
+ l_eFrameworkunifiedStatus = addFileToArchive(f_filePathAndName, f_destinationName);
+ } else {
+ // LCOV_EXCL_START 200: it can not be a symbolic link
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_filePathAndName.c_str(), l_stat.st_mode);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CErrorEventArchive::addToArchive(
+ std::vector<std::string> f_filePathAndNameList) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ std::vector<std::string>::iterator l_vIter = f_filePathAndNameList.begin();
+ while ((eFrameworkunifiedStatusOK == l_eFrameworkunifiedStatus)
+ && (l_vIter != f_filePathAndNameList.end())) {
+ l_eFrameworkunifiedStatus = addToArchive(*l_vIter, *l_vIter);
+ l_vIter++;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEventArchive::closeArchive(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (0 != tar_append_eof(m_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_append_eof's error case.
+ // LCOV_EXCL_START 5: tar_append_eof's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_append_eof()");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ if (0 != tar_close(m_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_close's error case.
+ // LCOV_EXCL_START 5: tar_close's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not close archive");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ m_pTarInfo = NULL;
+ g_gzFile = NULL;
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 6: it aways be ok
+#ifdef RELEASE_BUILD
+ l_eStatus = CLoggerUtil::PathCheckAndCopyFile(m_tmpName, m_pathAndName);
+#else
+ l_eStatus = CLoggerUtil::CopyFile(m_tmpName, m_pathAndName);
+#endif // RELEASE_BUILD
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ l_eStatus =
+ (0 == remove(m_tmpName.c_str())) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFault;
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 5: remove's error case.
+ // LCOV_EXCL_START 5: remove's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN,
+ __FUNCTION__,
+ " Warning. Failed to remove temporary archive. Will overwrite on next event");
+ // LCOV_EXCL_STOP
+ }
+ } else if (eFrameworkunifiedStatusErrNoEAGAIN == l_eStatus) { // LCOV_EXCL_BR_LINE 200: write can not be ErrNoEAGAIN
+ // LCOV_EXCL_START 200: write can not be ErrNoEAGAIN
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // disk space full
+ struct stat st_buf;
+ size_t req_size;
+ if (stat(m_tmpName.c_str(), &st_buf) != -1) { // LCOV_EXCL_BR_LINE 5: stat's error case.
+ req_size = st_buf.st_size;
+ if (eFrameworkunifiedStatusOK
+ == CLoggerUtil::forceDeleteOldLog(m_pathAndName, req_size)) {
+#ifdef RELEASE_BUILD
+ l_eStatus = CLoggerUtil::PathCheckAndCopyFile(m_tmpName, m_pathAndName);
+#else
+ l_eStatus = CLoggerUtil::CopyFile(m_tmpName, m_pathAndName);
+#endif // RELEASE_BUILD
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200: PathCheckAndCopyFile can not be fail
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Try Again but Error. Failed to copy to destination.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. force delete failed.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " emmc full: dest=%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ } else {
+ // LCOV_EXCL_START 5: stat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Warning. Failed to get tmp log file stat. dest=%s",
+ m_pathAndName.c_str());
+ // LCOV_EXCL_STOP
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ /*should we copy lost archive to emmc??*/
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed to copy to destination. %s", m_pathAndName.c_str());
+ }
+ remove(m_tmpName.c_str());
+ m_tmpName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::addFileToArchive(std::string f_filename,
+ std::string f_destinationName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK; /*check if Tar is open and if file can be read */
+
+ char path[PATH_MAX];
+
+ if ((NULL != m_pTarInfo) && (0 != f_destinationName.length()) // LCOV_EXCL_BR_LINE 200: it will awalys be true
+ && (realpath(f_filename.c_str(), path) != NULL)) {
+ int l_tarRetVal = tar_append_file(m_pTarInfo, path,
+ const_cast<char*>(f_destinationName. c_str()));
+ if (0 != l_tarRetVal) { // LCOV_EXCL_BR_LINE 5: tar_append_file's error case.
+ // LCOV_EXCL_START 5: tar_append_file's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not add file \'%s\' to tar archive.", f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: it will awalys be true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Archive not opened or could not access file: \"%s\"",
+ f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::addDirectoryToArchive(
+ std::string f_path, std::string f_destinationName, UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ struct dirent l_pDirent;
+ struct dirent* next;
+
+ DIR *l_pDir = opendir(f_path.c_str());
+ if (l_pDir != NULL) { // LCOV_EXCL_BR_LINE 5: opendir's error case.
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_extension = "/";
+ std::string l_fileName = f_path;
+ std::string l_destName = f_destinationName;
+ l_extension.append(l_pDirent.d_name);
+ l_fileName.append(l_extension);
+ l_destName.append(l_extension);
+ l_eFrameworkunifiedStatus = addToArchive(l_fileName, l_destName, static_cast<UI_8>(f_depth - 1));
+ }
+ }
+
+ closedir(l_pDir);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+SI_32 CErrorEventArchive::gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SI_32 l_siFileDescriptor = -1;
+
+ if (f_pcPathname) { // LCOV_EXCL_BR_LINE 6: Pathname is awalys be set
+ PCHAR l_pcGzoflags;
+
+ switch (f_siOflags & O_ACCMODE) { // LCOV_EXCL_BR_LINE 6: only O_WRONLY be set
+ case O_WRONLY: {
+ l_pcGzoflags = (PCHAR) "wb";
+ break;
+ }
+ // LCOV_EXCL_START 6: only O_WRONLY be set
+ case O_RDONLY: {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_pcGzoflags = (PCHAR) "rb";
+ break;
+ }
+ // LCOV_EXCL_STOP
+ case O_RDWR:
+ default: {
+ return -1;
+ }
+ }
+
+ if (-1 == (l_siFileDescriptor = // LCOV_EXCL_BR_LINE 5: open's error case.
+ open(f_pcPathname, f_siOflags, f_siMode))) {
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ if ((f_siOflags & O_CREAT) // LCOV_EXCL_BR_LINE 5: fchmod's error case.
+ && fchmod(l_siFileDescriptor, f_siMode)) {
+ // LCOV_EXCL_START 5: fchmod's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ g_gzFile = gzdopen(l_siFileDescriptor, l_pcGzoflags);
+ if (!g_gzFile) { // LCOV_EXCL_BR_LINE 5: gzdopen's error case.
+ // LCOV_EXCL_START 5: gzdopen's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path empty.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (SI_32) l_siFileDescriptor;
+}
+SI_32 CErrorEventArchive::gzCloseArchive() {
+ return gzclose(g_gzFile);
+}
+
+ssize_t CErrorEventArchive::gzWriteArchive(int fd, const void* buf,
+ size_t count) {
+ return gzwrite(g_gzFile, const_cast<void*>(buf), (unsigned int) count);
+}
+
+ssize_t CErrorEventArchive::gzReadArchive(int fd, void* buf, size_t count) {
+ return gzread(g_gzFile, buf, (unsigned int) count);
+}
diff --git a/systemservice/logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp b/systemservice/logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp
new file mode 100755
index 0000000..f400e83
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp
@@ -0,0 +1,147 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports notifying CAN abou HK and CAN error events
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include <time.h>
+#include <stub/Clock_API.h>
+#include "ss_logger_error_event_can_evt_reply.h"
+CLoggerErrorEventCANEvtReply::CLoggerErrorEventCANEvtReply() {
+}
+
+CLoggerErrorEventCANEvtReply::~CLoggerErrorEventCANEvtReply() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::Initialize(CLoggerCfg* f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+BOOL CLoggerErrorEventCANEvtReply::IsEventNeeded(TLoggerErrorEvent f_event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret =
+ ((f_event.EventBitMask & EVENT_BIT_CAN_NOTIFICATION) != 0) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishStartEvent(
+ HANDLE f_hApp, TLoggerErrorEvent f_event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == IsEventNeeded(f_event)) {
+ l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventStart, NULL, 0);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventStart,NULL,0)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishEndEvent(
+ HANDLE f_hApp, TLoggerErrorEvent f_event, UI_32 f_triggerNumber,
+ uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == IsEventNeeded(f_event)) {
+ STEventCANLoggerEventInfo l_info;
+ struct tm l_tm;
+ CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_tm);
+ if (CLOCK_OK == clock_ret) {
+ l_info.valid = TRUE;
+ l_info.success = TRUE;
+ l_info.triggerNumber = f_triggerNumber;
+ l_info.dateAndTime.DateTime_Stat = 0;
+ l_info.dateAndTime.DateTimeDay = static_cast<UI_8>(l_tm.tm_mday);
+ l_info.dateAndTime.DateTimeHour = static_cast<UI_8>(l_tm.tm_hour);
+ l_info.dateAndTime.DateTimeMinute = static_cast<UI_8>(l_tm.tm_min);
+ l_info.dateAndTime.DateTimeMonth = static_cast<UI_8>(l_tm.tm_mon + 1);
+ l_info.dateAndTime.DateTimeSecond = static_cast<UI_8>(l_tm.tm_sec);
+ l_info.dateAndTime.DateTimeYear = static_cast<UI_8>(l_tm.tm_year % 100);
+ l_info.dateAndTime.TimeFormat = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Time sent to CAN is: 20%2d/%2d/%2d %2d:%2d:%2d",
+ l_info.dateAndTime.DateTimeYear, l_info.dateAndTime.DateTimeMonth,
+ l_info.dateAndTime.DateTimeDay, l_info.dateAndTime.DateTimeHour,
+ l_info.dateAndTime.DateTimeMinute,
+ l_info.dateAndTime.DateTimeSecond);
+
+ } else {
+ l_info.success = TRUE;
+ l_info.valid = FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Passed time is invalid.");
+ }
+ l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventFinished,
+ &l_info, sizeof(l_info));
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventFinished,NULL,0)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishErrorEvent(
+ HANDLE f_hApp, TLoggerErrorEvent f_event, BOOL f_isValid,
+ UI_32 f_triggerNumber, uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == IsEventNeeded(f_event)) {
+ STEventCANLoggerEventInfo l_info;
+ struct tm l_tm;
+ CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_tm);
+ l_info.valid = f_isValid;
+ l_info.success = FALSE;
+ if (CLOCK_OK == clock_ret) {
+ l_info.triggerNumber = f_triggerNumber;
+ l_info.dateAndTime.DateTime_Stat = 0;
+ l_info.dateAndTime.DateTimeDay = static_cast<UI_8>(l_tm.tm_mday);
+ l_info.dateAndTime.DateTimeHour = static_cast<UI_8>(l_tm.tm_hour);
+ l_info.dateAndTime.DateTimeMinute = static_cast<UI_8>(l_tm.tm_min);
+ l_info.dateAndTime.DateTimeMonth = static_cast<UI_8>(l_tm.tm_mon + 1);
+ l_info.dateAndTime.DateTimeSecond = static_cast<UI_8>(l_tm.tm_sec);
+ l_info.dateAndTime.DateTimeYear = static_cast<UI_8>(l_tm.tm_year % 100);
+ l_info.dateAndTime.TimeFormat = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Time sent to CAN is: 20%2d/%2d/%2d %2d:%2d:%2d",
+ l_info.dateAndTime.DateTimeYear, l_info.dateAndTime.DateTimeMonth,
+ l_info.dateAndTime.DateTimeDay, l_info.dateAndTime.DateTimeHour,
+ l_info.dateAndTime.DateTimeMinute,
+ l_info.dateAndTime.DateTimeSecond);
+
+ } else {
+ l_info.valid = FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Passed time is invalid.");
+ }
+ l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventFinished,
+ &l_info, sizeof(l_info));
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: macro
+ l_eStatus,
+ "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventFinished,NULL,0)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
diff --git a/systemservice/logger_service/server/src/ss_logger_error_event_cfg.cpp b/systemservice/logger_service/server/src/ss_logger_error_event_cfg.cpp
new file mode 100755
index 0000000..fcd733e
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_error_event_cfg.cpp
@@ -0,0 +1,335 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <vector>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_error_event_cfg.h"
+
+enum ARTIFACT_BIT {
+ ARTIFACT_BIT_NONE = 0x00000000,
+ ARTIFACT_BIT_LOGGERSERVICE_DEBUG_LOG = 1 << (UI_32) eArtifactIdInterfaceunifiedDebugLog,
+ ARTIFACT_BIT_TRANSMIT_LOG = 1 << (UI_32) eArtifactIdTransmitLog,
+ ARTIFACT_BIT_PERFORMANCE_LOG = 1 << (UI_32) eArtifactIdPerformanceLog,
+ ARTIFACT_BIT_BOOT_MICRO_LOG = 1 << (UI_32) eArtifactIdBootMicroLog,
+ ARTIFACT_BIT_SYSTEM_DATA_LOG = 1 << (UI_32) eArtifactIdSystemDataCsv,
+ ARTIFACT_BIT_SHOW_MEM_TXT = 1 << (UI_32) eArtifactIdShowMemTxt,
+ ARTIFACT_BIT_PROCESS_CORE = 1 << (UI_32) eArtifactIdProcessCore,
+ ARTIFACT_BIT_DEBUG_DUMP_LOG = 1 << (UI_32) eArtifactIdDebugDumpLog,
+ ARTIFACT_BIT_KERNEL_LOG = 1 << (UI_32) eArtifactIdKernelLog,
+ ARTIFACT_BIT_KERNEL_BOOT_LOG = 1 << (UI_32) eArtifactIdKernelBootLog,
+ ARTIFACT_BIT_DRINITIAL_LOG = 1 << (UI_32) eArtifactIdDRInitialLog,
+ ARTIFACT_BIT_DRLOCATION_LOG = 1 << (UI_32) eArtifactIdDRLocationLog,
+ ARTIFACT_BIT_CHLM_MC_LOGS = 1 << (UI_32) eArtifactIdCpuHighLoadMonteCarloLogs,
+ ARTIFACT_BIT_METACORE_LOGS = 1 << (UI_32) eArtifactIdMetaCoreLogs,
+ ARTIFACT_BIT_SCREEN_SHOT = 1 << (UI_32) eArtifactIdScreenShot,
+ ARTIFACT_BIT_CMS_LOGS = 1 << (UI_32) eArtifactIdCmsLogs,
+ ARTIFACT_BIT_INTERNAL_DTC_LOG = 1 << (UI_32) eArtifactIDInternalDTC,
+ ARTIFACT_BIT_CLEAR_ALL_LOG = 1 << (UI_32) eArtifactIdClearAllLog,
+ ARTIFACT_BIT_NAVI_LOG = 1 << (UI_32) eArtifactIdNaviLog,
+ ARTIFACT_BIT_DEBUG_FOLDER_CONTENT = 1
+ << (UI_32) eArtifactIdDebugFolderContent,
+ ARTIFACT_BIT_DEBUG_FOLDER2_CONTENT = 1
+ << (UI_32) eArtifactIdDebugFolder2Content,
+ ARTIFACT_BIT_COM_LOG = 1 << (UI_32) eArtifactIdComDebugLog,
+ ARTIFACT_BIT_PSTORE_LOG = 1 << (UI_32) eArtifactIdPstoreLog
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+///// Definition for Logging Artifact Filepaths
+//////////////////////////////////////////////////////////////////////////////////////////
+const char LAF_DEBUG_FOLDER[] = "/nv/BS/ss/logger_service/rwdata";
+const char LAF_DEBUG_FOLDER2[] = "/nv/BS/ss/logger_service/rwdata/log2";
+const char LAF_MONTECARLO_FN[] = "/tmp/MonteCarlo";
+const char LAF_METACORE_FN[] = "/tmp/MetaCore";
+const char LAF_CMS_FN[] = "/tmp/cms";
+const char LAF_INT_DTC_FN[] = "/tmp/dtc_error.log";
+const char LAF_LOGGERSERVICELOG_COM[] = "/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/communication";
+const char LAF_KERNEL_BOOT_FN[] = "/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/kernelboot.log";
+const char LAF_PSTORELOG[] = "/dev/pstore";
+
+#define ARTIFACT_BIT_ALL_OUTPUT_LOG (ARTIFACT_BIT_LOGGERSERVICE_DEBUG_LOG | \
+ ARTIFACT_BIT_DEBUG_DUMP_LOG | \
+ ARTIFACT_BIT_SYSTEM_DATA_LOG | \
+ ARTIFACT_BIT_SHOW_MEM_TXT | \
+ ARTIFACT_BIT_COM_LOG | \
+ ARTIFACT_BIT_KERNEL_LOG | \
+ ARTIFACT_BIT_KERNEL_BOOT_LOG | \
+ ARTIFACT_BIT_SCREEN_SHOT | \
+ ARTIFACT_BIT_TRANSMIT_LOG | \
+ ARTIFACT_BIT_PERFORMANCE_LOG | \
+ ARTIFACT_BIT_DRINITIAL_LOG | \
+ ARTIFACT_BIT_DRLOCATION_LOG | \
+ ARTIFACT_BIT_CHLM_MC_LOGS | \
+ ARTIFACT_BIT_INTERNAL_DTC_LOG | \
+ ARTIFACT_BIT_METACORE_LOGS | \
+ ARTIFACT_BIT_PSTORE_LOG)
+
+TLoggingArtifactCfg CErrorEventCfg::m_loggerErrorEventCfgTbl[eErrorEventTypeMaxValue] = {
+ { eErrorEventTypeProcessCrash, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeProcessExit, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeHeartBeatFailure, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeSystemLowMemory, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedUserForceReset, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedCollectAllLogs, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeUserInvokedCollectScreenShot, { (ARTIFACT_BIT_NONE
+ | ARTIFACT_BIT_SCREEN_SHOT),
+
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeUserInvokedCollectDevLogs, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_NONE) }
+ },
+
+ { eErrorEventTypeBootMicroReset, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeEelExport, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeInterfaceunifiedEmmcLogs, { (ARTIFACT_BIT_DEBUG_FOLDER_CONTENT
+ | ARTIFACT_BIT_DEBUG_FOLDER2_CONTENT),
+
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeDiagEvent, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_DIAG) } },
+
+ { eErrorEventTypeCanEvent, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeDtcEvent, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG),
+
+ (EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeModConnFailed, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeStartRespFailed, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeModuleInvokedResetRequest, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeModuleInvokedCollectDebugLogs,
+ { (ARTIFACT_BIT_ALL_OUTPUT_LOG | ARTIFACT_BIT_NAVI_LOG),
+ (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedClearLogs, { (ARTIFACT_BIT_NONE
+ | ARTIFACT_BIT_CLEAR_ALL_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedCollectNaviLog, { (ARTIFACT_BIT_NONE
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeGroupRelaunch, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeReserved1, { (ARTIFACT_BIT_NONE), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeReserved2, { (ARTIFACT_BIT_NONE), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeReserved3, { (ARTIFACT_BIT_NONE), (EVENT_BIT_NONE) } } };
+
+TLoggingArtifact CErrorEventCfg::m_loggerErrorArtifactCfgTbl[eArtifactIdMaxValue] = { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ /*Artifact ID Owner Timeout Callback Type Path CallBack Function Delete tmp artifact*/
+ { eArtifactIdInterfaceunifiedDebugLog, { SERVICE_LOGGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSelf }, TRUE } },
+ { eArtifactIdTransmitLog, { SERVICE_LOGGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSelf }, TRUE } },
+ { eArtifactIdPerformanceLog, { SERVICE_LOGGER, 5, { eCbTypeFunction, "", SSLogger_SendtoSelf }, FALSE } },
+ { eArtifactIdBootMicroLog, { SERVICE_SYSMANAGER, 1000, { eCbTypeFunction, "", SSLogger_SendtoSM }, TRUE } },
+ { eArtifactIdSystemDataCsv, { SERVICE_SYSMANAGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSM }, TRUE } },
+ { eArtifactIdShowMemTxt, { SERVICE_SYSMANAGER, 8000, { eCbTypeFunction, "", SSLogger_SendtoSM }, TRUE } },
+ { eArtifactIdProcessCore, { SERVICE_SYSMANAGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSM }, TRUE } },
+ { eArtifactIdDebugDumpLog, { SERVICE_SYSMANAGER, 4000, { eCbTypeFunction, "", SSLogger_SendtoSM }, TRUE } },
+ { eArtifactIdScreenShot, { SERVICE_LOGGER, 1100, { eCbTypeFunction, "", SSLogger_SendtoSelf }, TRUE } },
+ { eArtifactIdDebugFolderContent, { SERVICE_LOGGER, 50000, { eCbTypePath, LAF_DEBUG_FOLDER, NULL }, FALSE } },
+ { eArtifactIdDebugFolder2Content, { SERVICE_LOGGER, 50000, { eCbTypePath, LAF_DEBUG_FOLDER2, NULL }, FALSE } },
+ { eArtifactIdKernelLog, { SERVICE_LOGGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSelf }, TRUE } },
+ { eArtifactIdKernelBootLog, { SERVICE_LOGGER, 5000, { eCbTypePath, LAF_KERNEL_BOOT_FN, NULL }, FALSE } },
+ { eArtifactIdDRInitialLog, { SERVICE_LOGGER, 500, { eCbTypeFunction, "", SSLogger_SendtoSelf }, TRUE } },
+ { eArtifactIdDRLocationLog, { SERVICE_LOGGER, 500, { eCbTypeFunction, "", SSLogger_SendtoSelf }, TRUE } },
+ { eArtifactIdCpuHighLoadMonteCarloLogs, { SERVICE_LOGGER, 50, { eCbTypePath, LAF_MONTECARLO_FN, NULL }, TRUE } },
+ { eArtifactIdMetaCoreLogs, { SERVICE_LOGGER, 50, { eCbTypePath, LAF_METACORE_FN, NULL }, TRUE } },
+ { eArtifactIdCmsLogs, { SERVICE_LOGGER, 500, { eCbTypePath, LAF_CMS_FN, NULL }, TRUE } },
+ { eArtifactIDInternalDTC, { SERVICE_LOGGER, 500, { eCbTypePath, LAF_INT_DTC_FN, NULL }, TRUE } },
+ { eArtifactIdComDebugLog, { SERVICE_LOGGER, 500, { eCbTypePath, LAF_LOGGERSERVICELOG_COM, NULL }, FALSE } },
+ { eArtifactIdPstoreLog, { SERVICE_LOGGER, 50, { eCbTypePath, LAF_PSTORELOG, NULL }, FALSE } },
+ { eArtifactIdClearAllLog, { SERVICE_LOGGER, 500, { eCbTypeFunction, "", SSLogger_SendtoSelf }, FALSE } },
+ { eArtifactIdNaviLog, { SERVICE_LOGGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSelf }, FALSE } },
+}; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+CErrorEventCfg::CErrorEventCfg() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CErrorEventCfg::~CErrorEventCfg() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEventCfg::Initialize(CLoggerCfg* p_logger_cfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_cnt;
+
+ m_ext_log_num = 0;
+ ExternalLogList ext_log = p_logger_cfg->GetExternalLogList();
+
+ for (l_cnt = 0; l_cnt < eArtifactIdMaxValue; l_cnt++) {
+ EArtifactId l_artifactId = m_loggerErrorArtifactCfgTbl[l_cnt].ArtifactId;
+ TLoggingArtifactInformation l_artifactInformation =
+ m_loggerErrorArtifactCfgTbl[l_cnt].Information;
+ m_errorArtifactMap[l_artifactId] = l_artifactInformation; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ for (l_cnt = 0; l_cnt < eErrorEventTypeMaxValue; l_cnt++) {
+ EErrorEventType l_eventType = m_loggerErrorEventCfgTbl[l_cnt].ErrorType;
+ TLoggingErrorEventInformation l_errorEvtInformation =
+ m_loggerErrorEventCfgTbl[l_cnt].Information;
+ m_errorEventTypeToArtifactBitMaskMap[l_eventType] = l_errorEvtInformation;
+ }
+
+ // Set external log info
+ if (ext_log.num > 0) {
+ if (ext_log.num <= ext_log.max) {
+ m_ext_log_num = ext_log.num;
+ } else {
+ m_ext_log_num = ext_log.max;
+ }
+
+ for (UI_32 i = 0; i < m_ext_log_num; i++) {
+ EArtifactId l_artifactId = (EArtifactId) (eArtifactIdMaxValue + i);
+ TLoggingArtifactInformation artifact_info;
+ artifact_info.Cb.Function = NULL;
+ artifact_info.Cb.Path = ext_log.p_info[i].path;
+ artifact_info.Cb.Type = eCbTypePath;
+ artifact_info.OwnerServiceName = SERVICE_LOGGER;
+ artifact_info.Remove = ext_log.p_info[i].remove;
+ artifact_info.RequestTimeoutMs = 5000;
+ m_errorArtifactMap[l_artifactId] = artifact_info;
+ }
+ }
+
+ l_eStatus = (EFrameworkunifiedStatus) ValidateConfiguration();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "ValidateConfiguration()"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+UI_32 CErrorEventCfg::ValidateConfiguration(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ UI_32 l_return = 0;
+
+ if ((eArtifactIdMaxValue + m_ext_log_num) != m_errorArtifactMap.size()) { // LCOV_EXCL_BR_LINE 6:Be sure not to exceed the eArtifactIdMaxValue
+ // LCOV_EXCL_START 6:Be sure not to exceed the eArtifactIdMaxValue
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Artifact map size mismatch: Expected: %d, Found: %d",
+ (eArtifactIdMaxValue + m_ext_log_num), m_errorArtifactMap.size());
+ l_return |= 1;
+ // LCOV_EXCL_STOP
+ }
+ if (eErrorEventTypeMaxValue != m_errorEventTypeToArtifactBitMaskMap.size()) { // LCOV_EXCL_BR_LINE 6:Be sure not to exceed the eErrorEventTypeMaxValue
+ // LCOV_EXCL_START 6:Be sure not to exceed the eErrorEventTypeMaxValue
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error event map size mismatch: Expected: %d, Found: %d",
+ eErrorEventTypeMaxValue, m_errorEventTypeToArtifactBitMaskMap.size());
+ l_return |= 4;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_return);
+}
+
+void CErrorEventCfg::GetArtifactRequestVec(
+ EErrorEventType f_eventType,
+ std::vector<TLoggingArtifact> &f_refArtifactRequestVec) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ ARTIFACT_BIT_MASK l_artifactRequestBits = 0;
+ ARTIFACT_BIT l_artifactBit;
+ TLoggingArtifact l_artifact;
+ UI_32 l_artifactId;
+
+ f_refArtifactRequestVec.clear();
+
+ if (f_eventType < eErrorEventTypeMaxValue) {
+ l_artifactRequestBits = m_errorEventTypeToArtifactBitMaskMap[f_eventType]
+ .ArtifactBitMask;
+ }
+
+ if (l_artifactRequestBits > 0) {
+ for (l_artifactId = 0; l_artifactId < eArtifactIdMaxValue; l_artifactId++) {
+ l_artifactBit = (ARTIFACT_BIT) (1 << l_artifactId);
+ if ((l_artifactRequestBits & l_artifactBit) > 0) {
+ l_artifact.ArtifactId = (EArtifactId) l_artifactId;
+ l_artifact.Information = m_errorArtifactMap[l_artifact.ArtifactId];
+ f_refArtifactRequestVec.push_back(l_artifact);
+ }
+ }
+
+ // Set external log info
+ if (m_ext_log_num > 0) {
+ for (l_artifactId = 0; l_artifactId < m_ext_log_num; l_artifactId++) {
+ l_artifact.ArtifactId = (EArtifactId) (eArtifactIdMaxValue + l_artifactId);
+ l_artifact.Information = m_errorArtifactMap[l_artifact.ArtifactId];
+ f_refArtifactRequestVec.push_back(l_artifact);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EVENT_BIT_MASK CErrorEventCfg::GetEventsForErrorEvent(
+ EErrorEventType f_eventType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EVENT_BIT_MASK l_events = EVENT_BIT_NONE;
+ if (f_eventType < eErrorEventTypeMaxValue) { // LCOV_EXCL_BR_LINE 6:Be sure not to exceed the eErrorEventTypeMaxValue
+ l_events = m_errorEventTypeToArtifactBitMaskMap[f_eventType].EventBitMask;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_events);
+} // LCOV_EXCL_BR_LINE 10:the last line
diff --git a/systemservice/logger_service/server/src/ss_logger_error_event_responses.cpp b/systemservice/logger_service/server/src/ss_logger_error_event_responses.cpp
new file mode 100755
index 0000000..dc23d8b
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_error_event_responses.cpp
@@ -0,0 +1,625 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <boost/bind.hpp>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/klog.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_sharedmem_reader.h>
+#include <native_service/ns_ringbuffer.h>
+#include <native_service/ns_logger_if.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <native_service/cl_process.h>
+#include <native_service/cl_lockid.h>
+#include <sstream>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "loggerservicedebug_thread_if.h"
+#include "ss_logger_error_event.h"
+#include "ss_logger_service_callbacks.h"
+#include "ss_logger_scrshot.h"
+#include "ss_logger_fs_directory.h"
+#include "ss_logger_common.h"
+#include "ss_logger_types.h"
+
+EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = SendLogArtifactRequestToSystemManager(f_artifact.ArtifactId);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. SendLogArtifactRequestToSystemManager returned: %d for artifact ID: %d",
+ l_eStatus, f_artifact.ArtifactId);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp, TLoggingArtifact f_artifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
+ if (NULL != f_hApp) { // LCOV_EXCL_BR_LINE 6: double check
+ l_eStatus = FrameworkunifiedSendSelf(f_hApp, SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ,
+ sizeof(f_artifact.ArtifactId),
+ &f_artifact.ArtifactId);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedSendSelf(SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ) returned error: %d for artifact ID: %d.",
+ l_eStatus, f_artifact.ArtifactId);
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+///////////////////////////////////////////////////////////////////////////
+// Function : SendLogArtifactResponseToSelf
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::SendLogArtifactResponseToSelf(
+ HANDLE f_hApp, EArtifactId f_artifactId,
+ std::string f_artifactFilePathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ARTIFACT_RESPONSE l_artifactResponse;
+
+ l_artifactResponse.ArtifactId = f_artifactId;
+
+ strncpy(l_artifactResponse.FilePathAndName, f_artifactFilePathAndName.c_str(),
+ sizeof(l_artifactResponse.FilePathAndName) - 1);
+
+ l_eStatus = FrameworkunifiedSendSelf(f_hApp, SS_SM_ERROR_EVENT_ARTIFACT_RSPN,
+ sizeof(l_artifactResponse), &l_artifactResponse);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedSendSelf(SS_SM_ERROR_EVENT_ARTIFACT_RSPN)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainLoggerserviceLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string dir_path = DEBUG_LOG_PATH_DIR;
+
+ l_eStatus = CFSDirectory::CreateDirectory(dir_path);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Create FRAMEWORKUNIFIEDLOG tmp directory %d",
+ l_eStatus);
+ } else {
+ UI_32 l_DumpSize = 0;
+ std::string src_file_path;
+ std::string dst_file_path;
+ PCSTR file_name;
+ UI_32 num;
+ bool log_clear = true;
+
+ switch (m_errorEventNtfData.EventType) {
+ // _DIAG
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeDiagEvent:
+ case eErrorEventTypeCanEvent:
+ case eErrorEventTypeDtcEvent:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ // _DEBUG
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ log_clear = false;
+ break;
+ default:
+ break;
+ }
+
+ num = NSLogGetFrameworkunifiedlogFileTotalNum();
+ for (UI_32 cont = 0; cont < num; cont++) {
+ file_name = NSLogGetFrameworkunifiedlogFileName(cont);
+ if (file_name == NULL) {
+ break;
+ }
+ src_file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ src_file_path.append("/");
+ src_file_path.append(file_name);
+ dst_file_path = DEBUG_LOG_PATH_DIR;
+ dst_file_path.append("/");
+ dst_file_path.append(file_name);
+ CNSRingBuffer* l_pLoggerservicelog;
+ int index;
+ index = NSLogGetFrameworkunifiedlogIndex(src_file_path.c_str());
+ l_pLoggerservicelog = new (std::nothrow) CNSRingBuffer(
+ src_file_path, 0, index + LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s",
+ src_file_path.c_str());
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pLoggerservicelog->DumpToFile(dst_file_path.c_str(),
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer DumpToFile failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ }
+ if (NULL != l_pLoggerservicelog) { // LCOV_EXCL_BR_LINE 5: new's error case
+ if (log_clear) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->ClearBuf())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer ClearBuf failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ }
+ }
+ (void) l_pLoggerservicelog->Close();
+ delete l_pLoggerservicelog;
+ }
+ }
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdInterfaceunifiedDebugLog,
+ DEBUG_LOG_PATH_DIR);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdInterfaceunifiedDebugLog)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainTransmitLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_RootPath;
+
+ l_eStatus = m_pReaderWriterControl->FlushCache(eReaderWriterLogTransmit);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pReaderWriterControl->FlushCache(eReaderWriterLogTransmit)");
+ l_RootPath = TRANSMIT_LOG_PATH_FN;
+ if (access(l_RootPath.c_str(), R_OK) != 0) {
+ l_RootPath = "";
+ }
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdTransmitLog,
+ l_RootPath.c_str());
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogArtifactResponseToSelf(eArtifactIdTransmitLog)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainPerformanceLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = m_pReaderWriterControl->FlushCache(eReaderWriterLogPerformance);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_pReaderWriterControl->FlushCache(eReaderWriterLogPerformance)");
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdPerformanceLog,
+ PERFORMANCE_LOG_PATH_FN);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdPerformanceLog)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainScreenShotRequest
+// brief : Collect screen shot artifact from PLM and return a response
+// to SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainScreenShotRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdScreenShot,
+ SCREEN_SHOT_PATH);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdScreenShot)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainScreenShotResponse
+// brief : Callback from PLM when the screen shot file has been written
+// to storage. The data received contains the file path and
+// name to the written screen shot file. See
+// SS_LOGGER_SCREENCAPTURE_EVT_ACK.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainScreenShotResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STScreenCaptureEvt l_ScreenCaptureEvtAck;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<STScreenCaptureEvt>(f_hApp, l_ScreenCaptureEvtAck))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP
+ } else {
+ if (FALSE == l_ScreenCaptureEvtAck.fSucessful) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Screen shot acquisition failed. l_ScreenCaptureEvtAck.fSucessful == FALSE.");
+ l_ScreenCaptureEvtAck.strNameAndLocation[0] = '\0';
+ }
+
+ l_eStatus = SendLogArtifactResponseToSelf(
+ f_hApp, eArtifactIdScreenShot,
+ l_ScreenCaptureEvtAck.strNameAndLocation); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 5:macro
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdScreenShot)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainKernelLogInfoRequest
+// brief : Collect kernel log artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainKernelLogInfoRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = CreateKernelLog(f_hApp, SS_LOGGER_KLOG_GET);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainDRInitialLogRequest
+// brief : Collect DRInitialLog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainDRInitialLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+
+ CNSSharedMemReader* l_pDRInitial = new (std::nothrow) CNSSharedMemReader(
+ SHMEM_DRINITIALLOG, FALSE);
+
+ if (NULL == l_pDRInitial) { // LCOV_EXCL_BR_LINE 5: new's error case
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial SharedMem handle is NULL");
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pDRInitial->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial Open failed %d", l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pDRInitial->DumpToFile(DRINITIAL_LOG_PATH_FN,
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial DumpToFile failed %d",
+ l_eStatus);
+ } else {
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdDRInitialLog,
+ DRINITIAL_LOG_PATH_FN);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdDRInitialLog)");
+ }
+
+ if (NULL != l_pDRInitial) { // LCOV_EXCL_BR_LINE 5: new's error case
+ (void) l_pDRInitial->Close();
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainDRLocationLogRequest
+// brief : Collect DRLocationLog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainDRLocationLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+
+ CNSSharedMemReader* l_pDRLocation = new (std::nothrow) CNSSharedMemReader(
+ SHMEM_DRLOCATIONLOG, FALSE);
+
+ if (NULL == l_pDRLocation) { // LCOV_EXCL_BR_LINE 5: new's error case
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial SharedMem handle is NULL");
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pDRLocation->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRLocation Open failed %d",
+ l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pDRLocation->DumpToFile(DRLOCATION_LOG_PATH_FN,
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRLocation DumpToFile failed %d",
+ l_eStatus);
+ } else {
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdDRLocationLog,
+ DRLOCATION_LOG_PATH_FN);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdDRLocationLog)");
+ }
+
+ if (NULL != l_pDRLocation) { // LCOV_EXCL_BR_LINE 5: new's error case
+ (void) l_pDRLocation->Close();
+ delete l_pDRLocation;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnClearAllLogRequest
+// brief : Callback from LoggerService when the event log file has been delete
+// from storage. The data received contains the file path.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnClearAllLogRequest(HANDLE f_hApp) {
+ std::string clear_file_path = CLEAR_LOG_PATH_FN;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_Logger Clear %s directory delete successful.",
+ clear_file_path.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger Clear %s directory delete failed.",
+ clear_file_path.c_str());
+ }
+
+ clear_file_path = "/nv/BS/ss/logger_service/rwdata/log2/awlog/";
+ if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_Logger Clear %s directory delete successful.",
+ clear_file_path.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger Clear %s directory delete failed.",
+ clear_file_path.c_str());
+ }
+
+ clear_file_path = "/nv/BS/ss/logger_service/rwdata/log2/core/";
+ if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_Logger Clear %s directory delete successful.",
+ clear_file_path.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger Clear %s directory delete failed.",
+ clear_file_path.c_str());
+ }
+
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdClearAllLog,
+ clear_file_path.c_str());
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogArtifactResponseToSelf(eArtifactIdClearAllLog)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnNaviLogRequest
+// brief : Callback from LoggerService when the event log file has been xxxxxx BUGBUG
+// from storage. The data received contains the file path.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnNaviLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ EFrameworkunifiedStatus naviLog_status;
+ switch (m_errorEventNtfData.EventType) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeModuleInvokedResetRequest:
+ case eErrorEventTypeGroupRelaunch:
+ naviLog_status = SaveNaviLog(epssdmsdtGENERIC_ERROR_RESET);
+ break;
+ default:
+ naviLog_status = SaveNaviLog(epssdmsdtNORMAL_RESET);
+ break;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Fail to save Navi Log %d",
+ naviLog_status);
+
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdNaviLog, "");
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogArtifactResponseToSelf(eArtifactIdNaviLog)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::CheckPathForArtifact(HANDLE f_hApp,
+ TLoggingArtifact f_artifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ std::string l_Path;
+
+ if (f_artifact.Information.Cb.Type == eCbTypePath) {
+ l_Path = f_artifact.Information.Cb.Path;
+ if (access(l_Path.c_str(), R_OK) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "File/Directory %s not found. Returning empty string.",
+ l_Path.c_str());
+ l_Path = "";
+ }
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, f_artifact.ArtifactId,
+ l_Path.c_str());
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogArtifactResponseToSelf()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+/* Read all messages remaining in the ring buffer. (allowed for non-root) */
+#define SYSLOG_ACTION_READ_ALL 3
+/* Return size of the log buffer */
+#define SYSLOG_ACTION_SIZE_BUFFER 10
+
+EFrameworkunifiedStatus CErrorEvent::CreateKernelLog(HANDLE f_hApp,
+ SS_LOGGER_KLOG_OPE_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int len;
+ int fd;
+ char* buf;
+ ssize_t wr_len;
+
+ len = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
+ if (len < 0) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to get syslog buffer size: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ buf = reinterpret_cast<char*>(malloc(len));
+ if (buf != NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ len = klogctl(SYSLOG_ACTION_READ_ALL, buf, len);
+ if ((len < 0) || (len == 0)) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to read syslog buffer: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ std::string file_put_path = "";
+ EArtifactId artifact_id = eArtifactIdMaxValue;
+ switch (type) {
+ case SS_LOGGER_KLOG_GET:
+ file_put_path = KERNEL_LOG_PATH_FN;
+ artifact_id = eArtifactIdKernelLog;
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ case SS_LOGGER_KBOOTLOG_CREATE:
+ file_put_path = KERNEL_BOOT_LOG_PATH_FN;
+ artifact_id = eArtifactIdKernelBootLog;
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ default:
+ fd = -1;
+ break;
+ }
+
+ if (fd == -1) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to open file: %s: %d, %s",
+ file_put_path.c_str(), errno, strerror(errno));
+ } else {
+ wr_len = write(fd, buf, len);
+ if (wr_len == -1) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. File write failed. errno: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ fsync(fd);
+ close(fd);
+
+ if (SS_LOGGER_KLOG_GET == type) {
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, artifact_id,
+ file_put_path.c_str());
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "SendLogArtifactResponseToSelf failed. EFrameworkunifiedStatus:%d, ArtifactID:%d, Path:%s",
+ l_eStatus, artifact_id, file_put_path.c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ free(buf);
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation Failed %s",
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
diff --git a/systemservice/logger_service/server/src/ss_logger_error_event_storage.cpp b/systemservice/logger_service/server/src/ss_logger_error_event_storage.cpp
new file mode 100755
index 0000000..ffdebe7
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_error_event_storage.cpp
@@ -0,0 +1,628 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_error_event_storage.h"
+#include <stdlib.h>
+#include <sched.h>
+#include <string.h>
+#include <errno.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <string>
+#include "ss_logger_util.h"
+#include "ss_logger_error_event_archive.h"
+#include "ss_logger_fs_directory.h"
+#include "ss_logger_common.h"
+
+CLoggerErrorEventStorage::CLoggerErrorEventStorage()
+ : m_parentMcQueue(NULL),
+ m_thread(-1),
+ m_sendQueue(-1),
+ m_receiveQueue(-1),
+ m_destination(""),
+ m_mutexInit(-1),
+ m_pLoggerCfg(NULL),
+ m_logTime(0) {
+ m_responseVec.clear();
+ m_mqattr.mq_flags = 0;
+ m_mqattr.mq_maxmsg = 1;
+ m_mqattr.mq_msgsize = 32;
+ m_mqattr.mq_curmsgs = 0;
+}
+
+CLoggerErrorEventStorage::~CLoggerErrorEventStorage() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ this->Cleanup();
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerErrorEventStorage::Initialize(HANDLE f_hApp,
+ std::string f_ParentName,
+ CLoggerCfg *f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ pthread_attr_t l_attr;
+ struct sched_param l_params;
+
+ /* Open the queue */
+ if (NULL == (m_pLoggerCfg = f_pLoggerCfg)) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ // LCOV_EXCL_START 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Parameter f_pLoggerCfg is NULL.");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_pLoggerCfg->GetLoggerStorageInfo(m_loggerStorageInfo))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetLoggerStorageInfo(m_loggerStorageInfo)");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (m_parentMcQueue = McOpenSender(f_ParentName.c_str()))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. McOpenSender(f_ParentName)");
+ // LCOV_EXCL_STOP
+ } else if (-1 == (this->m_sendQueue = mq_open(m_loggerStorageInfo.Name.c_str(), O_CREAT | O_WRONLY, 0666, &m_mqattr))) { // LCOV_EXCL_BR_LINE 5:C code eror // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. mq_open(ERROR_EVENT_STORAGE_QUEUE_NAME,O_CREAT | O_WRONLY, 0666, NULL)");
+ // LCOV_EXCL_STOP
+ } else if (-1 == (this->m_receiveQueue = mq_open(m_loggerStorageInfo.Name.c_str(), O_RDONLY))) { // LCOV_EXCL_BR_LINE 5:C code eror // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusSessionLimitMaxedOut;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. mq_open(ERROR_EVENT_STORAGE_QUEUE_NAME,O_RDONLY)");
+ // LCOV_EXCL_STOP
+ } else if (EOK != (m_mutexInit = pthread_mutex_init(&this->m_mutex, NULL))) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. pthread_mutex_init(&this->m_mutex, NULL)");
+ // LCOV_EXCL_STOP
+ } else if (EOK != pthread_attr_init(&l_attr)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusSemUnlockFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_attr_init()");
+ // LCOV_EXCL_STOP
+ } else if (EOK != pthread_attr_getschedparam(&l_attr, &l_params)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusSemCloseFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_attr_getschedparam()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_params.sched_priority = m_loggerStorageInfo.Priority;
+ if (EOK != pthread_attr_setinheritsched(&l_attr, PTHREAD_EXPLICIT_SCHED)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_attr_setinheritsched()");
+ // LCOV_EXCL_STOP
+ } else if (EOK != pthread_attr_setschedparam(&l_attr, &l_params)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error but continue. pthread_attr_setschedparam(), priority = %d: %s",
+ m_loggerStorageInfo.Priority, strerror(errno)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ if (EOK != pthread_create(&this->m_thread, &l_attr, &CLoggerErrorEventStorage::ThreadFunctionWrapper, this)) { // LCOV_EXCL_BR_LINE 5:C code eror // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_create()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ this->Cleanup(); // LCOV_EXCL_LINE 200:To ensure success
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventStorage::Start(
+ std::string f_target, TArtifactResponseVec f_responseVector,
+ uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ /* Start the thread*/
+ if (EOK == pthread_mutex_lock(&this->m_mutex)) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ this->m_destination = f_target;
+ this->m_responseVec = f_responseVector;
+ this->m_logTime = f_time;
+ (void) pthread_mutex_unlock(&this->m_mutex);
+ }
+ UI_8 l_cmd[MAX_QUEUE_MSG_SIZE];
+ l_cmd[0] = 1;
+ if (-1 == mq_send(this->m_sendQueue, reinterpret_cast<CHAR*>(l_cmd), m_mqattr.mq_msgsize, 0)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. mq_send(this->m_sendQueue %d) return %s", m_sendQueue,
+ strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+void CLoggerErrorEventStorage::ThreadFunction(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ char l_data[MAX_QUEUE_MSG_SIZE] = { };
+ SI_32 l_bytesRead = -1;
+ SI_32 l_oldState;
+ ELoggerStorageThreadCommands l_cmdId = eLoggerStorageThreadCmdWriteFailed;
+ EFrameworkunifiedStatus l_eStatus;
+
+ (void) pthread_setname_np(pthread_self(), ERROR_EVENT_STORAGE_QUEUE_NAME);
+
+ pthread_cleanup_push(&CLoggerErrorEventStorage::CleanupWrapper, this);
+ while (-1 // LCOV_EXCL_BR_LINE 200: mq_send can not send size of -1
+ != (l_bytesRead =
+ static_cast<SI_32>(mq_receive(this->m_receiveQueue, reinterpret_cast<char *>(l_data),
+ (size_t) m_mqattr.mq_msgsize, NULL)))) {
+ std::string l_target;
+ TArtifactResponseVec l_responseVec;
+ uint32_t l_logTime;
+ uint8_t status;
+ Clock_getSystemTimeY2K38(&l_logTime, &status);
+ (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &l_oldState);
+ if (EOK == pthread_mutex_lock(&this->m_mutex)) { // LCOV_EXCL_BR_LINE 5: pthread_mutex_lock's error case.
+ l_target = this->m_destination;
+ l_responseVec = this->m_responseVec;
+ l_logTime = this->m_logTime;
+ this->m_responseVec.clear();
+ this->m_destination = "";
+
+ (void) pthread_mutex_unlock(&this->m_mutex);
+ }
+ (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &l_oldState);
+ if (access(l_target.c_str(), F_OK) == 0) {
+ if (CFSDirectory::IsDirectory(l_target)) { // LCOV_EXCL_BR_LINE 6: can not be a dir
+ // LCOV_EXCL_START 6: new file create, it can not be find
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL isDeleteFiles = FALSE;
+ SI_32 l_filesCopied = this->CopyFiles(l_target, l_responseVec,
+ isDeleteFiles);
+
+ switch (l_filesCopied) {
+ case -1:
+ /*Error while moving files*/
+ l_cmdId = eLoggerStorageThreadCmdWriteFailed;
+ break;
+ case 0:
+ /*No files where moved*/
+ l_cmdId = eLoggerStorageThreadCmdNoWritten;
+ break;
+ default:
+ if (l_filesCopied > 0) {
+ l_cmdId = eLoggerStorageThreadCmdOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. %d files successfully copied.", l_filesCopied);
+ }
+ break;
+ }
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = this->PackageAndPlaceArtifacts(l_target,
+ l_responseVec,
+ l_logTime))) {
+ /*Write Error.*/
+ l_cmdId = eLoggerStorageThreadCmdWriteFailed;
+ } else {
+ l_cmdId = eLoggerStorageThreadCmdOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Archive successfully written.");
+ }
+ if (eFrameworkunifiedStatusOK != RemoveDeprecatedArtifacts(l_responseVec)) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN, __FUNCTION__,
+ " Warning. Wasn't able to delete all deprecated log artifacts.");
+ }
+ }
+
+ std::string l_usb_path;
+ size_t l_usb_path_length = 0;
+ if (m_pLoggerCfg != NULL) { // LCOV_EXCL_BR_LINE 6: m_pLoggerCfg can not be null
+ l_usb_path = m_pLoggerCfg->getUsb0MountPath();
+ l_usb_path_length = l_usb_path.length();
+ if ((l_usb_path_length > 1)
+ && (l_usb_path[l_usb_path.length() - 1] == '/')) {
+ l_usb_path_length--;
+ }
+ }
+ if ((l_usb_path_length > 0)
+ && (l_target.compare(0, l_usb_path_length, l_usb_path, 0,
+ l_usb_path_length) != 0)) {
+ l_usb_path_length = 0;
+ }
+ if ((l_usb_path_length == 0)
+ && (l_target.compare(0, sizeof(DEBUG_USB_PATH) - 1, DEBUG_USB_PATH, 0,
+ sizeof(DEBUG_USB_PATH) - 1) == 0)) {
+ l_usb_path = DEBUG_USB_PATH;
+ l_usb_path_length = sizeof(DEBUG_USB_PATH) - 1;
+ }
+ if (l_usb_path_length > 1) { // if USB path is '/' only, length is 1.
+ // So conditions to be syncfs is greater than 1
+ // sync usb device
+ DIR* l_dirp = opendir(l_usb_path.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: c code error case
+ int fd = dirfd(l_dirp);
+ if (fd != -1) { // LCOV_EXCL_BR_LINE 5: c code error case
+ if (syncfs(fd) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. syncfs failed path=%s [%s]", l_usb_path.c_str(),
+ strerror(errno));
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. syncfs get fd failed path=%s, [%s]",
+ l_usb_path.c_str(), strerror(errno));
+ }
+ closedir(l_dirp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. syncfs opendir failed path=%s, [%s]",
+ l_usb_path.c_str(), strerror(errno));
+ }
+ {
+#define USB_MEMORY_SYNC_WAITTIME 8 // 8 sec
+ const struct timespec intval = { USB_MEMORY_SYNC_WAITTIME, 0 };
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "%d sec:Waiting for USB Memory Synchronization.(%s)",
+ USB_MEMORY_SYNC_WAITTIME, l_usb_path.c_str());
+ nanosleep(&intval, NULL);
+ }
+ }
+ if (eFrameworkunifiedStatusOK
+ != McSend(this->m_parentMcQueue, m_loggerStorageInfo.Name.c_str(),
+ l_cmdId, 0, NULL)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. McSend(this->m_parentMcQueue)");
+ }
+ }
+ pthread_cleanup_pop(1);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void CLoggerErrorEventStorage::Cleanup(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (-1 != this->m_receiveQueue) { // LCOV_EXCL_BR_LINE 200: m_receiveQueue cam not be -1
+ if (-1 == mq_close(this->m_receiveQueue)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_close()");
+ }
+ this->m_receiveQueue = -1;
+ }
+ if (-1 != this->m_sendQueue) { // LCOV_EXCL_BR_LINE 200: m_sendQueue cam not be -1
+ if (-1 == mq_close(this->m_sendQueue)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_close()");
+ }
+ this->m_sendQueue = -1;
+ if (-1 == mq_unlink(m_loggerStorageInfo.Name.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_unlink()");
+ }
+ }
+
+ if (-1 != m_mutexInit) { // LCOV_EXCL_BR_LINE 200: m_mutexInit cam not be -1
+ if (EOK != pthread_mutex_destroy(&this->m_mutex)) { // LCOV_EXCL_BR_LINE 5: c code error case
+ // LCOV_EXCL_START 5: c code error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_unlink()");
+ // LCOV_EXCL_STOP
+ }
+ m_mutexInit = -1;
+ }
+
+ if (NULL != m_parentMcQueue) { // LCOV_EXCL_BR_LINE 200: m_parentMcQueue cam not be null
+ if (eFrameworkunifiedStatusOK != McClose(m_parentMcQueue)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. McClose()");
+ }
+ this->m_parentMcQueue = NULL;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void* CLoggerErrorEventStorage::ThreadFunctionWrapper(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CLoggerErrorEventStorage* l_pObj =
+ reinterpret_cast<CLoggerErrorEventStorage *>(param);
+
+ l_pObj->ThreadFunction();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return NULL;
+}
+
+void CLoggerErrorEventStorage::CleanupWrapper(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CLoggerErrorEventStorage* l_pObj =
+ reinterpret_cast<CLoggerErrorEventStorage *>(param);
+
+ l_pObj->Cleanup();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : PackageAndPlaceArtifacts
+// brief : This function creates an archive for all collected artifacts
+// and places the archive in the required location depending
+// on the event type and required naming criteria.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerErrorEventStorage::PackageAndPlaceArtifacts(
+ std::string f_archiveDestination, TArtifactResponseVec &f_responseVector,
+ uint32_t f_logTime) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_coreFileName = "";
+ SI_32 l_ret = 0;
+
+ if (f_archiveDestination.size() == 0) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Unknown package file path and name. Logging artifacts not stored!");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ CErrorEventArchive l_archiver;
+ l_eStatus = l_archiver.openArchive(f_archiveDestination);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: it can not be fail
+ // LCOV_EXCL_START 6: it can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Failed to create logging archive: %s. Log archive will not be stored!",
+ f_archiveDestination.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ for (UI_32 i = 0; (i < f_responseVector.size()); i++) {
+ if (f_responseVector[i].Filepath != std::string("")) {
+ std::string l_destName = f_responseVector[i].Filepath;
+
+ if ((f_responseVector[i].Filepath.find(".bmp") // LCOV_EXCL_BR_LINE 200: no bmp file be set
+ == f_responseVector[i].Filepath.find_last_of('.'))
+ && (f_responseVector[i].Filepath.find(".bmp")
+ != std::string::npos)) {
+ // LCOV_EXCL_START 200: no bmp file be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ char buffer[20];
+ struct tm local_time;
+ Clock_getLocalTimeY2K38(&f_logTime, &local_time);
+ if (0
+ != strftime(buffer, sizeof(buffer), "%Y%m%d%H%M%S.bmp",
+ &local_time)) {
+ l_destName = buffer;
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ l_destName = f_responseVector[i].Filepath.substr(
+ f_responseVector[i].Filepath.find_last_of('/') + 1);
+ }
+ if (f_responseVector[i].ArtifactId == eArtifactIdPstoreLog) { // LCOV_EXCL_BR_LINE 200: can not be eArtifactIdPstoreLog // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_destName = KERNEL_LOG_PATH_DIR; // LCOV_EXCL_LINE 200: can not be eArtifactIdPstoreLog
+ }
+ l_eStatus = l_archiver.addToArchive(f_responseVector[i].Filepath,
+ l_destName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200: can not be fail
+ // LCOV_EXCL_START 200: can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Failed to add artifact: %s to archive %s. Continuing with next artifact.",
+ f_responseVector[i].Filepath.c_str(),
+ f_archiveDestination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ l_ret++;
+ if ((l_ret % m_loggerStorageInfo.TimeoutAfter) == 0) {
+ usleep(m_loggerStorageInfo.Timeout);
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_archiver.closeArchive()) { // LCOV_EXCL_BR_LINE 200: closeArchive can not be fail
+ // LCOV_EXCL_START 200: closeArchive can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_archiver.closeArchive()");
+ // LCOV_EXCL_STOP
+ } else {
+ // Cleanup artifacts that are no longer required.
+ int rc = access(f_archiveDestination.c_str(), F_OK);
+ if (0 != rc) { // LCOV_EXCL_BR_LINE 5: f_archiveDestination is aways exist
+ // LCOV_EXCL_START 5: f_archiveDestination is aways exist
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Archive verification failed. Errno: %d, %s.", errno,
+ strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ TEXT(__FUNCTION__,
+ " Error Event: A archive successfully written to: %s.",
+ f_archiveDestination.c_str());
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////
+/// File Copy
+/// arg:
+/// isDeleteFiles : TRUE - delete original files after copy.
+/// FALSE - not delete after copy.
+/// returns:
+/// -1: error while writing
+/// else, number of files written
+///////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: can not be called
+SI_32 CLoggerErrorEventStorage::CopyFiles(
+ std::string f_destination, TArtifactResponseVec &f_responseVector,
+ BOOL isDeleteFiles) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SI_32 l_ret = 0;
+ BOOL l_isFaile = FALSE;
+ for (UI_32 i = 0; i < f_responseVector.size(); i++) {
+ if (f_responseVector[i].Filepath != "") {
+ if (CFSDirectory::IsDirectory(f_responseVector[i].Filepath)) {
+ DIR * l_pDir = opendir(f_responseVector[i].Filepath.c_str());
+ if (l_pDir == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s",
+ f_responseVector[i].Filepath.c_str());
+ } else {
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_fileSource = f_responseVector[i].Filepath;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ EFrameworkunifiedStatus loggerserviceRet = eFrameworkunifiedStatusOK;
+ if (isDeleteFiles == TRUE) {
+ loggerserviceRet = CLoggerUtil::MoveUntyped(l_fileSource,
+ l_fileDestination);
+ } else {
+ loggerserviceRet = CLoggerUtil::CopyUntyped(l_fileSource,
+ l_fileDestination);
+ }
+
+ if (eFrameworkunifiedStatusOK == loggerserviceRet) {
+ l_ret++;
+ if ((l_ret % m_loggerStorageInfo.TimeoutAfter) == 0) {
+ usleep(m_loggerStorageInfo.Timeout);
+ }
+ } else {
+ l_isFaile = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not move: %s",
+ l_fileSource.c_str());
+ }
+ }
+ }
+ (void) closedir(l_pDir);
+ }
+ } else {
+ std::string l_filename = f_responseVector[i].Filepath.substr(
+ f_responseVector[i].Filepath.find_last_of('/'));
+ std::string l_destination = std::string(f_destination).append(
+ l_filename);
+ if (eFrameworkunifiedStatusOK
+ == CLoggerUtil::MoveUntyped(f_responseVector[i].Filepath,
+ l_destination)) {
+ l_ret++;
+ if ((l_ret % m_loggerStorageInfo.TimeoutAfter) == 0) {
+ usleep(m_loggerStorageInfo.Timeout);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not move: %s",
+ f_responseVector[i].Filepath.c_str());
+ l_isFaile = TRUE;
+ }
+ }
+ }
+ }
+ if (l_isFaile)
+ l_ret = -1;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerErrorEventStorage::RemoveDeprecatedArtifacts(
+ TArtifactResponseVec &f_responseVector) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_success = TRUE;
+ for (UI_32 i = 0; i < f_responseVector.size(); i++) {
+ if ((f_responseVector[i].Filepath != "")
+ && (TRUE == f_responseVector[i].Remove)) {
+ if (CFSDirectory::IsDirectory(f_responseVector[i].Filepath)) {
+ if (TRUE
+ != CFSDirectory::RemoveDirectory(f_responseVector[i].Filepath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. Directory %s failed to be deleted.",
+ f_responseVector[i].Filepath.c_str());
+ l_success &= FALSE;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Directory %s has been successfully deleted.",
+ f_responseVector[i].Filepath.c_str());
+ }
+
+ } else {
+ errno = 0;
+ if (0 != remove(f_responseVector[i].Filepath.c_str())) { // LCOV_EXCL_BR_LINE 5: c code error case
+ // LCOV_EXCL_START 5: c code error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno == ENOENT) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. %s not available. Skipping file deletion.",
+ f_responseVector[i].Filepath.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. File %s failed to be deleted.",
+ f_responseVector[i].Filepath.c_str());
+ l_success &= FALSE;
+ }
+ errno = 0;
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. File %s has been successfully deleted.",
+ f_responseVector[i].Filepath.c_str());
+ }
+ }
+ }
+ }
+ l_eStatus = (l_success == TRUE) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/systemservice/logger_service/server/src/ss_logger_fs_directory.cpp b/systemservice/logger_service/server/src/ss_logger_fs_directory.cpp
new file mode 100755
index 0000000..4cb3996
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_fs_directory.cpp
@@ -0,0 +1,236 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file contains declaration of class CFSDirectory.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_fs_directory.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_types.h"
+#include "ss_logger_util.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFSDirectory
+/// Constructor of CFSDirectory class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFSDirectory::CFSDirectory() { // LCOV_EXCL_START 14:static instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFSDirectory
+/// Destructor of CFSDirectory class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFSDirectory::~CFSDirectory() { // LCOV_EXCL_START 14:static instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDirectory
+/// Method to create a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFSDirectory::CreateDirectory(std::string &f_cDirPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (!f_cDirPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cDirPath is aways not empty
+ PSTR l_cTempDirPath;
+ PSTR l_cParsedDirPath;
+ PCSTR l_cCopypath = f_cDirPath.c_str();
+
+ l_cTempDirPath = const_cast<PSTR>(f_cDirPath.c_str());
+ while (l_eStatus == eFrameworkunifiedStatusOK
+ && (l_cParsedDirPath = std::strchr(l_cTempDirPath, '/')) != 0) {
+ if (l_cParsedDirPath != l_cTempDirPath) {
+ /* Neither root nor double slash in path */
+ *l_cParsedDirPath = '\0';
+ if (0
+ != mkdir(l_cCopypath,
+ S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (EEXIST != errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Cannot Create directory %s",
+ l_cCopypath);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // file already exist
+ }
+ }
+ *l_cParsedDirPath = '/';
+ }
+ l_cTempDirPath = l_cParsedDirPath + 1;
+ }
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (0
+ != mkdir(l_cCopypath,
+ S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (EEXIST != errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Cannot Create directory %s",
+ l_cCopypath);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // file already exist
+ }
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cDirPath is aways not empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "String Empty.");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// DoesDirectoryExist
+/// Method to check if a directory exists.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::DoesDirectoryExist(std::string &f_cDirPath) {
+ DIR* l_pDirDescriptor = opendir(f_cDirPath.c_str());
+ if (NULL != l_pDirDescriptor) {
+ closedir(l_pDirDescriptor);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsDirectory
+/// Method to check if the entity is a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::IsDirectory(std::string &f_cPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = FALSE;
+
+ if (!f_cPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cPath can not be empty
+ struct stat st_buf;
+ if (-1 == stat(f_cPath.c_str(), &st_buf)) { // LCOV_EXCL_BR_LINE 5: c code.
+ // LCOV_EXCL_START 5: c code.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: stat failed for path/file %s, errno %d", f_cPath.c_str(),
+ errno);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ l_bReturn = FALSE;
+ return l_bReturn;
+ // LCOV_EXCL_STOP
+ }
+
+ // Get the status of the file
+ if (S_ISREG(st_buf.st_mode)) {
+ l_bReturn = FALSE; // return false if f_cPath is a regular file
+ }
+ if (S_ISDIR(st_buf.st_mode)) {
+ l_bReturn = TRUE; // return true if f_cPath is a directory
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cPath can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Pathname empty.");
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveDirectory
+/// Method to remove a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::RemoveDirectory(std::string &f_cPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = FALSE;
+
+ if (RemoveSubDirectory(f_cPath)) {
+ // delete the parent directory
+ if (0 == rmdir(f_cPath.c_str())) { // LCOV_EXCL_BR_LINE 5: c code error case
+ l_bReturn = TRUE;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveSubDirectory
+/// Method to remove a sub directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::RemoveSubDirectory(std::string &f_cPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = TRUE;
+
+ if (!f_cPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cPath can not be empty
+ std::string l_cFilePath = "";
+
+ struct dirent l_Dirent;
+ struct dirent* next;
+ DIR *l_pDir = NULL;
+
+ l_pDir = opendir(f_cPath.c_str());
+ if (NULL != l_pDir) { // LCOV_EXCL_BR_LINE 5: c code.
+ if ('/' != f_cPath[f_cPath.length() - 1]) {
+ f_cPath.append("/");
+ }
+
+ while (0 == readdir_r(l_pDir, &l_Dirent, &next) && next != NULL) {
+ if (0 != std::strcmp(l_Dirent.d_name, ".")
+ && 0 != std::strcmp(l_Dirent.d_name, "..")
+ && 0 != std::strcmp(l_Dirent.d_name, "lost+found")) {
+ l_cFilePath.assign(f_cPath);
+ l_cFilePath.append(l_Dirent.d_name); // concatenate the strings to get the complete f_cPath
+
+ if (TRUE == IsDirectory(l_cFilePath)) {
+ l_bReturn = RemoveDirectory(l_cFilePath);
+ } else {
+ // it's a file, we can use unlink
+ if (unlink(l_cFilePath.c_str()) == -1) {
+ l_bReturn = FALSE;
+ }
+ }
+ }
+ }
+ closedir(l_pDir); // close the directory
+ CLoggerUtil::SyncDir(f_cPath);
+ } else {
+ // LCOV_EXCL_START 5: c code.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pDir is NULL");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cPath can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Pathname empty.");
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
diff --git a/systemservice/logger_service/server/src/ss_logger_popups.cpp b/systemservice/logger_service/server/src/ss_logger_popups.cpp
new file mode 100755
index 0000000..92a5737
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_popups.cpp
@@ -0,0 +1,176 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_popups.h"
+#include <string>
+#include <vector>
+CLoggerPopups::CLoggerPopups()
+ : m_pLoggerCfg(NULL),
+ m_startShown(FALSE) {
+}
+
+CLoggerPopups::~CLoggerPopups() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerPopups::Initialize(CLoggerCfg* f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ l_eStatus = (m_pLoggerCfg == NULL) ? eFrameworkunifiedStatusNullPointer : eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+BOOL CLoggerPopups::IsPopupNeeded(TLoggerErrorEvent f_event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret = ((f_event.EventBitMask & EVENT_BIT_POPUP) != 0) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+BOOL CLoggerPopups::CanShowStartPopup(
+ std::vector<TLoggingArtifact>* f_remainingArtifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret = FALSE;
+ if (f_remainingArtifact != NULL) {
+ l_ret = TRUE;
+ std::vector<TLoggingArtifact>::iterator l_iter;
+ for (l_iter = f_remainingArtifact->begin();
+ f_remainingArtifact->end() != l_iter; l_iter++) {
+ if (l_iter->ArtifactId == eArtifactIdScreenShot) {
+ l_ret = FALSE;
+ break;
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+std::string CLoggerPopups::getDeviceName(std::string f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ if (f_dest.length() == 0) {
+ } else if (f_dest.find(this->m_pLoggerCfg->m_usb0MountPath) != std::string::npos) {
+ l_ret = "USB 1";
+ } else if (f_dest.find(this->m_pLoggerCfg->m_usb1MountPath) != std::string::npos) {
+ l_ret = "USB 2";
+ } else if (f_dest.find(this->m_pLoggerCfg->m_sdMountPath) != std::string::npos) {
+ l_ret = "SD card";
+ } else if (f_dest.find(this->m_pLoggerCfg->m_emmcOutputPath)
+ != std::string::npos) {
+ l_ret = "Emmc";
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. No matching Path found for %s",
+ f_dest.c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %s", l_ret.c_str());
+ return (l_ret);
+}
+
+EFrameworkunifiedStatus CLoggerPopups::ShowStartPopup(
+ HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::vector<TLoggingArtifact>* f_remainingArtifact, std::string f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (this->m_startShown != FALSE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Pop up already shown");
+ } else if (TRUE != IsPopupNeeded(f_event)) {
+ this->m_startShown = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Start pop up not needed for event %d.",
+ f_event.EventType);
+ } else if (TRUE != CanShowStartPopup(f_remainingArtifact)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Screenshot still in artifact vector.");
+ } else {
+ this->m_startShown = TRUE;
+ STLoggerFolderInfo l_folderInfo;
+ l_folderInfo.FoldernameAndLogname[0] = '\0';
+ std::string l_dest = this->getDeviceName(f_dest);
+ std::size_t l_len = l_dest.copy(l_folderInfo.StorageTarget,
+ sizeof(l_folderInfo.StorageTarget) - 1u, 0);
+ l_folderInfo.StorageTarget[l_len] = '\0';
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Show start pop up. Destination: %s",
+ l_folderInfo.StorageTarget);
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_LOGSTARTED_EVT,
+ NULL,
+ &l_folderInfo, sizeof(l_folderInfo));
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedPublishEvent(SS_LOGGER_LOGSTARTED_EVT)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerPopups::ShowEndPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::string f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ this->m_startShown = FALSE;
+ if (TRUE != IsPopupNeeded(f_event)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. No pop up needed at end of Logging.");
+ } else {
+ STLoggerFolderInfo l_folderInfo;
+ std::size_t l_len = f_dest.copy(
+ l_folderInfo.FoldernameAndLogname,
+ sizeof(l_folderInfo.FoldernameAndLogname) - 1u,
+ f_dest.find_last_of('/') + 1);
+ l_folderInfo.FoldernameAndLogname[l_len] = '\0';
+
+ std::string l_dest = this->getDeviceName(f_dest);
+ l_len = l_dest.copy(l_folderInfo.StorageTarget,
+ sizeof(l_folderInfo.StorageTarget) - 1, 0);
+ l_folderInfo.StorageTarget[l_len] = '\0';
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Show end pop up. Filepath: %s, Device: %s",
+ l_folderInfo.FoldernameAndLogname, l_folderInfo.StorageTarget);
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_LOGINFO_EVT,
+ NULL,
+ &l_folderInfo, sizeof(l_folderInfo));
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_LOGGER_LOGINFO_EVT)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerPopups::ShowErrorPopup(HANDLE f_hApp,
+ TLoggerErrorEvent f_event,
+ UI_16 f_errCode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_16 l_errorcode = (UI_16) f_errCode;
+ this->m_startShown = FALSE;
+ if (IsPopupNeeded(f_event) == TRUE) {
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_ERRORINFO_EVT,
+ NULL,
+ &l_errorcode, sizeof(l_errorcode));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_LOGGER_ERRORINFO_EVT)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
diff --git a/systemservice/logger_service/server/src/ss_logger_reader_writer_control.cpp b/systemservice/logger_service/server/src/ss_logger_reader_writer_control.cpp
new file mode 100755
index 0000000..692cab8
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_reader_writer_control.cpp
@@ -0,0 +1,151 @@
+/*
+ * @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.
+ */
+
+/*
+ * ss_logger_reader_writer_control.cpp
+ */
+#include "ss_logger_reader_writer_control.h"
+#include <boost/bind.hpp>
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_transmit_log.h>
+#include <native_service/ns_logger_if.h>
+#include <string>
+#include "ss_logger_common.h"
+
+#define LOGGERSERVICELOG_REMOTE_IP_PORT 3500
+#define TRANSMIT_REMOTE_IP_PORT 3500
+
+CReaderWriterControl::CReaderWriterControl()
+ : m_pLoggerCfg(NULL) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+}
+
+CReaderWriterControl::~CReaderWriterControl() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CReaderWriterControl::Initialize(CLoggerCfg * f_pLoggerCfg) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (NULL != f_pLoggerCfg) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ this->m_pLoggerCfg = f_pLoggerCfg;
+
+ l_eStatus = m_debugReaderWriter.Initialize( // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ f_pLoggerCfg, ReaderWriter::eReaderWriterTypeMem, std::string(FRAMEWORKUNIFIEDLOG_SHAREDMEM_NAME),
+ FRAMEWORKUNIFIEDLOG_SHAREDMEM_SIZE, ReaderWriter::eReaderWriterTypeUdp,
+ std::string("169.254.80.9"), LOGGERSERVICELOG_REMOTE_IP_PORT, "", 0); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ l_eStatus = m_debugReaderWriter.Start(std::string("pdg.LogQueR"));
+ }
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus, "m_debugReaderWriter.Start(std::string(pdg.TransQueR)");
+
+
+ l_eStatus = m_transmitReaderWriter.Initialize( // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ f_pLoggerCfg, ReaderWriter::eReaderWriterTypeMem,
+ std::string(TRANSMIT_LOG_SHAREDMEM_NAME), TRANSMIT_LOG_SHAREDMEM_SIZE,
+ ReaderWriter::eReaderWriterTypeUdp, std::string("169.254.80.9"),
+ TRANSMIT_REMOTE_IP_PORT, "", 0); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 6:it can not be fail
+ l_eStatus = m_transmitReaderWriter.Start(std::string("pdg.TransQueR")); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus, "m_transmitReaderWriter.Start(std::string(pdg.TransQueR)");
+
+
+ l_eStatus = m_performanceReaderWriter.Initialize( // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ f_pLoggerCfg, ReaderWriter::eReaderWriterTypeQueue, std::string("/NSplog"), 0,
+ ReaderWriter::eReaderWriterTypeFile, std::string(PERFORMANCE_LOG_PATH_FN),
+ f_pLoggerCfg->m_performanceLogMaxFileSize, std::string("169.254.80.9"),
+ 0); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 6:it can not be fail
+ l_eStatus = m_performanceReaderWriter.Start(
+ std::string("pdg.PerformQueR")); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus,
+ "m_performanceReaderWriter.Start(std::string(pdg.PerformQueR)");
+
+
+ this->m_pLoggerCfg->AddLoggingParamCB(
+ boost::bind(&CReaderWriterControl::UpdateLoggingParams, this, _1));
+ }
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriterControl::UpdateLoggingParams(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = this->m_debugReaderWriter.UpdateLoggingParameters();
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15:macro
+ "this->m_debugReaderWriter.UpdateLoggingParameters()");
+
+ l_eStatus = this->m_transmitReaderWriter.UpdateLoggingParameters();
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus, "this->m_transmitReaderWriter.UpdateLoggingParameters()");
+
+ l_eStatus = this->m_performanceReaderWriter.UpdateLoggingParameters();
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus,
+ "this->m_performanceReaderWriter."
+ "UpdateLoggingParameters()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriterControl::FlushCache(EReaderWriterType f_type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ switch (f_type) { // LCOV_EXCL_BR_LINE 8: eReaderWriterLogDebug and eReaderWriterLogInvalid can not be called
+ // LCOV_EXCL_START 8: dead code
+ case eReaderWriterLogDebug:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = this->m_debugReaderWriter.FlushCache(
+ std::string(DEBUG_LOG_PATH_FN));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "this->m_debugReaderWriter.FlushCache(DEBUG_LOG_PATH_FN)");
+ break;
+ // LCOV_EXCL_STOP
+ case eReaderWriterLogTransmit:
+ l_eStatus = this->m_transmitReaderWriter.FlushCache(
+ std::string(TRANSMIT_LOG_PATH_FN));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->m_debugReaderWriter.FlushCache(TRANSMIT_LOG_PATH_FN)");
+ break;
+
+ case eReaderWriterLogPerformance:
+ l_eStatus = this->m_performanceReaderWriter.FlushCache(
+ std::string(PERFORMANCE_LOG_PATH_FN));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->m_debugReaderWriter.FlushCache(PERFORMANCE_LOG_PATH_FN)");
+ break;
+ // LCOV_EXCL_START 8: dead code
+ case eReaderWriterLogInvalid:
+ default:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ break;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
diff --git a/systemservice/logger_service/server/src/ss_logger_server_callbacks.cpp b/systemservice/logger_service/server/src/ss_logger_server_callbacks.cpp
new file mode 100755
index 0000000..82a677b
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_server_callbacks.cpp
@@ -0,0 +1,900 @@
+/*
+ * @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_SS_LoggerService
+/// \brief This file contains the callback for Notifications and Protocol
+/// commands.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_service_callbacks.h"
+#include <string.h>
+#include <boost/bind.hpp>
+#include <errno.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_logger_service.h>
+#include <ss_logger_common.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/nslogutil_cmd_if.h>
+#include <system_service/ss_sm_client_if.h>
+#include <queue>
+#include <new>
+#include <string>
+#include "ss_logger_error_event.h"
+#include "loggerservicedebug_loggerservicelog.h"
+#include "loggerservicedebug_thread_if.h"
+extern CErrorEvent g_errorEventHandler;
+extern HANDLE g_thrdEvntLogWriter;
+
+// Global variables
+STCanCurrentDateTime g_stDateAndTime = { 0 };
+UEvtLoggerCommonInfo g_uEvtLoggerCommonInfo;
+UI_16 g_u16DiagId = 0;
+
+CLoggerServiceCallbacks::CLoggerServiceCallbacks()
+ : m_pLoggerCfg(NULL),
+ m_pErrorEvent(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FrameworkunifiedProtocolCallbackHandler l_protocolHandlers[kNUMBER_PROTOCOL_HANDLERS] =
+ { { SS_LOGGER_MILEAGE_DATA, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_SetMileageData, this, _1) },
+ { SS_LOGGER_SET_PARAMS, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_SetLoggerParams, this, _1) },
+ { SS_LOGGER_UDP_LOGGING, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_UDPLogging, this, _1) },
+ { SS_LOGGERCOPYEVENTUSB, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnCopyEvntLog, this,_1) },
+ { SS_LOGGERCLEAREVENT, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnClearEvntLog, this, _1) },
+ { SS_LOGGER_READ_STATL_COUNTER, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnReadStatCounter, this, _1) },
+ { SS_LOGGER_EVENT_COMMONINFO, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_UpdateCommonInfo, this, _1) },
+ { SS_LOGGER__CWORD56__EVENT_INFO, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_Handle_CWORD56_Events, this, _1) },
+ { SS_LOGGER_RESET_STATL_COUNTER, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnResetStatCounter, this, _1) },
+ { SS_LOGGER_SET_VIN, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnSetVIN, this, _1) },
+ { SS_LOGGERCOPYEMERGENCYLOGS, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnCopyEmergencyLog, this, _1) },
+ { eSSLoggerCANProtocolIDCANTrigger, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnCANTrigger, this, _1) },
+ { eSSLoggerCANProtocolIDDTCTrigger, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnDTCTrigger, this, _1) },
+ { SS_LOGGER_SHUTDOWN_COMPLETE, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_On_SHTDWN_Complete, this, _1) },
+ { SS_LOGGER_ENG_READ_NUMOFEVENTS, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnReadNumberOfEvents, this, _1) },
+ { SS_LOGGER_SET_DIAGID, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnSetDiagID, this, _1) },
+ { SS_LOGGER_UPLOAD_EVENTLOG, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_UploadEventLog, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ for (UI_8 i = 0u; i < kNUMBER_PROTOCOL_HANDLERS; i++) {
+ m_protocolHandlers[i].iCmd = l_protocolHandlers[i].iCmd;
+ m_protocolHandlers[i].callBack = l_protocolHandlers[i].callBack; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CLoggerServiceCallbacks::~CLoggerServiceCallbacks() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::Initialize(HANDLE f_hApp,
+ CLoggerCfg *f_pLoggerCfg,
+ CErrorEvent* f_pErrorEvent) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ m_pLoggerCfg = f_pLoggerCfg;
+ m_pErrorEvent = f_pErrorEvent;
+
+ if ((NULL == m_pLoggerCfg) || (NULL == m_pErrorEvent)) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "NULL pointer passed to Initialize function!!!!!");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ // Attach callback : Open Session Request
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(f_hApp, FRAMEWORKUNIFIED_ANY_SOURCE, PROTOCOL_OPEN_SESSION_REQ, boost::bind(&CLoggerServiceCallbacks::LoggerServerOnOpenSession, this, _1)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher PROTOCOL_OPEN_SESSION_REQ (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if ( eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(f_hApp, NTFY_SS_LoggerService_Availability))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+//////////////////////////////////////////
+// Function : DevDetectionServerOnOpenSession
+// Callback for PROTOCOL_OPEN_SESSION_REQ
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServerOnOpenSession(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hClientService = NULL;
+ HANDLE l_hSession = NULL;
+
+ // Get the requester name
+ PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
+ OpenSessionAck tOpenAck;
+
+ if (pRequester) { // LCOV_EXCL_BR_LINE 4:NSFW
+ l_hClientService = FrameworkunifiedMcOpenSender(hApp, pRequester);
+
+ if (l_hClientService) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // Create a session
+ l_hSession = FrameworkunifiedCreateSession(hApp, pRequester);
+ UI_32 l_nSessionId = 0;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher( hApp, pRequester, m_protocolHandlers, kNUMBER_PROTOCOL_HANDLERS, l_hSession))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __PRETTY_FUNCTION__,
+ "FrameworkunifiedAttachCallbacksToDispatcher ss_logger_server_protocol_handlers Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = this->m_pErrorEvent->OnOpenSession(hApp, pRequester,
+ l_hSession);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_pErrorEvent->OnOpenSession(%s, %p) returned: %d.",
+ pRequester, l_hSession, l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ // Attach callback : close Session Request
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, pRequester, PROTOCOL_CLOSE_SESSION_REQ, boost::bind(&CLoggerServiceCallbacks::LoggerServerOnCloseSession, this, _1)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher " "PROTOCOL_CLOSE_SESSION_REQ (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_nSessionId = FrameworkunifiedGetSessionId(l_hSession);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Session id is %d", l_nSessionId); // LCOV_EXCL_BR_LINE 15:macro
+ // sending the session open
+ tOpenAck.eStatus = eFrameworkunifiedStatusOK;
+ tOpenAck.sessionId = l_nSessionId;
+ tOpenAck.sessionType = 1;
+
+ // Copy session name to data structure
+ strncpy(tOpenAck.cSessionName, FrameworkunifiedGetAppName(hApp),
+ MAX_QUEUE_NAME_SIZE - 1);
+ tOpenAck.cSessionName[MAX_QUEUE_NAME_SIZE - 1] = '\0';
+
+ // send OpenSession ACK
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(l_hClientService, PROTOCOL_OPEN_SESSION_ACK, sizeof(OpenSessionAck), (PVOID) &tOpenAck))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "FrameworkunifiedSendMsg PROTOCOL_OPEN_SESSION_ACK Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = FrameworkunifiedSetSessionHandle(hApp, FrameworkunifiedGetMsgSrc(hApp), l_hSession);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSessionHandle()"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+ }
+ l_eStatus = FrameworkunifiedMcClose(l_hClientService);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedMcClose()"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+// Function : DevDetectionServerOnCloseSession
+// Callback for PROTOCOL_CLOSE_SESSION_REQ
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServerOnCloseSession(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ HANDLE hSession = NULL;
+ HANDLE l_hClientService = NULL;
+ // Get the requester name
+ PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
+ CloseSessionAck tCloseAck;
+ CloseSessionReq tClose;
+
+ if (pRequester) { // LCOV_EXCL_BR_LINE 4:NSFW
+ l_hClientService = FrameworkunifiedMcOpenSender(hApp, pRequester);
+ if (l_hClientService) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // Read the data from the message
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tClose, sizeof(tClose), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(l_hClientService))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedMcClose failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+ // LCOV_EXCL_STOP
+ }
+
+ hSession = FrameworkunifiedGetSessionHandle(hApp, pRequester, tClose.sessionId);
+
+ // Create a list of commands to be detached from the dispatcher
+ UI_32 cmd_array[kNUMBER_PROTOCOL_HANDLERS] = { 0 };
+ for (UI_32 i = 0; i < kNUMBER_PROTOCOL_HANDLERS; i++) {
+ cmd_array[i] = m_protocolHandlers[i].iCmd;
+ }
+
+ if (NULL != hSession) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // Detach callbacks associated with client
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp, pRequester, cmd_array, kNUMBER_PROTOCOL_HANDLERS, hSession))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __PRETTY_FUNCTION__,
+ "FrameworkunifiedAttachCallbacksToDispatcher ss_logger_server_protocol_handlers Failed Status:0x%x ",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ eStatus = m_pErrorEvent->OnCloseSession(hApp, pRequester, hSession);
+ if (eFrameworkunifiedStatusOK != eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_pErrorEvent->OnCloseSession(%s, %p) returned: %d.",
+ pRequester, hSession, eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ // API to destroy the session handle and remove it from the Application Framework.
+ // LCOV_EXCL_BR_START 4:NSFW
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDestroySession(hApp, // Application Handle
+ hSession))) { // Session Handle
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session destroy failed");
+ // LCOV_EXCL_STOP
+ }
+ }
+ // sending the session close ack
+ tCloseAck.eStatus = eFrameworkunifiedStatusOK;
+ tCloseAck.sessionId = tClose.sessionId;
+
+ // send CloseSession ACK
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(l_hClientService, PROTOCOL_CLOSE_SESSION_ACK, sizeof(CloseSessionAck), (PVOID) &tCloseAck))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "FrameworkunifiedSendMsg PROTOCOL_CLOSE_SESSION_ACK Failed Status:0x%x ",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(l_hClientService))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedMcClose failed"); // LCOV_EXCL_LINE 15:macro
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : LoggerServer_SetMileageData
+// Callback for SS_LOGGER_MILEAGE_DATA
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_SetMileageData(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ STLOGGER_CANDIAGSTAT MileageInfo_t;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ memset(&MileageInfo_t, 0x00, sizeof(STLOGGER_CANDIAGSTAT));
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &MileageInfo_t, sizeof(MileageInfo_t), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ UI_32 l_mileage = (MileageInfo_t.Odo_MSB_H << 24
+ | MileageInfo_t.Odo_MSB_L << 16 | MileageInfo_t.Odo_LSB_H << 8
+ | MileageInfo_t.Odo_LSB_L);
+ // if value set to SNA
+ if (0xFFFFFFFF != l_mileage) {
+ this->m_pErrorEvent->SetMileage(l_mileage);
+ // Immediate Persist Event Log
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdMileageData, sizeof(UI_32), &l_mileage))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%d", l_eStatus); // LCOV_EXCL_LINE 15:macro
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+// Function : LoggerServer_SetLoggerParams
+// Callback for SS_LOGGER_SET_PARAMS
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_SetLoggerParams(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ STLoggerSetParams l_stLoggerSetParams = { eInvalid_LoggerState, eDevUSB1 };
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stLoggerSetParams, sizeof(l_stLoggerSetParams), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+ // LCOV_EXCL_STOP
+ } else {
+ eStatus = m_pLoggerCfg->SetLoggingParams(hApp, l_stLoggerSetParams);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : LoggerServer_SetLoggerParams
+// Callback for SS_LOGGER_SET_PARAMS
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UDPLogging(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ELOGGER_STAT l_eUDPLoggingStatus = eInvalid_LoggerState;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_eUDPLoggingStatus, sizeof(l_eUDPLoggingStatus), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = m_pLoggerCfg->SetUDPLogging(hApp, l_eUDPLoggingStatus);
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus,
+ "m_pLoggerCfg->SetUDPLogging()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UpdateCommonInfo(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &g_uEvtLoggerCommonInfo.u_stEvtLoggerCommonInfo, sizeof(g_uEvtLoggerCommonInfo.u_stEvtLoggerCommonInfo), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_Handle_CWORD56_Events(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ STEventLoggerEventInfo l_stEventLoggingEventInfo;
+ UI_16 l_evtid = 0;
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stEventLoggingEventInfo, sizeof(l_stEventLoggingEventInfo), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ l_evtid = static_cast<UI_16>(((l_stEventLoggingEventInfo.EventGroup & 0x00FF) << 8)
+ | (l_stEventLoggingEventInfo.EventIdentifier & 0x00FF));
+ FRAMEWORKUNIFIEDLOG_EVT(ZONE_INFO, l_evtid, 4, l_stEventLoggingEventInfo.EventData[3],
+ l_stEventLoggingEventInfo.EventData[2],
+ l_stEventLoggingEventInfo.EventData[1],
+ l_stEventLoggingEventInfo.EventData[0]);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCopyEmergencyLog(
+ HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EDevNumber l_eDevNumber;
+ std::string l_path = "";
+ std::string l_srcName = "";
+
+ if (NULL != f_hApp) { // LCOV_EXCL_BR_LINE 6: it can't be null.
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(f_hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can't be null.
+ l_srcName = l_tmp_srcname;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_eDevNumber,
+ sizeof(l_eDevNumber), eSMRRelease))) {
+ switch (l_eDevNumber) {
+ case eEEL_USB1:
+ l_path = m_pLoggerCfg->m_usb0MountPath;
+ break;
+
+ case eEEL_USB2:
+ l_path = m_pLoggerCfg->m_usb1MountPath;
+ break;
+
+ case eEEL_SD:
+ l_path = m_pLoggerCfg->m_sdMountPath;
+ break;
+
+ default:
+ /*send back error response wrong param*/
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get msg Data.");
+ }
+
+ HANDLE l_hSession = NULL;
+ if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(f_hApp))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ m_pErrorEvent->SetDiagSessionHandle(l_hSession);
+ }
+ if (0 == l_srcName.length()) { // LCOV_EXCL_BR_LINE 6: it can't be 0.
+ // LCOV_EXCL_START 6: it can't be 0.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Could not get name of source service.");
+ // LCOV_EXCL_STOP
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ } else if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Invalid parameter l_eDevNumber(%d).", l_eDevNumber);
+ l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO,
+ l_srcName);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse(l_srcName)");
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = m_pErrorEvent->SetDiagEventSourceName(l_srcName))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_pErrorEvent->SetDiagEventSourceName() returned %d.", l_eStatus);
+ l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO,
+ l_srcName);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse(l_srcName)");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus =
+ SendDiagLoggingRequestToSystemManager(l_path))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ /* call System Manager interface*/
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. SendDiagLoggingRequestToSystemManager() returned %d.", l_eStatus);
+ l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse()");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Log Request passed to SystemManager.");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCANTrigger(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = SendCANLoggingRequestToSystemManager();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendCANLoggingRequestToSystemManager()"); // LCOV_EXCL_BR_LINE 15:macro
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnDTCTrigger(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_dtc;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_dtc, sizeof(l_dtc), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get msg Data.");
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = SendDTCLoggingRequestToSystemManager(l_dtc);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendDTCLoggingRequestToSystemManager(dtc)"); // LCOV_EXCL_BR_LINE 15:macro
+ // Immediate Persist Event Log
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(f_hApp, g_thrdEvntLogWriter, eThrdCmdImmPersistEvtLog, 0x00, NULL))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%X", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_On_SHTDWN_Complete(
+ HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = LoggerService_OnStop(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "LoggerService_OnStop()"); // LCOV_EXCL_BR_LINE 15:macro
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnSetVIN
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnSetVIN(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STVIN_NUMBER l_stVIN_Number;
+
+ if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stVIN_Number, sizeof(l_stVIN_Number), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdSetVINnumber, sizeof(STVIN_NUMBER), &l_stVIN_Number))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%X", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize failed errval: %X",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnCopyEvntLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCopyEvntLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TWriteFilesToUsbCmdData l_stCmdData;
+ HANDLE l_hSession = NULL;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_stCmdData.stSessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EEvtLogUSBDevNumber>(hApp, l_stCmdData.eDevId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdWriteEvntFilesToUsb,
+ sizeof(TWriteFilesToUsbCmdData),
+ &l_stCmdData))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid App handler"); // LCOV_EXCL_LINE 6: it can not be null
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnClearEvntLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnClearEvntLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ TSessionData l_sessiondata;
+ HANDLE l_hSession = NULL;
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 4:NSFW
+ l_sessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_sessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 4:As it is guaranteed by NSFW and is not always an empty string
+ // LCOV_EXCL_START 4:As it is guaranteed by NSFW and is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdClearEvntLogs, sizeof(TSessionData), &l_sessiondata))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()");
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnReadStatCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnReadStatCounter(
+ HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ TStatisticalCountersCmd l_stCmdData;
+ HANDLE l_hSession = NULL;
+
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_stCmdData.stSessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EStatCounterGroupID>(hApp,
+ l_stCmdData.eGroupId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdStatisticalCounter,
+ sizeof(TStatisticalCountersCmd),
+ &l_stCmdData))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()");// LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnResetStatCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnResetStatCounter(
+ HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ TStatisticalCountersCmd l_stCmdData;
+ HANDLE l_hSession = NULL;
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_stCmdData.stSessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EStatCounterGroupID>(hApp,
+ l_stCmdData.eGroupId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdResetStatisticalCntrs,
+ sizeof(TStatisticalCountersCmd),
+ &l_stCmdData))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnReadNumberOfEvents
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnReadNumberOfEvents(
+ HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSessionData l_sessiondata;
+ HANDLE l_hSession = NULL;
+
+ l_sessiondata.strSrcName = FrameworkunifiedGetMsgSrc(hApp);
+ if (l_sessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdGetNumberOfEventsLogged,
+ sizeof(TSessionData), &l_sessiondata))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnSetDiagID
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnSetDiagID(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_16 l_DiagId = 0;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<UI_16>(hApp, l_DiagId))) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP
+ } else {
+ g_u16DiagId = l_DiagId;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_UploadEventLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UploadEventLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSessionData l_sessiondata;
+ HANDLE l_hSession = NULL;
+
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_sessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_sessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdUploadEventLog,
+ sizeof(TSessionData), &l_sessiondata))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
diff --git a/systemservice/logger_service/server/src/ss_logger_util.cpp b/systemservice/logger_service/server/src/ss_logger_util.cpp
new file mode 100755
index 0000000..6ac7225
--- /dev/null
+++ b/systemservice/logger_service/server/src/ss_logger_util.cpp
@@ -0,0 +1,1273 @@
+/*
+ * @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_SS_LoggerService
+/// \brief Provide support for SS Logger module utility functions.
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_util.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stub/Clock_API.h>
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <algorithm>
+#include <vector>
+#include "ss_logger_common.h"
+
+#include <system_service/ss_logger_store_logs.h>
+
+#define SS_STORE_FILENAME_SYSILG_TERM "_SYS_ILG_RESET.tar.gz"
+#define SS_STORE_FILENAME__CWORD52__TERM "__CWORD52_.log"
+
+
+char CLoggerUtil::m_usbpath[USB_PATH_SIZE];
+
+///////////////////////////////////////////////////////////////////////////////
+// CLASS METHODS
+///////////////////////////////////////////////////////////////////////////////
+CLoggerUtil::CLoggerUtil(void)
+ : m_pCfg(NULL),
+ m_Milage(0),
+ m_bootCount(0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_usbpath[0] = '\0';
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CLoggerUtil::~CLoggerUtil(void) { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerUtil::Initialize(CLoggerCfg *f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ m_pCfg = f_pLoggerCfg;
+ l_eStatus = (NULL != f_pLoggerCfg) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusInvldParam;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+std::string CLoggerUtil::getDestination(TLoggerErrorEvent &f_eventNtfData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+: %d ", f_eventNtfData.EventType);
+ std::string l_path = "";
+ EFrameworkunifiedStatus l_eStatus;
+
+ switch (f_eventNtfData.EventType) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ case eErrorEventTypeModuleInvokedResetRequest:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ case eErrorEventTypeDtcEvent:
+ case eErrorEventTypeUserInvokedClearLogs:
+ case eErrorEventTypeGroupRelaunch:
+ l_eStatus = m_pCfg->GetEmmcDestination(l_path);
+ break;
+
+ case eErrorEventTypeUserInvokedCollectNaviLog:
+ l_eStatus = m_pCfg->GetEmmcNaviLogDestination(l_path);
+ break;
+
+ case eErrorEventTypeEelExport:
+ l_path = f_eventNtfData.ModuleName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ case eErrorEventTypeInterfaceunifiedEmmcLogs:
+ l_path = f_eventNtfData.ModuleName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeCanEvent:
+ l_eStatus = m_pCfg->GetUserInvokedDestination(l_path);
+ break;
+
+ case eErrorEventTypeDiagEvent:
+ l_path = f_eventNtfData.ModuleName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ default:
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get filepath ");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %s", l_path.c_str());
+ return (l_path);
+}
+EFrameworkunifiedStatus CLoggerUtil::checkDestinationAvailable(
+ TLoggerErrorEvent &f_eventNtfData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string l_path = CLoggerUtil::getDestination(f_eventNtfData);
+ std::string::size_type ret;
+
+ if (l_path.length() > 0) {
+ ret = l_path.find(DEBUG_USB_PATH);
+ if (ret != std::string::npos && ret == 0) {
+ if (0 == access(m_usbpath, W_OK)) { // LCOV_EXCL_BR_LINE 5:C code
+ // LCOV_EXCL_START 5:C code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::string path = l_path.substr(sizeof(DEBUG_USB_PATH) - 1);
+ f_eventNtfData.ModuleName = m_usbpath;
+ f_eventNtfData.ModuleName.append(path);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ if (0 == access(l_path.c_str(), W_OK)) { // LCOV_EXCL_BR_LINE 5:C code
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed the check path: l_eStatus(%d), l_path(%s)",
+ l_eStatus, l_path.c_str()); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+static void SetSuffixFromType(std::string &pathAndName, EErrorEventType type) { // NOLINT (runtime/references)
+ switch (type) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeModuleInvokedResetRequest:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_ERR");
+ break;
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeDiagEvent:
+ case eErrorEventTypeCanEvent:
+ case eErrorEventTypeDtcEvent:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_DIAG");
+ break;
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_DEBUG");
+ break;
+ case eErrorEventTypeGroupRelaunch:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_GRP_RELAUNCH");
+ break;
+ default:
+ break;
+ }
+}
+
+EFrameworkunifiedStatus CLoggerUtil::getFilePathAndName(HANDLE f_hApp,
+ TLoggerErrorEvent &f_eventNtfData,
+ uint32_t f_time,
+ std::string &f_pathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_pathAndName = "";
+
+ switch (f_eventNtfData.EventType) { // LCOV_EXCL_BR_LINE 200: eErrorEventTypeEelExport ex. can not be run
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeGroupRelaunch:
+ l_eStatus = m_pCfg->GetEmmcDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6:it will aways return ok
+ // LCOV_EXCL_START 6:it will aways return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmcDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetEmmcFilename(f_time));
+ }
+ break;
+
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ l_eStatus = m_pCfg->GetEmmcDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6:it will aways return ok
+ // LCOV_EXCL_START 6:it will aways return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmcDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetEmmcFilename(f_time));
+ }
+ break;
+ case eErrorEventTypeModuleInvokedResetRequest:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ case eErrorEventTypeDtcEvent:
+ l_eStatus = m_pCfg->GetEmmcDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6:it will aways return ok
+ // LCOV_EXCL_START 6:it will aways return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmcDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetEmmcFilename(f_time));
+ if (!f_eventNtfData.ModuleName.empty()) { // LCOV_EXCL_BR_LINE 6: ModuleName can not be empty
+ size_t l_pos = f_pathAndName.find(".tar.gz");
+ if (l_pos != std::string::npos) { // LCOV_EXCL_BR_LINE 6: ".tar.gz" is aways exist
+ f_pathAndName.insert(l_pos, f_eventNtfData.ModuleName);
+ }
+ }
+ }
+ break;
+ case eErrorEventTypeEelExport: // LCOV_EXCL_START 6: impossible to confirm because it can not get in
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_pathAndName = f_eventNtfData.ModuleName;
+ f_pathAndName.append("/");
+ f_pathAndName.append("loggerservicelogs_export_");
+ f_pathAndName.append(GetTimeString(f_time));
+ f_pathAndName.append(".tar.gz");
+ break;
+ // LCOV_EXCL_STOP
+ case eErrorEventTypeInterfaceunifiedEmmcLogs: // LCOV_EXCL_START 6: impossible to confirm because it can not get in
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // store the target location on event trigger
+ f_pathAndName = f_eventNtfData.ModuleName;
+ break;
+ // LCOV_EXCL_STOP
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ l_eStatus = m_pCfg->GetUserInvokedDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: impossible to confirm because it can not be fail
+ // LCOV_EXCL_START 6: impossible to confirm because it can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetUserInvokedDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ std::string l_emmc_path = m_pCfg->getEmmcOutputPath();
+ f_pathAndName.append(l_emmc_path);
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetUserInvokedFilename(f_hApp, f_time));
+ if (!f_eventNtfData.ModuleName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ size_t l_pos = f_pathAndName.find(".tar.gz");
+ if (l_pos != std::string::npos) { // LCOV_EXCL_BR_LINE 6: ".tar.gz" is aways exist
+ f_pathAndName.insert(l_pos, f_eventNtfData.ModuleName);
+ }
+ }
+ }
+ break;
+
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeCanEvent:
+ l_eStatus = m_pCfg->GetUserInvokedDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: impossible to confirm because it can not be fail
+ // LCOV_EXCL_START 6: impossible to confirm because it can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetUserInvokedDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetUserInvokedFilename(f_hApp, f_time));
+ }
+ break;
+
+ case eErrorEventTypeDiagEvent: // LCOV_EXCL_START 6: impossible to confirm because it can not get in
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_pathAndName = f_eventNtfData.ModuleName;
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetUserInvokedFilename(f_hApp, f_time));
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+ // LCOV_EXCL_STOP
+ case eErrorEventTypeUserInvokedClearLogs:
+ case eErrorEventTypeUserInvokedCollectNaviLog:
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Unknown event type: %d.",
+ f_eventNtfData.EventType);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+
+ SetSuffixFromType(f_pathAndName, f_eventNtfData.EventType);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+// LCOV_EXCL_START 13:
+EFrameworkunifiedStatus CLoggerUtil::getNaviLogFilePathAndName(std::string &f_prefix,
+ uint32_t f_time,
+ std::string &f_pathAndName) { // LCOV_EXCL_BR_LINE 13:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = m_pCfg->GetEmmcNaviLogDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmNaviLogDestination() returned %d.",
+ l_eStatus);
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(f_prefix);
+ f_pathAndName.append(GetEmmcNaviLogFilename(f_time));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200:
+EFrameworkunifiedStatus CLoggerUtil::getEmmcNaviLogParams(
+ uint32_t f_time, EPWR_SHUTDOWN_TRIGGER_TYPE errorType,
+ std::string &f_pathName, UI_32 &f_logMax) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR *l_dirp = NULL;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_prefix = "";
+
+ std::vector<std::string> l_vector;
+ std::string l_path = m_pCfg->getEmmcOutputNaviLogPath();
+
+ if ((errorType == epssdmsdtGENERIC_ERROR_RESET)
+ || (errorType == epssdmsdtFATAL_ERROR_RESET)) {
+ /*When reset occured !!*/
+ f_logMax = m_pCfg->m_emmcOutputNaviLogErrMax;
+ l_prefix = "ERR_";
+ } else {
+ /* ACC OFF occured*/
+ f_logMax = m_pCfg->m_emmcOutputNaviLogNmlMax;
+ l_prefix = "NML_";
+ }
+
+ if (f_logMax == 0) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ return l_eStatus;
+ }
+
+ l_dirp = opendir(l_path.c_str());
+ if (l_dirp != NULL) {
+ struct dirent l_dirent;
+ struct dirent* next;
+
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_findFileName = l_dirent.d_name;
+ size_t l_find_pos_top = l_findFileName.find(l_prefix.c_str());
+ size_t l_find_pos = l_findFileName.find(".log");
+ if (std::string::npos != l_find_pos
+ && std::string::npos != l_find_pos_top) {
+ l_vector.push_back(l_findFileName);
+ }
+ }
+ closedir(l_dirp);
+ }
+ std::sort(l_vector.begin(), l_vector.end());
+
+ for (UI_32 i = static_cast<UI_32>(l_vector.size()); i != 0; i--) {
+ std::string l_FilePath = l_path;
+ std::string l_FileName = l_vector.at(i - 1);
+ l_FilePath.append("/");
+ l_FilePath.append(l_FileName.c_str());
+
+ if (i < f_logMax) {
+ size_t l_pos = l_FileName.find("_", l_prefix.size());
+ if (std::string::npos != l_pos) {
+ std::string l_renameFilePath = l_path;
+ std::stringstream l_numStream;
+ l_numStream << std::setw(5) << std::setfill('0') << std::right << std::dec << (i + 1);
+ l_renameFilePath.append("/");
+ l_renameFilePath.append(l_prefix);
+ l_renameFilePath.append(l_numStream.str());
+ l_renameFilePath.append(l_FileName, l_pos, (l_FileName.size() - l_pos));
+ if (0 != rename(l_FilePath.c_str(), l_renameFilePath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. rename navilog file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ } else {
+ if (0 != unlink(l_FilePath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete navilog file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ }
+ // sync parent directory
+ SyncDir(l_path);
+
+ l_eStatus = getNaviLogFilePathAndName(l_prefix, f_time, f_pathName);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200: can not be called
+size_t CLoggerUtil::deleteRequestLogs(std::string f_emmcpath,
+ ELOGGERSERVICELOGTYPE f_reqtype, size_t f_reqsize,
+ ELOGGERSERVICELOGTYPE f_deltype) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR* l_dirp = NULL;
+ std::vector<std::string> vect;
+ std::vector<std::string>::iterator it;
+ UI_32 l_count = 0;
+ size_t l_totalsize = 0;
+
+ // create saved file list on eMMC
+ l_dirp = opendir(f_emmcpath.c_str());
+ if (l_dirp != NULL) {
+ struct dirent l_dirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_filename = l_dirent.d_name;
+ if (CLoggerUtil::QueryLoggerservicelogType(l_filename) == f_deltype) {
+ vect.push_back(l_filename);
+ }
+ }
+ closedir(l_dirp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " open failed eMMC path: %s",
+ f_emmcpath.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return 0;
+ }
+
+ // get num of delete logs
+ std::sort(vect.begin(), vect.end());
+ for (it = vect.begin(); it != vect.end(); it++) {
+ l_count++;
+
+ std::string l_filename = *it;
+ struct stat st_buf;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (stat(l_tmpstr.c_str(), &st_buf) != -1) {
+ l_totalsize += st_buf.st_size;
+ }
+
+ if (l_totalsize > f_reqsize) {
+ break;
+ }
+ }
+
+ // start delete logs
+ if ((l_totalsize > f_reqsize) || (f_reqtype == eLoggerservicelogTypeAbnormal)
+ || (f_reqtype == eLoggerservicelogTypeGrpRelaunch)) {
+ for (it = vect.begin(); it != vect.end() && l_count > 0; it++) {
+ l_count--;
+
+ std::string l_filename = *it;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (unlink(l_tmpstr.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d.",
+ l_tmpstr.c_str(), errno);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " del-file=%s total=%d", l_tmpstr.c_str(),
+ l_totalsize);
+ }
+ SyncDir(f_emmcpath);
+ } else {
+ l_totalsize = 0;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ " nothing to delete logs req-type=%d del-logtype=%d total=%d, log_count=%d",
+ f_reqtype, f_deltype, l_totalsize, l_count);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_totalsize;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200: can not be called
+EFrameworkunifiedStatus CLoggerUtil::forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string l_emmc_path;
+ size_t l_delsize = 0;
+ ELOGGERSERVICELOGTYPE l_logtype = eLoggerservicelogTypeOther;
+
+ size_t l_pos = f_archive_destination.find_last_of('/');
+ if (std::string::npos != l_pos) {
+ l_emmc_path = f_archive_destination.substr(0, l_pos);
+ l_emmc_path.append("/");
+ l_logtype = CLoggerUtil::QueryLoggerservicelogType(
+ f_archive_destination.substr(l_pos + 1,
+ f_archive_destination.size() - l_pos + 1));
+ }
+
+ if (l_logtype == eLoggerservicelogTypeOther) {
+ // not found
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Invalid Parameter. dest=%s",
+ f_archive_destination.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ // remove dirty-file if exist
+ if (unlink(f_archive_destination.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d.",
+ f_archive_destination.c_str(), errno);
+ }
+
+ // delete normal log
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, f_req_size,
+ eLoggerservicelogTypeNormal);
+ if (l_delsize >= f_req_size) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete normal logs success: req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (l_logtype == eLoggerservicelogTypeAbnormal) {
+ // delete abnormal log if request type is abnormal
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete abnormal logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeAbnormal);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete abnormal logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " abnormal log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else if (l_logtype == eLoggerservicelogTypeGrpRelaunch) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete group relaunch logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeGrpRelaunch);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete group relaunch logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " group relaunch log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " normal log del not complete. req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerUtil::deleteOldLog(std::string log_path,
+ std::vector<std::string>& l_vector,
+ std::string& f_archive_destination,
+ UI_32 max_num) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t l_pos = f_archive_destination.find_last_of('/');
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 200: there is always '/' in f_destination
+ std::sort(l_vector.begin(), l_vector.end());
+ std::vector<std::string>::iterator itr = l_vector.begin();
+ for (UI_32 i = static_cast<UI_32>(l_vector.size()); (max_num - 1) < i; i--, itr++) {
+ if (itr == l_vector.end()) { // LCOV_EXCL_BR_LINE 200: (max_num - 1) can not be -1.
+ break;
+ }
+ std::string l_FilePath = log_path;
+ std::string l_FileName = *itr;
+ l_FilePath.append("/");
+ l_FilePath.append(l_FileName.c_str());
+ if (0 != unlink(l_FilePath.c_str())) {
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete old log file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ SyncDir(log_path);
+ } else {
+ // LCOV_EXCL_START 200: there is always '/' in f_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete target not found. %s",
+ f_archive_destination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CLoggerUtil::deleteOldEmmcLog(std::string& f_archive_destination,
+ EErrorEventType type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR *l_dirp = NULL;
+ std::vector<std::string> vect_abnrm; /* ILLEGAL RESET LOG INFO or ERROR EXIT LOG INFO */
+ std::vector<std::string> vect_nrm; /* NORMAL LOG INFO */
+ std::vector<std::string> vect_rlnc; /* RELAUNCH LOG INFO */
+ std::string l_emmc_path = m_pCfg->getEmmcOutputPath();
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ UI_32 abnrm_count = 0;
+
+ l_dirp = opendir(l_emmc_path.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: opendir's error case.
+ struct dirent l_dirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_findFileName = l_dirent.d_name;
+
+// if ((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz"))
+// || (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+// vect_abnrm.push_back(l_findFileName);
+ if ((l_findFileName == ".") || (l_findFileName == "..")) {
+ continue;
+ } else if (std::string::npos != l_findFileName.find(SS_STORE_FILENAME_SYSILG_TERM)) {
+ vect_abnrm.push_back(l_findFileName);
+ } else if(std::string::npos != l_findFileName.find(SS_STORE_FILENAME__CWORD52__TERM)) { // LCOV_EXCL_BR_LINE 8: SS_STORE_FILENAME__CWORD52__TERM can not be set // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ vect_abnrm.push_back(l_findFileName); // LCOV_EXCL_LINE 8: SS_STORE_FILENAME_SYSILG_TERM can not be set // NOLINT[whitespace/line_length]
+ } else if((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz")) ||
+ (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+ vect_abnrm.push_back(l_findFileName);
+ abnrm_count++;
+
+ } else if (std::string::npos
+ != l_findFileName.find("_GRP_RELAUNCH.tar.gz")) {
+ vect_rlnc.push_back(l_findFileName);
+ } else if (std::string::npos != l_findFileName.find(".tar.gz")) {
+ vect_nrm.push_back(l_findFileName);
+ }
+ }
+ closedir(l_dirp);
+ }
+
+ switch (type) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeModuleInvokedResetRequest:
+
+// if ((UI_32) m_pCfg->m_emmcOutputErrMax <= vect_abnrm.size()) {
+// l_eStatus = deleteOldLog(l_emmc_path, vect_abnrm, f_archive_destination,
+// (UI_32) m_pCfg->m_emmcOutputErrMax);
+ if ((UI_32)m_pCfg->m_emmcOutputErrMax <= abnrm_count) {
+ l_eStatus = SS_LoggerStoreLogs_deleteOldLogAbnrm(l_emmc_path, vect_abnrm, f_archive_destination,
+ (UI_32)m_pCfg->m_emmcOutputErrMax, abnrm_count);
+
+ }
+ break;
+ case eErrorEventTypeGroupRelaunch:
+ if ((UI_32) m_pCfg->m_emmcOutputGrpRelaunchMax <= vect_rlnc.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_rlnc, f_archive_destination,
+ (UI_32) m_pCfg->m_emmcOutputGrpRelaunchMax);
+ }
+ break;
+ default:
+ if ((UI_32) m_pCfg->m_emmcOutputMax <= vect_nrm.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_nrm, f_archive_destination,
+ (UI_32) m_pCfg->m_emmcOutputMax);
+ }
+ break;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+void CLoggerUtil::SetMilage(UI_32 f_Milage) {
+ m_Milage = f_Milage;
+}
+
+std::string CLoggerUtil::GetUserInvokedFilename(HANDLE f_hApp, uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_seqNumber = 0;
+
+ EFrameworkunifiedStatus l_eStatus = m_pCfg->GetIncrementAndPersistUserInvokedCounter(
+ f_hApp, l_seqNumber);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "GetIncrementAndPersistUserInvokedCounter()");
+
+ /* new counter value was not persisted if l_eStatus != eFrameworkunifiedStatusOK */
+
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_seqNumber << '_';
+ l_nameStream << std::setw(8) << std::setfill('0') << std::right << std::dec << m_Milage << '_';
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << m_bootCount << '_';
+ l_nameStream << std::setw(15) << GetTimeString(f_time) << ".tar.gz";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+std::string CLoggerUtil::GetEmmcFilename(uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_counter = 0;
+
+ m_pCfg->GetAndIncrementEmmcCounter(l_counter);
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_counter << '_';
+ l_nameStream << std::setw(15) << this->GetTimeString(f_time) << ".tar.gz";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+// LCOV_EXCL_START 8: dead code
+std::string CLoggerUtil::GetEmmcErrorFilename(uint32_t f_time) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_counter = 0;
+
+ m_pCfg->GetAndIncrementEmmcCounter(l_counter);
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_counter << '_';
+ l_nameStream << std::setw(15) << this->GetTimeString(f_time) << "_ERR.tar.gz";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 13:
+std::string CLoggerUtil::GetEmmcNaviLogFilename(uint32_t f_time) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_counter = 1;
+
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_counter << '_';
+ l_nameStream << std::setw(15) << this->GetTimeString(f_time) << ".log";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+// LCOV_EXCL_STOP
+
+std::string CLoggerUtil::GetTimeString(uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "00000000_000000";
+ struct tm local_time;
+ Clock_getLocalTimeY2K38(&f_time, &local_time);
+ char buffer[20];
+ if (0
+ != strftime(buffer, sizeof(buffer), "%Y%m%d_%H%M%S", // LCOV_EXCL_BR_LINE 5: c code
+ &local_time)) {
+ l_ret = buffer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+void CLoggerUtil::SetUsbMountPath(std::string usbpath) {
+ strncpy(m_usbpath, usbpath.c_str(), USB_PATH_SIZE - 1);
+ m_usbpath[USB_PATH_SIZE - 1] = '\0';
+}
+#ifdef RELEASE_BUILD
+EFrameworkunifiedStatus CLoggerUtil::PathCheckAndCopyFile(std::string f_source,
+ std::string f_destination) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string::size_type ret;
+
+ ret = f_destination.find(m_usbpath);
+ l_eStatus = CopyFile(f_source, f_destination);
+
+ return l_eStatus;
+}
+#endif // RELEASE_BUILD
+/////////////////////////////////////////////////////////////////////////
+///// Static Functions
+/////////////////////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus CLoggerUtil::CopyFile(std::string f_source,
+ std::string f_destination) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ssize_t l_nrd;
+ ssize_t l_nwr;
+ char l_buf[BUF_MAX_SIZE];
+
+ int l_if = open(f_source.c_str(), O_RDONLY | O_CLOEXEC, 0);
+ if (-1 == l_if) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "src open fail:%s,errno:%d,msg:%s",
+ f_source.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ bool isWebdav = false;
+ std::string l_tmpDest;
+ size_t l_pos = f_destination.find_last_of('/');
+
+ l_tmpDest = f_destination;
+ if (f_destination.find("/mnt/import") != std::string::npos) { // LCOV_EXCL_BR_LINE 13:
+ // if output to webdav's directory, don't create temporary file.
+ // because of being unable to rename the file on it.
+ isWebdav = true;
+ }
+
+ int l_of = open(l_tmpDest.c_str(), O_WRONLY | O_CREAT | O_CLOEXEC, 0640);
+ if (-1 == l_of) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest open fail:%s,errno:%d,msg:%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ do {
+ l_nrd = read(l_if, l_buf, sizeof(l_buf));
+ if (l_nrd == -1) { // LCOV_EXCL_BR_LINE 5: read's error case.
+ // LCOV_EXCL_START 5: read's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "read fail:%s,errno:%d,msg:%s",
+ f_source.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ break;
+ // LCOV_EXCL_STOP
+ }
+
+ l_nwr = write(l_of, l_buf, l_nrd);
+ if (l_nwr == -1) { // LCOV_EXCL_BR_LINE 5: write's error case.
+ // LCOV_EXCL_START 5: write's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (ENOSPC == errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "write fail(ENOSPC):%s,errno:%d,msg:%s", l_tmpDest.c_str(),
+ errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusErrNoEAGAIN;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "write fail:%s,errno:%d,msg%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ break;
+ // LCOV_EXCL_STOP
+ }
+ } while (l_nrd > 0);
+
+ fsync(l_of);
+ close(l_of);
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 6: can not be fail
+ // LCOV_EXCL_START 6: can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_if);
+ return l_eStatus;
+ // LCOV_EXCL_STOP
+ }
+
+ {
+ struct stat istat_buf, ostat_buf;
+ int ret;
+ ret = fstat(l_if, &istat_buf);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: fstat's error case.
+ // LCOV_EXCL_START 5: fstat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. stat(%s). errno: %d, %s",
+ f_source.c_str(), errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ while (1) {
+ ret = stat(l_tmpDest.c_str(), &ostat_buf);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: stat's error case.
+ // LCOV_EXCL_START 5: stat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. stat(%s). errno: %d, %s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ break;
+ // LCOV_EXCL_STOP
+ }
+ if (ostat_buf.st_size >= istat_buf.st_size) { // LCOV_EXCL_BR_LINE 5: read and write can not fail, so the size is same // NOLINT[whitespace/line_length]
+ break;
+ }
+ usleep(10000); // interval
+ }
+ }
+ }
+ }
+ close(l_if);
+
+ if (!isWebdav) { // LCOV_EXCL_BR_LINE 6: isWebdav is aways false
+ if (rename(l_tmpDest.c_str(), f_destination.c_str()) != 0) { // LCOV_EXCL_BR_LINE 5: rename's error case.
+ // LCOV_EXCL_START 5: rename's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "rename %s to %s fail,errno:%d,msg:%s",
+ l_tmpDest.c_str(), f_destination.c_str(), errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 200: there is always '/' in f_destination
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest invalid:%s", f_destination.c_str()); // LCOV_EXCL_LINE 200: there is always '/' in f_destination // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::CopyUntyped(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ struct stat l_stat;
+ int l_statRetVal;
+ if (0 != access(f_source.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_source.c_str());
+ } else if (0 != (l_statRetVal = lstat(f_source.c_str(), &l_stat))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_source.c_str(), l_statRetVal);
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ l_eStatus = CopyDirectory(f_source, f_destination);
+ } else if (0 != S_ISLNK(l_stat.st_mode)) {
+ // avoid duplicate copy for eErrorEventTypeInterfaceunifiedEmmcLogs: /nv/log/awlog -> /nv/BS/ss/logger_service/rwdata/log2/awlog
+ if (f_source.find("/nv/BS/ss/logger_service/rwdata/awlog") == std::string::npos) {
+ l_eStatus = CopyDirectory(f_source, f_destination);
+ }
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+#ifdef RELEASE_BUILD
+ l_eStatus = PathCheckAndCopyFile(f_source, f_destination);
+#else
+ l_eStatus = CopyFile(f_source, f_destination);
+#endif // RELEASE_BUILD
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_source.c_str(), l_stat.st_mode);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::CopyDirectory(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ DIR * l_pDir = opendir(f_source.c_str());
+
+ if (l_pDir == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s",
+ f_source.c_str());
+ } else {
+ if (mkdir(f_destination.c_str(), 0775) == -1) {
+ if (errno == EEXIST) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Directory: %s already exists.",
+ f_destination.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not create directory: %s. Errno: %s",
+ f_destination.c_str(), strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ SyncDir(f_destination);
+ size_t l_pos = f_destination.find_last_of('/');
+ if (l_pos != std::string::npos) {
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ }
+ }
+
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_fileSource = f_source;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ l_eStatus = CopyUntyped(l_fileSource, l_fileDestination);
+ }
+ }
+
+ closedir(l_pDir);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::MoveFile(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+#ifdef RELEASE_BUILD
+ l_eStatus = CLoggerUtil::PathCheckAndCopyFile(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "CLoggerUtil::PathCheckAndCopyFile()");
+#else
+ l_eStatus = CLoggerUtil::CopyFile(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "CLoggerUtil::CopyFile()");
+#endif // RELEASE_BUILD
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ l_eStatus = (0 == remove(f_source.c_str())) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ if (l_eStatus == eFrameworkunifiedStatusOK) {
+ size_t l_pos = f_source.find_last_of('/');
+ if (std::string::npos != l_pos) {
+ std::string l_emmc_path = f_source.substr(0, l_pos);
+ SyncDir(l_emmc_path);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::MoveUntyped(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ struct stat l_stat;
+ int l_statRetVal;
+ if (0 != access(f_source.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_source.c_str());
+ } else if (0 != (l_statRetVal = stat(f_source.c_str(), &l_stat))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_source.c_str(), l_statRetVal);
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ l_eStatus = CLoggerUtil::MoveDirectory(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "CLoggerUtil::MoveDirectory(f_source, f_destination);");
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ l_eStatus = CLoggerUtil::MoveFile(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "CLoggerUtil::MoveFile(f_source, f_destination)");
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_source.c_str(), l_stat.st_mode);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::MoveDirectory(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ DIR * l_pDir = opendir(f_source.c_str());
+
+ if (l_pDir == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s",
+ f_source.c_str());
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ errno = 0;
+ if (mkdir(f_destination.c_str(), 0666) == -1) {
+ if (errno == EEXIST) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Directory: %s already exists.",
+ f_destination.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not create directory: %s. Errno: %s",
+ f_destination.c_str(), strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ errno = 0;
+ } else {
+ SyncDir(f_destination);
+ size_t l_pos = f_destination.find_last_of('/');
+ if (l_pos != std::string::npos) {
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { /* if directory already exists or has been newly created */
+ struct dirent l_pDirent;
+ struct dirent* next;
+
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_fileSource = f_source;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ l_eStatus = MoveUntyped(l_fileSource, l_fileDestination);
+ }
+ }
+ } else {
+ }
+ closedir(l_pDir);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200: can not be called
+ELOGGERSERVICELOGTYPE CLoggerUtil::QueryLoggerservicelogType(std::string f_logname) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+ if (f_logname.find(SS_STORE_FILENAME_SYSILG_TERM) != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find(SS_STORE_FILENAME__CWORD52__TERM) != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+
+ || f_logname.find("_ERR.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find("_GRP_RELAUNCH.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeGrpRelaunch;
+ } else if (f_logname.find(".tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeNormal;
+ } else {
+ return eLoggerservicelogTypeOther;
+ }
+}
+// LCOV_EXCL_STOP
+
+void CLoggerUtil::SyncDir(std::string f_dir_path) {
+ int fd = open(f_dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+#define OPE_ERR_MSG "%s %s failed. errno:%d,msg:%s"
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "open",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ if (fsync(fd) == -1) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "fsync",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ if (close(fd) == -1) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "close",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+#undef OPE_ERR_MSG
+}
+
diff --git a/systemservice/logger_service/server/src/testapps/fopen b/systemservice/logger_service/server/src/testapps/fopen
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/systemservice/logger_service/server/src/testapps/fopen
diff --git a/systemservice/logger_service/server/src/testapps/testapps.log b/systemservice/logger_service/server/src/testapps/testapps.log
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/systemservice/logger_service/server/src/testapps/testapps.log
diff --git a/systemservice/logger_service/server/src/testapps/testapps.tar.gz b/systemservice/logger_service/server/src/testapps/testapps.tar.gz
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/systemservice/logger_service/server/src/testapps/testapps.tar.gz
diff --git a/systemservice/logger_service/server/src/udp_file_writer.cpp b/systemservice/logger_service/server/src/udp_file_writer.cpp
new file mode 100755
index 0000000..c07db07
--- /dev/null
+++ b/systemservice/logger_service/server/src/udp_file_writer.cpp
@@ -0,0 +1,161 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/udp_file_writer.h"
+#include "readerWriter/writer/file_writer.h"
+#include "readerWriter/writer/cached_file_writer.h"
+
+namespace ReaderWriter {
+
+// LCOV_EXCL_START 8:dead code
+CUdpFileWriter::CUdpFileWriter()
+ : m_pUdpWriter(NULL),
+ m_pFileWriter(NULL),
+ m_pLoggerCfg(NULL),
+ m_ipAddress(""),
+ m_port(0),
+ m_FileName(""),
+ m_FileSize(0) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+CUdpFileWriter::~CUdpFileWriter() { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (this->m_pFileWriter != NULL) {
+ delete (this->m_pFileWriter);
+ this->m_pFileWriter = NULL;
+ }
+ if (this->m_pUdpWriter != NULL) {
+ delete (this->m_pUdpWriter);
+ this->m_pUdpWriter = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus CUdpFileWriter::Initialize(CLoggerCfg* f_pLoggerCfg,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((NULL == this->m_pFileWriter) && (NULL == this->m_pUdpWriter)
+ && (NULL != f_pLoggerCfg)) {
+ this->m_pFileWriter = new (std::nothrow) CCachedFileWriter();
+ this->m_pUdpWriter = new (std::nothrow) CUdpWriter();
+ m_pLoggerCfg = f_pLoggerCfg;
+ m_ipAddress = f_Name2;
+ m_port = f_size2;
+ m_FileName = f_Name1;
+ m_FileSize = f_size1;
+ EFrameworkunifiedStatus l_eStatus1 = this->m_pUdpWriter->Initialize(m_pLoggerCfg,
+ m_ipAddress, m_port,
+ "", 0);
+ EFrameworkunifiedStatus l_eStatus2 = this->m_pFileWriter->Initialize(m_pLoggerCfg,
+ m_FileName,
+ m_FileSize, "", 0);
+ l_eStatus =
+ ((l_eStatus1 != eFrameworkunifiedStatusOK) || (eFrameworkunifiedStatusOK != l_eStatus2)) ?
+ eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+ if (l_eStatus == eFrameworkunifiedStatusOK) {
+ l_eStatus = this->Open();
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CUdpFileWriter::Open(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((NULL != this->m_pFileWriter) && (NULL != this->m_pUdpWriter)) {
+ EFrameworkunifiedStatus l_eStatus1 = this->m_pUdpWriter->Open();
+ EFrameworkunifiedStatus l_eStatus2 = this->m_pFileWriter->Open();
+ l_eStatus =
+ ((l_eStatus1 != eFrameworkunifiedStatusOK) || (eFrameworkunifiedStatusOK != l_eStatus2)) ?
+ eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+ }
+
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+BOOL CUdpFileWriter::IsOpen(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL l_ret = FALSE;
+ if ((this->m_pUdpWriter != NULL) && (this->m_pFileWriter != NULL)) {
+ l_ret = (m_pUdpWriter->IsOpen() && m_pFileWriter->IsOpen());
+ }
+ return l_ret;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus CUdpFileWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if ((NULL != this->m_pUdpWriter)) {
+ l_eStatus = this->m_pUdpWriter->Write(f_data, f_length, f_bytesWritten);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "this->m_pUdpWriter->Write() failed.");
+ }
+
+ if ((NULL != this->m_pFileWriter)) {
+ l_eStatus = this->m_pFileWriter->Write(f_data, f_length, f_bytesWritten);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "this->m_pFileWriter->Write() failed.");
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+void CUdpFileWriter::Close() { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (this->m_pFileWriter != NULL) {
+ this->m_pFileWriter->Close();
+ delete (this->m_pFileWriter);
+ this->m_pFileWriter = NULL;
+ }
+ if (this->m_pUdpWriter != NULL) {
+ this->m_pUdpWriter->Close();
+ delete (this->m_pUdpWriter);
+ this->m_pUdpWriter = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CUdpFileWriter::FlushCache(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return (this->m_pFileWriter->FlushCache());
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CUdpFileWriter::UpdateLoggingParameters(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return (this->m_pUdpWriter->UpdateLoggingParameters());
+}
+} // namespace ReaderWriter
+
+// LCOV_EXCL_STOP
diff --git a/systemservice/logger_service/server/src/udp_writer.cpp b/systemservice/logger_service/server/src/udp_writer.cpp
new file mode 100755
index 0000000..8fc4d84
--- /dev/null
+++ b/systemservice/logger_service/server/src/udp_writer.cpp
@@ -0,0 +1,295 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/udp_writer.h"
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <string.h>
+#include <inttypes.h>
+#ifdef AGL_STUB
+#include <other_service/PosixBasedOS001ClockCycleApi.h>
+#else
+#include <sys/syspage.h>
+#include <sys/neutrino.h>
+#endif
+#include <native_service/ns_logger_if.h>
+#include <string>
+#include <algorithm>
+
+#define TIME_UNTIL_UDP_START (UI_32)25
+
+namespace ReaderWriter {
+
+CUdpWriter::CUdpWriter()
+ : m_SocketHandle(-1),
+ m_IPAddress(""),
+ m_index(0),
+ m_port(REMOTE_IP_PORT),
+ m_InitialTimeElapsed(FALSE) {
+ std::memset(&m_oSAInfo, 0, sizeof(sockaddr_in));
+ std::memset(&m_buffer[0], 0, UDP_CACHED_BLOCK_SIZE);
+}
+
+CUdpWriter::~CUdpWriter() {
+ if (m_SocketHandle != -1) {
+ this->Close();
+ }
+}
+
+EFrameworkunifiedStatus CUdpWriter::Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2,
+ UI_32 f_size2) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ this->m_IPAddress = f_Name1;
+ if (NULL == f_pLoggerCfg) { // LCOV_EXCL_BR_LINE 200: f_pLoggerCfg can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 200: f_pLoggerCfg can not be null
+ } else if ((f_pLoggerCfg->IsUDPLoggingEnabled())) {
+ if (m_IPAddress.length() > 0) {
+ this->m_port = f_size1;
+ l_eStatus = this->Open();
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->Open() failed. UDP logging disabled. Enable via Engineering Menu.");
+ // Continue without UDP Logging;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ this->m_SocketHandle = -1;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+BOOL CUdpWriter::IsOpen(void) {
+ BOOL l_ret = (-1 != m_SocketHandle) ? TRUE : FALSE;
+ if (TRUE == l_ret) {
+#ifdef AGL_STUB
+ UI_32 l_elapsed = ((UI_32)((F_64)ClockCycle()/1000000));
+#else
+ UI_32 l_elapsed = ((UI_32) ((F_64) ClockCycle()
+ / (F_64) (SYSPAGE_ENTRY(qtime)->cycles_per_sec)));
+#endif
+ // check if 20 Seconds have elapsed since startup
+ if (TIME_UNTIL_UDP_START <= l_elapsed) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "%d seconds elapsed. Starting UDP logging", l_elapsed);
+ m_InitialTimeElapsed = TRUE;
+ l_ret = TRUE;
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Time before starting UDP not yet elapsed. Waiting for %d more seconds",
+ (TIME_UNTIL_UDP_START - l_elapsed));
+ usleep((TIME_UNTIL_UDP_START - l_elapsed)*1000);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Starting UDP now!");
+ }
+ }
+ return l_ret;
+}
+
+EFrameworkunifiedStatus CUdpWriter::Open() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((m_IPAddress.length() > 0)) {
+ int l_SocketOption = 1;
+ // Set the domain using the classes domain value.
+ m_oSAInfo.sin_family = AF_INET;
+ m_oSAInfo.sin_addr.s_addr = inet_addr(OWN_ADDRESS); // m_IPAddress.c_str()); // "192.168.1.2");//htonl(INADDR_ANY);
+ m_oSAInfo.sin_port = htons(this->m_port);
+ if (FALSE == this->m_pLoggerCfg->IsUDPLoggingEnabled()) {
+ this->Close();
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else if (this->m_SocketHandle != -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. socket already opened. No action required");
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (-1 == (this->m_SocketHandle = socket(AF_INET, SOCK_DGRAM, 0))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. socket(AF_INET, SOCK_DGRAM, 0) returned -1. errno: %s",
+ strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbExecuteFail;
+ } else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_REUSEADDR,
+ &l_SocketOption, sizeof(l_SocketOption)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "setsockopt(SO_REUSEADDR) failed.errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ }
+#ifdef AGL_STUB
+ else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_REUSEADDR , // LCOV_EXCL_BR_LINE 6: the same calls will get the same return // NOLINT (readability/braces)
+ &l_SocketOption, sizeof(l_SocketOption)) == -1)
+#else
+ else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_REUSEPORT, // NOLINT (readability/braces)
+ &l_SocketOption, sizeof(l_SocketOption)) == -1)
+#endif
+ {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "setsockopt(SO_REUSEPORT) failed. errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ } else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_DONTROUTE,
+ &l_SocketOption, sizeof(l_SocketOption)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "setsockopt(SO_DONTROUTE) failed. errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ } else if (INADDR_NONE == m_oSAInfo.sin_addr.s_addr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Invalid local address.");
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ } else if (0
+ != bind(this->m_SocketHandle, (const struct sockaddr *) &m_oSAInfo,
+ sizeof(m_oSAInfo))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. bind() returned not zero. errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusSemUnlockFail;
+ } else {
+ m_oSAInfo.sin_addr.s_addr = inet_addr(m_IPAddress.c_str());
+ if (INADDR_NONE == m_oSAInfo.sin_addr.s_addr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Invalid target address.");
+ l_eStatus = eFrameworkunifiedStatusFault;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ this->Close();
+ m_SocketHandle = -1;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CUdpWriter::WriteData(UI_8 *f_data, UI_32 f_length,
+ SI_32 &f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_8 l_retry = SEND_RETRY_VALUE;
+ if (this->m_SocketHandle == -1) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ while ((0 != l_retry)
+ && ((f_bytesWritten >= 0) && ((UI_32) f_bytesWritten != f_length))) {
+ SI_32 l_bytesWritten = (SI_32)(sendto(m_SocketHandle, &f_data[f_bytesWritten],
+ f_length - f_bytesWritten, 0,
+ (const struct sockaddr *) &m_oSAInfo,
+ sizeof(m_oSAInfo)));
+ f_bytesWritten += l_bytesWritten;
+ l_eStatus = (l_bytesWritten >= 0) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "l_retry: %d, errno: %s", l_retry,
+ strerror(errno));
+ errno = 0;
+ l_retry--;
+ usleep(100);
+ } else {
+ l_retry = SEND_RETRY_VALUE;
+ }
+ }
+ }
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CUdpWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_bytesWritten = 0;
+ if ((f_data == NULL)) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ } else if ((-1 == m_SocketHandle)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (f_length > UDP_MAX_LENGTH) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Possible memory corruption.");
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Length(%d) bigger than cache. ",
+ f_length);
+ } else {
+ UI_32 l_remainingIndex = 0;
+
+ while (l_remainingIndex != f_length) {
+ UI_32 l_offset = (UDP_CACHED_BLOCK_SIZE - this->m_index);
+ l_offset = std::min(l_offset, (f_length - l_remainingIndex));
+ (void) std::memcpy(&this->m_buffer[this->m_index],
+ &f_data[l_remainingIndex], l_offset);
+ l_remainingIndex += l_offset;
+ this->m_index += l_offset;
+ if (this->m_index == UDP_CACHED_BLOCK_SIZE) {
+ (void) this->FlushCache();
+ this->m_index = 0;
+ }
+ }
+ f_bytesWritten = f_length;
+ }
+ }
+ return (l_eStatus);
+}
+void CUdpWriter::Close() {
+ if (m_SocketHandle != -1) {
+ (void) close(m_SocketHandle);
+ m_SocketHandle = -1;
+ }
+}
+
+EFrameworkunifiedStatus CUdpWriter::UpdateLoggingParameters(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (this->m_pLoggerCfg != NULL) {
+ BOOL l_enabled = this->m_pLoggerCfg->IsUDPLoggingEnabled();
+ if ((TRUE == l_enabled) && (m_SocketHandle == -1)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Opening UDP.");
+ l_eStatus = this->Open();
+ } else if (((FALSE == l_enabled) && (m_SocketHandle != -1))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Closing UDP.");
+ l_eStatus = eFrameworkunifiedStatusOK;
+ this->Close();
+ } else {
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- :%d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CUdpWriter::FlushCache(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SI_32 l_written = 0;
+ SI_32 l_writtenTotal = 0;
+ while (((l_writtenTotal >= 0) && ((UI_32) l_writtenTotal < this->m_index))
+ && (eFrameworkunifiedStatusOK == l_eStatus)) {
+ l_eStatus = this->WriteData(&this->m_buffer[l_writtenTotal],
+ this->m_index - l_writtenTotal, l_written);
+ l_writtenTotal += l_written;
+ l_written = 0;
+ }
+ this->m_index = 0;
+ return l_eStatus;
+}
+} // namespace ReaderWriter
diff --git a/systemservice/logger_service/server/src/writer.cpp b/systemservice/logger_service/server/src/writer.cpp
new file mode 100755
index 0000000..907b202
--- /dev/null
+++ b/systemservice/logger_service/server/src/writer.cpp
@@ -0,0 +1,86 @@
+/*
+ * @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_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include <new>
+#include <iostream>
+#include "readerWriter/writer/writer.h"
+#include "readerWriter/writer/file_writer.h"
+#include "readerWriter/writer/udp_writer.h"
+#include "readerWriter/writer/udp_file_writer.h"
+#include "readerWriter/writer/cached_file_writer.h"
+
+namespace ReaderWriter {
+
+CWriter::CWriter()
+ : m_pLoggerCfg(NULL) {
+}
+
+CWriter::~CWriter() {
+}
+
+CWriter* CWriter::OpenWriter(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2) {
+ CWriter* l_ret = NULL;
+ if ((f_Name1.length() != 0) && (f_pLoggerCfg != NULL)) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ switch (f_type) {// LCOV_EXCL_BR_LINE 200:As it must be eReaderWriterTypeQueue or eReaderWriterTypeMem
+ case eReaderWriterTypeFile:
+ l_ret = new (std::nothrow) CCachedFileWriter(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+
+ case eReaderWriterTypeUdp:
+ l_ret = new (std::nothrow) CUdpWriter(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+ case eReaderWriterTypeUdpAndFile: // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (f_Name2.length() != 0) {
+ l_ret = new (std::nothrow) CUdpFileWriter();
+ }
+ // LCOV_EXCL_STOP
+ default:
+ break;
+ }
+ }
+ if (NULL != l_ret) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ if (eFrameworkunifiedStatusOK != l_ret->Initialize(f_pLoggerCfg, f_Name1, f_size1, f_Name2, f_size2)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Open Writer Failed");
+ delete (l_ret);
+ l_ret = NULL;
+ }
+ }
+
+ return l_ret;
+}
+
+EFrameworkunifiedStatus CWriter::FlushCache(void) { // LCOV_EXCL_START 8:Base class virtual functions
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Default function called!");
+ return (eFrameworkunifiedStatusOK);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CWriter::UpdateLoggingParameters(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Default function called!");
+ return (eFrameworkunifiedStatusOK);
+}
+} // namespace ReaderWriter
+
diff --git a/systemservice/logger_service/server/work/Makefile b/systemservice/logger_service/server/work/Makefile
new file mode 100755
index 0000000..79cef35
--- /dev/null
+++ b/systemservice/logger_service/server/work/Makefile
@@ -0,0 +1,126 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = SS_LoggerService
+
+
+######### compiled sources #############
+SS_LoggerService_SRCS += mod_version.c
+SS_LoggerService_SRCS += cached_file_writer.cpp
+SS_LoggerService_SRCS += file_writer.cpp
+SS_LoggerService_SRCS += mem_reader.cpp
+SS_LoggerService_SRCS += loggerservice_application.cpp
+SS_LoggerService_SRCS += loggerservice_main.cpp
+SS_LoggerService_SRCS += loggerservicedebug_child_thread.cpp
+SS_LoggerService_SRCS += loggerservicedebug_writer_Evntworker.cpp
+SS_LoggerService_SRCS += queue_reader.cpp
+SS_LoggerService_SRCS += reader.cpp
+SS_LoggerService_SRCS += reader_writer.cpp
+SS_LoggerService_SRCS += ss_logger_cfg.cpp
+SS_LoggerService_SRCS += ss_logger_device_detection.cpp
+SS_LoggerService_SRCS += ss_logger_error_event.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_archive.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_can_evt_reply.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_cfg.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_responses.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_storage.cpp
+SS_LoggerService_SRCS += ss_logger_fs_directory.cpp
+SS_LoggerService_SRCS += ss_logger_popups.cpp
+SS_LoggerService_SRCS += ss_logger_reader_writer_control.cpp
+SS_LoggerService_SRCS += ss_logger_server_callbacks.cpp
+SS_LoggerService_SRCS += ss_logger_util.cpp
+SS_LoggerService_SRCS += udp_writer.cpp
+SS_LoggerService_SRCS += writer.cpp
+SS_LoggerService_SRCS += udp_file_writer.cpp
+
+######## add source path #############
+VPATH += ../src
+VPATH += ../include/$(COMPONENT_NAME)
+VPATH += -I../include/readerWriter/reader
+VPATH += -I../include/readerWriter/writer
+
+
+######### add include path #############
+CPPFLAGS += -I./
+CPPFLAGS += -I../include
+CPPFLAGS += -I../include/readerWriter
+CPPFLAGS += -I../include/readerWriter/reader
+CPPFLAGS += -I../include/readerWriter/writer
+CPPFLAGS += -Wl,--no-undefined
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+######### add compile option #############
+CPPFLAGS += -DRELEASE_BUILD
+CPPFLAGS += -DLINUX
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+
+CPPFLAGS_mem_reader.o = -fno-exceptions
+CPPFLAGS_reader.o = -fno-exceptions
+CPPFLAGS_reader_writer.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_archive.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_can_evt_reply.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_cfg.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_responses.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_storage.o = -fno-exceptions
+CPPFLAGS_ss_logger_fs_directory.o = -fno-exceptions
+CPPFLAGS_ss_logger_popups.o = -fno-exceptions
+CPPFLAGS_ss_logger_reader_writer_control.o = -fno-exceptions
+CPPFLAGS_ss_logger_server_callbacks.o = -fno-exceptions
+CPPFLAGS_ss_logger_util.o = -fno-exceptions
+CPPFLAGS_writer.o = -fno-exceptions
+CPPFLAGS_mod_version.o = -fno-exceptions
+CPPFLAGS_cashed_file_writer.o = -fno-exceptions
+CPPFLAGS_file_writer.o = -fno-exceptions
+CPPFLAGS_loggerservice_application.o = -fno-exceptions
+CPPFLAGS_loggerservice_main.o = -fno-exceptions
+CPPFLAGS_loggerservicedebug_child_thread.o = -fno-exceptions
+CPPFLAGS_loggerservicedebug_writer_Evntworker.o = -fno-exceptions
+CPPFLAGS_queue_reader.o = -fno-exceptions
+CPPFLAGS_ss_logger_device_detection.o = -fno-exceptions
+CPPFLAGS_udp_file_writer.o = -fno-exceptions
+CPPFLAGS_udp_writer.o = -fno-exceptions
+
+######### linked library #############
+LDFLAGS += -L../lib/
+LDLIBS += -Wl,-Bstatic -lSS_LoggerStoreLogs
+LDLIBS += -Wl,-Bstatic -lPFDRECThread
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lc #Substitute for libsocket
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lrt # for mq_xxx
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -ltar
+LDLIBS += -Wl,-Bdynamic -lz
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+LDLIBS += -Wl,-Bdynamic -lns_backup #for PFDRECTread
+LDLIBS += -Wl,-Bdynamic -lcommon
+LDLIBS += -Wl,-Bdynamic -lcrypto
+LDLIBS += -Wl,-Bdynamic -lextension
+LDLIBS += -Wl,-Bdynamic -lClock_API
+
+
+LINK_CXX=Y
+include ../../../system_service.mk
diff --git a/systemservice/power_service/LICENSE b/systemservice/power_service/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/power_service/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/power_service/Makefile.server b/systemservice/power_service/Makefile.server
new file mode 100755
index 0000000..b11e0d8
--- /dev/null
+++ b/systemservice/power_service/Makefile.server
@@ -0,0 +1,19 @@
+#
+# @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.
+#
+
+SUBDIRS = server
+
+include ../system_service.mk
diff --git a/systemservice/power_service/server/Makefile b/systemservice/power_service/server/Makefile
new file mode 100755
index 0000000..f81d2ba
--- /dev/null
+++ b/systemservice/power_service/server/Makefile
@@ -0,0 +1,51 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = SS_PowerService
+
+
+######### compiled sources #############
+SS_PowerService_SRCS += ./src/powerservice_application.cpp
+SS_PowerService_SRCS += ./src/powerservice_main.cpp
+SS_PowerService_SRCS += ./src/ss_power.cpp
+SS_PowerService_SRCS += ./src/ss_power_config.cpp
+SS_PowerService_SRCS += ./src/ss_power_session.cpp
+SS_PowerService_SRCS += ./src/ss_power_state_machine.cpp
+SS_PowerService_SRCS += ./src/ss_pwr_test_client_handlers.cpp
+SS_PowerService_SRCS += ./src/ss_supervisor_handlers.cpp
+SS_PowerService_SRCS += ./src/ss_system_handlers.cpp
+
+
+######### add include path #############
+CPPFLAGS += -I./include
+
+
+######### add compile option #############
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x09 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,13,9,8,3 ## open log-tag
+CPPFLAGS += -DTARGET_SOC_$(TARGET_SOC)
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+
+######### add library path #############
+LDFLAGS += -g -Wl,--gc-sections
+
+include ../../system_service.mk
diff --git a/systemservice/power_service/server/include/ss_power.h b/systemservice/power_service/server/include/ss_power.h
new file mode 100755
index 0000000..b1e3de5
--- /dev/null
+++ b/systemservice/power_service/server/include/ss_power.h
@@ -0,0 +1,318 @@
+/*
+ * @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_PowerService
+/// \brief Handles Power Service Business logic
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_H_
+
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_templates.h>
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include <vector>
+#include <string>
+#include <exception>
+
+#include "ss_power_session.h"
+#include "ss_power_config.h"
+#include "ss_power_state_machine.h"
+#include "ss_power_powerservicelog.h"
+
+typedef enum _SS_PSState {
+ SS_PS_READY_TO_WAKEUP = 0x01,
+ SS_PS_WAKEUP_INITIATED,
+ SS_PS_WAKEUP_COMPLETE,
+ SS_PS_POWER_ON_COMPLETE,
+ SS_PS_POWER_OFF_INITIATED,
+ SS_PS_POWER_OFF_COMPLETE,
+ SS_PS_SHUTDOWN_INITIATED,
+ SS_PS_SHUTDOWN_COMPLETE
+ // This is not real state, used only to know total states
+ ,
+ SS_PS_STATE_MAX
+} SS_PSState;
+
+typedef struct {
+ std::string m_cmd;
+ UI_64 m_time;
+ std::string m_sender;
+} Ts_cmdHist;
+
+typedef std::vector<Ts_cmdHist> cmdHist;
+typedef cmdHist::iterator cmdHistIter;
+
+class Power {
+ public:
+ Power();
+ virtual ~Power();
+ EFrameworkunifiedStatus Initialize(HANDLE h_app);
+ static Power & GetInstance();
+
+ /// Session Request Handlers
+ EFrameworkunifiedStatus OnOpenSession(HANDLE h_app);
+ EFrameworkunifiedStatus OnCloseSession(HANDLE h_app);
+
+ /// Session Response\Ack Handlers
+ EFrameworkunifiedStatus OnWakeUpComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnPrintConnections(HANDLE h_app);
+ EFrameworkunifiedStatus OnPrintStack(HANDLE h_app);
+
+ /// SSM Handlers
+
+ /// Supervisor Handlers
+ EFrameworkunifiedStatus OnPowerRequestMsg(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetPowerState(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetCommWakeUp(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetCommSleep(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownRequestMsg(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnPowerOnOffNotification(HANDLE h_app);
+ EFrameworkunifiedStatus OnStartModules(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownModules(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnHysteresisTimeout(HANDLE h_app);
+
+ // System Handlers
+ EFrameworkunifiedStatus OnSystemLaunchComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnSystemShutdownComplete(HANDLE h_app);
+ EFrameworkunifiedStatus OnWakeUpTimeout(HANDLE h_app);
+ EFrameworkunifiedStatus OnShutdownTimeout(HANDLE h_app);
+
+ // Get Result query from power test client
+ EFrameworkunifiedStatus OnCurrentPowerStateQuery(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnSetVoltageState(HANDLE h_app);
+ EFrameworkunifiedStatus OnSetCrankState(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnSystemModeInfoRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnSystemModeInfoResponse(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnInitCompReport(HANDLE h_app);
+
+ EFrameworkunifiedStatus OnSystemMgrConnectionEstablished(HANDLE h_app);
+
+ //
+ // Start Confirmation callback functions
+ //
+ EFrameworkunifiedStatus OnSendStartupConfirmationRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnSendStartupConfirmationResponse(HANDLE h_app);
+
+ //
+ // User Mode Protocol callback functions
+ //
+ EFrameworkunifiedStatus OnUserModeResponse(HANDLE h_app);
+
+ //
+ // Shutdown Condition Notification Protocol function
+ //
+ EFrameworkunifiedStatus OnPublishShutdownPopupRequest(HANDLE h_app);
+
+ //
+ // Power Popup Notification Protocol function
+ //
+ EFrameworkunifiedStatus OnPublishPowerPopupRequest(HANDLE h_app);
+
+ //
+ // HeartBeat Protocol callback functions
+ //
+ EFrameworkunifiedStatus On_CWORD56_HeartBeatRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnSM_CWORD56_HeartBeatResponse(HANDLE h_app);
+
+ //
+ // Hard Reset Protocol callback functions
+ //
+ EFrameworkunifiedStatus OnCpuResetRequest(HANDLE h_app);
+
+ //
+ // Remote Data Reset Protocol callback functions
+ //
+ EFrameworkunifiedStatus OnRemoteDataResetRequest(HANDLE h_app);
+ EFrameworkunifiedStatus OnRemoteDataResetResponse(HANDLE h_app);
+
+ cmdHist m__CWORD56_RepHist;
+ cmdHistIter m__CWORD56_RepIter;
+ cmdHist m_PubCmdHist;
+ cmdHistIter m_PubHistIter;
+ cmdHist m_ErrHist;
+ cmdHistIter m_ErrHistIter;
+ cmdHist m_VCmdHist;
+ cmdHistIter m_VHistIter;
+
+ void SSPowerDebugDump(HANDLE h_app);
+
+ private:
+#define LOG_POWERSERVICELOG_CNT(caseid, Cnt) \
+ FRAMEWORKUNIFIEDLOG_CNT(ZONE_INFO, Cnt, 0); \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " case " #caseid \
+ ": FRAMEWORKUNIFIEDLOG_CNT(ZONE_INFO, " #Cnt ", 0)");
+
+#define LOG_POWERSERVICELOG_EVT(caseid, Evt, Data0) \
+ FRAMEWORKUNIFIEDLOG_EVT(ZONE_INFO, Evt, 1, Data0); \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " case " #caseid \
+ ": FRAMEWORKUNIFIEDLOG_EVT(ZONE_INFO, " #Evt ", " #Data0 ")");
+
+#define LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(l_eStatus, pStr) \
+ if (eFrameworkunifiedStatusOK != l_eStatus) { \
+ LOG_ERROR(pStr); \
+ SetCmdHist(pStr, m_ErrHist, m_ErrHistIter, GetStr(static_cast<EFrameworkunifiedStatus>(l_eStatus)).c_str()); \
+ } // End of #define LOG_STATUS_IF_ERRORED(l_eStatus,pStr)
+
+#define SS_PWR_LOG_HIST(cmd, hist, it, sender, l_eStatus) \
+ if (eFrameworkunifiedStatusOK == l_eStatus) { \
+ SetCmdHist((static_cast< std::string> (cmd)), (static_cast<cmdHist&> (hist)), \
+ (static_cast<cmdHistIter&> (it)), (static_cast< std::string> (sender))); \
+ }
+ //**************************************************************************
+ // Counter Logging enums & typedefs *
+ // *
+ // Counter Event IDs *
+ typedef enum { // *
+ CT_Startup_CanSignal = 0x0114, // *
+ CT_Startup_DiagMsg = 0x0118, // *
+ // *
+ CT_Shutdown_CanSignal = 0x0121, // *
+ CT_Shutdown_Timeout = 0x0124, // *
+ CT_Shutdown_Temperature = 0x0125, // *
+ CT_Shutdown_Error = 0x0126, // *
+ CT_Shutdown_Voltage = 0x0127 // *
+ } EPWR_COUNTER_EVENT_ID_TYPE; // *
+ // *
+ // End of Counter Logging enums & typedefs *
+ //**************************************************************************
+
+ //**************************************************************************
+ // Event Logging enums & typedefs *
+ // *
+ // Event ID *
+ typedef enum { // *
+ // Startup Event IDs *
+ Ei_StartUp_Cansignal = 0x0101, // *
+ Ei_StartUp_HK_On = 0x0102, // *
+ // 0x0103 not specified // *
+ // 0x0104 not specified // *
+ // 0x0105 System Svcs not responsible// *
+ // 0x0106 not specified // *
+ Ei_StartUp_ActivationLine = 0x0107, // *
+ Ei_StartUp_DiagMsg = 0x0108, // *
+ // *
+ // Shutdown Event IDs *
+ Ei_shutdown_CANsignal = 0x0201, // *
+ Ei_shutdown_HkOFF = 0x0202, // *
+ // 0x0203 not specified // *
+ // 0x0204 not specified // *
+ Ei_shutdown_Temperature = 0x0205, // *
+ Ei_shutdown_NetworkError = 0x0206, // *
+ Ei_shutdown_Voltage = 0x0207 // *
+ } EPWR_LOGGING_EVENT_ID_TYPE; // *
+ // *
+ // Ei_StartUp_CanSignal byte0 Event Detail *
+ typedef enum { // *
+ epseisuedIGNITION = 0x00, // *
+ epseisuedHK_ON = 0x01, // *
+ epseisuedDOOR_MODULES = 0x02, // *
+ // 0x03 not specified // *
+ // 0x04 not specified // *
+ epseisuedPASS = 0x05, // *
+ epseisuedIHTM = 0x06, // *
+ epseisuedMPM = 0x07, // *
+ epseisuedSNA = 0xFF // *
+ } EPWR_LOGGING_EVT_DETAIL_SU_CAN_TYPE; // *
+
+ //
+ // Ei_StartUp_HkOn
+ typedef enum {
+ epseisuedHK_ON_Key = 0x00
+ } EPWR_LOGGING_EVT_DETAIL_SU_KEY_TYPE;
+
+ //
+ // Ei_StartUp_ActivationLine
+ typedef enum {
+ epseisuedACV_LINE = 0x00
+ } EPWR_LOGGING_EVT_DETAIL_SU_LINE_TYPE;
+
+ // *
+ // Ei_StartUp_DiagMsg byte0 Event Detail *
+ typedef enum { // *
+ epseisuedHU = 0x01, // *
+ epseisuedCAN = 0x02, // *
+ } EPWR_LOGGING_EVT_DETAIL_SU_DIAG_TYPE; // *
+ // *
+ // Ei_ShutDown_CanSignal byte0 Event Detail *
+ typedef enum { // *
+ epseisdcsIGN_STATE = 0x00, // *
+ epseisdcsHK_ON = 0x01 // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_CAN_TYPE; // *
+ // *
+ // Ei_ShutDown_Temperature byte0 Event Detail *
+ typedef enum { // *
+ epseisdtempECU_LOW = 0x00, // *
+ epseisdtempECU_HIGH = 0x01, // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_TEMP_TYPE; // *
+ // *
+ // Ei_ShutDown_NetworkError byte0 Event Detail *
+ typedef enum { // *
+ epseisdneHMI_CAN = 0x00, // *
+ epseisdneHU_CAN = 0x01 // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_NETWORK_ERROR_TYPE; // *
+ // *
+ // Ei_ShutDown_Voltage byte0 Event Detail *
+ typedef enum { // *
+ epseisdnvoltBATTERY_CUT_OFF = 0x00, // *
+ epseisdnvoltLIMP_HOME = 0x01, // *
+ epseisdnvoltUNKNOWN = 0xFF // *
+ } EPWR_LOGGING_EVT_DETAIL_SD_VOLTAGE_TYPE; // *
+ // *
+ // End of Event Logging enums & typedefs *
+ //**************************************************************************
+
+ PowerSessionHandler m_oSessionHandler;
+ PowerConfigParams m_tConfigData;
+ PowerStateMachine m_oStateMachine;
+ UI_32 m_aTimerIDs[15];
+ wakeInfo m_WakeUpData; /// WakeUp data received from SPM
+ SS_PSState m_PowerState;
+ ePowerSrvVoltageStates m_VoltageState;
+ ePowerSrvCrankStates m_CrankState;
+ UI_32 m_MaxShutdownTimeout;
+ std::map<SS_PSState, std::string> m_PPStateStrMap;
+
+ // Notify Module on Voltage change detected.
+ EFrameworkunifiedStatus PublishVoltageStateChange(HANDLE h_app);
+ EFrameworkunifiedStatus ConstructPwrStateResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus AddStateInformationToResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus AddVoltageInformationToResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus AddCrankInformationToResponse(CHAR *f_MessageResponse);
+ EFrameworkunifiedStatus RegisterAllCallbacksAndNofitications(HANDLE h_app);
+ VOID SetPowerServiceState(SS_PSState f_NewState);
+ EFrameworkunifiedStatus ValidateUserModeMessage(HANDLE h_app,
+ EPWR_USER_MODE_TYPE &l_eUserModeState); // NOLINT (runtime/references)
+
+ pthread_mutex_t pwr_hist_mutex;
+
+ void SetCmdHist(std::string cmd,
+ cmdHist &hist, // NOLINT (runtime/references)
+ cmdHistIter &it, // NOLINT (runtime/references)
+ std::string sender);
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_H_
diff --git a/systemservice/power_service/server/include/ss_power_config.h b/systemservice/power_service/server/include/ss_power_config.h
new file mode 100755
index 0000000..09ca70d
--- /dev/null
+++ b/systemservice/power_service/server/include/ss_power_config.h
@@ -0,0 +1,147 @@
+/*
+ * @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_PowerService
+/// \brief This file supports power service configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
+
+
+#include <system_service/ss_system_types.h>
+#include <system_service/ss_templates.h>
+#include <native_service/ns_config_parser_if.h>
+#include <list>
+#include <string>
+#include "ss_power_powerservicelog.h"
+
+typedef std::list<SS_String> RequiredModuleList;
+typedef RequiredModuleList::iterator RequiredModuleListIter;
+
+#define SS_PWR__CWORD56__REP_HIST_SIZE (10u)
+#define SS_PWR_PUB_CMD_HIST_SIZE (5u)
+#define SS_PWR_ERR_HIST_SIZE (5u)
+#define SS_PWR_V_HIST_SIZE (10u)
+#define SS_PWR_DEBUG_DUMP_MAX_SIZE (4096u)
+
+typedef struct _PowerConfigParams { // NOLINT (readability/naming) // LCOV_EXCL_BR_LINE 14:it will be called when poweron
+ typedef struct {
+ SI_32 timeout;
+ struct {
+ BOOL enabled;
+ SI_32 timeout;
+ SI_32 tries;
+ } hysteresis;
+ } PowerOffInfo;
+
+ SS_String power_logic_plugin;
+ PowerOffInfo lvi1;
+ PowerOffInfo lvi2;
+ PowerOffInfo shutdown;
+ RequiredModuleList wakeup_modules;
+ RequiredModuleList shutdown_modules;
+ RequiredModuleList lvi2_modules;
+} PowerConfigParams;
+
+class PowerConfiguration {
+ public:
+ // define all the configuration parmeters that will be used to get data
+ static const char * kPowerLogicPlugin;
+ static const char * kLVI1Timeout;
+ static const char * kLVI1HysteresisTimeout;
+ static const char * kLVI1HysteresisEnabled;
+ static const char * kLVI1HysteresisTries;
+ static const char * kLVI2Timeout;
+ static const char * kLVI2HysteresisTimeout;
+ static const char * kLVI2HysteresisEnabled;
+ static const char * kLVI2HysteresisTries;
+ static const char * kShutdownTimeout;
+ static const char * kShutdownHysteresisTimeout;
+ static const char * kShutdownHysteresisEnabled;
+ static const char * kShutdownHysteresisTries;
+
+ /// < defines the names in the xml file that are used to get required modules names
+ static const char * kRequiredWakeupModules; /// < once all the modules have been wakened up send wake-up complete
+ static const char * kRequiredShutdownModules; /// < once all the modules have been shutdown send shutdown complete
+ static const char * kRequiredLvi2Modules; /// < once all the modules have been wakened up send wake-up complete
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PowerConfiguration
+ /// \brief Here it is checked whether the new connection is to be connected or not, if yes then whether the old
+ /// connection is to be disconnected or to be paused or to be played simultaneously.
+ ///
+ /// \param [in] f_configFileName Configuration file name.
+ ///
+ /// \return NA
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ explicit PowerConfiguration(std::string f_configfilename);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~PowerConfiguration
+ /// \brief Here it is checked whether the new connection is to be connected or not, if yes then whether the old
+ /// connection is to be disconnected or to be paused or to be played simultaneously.
+ ///
+ /// \param [in] pRequestingSrc
+ /// Source* - Pointer to the requesting source.
+ ///
+ /// \return bool
+ /// bool - TRUE or FALSE
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~PowerConfiguration();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// LoadParameters
+ /// \brief Load module parameters from configuration file.
+ ///
+ /// \param [in] params - Ref to variable which to store the loaded module parameters.
+ ///
+ /// \return bool
+ /// bool - TRUE or FALSE
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL LoadParameters(PowerConfigParams & params); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// LoadDefaultParameters
+ /// \brief Laod default power services parameters.
+ ///
+ /// \param [in] params - Ref to variable for which to store the default module parameters.
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void LoadDefaultParameters(PowerConfigParams & params); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintConfigInfo
+ /// \brief Print configuration information.
+ ///
+ /// \param [in] params - Ref to variable containing the configuration parameters to load.params
+ ///
+ /// \return none.
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void PrintConfigInfo(PowerConfigParams & f_params); // NOLINT (runtime/references)
+
+ protected:
+ PowerConfiguration(const PowerConfiguration &);
+ PowerConfiguration & operator =(const PowerConfiguration &); // NOLINT (runtime/references)
+
+ private:
+ std::string m_ConfigFileName;
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
diff --git a/systemservice/power_service/server/include/ss_power_powerservicelog.h b/systemservice/power_service/server/include/ss_power_powerservicelog.h
new file mode 100755
index 0000000..3d912fa
--- /dev/null
+++ b/systemservice/power_service/server/include/ss_power_powerservicelog.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_PowerService
+/// \brief This file supports 002 application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_POWERSERVICELOG_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_POWERSERVICELOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_FUNC_IPC ZONEMASK(13)
+#define ZONE_POWER_MONITOR ZONEMASK(14)
+#define ZONE_POWER_STATEMACHINE ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_INFO_IPC ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 "Ipc Function"
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 "Power StateMachine"
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 "Ipc Info"
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN, ZONE_ERR //, ZONE_INFO,ZONE_POWER_STATEMACHINE, ZONE_DEBUG_DUMP, ZONE_FUNC
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern const CHAR AppName[]; // NOLINT (readability/naming)
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_POWERSERVICELOG_H_
diff --git a/systemservice/power_service/server/include/ss_power_session.h b/systemservice/power_service/server/include/ss_power_session.h
new file mode 100755
index 0000000..47a4a4a
--- /dev/null
+++ b/systemservice/power_service/server/include/ss_power_session.h
@@ -0,0 +1,70 @@
+/*
+ * @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_PowerService
+/// \brief This file supports power service session management.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_SESSION_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_SESSION_H_
+
+#include <system_service/ss_power_service.h>
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include <string>
+#include "ss_power_config.h"
+
+typedef std::string SubscriberName; // The name of the module that is trying to open a session with Power
+
+/*
+ *
+ */
+class PowerSessionHandler {
+ public:
+ PowerSessionHandler();
+ virtual ~PowerSessionHandler();
+ EFrameworkunifiedStatus OpenSesion(HANDLE h_app);
+ EFrameworkunifiedStatus CloseSession(HANDLE h_app);
+ EFrameworkunifiedStatus StartComplete(HANDLE h_app);
+ EFrameworkunifiedStatus StopComplete(HANDLE h_app);
+
+ VOID Print();
+
+ // Methods that do the heavy lifting
+ BOOL WakeupComplete(RequiredModuleList & wakeup_modules); // NOLINT (runtime/references)
+ BOOL ShutdownComplete(RequiredModuleList & shutdown_modules); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus SendToSupervisor(UI_32 cmd, UI_32 length, PVOID data);
+ BOOL AllClientsInGroupStarted(UI_32 f_ungrpid);
+ BOOL ClientPresent(PCSTR f_sclientname);
+
+ private:
+ struct PwSessionInfo {
+ std::string sz_name;
+ std::string sz_servicename;
+ HANDLE hsession;
+ BOOL frunning;
+ EPWR_SESSION_TYPE esessiontype;
+ UI_32 ui_groupid;
+ };
+
+ typedef std::map<SubscriberName, PwSessionInfo> PwSessionMap;
+ typedef PwSessionMap::iterator PwSessionIter;
+
+ PwSessionMap m_mapSessions;
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_SESSION_H_
diff --git a/systemservice/power_service/server/include/ss_power_state_hysteresis.h b/systemservice/power_service/server/include/ss_power_state_hysteresis.h
new file mode 100755
index 0000000..c136630
--- /dev/null
+++ b/systemservice/power_service/server/include/ss_power_state_hysteresis.h
@@ -0,0 +1,74 @@
+/*
+ * @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_PowerService
+/// \brief This file supports power service hysteresis management.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
+
+#include "ss_power_config.h"
+
+class PowerStateHysteresis {
+ public:
+ PowerStateHysteresis()
+ : m_unTries(0) {
+ bzero(&m_tHysteresisInfo, sizeof(m_tHysteresisInfo));
+ }
+
+ virtual ~PowerStateHysteresis() { // LCOV_EXCL_START 14: do it when power off
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ m_unTries = 0;
+ }
+ // LCOV_EXCL_STOP 14: do it when power off
+ explicit PowerStateHysteresis(PowerConfigParams::PowerOffInfo & info) // NOLINT (runtime/references)
+ : m_unTries(0),
+ m_tHysteresisInfo(info) {
+ }
+ void set(PowerConfigParams::PowerOffInfo & info) { // NOLINT (runtime/references)
+ m_tHysteresisInfo = info;
+ }
+ BOOL getEnabled() const {
+ return m_tHysteresisInfo.hysteresis.enabled;
+ }
+ UI_32 getTimeout() const {
+ return m_tHysteresisInfo.hysteresis.timeout;
+ }
+ UI_32 getTries() const {
+ return m_tHysteresisInfo.hysteresis.tries;
+ }
+
+ void clearTryCounter() {
+ m_unTries = 0;
+ }
+ void bumbTryCounter() {
+ m_unTries++;
+ }
+ BOOL maxTries() const {
+ if (m_unTries < getTries())
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ private:
+ UI_32 m_unTries;
+ PowerConfigParams::PowerOffInfo m_tHysteresisInfo;
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
diff --git a/systemservice/power_service/server/include/ss_power_state_machine.h b/systemservice/power_service/server/include/ss_power_state_machine.h
new file mode 100755
index 0000000..086f36c
--- /dev/null
+++ b/systemservice/power_service/server/include/ss_power_state_machine.h
@@ -0,0 +1,414 @@
+/*
+ * @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_PowerService
+/// \brief This file supports the power service state machine.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_MACHINE_H_
+#define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_MACHINE_H_
+
+#include <system_service/ss_power_service.h>
+#include "ss_power_state_hysteresis.h"
+
+class PowerSessionHandler;
+
+class PowerStateMachine {
+ class Base_State {
+ public:
+ virtual void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ virtual void onStartComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ virtual void onLaunchComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+ virtual void onStopComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ virtual void onShutdownComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onSoftwareUpdate(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+ virtual PCSTR name() = 0;
+
+ /// State Entry and Exit methods
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+
+ // LCOV_EXCL_START 200: virtual function
+ virtual void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 200: virtual function
+ };
+
+ friend class Base_State;
+
+ class Wakeup : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onSoftwareUpdate(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ virtual PCSTR name();
+
+ // LCOV_EXCL_START 8: fist status, no entry
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP 8: fist status, no entry
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ };
+
+ friend class Wakeup;
+
+ class WakeupActive : public Wakeup {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ };
+
+ friend class WakeupActive;
+
+ class WakeupPending : public Wakeup {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onStartComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLaunchComplete(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ };
+
+ friend class WakeupPending;
+
+ class Shutdown : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession) { // NOLINT (runtime/references)
+ }
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class Shutdown;
+
+ class ShutdownActive : public Base_State {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class ShutdownActive;
+
+ class LowVoltage1 : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage1;
+
+ class LowVoltage1Active : public Base_State {
+ public:
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage1Active;
+
+ class LowVoltage2 : public Base_State {
+ public:
+ void onWakeup(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisAborted(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onHysteresisTimeout(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage2;
+
+ class LowVoltage2Active : public Base_State {
+ public:
+ void onNormalVoltageEncountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class LowVoltage2Active;
+
+ class NormalVoltage : public Base_State {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onSoftwareUpdate(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class NormalVoltage;
+
+ class SoftwareUpdate : public Base_State {
+ public:
+ void onShutdown(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage1Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onLowVoltage2Encountered(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ PCSTR name();
+
+ void onEntry(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void onExit(PowerStateMachine &u, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ };
+
+ friend class SoftwareUpdate;
+
+ public:
+ typedef enum _Power_State_Machine_Events {
+ epsmeWAKEUP = epswsPWRON,
+ epsmeSHUTDOWN = epscnCANSLEEP,
+ epsmeLVI1_ENCOUNTERED = epsvsLVI1,
+ epsmeLVI2_ENCOUNTERED = epsvsLVI2,
+ epsmeNORMAL_VOLTAGE_ENCOUNTERED = epsvsNORMAL,
+ epsmeSTART_COMPLETE = 0xD1,
+ epsmeSTOP_COMPLETE = 0xD2,
+ epsmeSOFTWARE_UPDATE = 0xE1,
+ epsmeSHUTDOWN_HYSTERESIS_ABORTED = 0xF1,
+ epsmeLVI1_HYSTERESIS_ABORTED = 0xF2,
+ epsmeLVI2_HYSTERESIS_ABORTED = 0xF3,
+ epsmeSHUTDOWN_HYSTERESIS_TM_OUT = 0xFA,
+ epsmeLVI1_HYSTERESIS_TM_OUT = 0xFB,
+ epsmeLVI2_HYSTERESIS_TM_OUT = 0xFC,
+ } ePowerStateMachineEvents;
+
+ PowerStateMachine();
+ virtual ~PowerStateMachine();
+ void onEvent(HANDLE h_app, PowerSessionHandler & oSession, // NOLINT (runtime/references)
+ ePowerStateMachineEvents evt);
+ EFrameworkunifiedStatus initialize(HANDLE h_app, PowerConfigParams & refConfigParms); // NOLINT (runtime/references)
+ PCSTR name();
+
+ private:
+ static Wakeup WakeupState;
+ static WakeupActive WakeupActiveState;
+ static WakeupPending WakeupPendingState;
+ static LowVoltage1 LowVoltage1State;
+ static LowVoltage1Active LowVoltage1ActiveState;
+ static LowVoltage2 LowVoltage2State;
+ static LowVoltage2Active LowVoltage2ActiveState;
+ static Shutdown ShutdownState;
+ static ShutdownActive ShutdownActiveState;
+ static NormalVoltage NormalVoltageState;
+ static SoftwareUpdate SoftwareUpdateState;
+
+ Base_State *m_pCurrentState;
+ Base_State *m_pPreviousState;
+ Base_State *m_pOnHysteresisTimeoutState;
+ PowerStateHysteresis m_oShutdownHysteresis;
+ PowerStateHysteresis m_oLowVoltage1Hysteresis;
+ PowerStateHysteresis m_oLowVoltage2Hysteresis;
+ RequiredModuleList m_lstWakeupModules;
+ RequiredModuleList m_lstShutdownModules;
+ RequiredModuleList m_lstLvi2Modules;
+ HANDLE m_hHysteresisTimer;
+
+ typedef struct _state_info {
+ EPWR_POWER_STATE_TYPE wake;
+ EPWR_VOLTAGE_STATE_TYPE voltage;
+ EPWR_WAKEUP_LEVEL_TYPE level;
+ EPWR_WAKEUP_FACTOR_TYPE factor;
+ EPWR_CRANK_STATE_TYPE crank;
+ } Pwr_StateInfo;
+
+ Pwr_StateInfo m_tStateInfo;
+
+ PowerStateMachine(PowerStateMachine&);
+ PowerStateMachine & operator=(PowerStateMachine &);
+
+ /// Helper methods
+ void NextState(Base_State & refState, HANDLE h_app, // NOLINT (runtime/references)
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+ void GotoStateOnHysteresisTimeout(Base_State & refState); // NOLINT (runtime/references)
+ void startHysteresisTimer(PowerStateHysteresis & hys_info); // NOLINT (runtime/references)
+ void reStartHysteresisTimer(PowerStateHysteresis & hys_info); // NOLINT (runtime/references)
+ void stopHysteresisTimer(PowerStateHysteresis & hys_info); // NOLINT (runtime/references)
+ void publishPowerLVIStatus(HANDLE h_app, PCSTR nNotifNm, UI_32 value);
+ void publishPowerLevelType(HANDLE h_app, UI_32 value);
+
+ void OnVoltage(Base_State * pState, HANDLE h_app,
+ PowerSessionHandler & oSession); // NOLINT (runtime/references)
+};
+
+#endif // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_MACHINE_H_
diff --git a/systemservice/power_service/server/src/powerservice_application.cpp b/systemservice/power_service/server/src/powerservice_application.cpp
new file mode 100755
index 0000000..4c44459
--- /dev/null
+++ b/systemservice/power_service/server/src/powerservice_application.cpp
@@ -0,0 +1,236 @@
+/*
+ * @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_PowerService
+/// \brief This file contains the standard set functions called by the NS
+// dispatcher on application initialization, cleanup and wakeup.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <system_service/ss_services.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+#include "ss_power_powerservicelog.h"
+#include "ss_power.h"
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app)
+ * @brief Handles setup for SS_Power subsystem, registers with
+ * NP_Service and indicates that its ready.
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ eStatus = Power::GetInstance().Initialize(h_app);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+/**
+ * EFrameworkunifiedStatus PowerserviceOnWakepup(HANDLE h_app)
+ * @brief This is not handled by the Power Subsystem since send out the
+ * notifications that indicated Wakeup.
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus PowerserviceOnWakepup(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP 200: not called by NSFW
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE h_app)
+ * @brief This is not handled by the Power Subsystem since send out the
+ * notifications that indicated Shutdown.
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP 200: not called by NSFW
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE h_app)
+ * @brief This is not handled by the Power Subsystem since send out the
+ * notifications that indicated Emergency Shutdown.
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP 200: not called by NSFW
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app)
+ * @brief SS_Power will exit when this method is invoked,
+ * return value will always be invalid.
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__,
+ " This method is not valid for %s, returning "
+ "eFrameworkunifiedStatusNotImplemented",
+ SERVICE_POWER);
+ return eFrameworkunifiedStatusNotImplemented;
+}
+// LCOV_EXCL_STOP 200: not called by NSFW
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app)
+ * @brief Used to ask SS_Power to dump its vital information about the subsystem.
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) { // LCOV_EXCL_START 7: debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ Power* l_instance = &Power::GetInstance();
+
+ if (l_instance != NULL) {
+ l_instance->SSPowerDebugDump(h_app);
+
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ return eStatus;
+}
+// LCOV_EXCL_STOP 7: debug code
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app)
+ * @brief Used to .
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app)
+ * @brief Used to .
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app)
+ * @brief Used to .
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) { // LCOV_EXCL_START 200: not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "N/A; returning eFrameworkunifiedStatusOK");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP 200: not called by NSFW
+// EOF
+
diff --git a/systemservice/power_service/server/src/powerservice_main.cpp b/systemservice/power_service/server/src/powerservice_main.cpp
new file mode 100755
index 0000000..0b1ccfe
--- /dev/null
+++ b/systemservice/power_service/server/src/powerservice_main.cpp
@@ -0,0 +1,70 @@
+/*
+ * @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_PowerService
+/// \brief Application entry point.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <system_service/ss_services.h>
+#include <system_service/ss_version.h>
+#include <system_service/ss_system_if.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/ns_message_center_if.h>
+
+#include "ss_power_powerservicelog.h"
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
+
+/// \brief: Name of the Queue that will be
+/// used to read data from.
+const CHAR AppName[] = SERVICE_POWER;
+
+/// \brief: public structure that is used
+/// for logging by NSLogger.
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
+FRAMEWORKUNIFIEDLOGOPTIONS, {
+ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ZONE_TEXT_31 }, FRAMEWORKUNIFIEDLOGZONES };
+
+/**
+ *int main(int argc, char *argv[])
+ * @brief Main function for SS_Power subsystem.
+ *
+ * @param argc number of arguments passed to SS_Power
+ * @param argv array of arguments passed to SS_Power
+ *
+ * @return int status of applications exit.
+ */
+int main(int argc, char *argv[]) {
+ FRAMEWORKUNIFIED_SET_ZONES();
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cbFuncs);
+
+ EFrameworkunifiedStatus eStatus = FrameworkunifiedDispatcherWithArguments(AppName, argc, argv,
+ &cbFuncs);
+ return eStatus;
+}
+
diff --git a/systemservice/power_service/server/src/ss_power.cpp b/systemservice/power_service/server/src/ss_power.cpp
new file mode 100755
index 0000000..26e8881
--- /dev/null
+++ b/systemservice/power_service/server/src/ss_power.cpp
@@ -0,0 +1,1672 @@
+/*
+ * @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_PowerService
+/// \brief Handles Power Service Business logic
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "ss_power.h"
+#include <inttypes.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_notifications_local.h>
+#include <system_service/ss_power_service_local.h>
+#include <native_service/frameworkunified_timer.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <other_service/PosixBasedOS001ClockCycleApi.h>
+#include <utility>
+#include <string>
+
+#include "ss_power_powerservicelog.h"
+
+using namespace std; // NOLINT (build/namespaces)
+
+static Power g_PowerSubsystem;
+
+/**
+ * @brief
+ *
+ * @param
+ * @param
+ *
+ * @return
+ */
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus PowerCallback(
+ HANDLE h_app) {
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ C * pObj = static_cast<C *>(&g_PowerSubsystem);
+
+ if (pObj) {
+ l_eStatus = (pObj->*M)(h_app);
+ }
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// GetInstance
+/// Return global instance of Power object. Power is singleton class
+///
+//////////////////////////////////////////////////////////////////////
+Power & Power::GetInstance() {
+ return g_PowerSubsystem;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Power
+/// Constructor of Power class
+///
+//////////////////////////////////////////////////////////////////////
+Power::Power()
+ : m__CWORD56_RepHist(SS_PWR__CWORD56__REP_HIST_SIZE),
+ m_PubCmdHist(SS_PWR_PUB_CMD_HIST_SIZE),
+ m_ErrHist(SS_PWR_ERR_HIST_SIZE),
+ m_VCmdHist(SS_PWR_V_HIST_SIZE),
+ m_PowerState(SS_PS_READY_TO_WAKEUP),
+ m_VoltageState(epsvsINVALID),
+ m_CrankState(epscsINVALID),
+ m_MaxShutdownTimeout(0) {
+ m_PPStateStrMap[SS_PS_READY_TO_WAKEUP] = "SS_PS_READY_TO_WAKEUP";
+ m_PPStateStrMap[SS_PS_WAKEUP_INITIATED] = "SS_PS_WAKEUP_INITIATED";
+ m_PPStateStrMap[SS_PS_WAKEUP_COMPLETE] = "SS_PS_WAKEUP_COMPLETE";
+ m_PPStateStrMap[SS_PS_POWER_ON_COMPLETE] = "SS_PS_POWER_ON_COMPLETE";
+ m_PPStateStrMap[SS_PS_POWER_OFF_INITIATED] = "SS_PS_POWER_OFF_INITIATED";
+ m_PPStateStrMap[SS_PS_POWER_OFF_COMPLETE] = "SS_PS_POWER_OFF_COMPLETE";
+ m_PPStateStrMap[SS_PS_SHUTDOWN_INITIATED] = "SS_PS_SHUTDOWN_INITIATED";
+ m_PPStateStrMap[SS_PS_SHUTDOWN_COMPLETE] = "SS_PS_SHUTDOWN_COMPLETE";
+ m_PPStateStrMap[SS_PS_STATE_MAX] = "SS_PS_STATE_MAX";
+
+ m__CWORD56_RepIter = m__CWORD56_RepHist.begin();
+ m_PubHistIter = m_PubCmdHist.begin();
+ m_ErrHistIter = m_ErrHist.begin();
+ m_VHistIter = m_VCmdHist.begin();
+ bzero(&m_WakeUpData, sizeof(m_WakeUpData));
+}
+
+///////////////////////////////////////////////////////////////////////
+/// ~Power
+/// Destructor of Power class
+///
+//////////////////////////////////////////////////////////////////////
+Power::~Power() { // LCOV_EXCL_START 14 Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
+
+///////////////////////////////////////////////////////////////////////
+/// Initialize
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::Initialize(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus;
+ BOOL l_SpecifiedCfgLoaded;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ SetPowerServiceState(SS_PS_READY_TO_WAKEUP);
+
+ pthread_mutex_init(&pwr_hist_mutex, NULL);
+
+ /// Open and parse the configuration data for Power
+ const CHAR configFileName[] = "/usr/agl/conf/BS/ss/power_service/rodata/gpf_ss_ps_config.cfg";
+
+ PowerConfiguration config(configFileName);
+ l_SpecifiedCfgLoaded = config.LoadParameters(m_tConfigData);
+ if (FALSE == l_SpecifiedCfgLoaded) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ "Reading configuration from file: %s failed. Using default parameters.",
+ configFileName);
+ config.LoadDefaultParameters(m_tConfigData);
+ }
+
+ config.PrintConfigInfo(m_tConfigData);
+
+ /// init PowerStateMachine
+ m_oStateMachine.initialize(h_app, m_tConfigData);
+
+ // Register all callbacks to dispatcher and notifications
+ l_eStatus = RegisterAllCallbacksAndNofitications(h_app);
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus, "RegisterAllCallbacksAndNofitications()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// RegisterAllCallbacksAndNofitications
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::RegisterAllCallbacksAndNofitications(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app, szNTFY_PowerAvailability))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR(
+ "FrameworkunifiedRegisterServiceAvailabilityNotification( "szNTFY_PowerAvailability" )");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ l_eStatus = FrameworkunifiedPublishServiceAvailability(h_app, FALSE);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedPublishServiceAvailability()");
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+
+ SS_PWR_LOG_HIST("FrameworkunifiedPublishServiceAvailability()", m_PubCmdHist,
+ m_PubHistIter, "", l_eStatus);
+ }
+
+ // Attach Notification callbacks to dispatcher
+ FrameworkunifiedNotificationsList
+ ss_power_notifications[] = {
+ { szNTFY_PowerLVI1, sizeof(PowerSrvLVIStatus), eFrameworkunifiedStateVar}
+ , {szNTFY_PowerLVI2, sizeof(PowerSrvLVIStatus), eFrameworkunifiedStateVar}
+ , {szNTFY_PowerLevel, sizeof(PowerSrvLevelType), eFrameworkunifiedStateVar}
+ , {szNTFY_ShutdownPopup, sizeof(EPWR_SHUTDOWN_POPUP_TYPE), eFrameworkunifiedStateVar}
+ , {szNTFY_PowerPopup, sizeof(EPWR_POWER_POPUP_TYPE), eFrameworkunifiedStateVar}
+ };
+ // Register Notifications
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPRegisterNotifications(h_app, ss_power_notifications, _countof(ss_power_notifications)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedNPRegisterNotifications(ss_power_notifications)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ // Subscribe and attach call back for notification
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(h_app, NTFY_SSSystemMgrPowerOnOff, PowerCallback<Power, &Power::OnPowerOnOffNotification>))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSubscribeNotificationWithCallback()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+
+//*************************
+
+/// < Attach to the following session handles.
+ FrameworkunifiedProtocolCallbackHandler ss_power_session_req_handlers[] = {
+ /// session handles.
+ { PROTOCOL_OPEN_SESSION_REQ, PowerCallback<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> }, {
+ SS_POWER_STATE_CHANGE_REQ, PowerCallback<Power,
+ &Power::OnSetPowerState> }, { SS_POWER_POWER_REQUEST_MSG,
+ PowerCallback<Power, &Power::OnPowerRequestMsg> }, {
+ SS_POWER_COMM_WAKEUP,
+ PowerCallback<Power, &Power::OnSetCommWakeUp> }, {
+ SS_POWER_SHUTDOWN_REQ,
+ PowerCallback<Power, &Power::OnSetCommSleep> }, {
+ SS_POWER_SHUTDOWN_REQUEST_MSG, PowerCallback<Power,
+ &Power::OnShutdownRequestMsg> }
+
+ /// Wake-up / Shutdown Protocol commands for System Manager.
+ , { SS_SM_WAKEUP_MODULES_CMPL_RSPN, PowerCallback<Power,
+ &Power::OnWakeUpComplete> }, { SS_SM_SHUTDOWN_MODULES_CMPL_RSPN,
+ PowerCallback<Power, &Power::OnShutdownComplete> }
+ //
+ , { SS_POWER_PRINT_CONNECTIONS, PowerCallback<Power,
+ &Power::OnPrintConnections> }, { SS_POWER_PRINT_STACK,
+ PowerCallback<Power, &Power::OnPrintStack> }
+ /// Set Voltage & Crank states from shadow?
+ , { SS_POWER_VOLTAGE_STATE, PowerCallback<Power,
+ &Power::OnSetVoltageState> }, { SS_POWER_CRANK_STATE,
+ PowerCallback<Power, &Power::OnSetCrankState> }
+ /// Current Power Service State inquiry from Test Client
+ , { SS_POWER_CRNT_STATE_QUERY, PowerCallback<Power,
+ &Power::OnCurrentPowerStateQuery> }, {
+ SS_POWER_SYSTEM_MODE_INFO_REQ, PowerCallback<Power,
+ &Power::OnSystemModeInfoRequest> }, {
+ SS_SM_SYSTEM_MODE_INFO_RSPN, PowerCallback<Power,
+ &Power::OnSystemModeInfoResponse> }
+ /// InitComp report to SystemManager
+ , { SS_POWER_INITCOMP_REP, PowerCallback<Power,
+ &Power::OnInitCompReport> }
+ //
+ // Startup Confirmation Request ( from Power Shadow ) and
+ // Startup Confirmation Response ( from System Manager )
+ , { SS_POWER_FWD_START_CONFIRMATION_MSG_REQ, PowerCallback<Power,
+ &Power::OnSendStartupConfirmationRequest> }, {
+ SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, PowerCallback<Power,
+ &Power::OnSendStartupConfirmationResponse> }
+ //
+ // User Mode Request ( from Power Shadow ) and
+ // User Mode Response ( from System Manager )
+ , { SS_SM_USER_MODE_SET_RESP, PowerCallback<Power,
+ &Power::OnUserModeResponse> }
+
+ //
+ // Heartbeat Request ( from Power Shadow )
+ , { SS_POWER_HEARTBEAT_REQ, PowerCallback<Power,
+ &Power::On_CWORD56_HeartBeatRequest> }, { SS_SM__CWORD56__HEARTBEAT_RSPN,
+ PowerCallback<Power, &Power::OnSM_CWORD56_HeartBeatResponse> }
+
+ // System Manager to Power Services
+ , { SS_SM_CPU_RESET_REQ, PowerCallback<Power,
+ &Power::OnCpuResetRequest> }, { SS_SM_REMOTE_DATA_RESET_REQ,
+ PowerCallback<Power, &Power::OnRemoteDataResetRequest> } };
+
+ // Attach callback
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, ss_power_session_req_handlers, _countof(ss_power_session_req_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher( ss_power_session_req_handlers )");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+
+ //*************************
+
+ // Publish szNTFY_PowerAvailable so that other services can start connecting via sessions.
+
+ l_eStatus = RegisterSMSessionAckCallback(
+ PowerCallback<Power, &Power::OnSystemMgrConnectionEstablished>);
+ LOG_STATUS(l_eStatus, "RegisterSMSessionAckCallback()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnSetCommWakeUp
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnSetCommWakeUp(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ Pwr_ServiceSetInterface l_CanStatesData;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, l_CanStatesData))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else if (l_CanStatesData.data.commwake.state == epscnCANWAKEUP) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Received WakeUp from %s, Processing Ignored !!",
+ FrameworkunifiedGetMsgSrc(h_app));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnSetCommSleep
+///
+///
+//////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 200: can not be called from power class
+EFrameworkunifiedStatus Power::OnSetCommSleep(HANDLE h_app) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ Pwr_ServiceSetInterface l_CanStatesData;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, l_CanStatesData))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else if (l_CanStatesData.data.commwake.state != epscnCANSLEEP) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: %s: l_CanStatesData.data.commwake.state != epscnCANSLEEP",
+ FrameworkunifiedGetMsgSrc(h_app));
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Received Sleep from %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+
+ // Send to System Manager to WakeUp Modules
+ l_eStatus = SendShutdownToSystemManager(&l_CanStatesData);
+ if (l_eStatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("SendShutdownToSystemManager()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ SetPowerServiceState(SS_PS_SHUTDOWN_INITIATED);
+ LOG_SUCCESS("SendShutdownToSystemManager()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP 200: can not be called from power class
+
+///////////////////////////////////////////////////////////////////////
+/// SetPowerServiceState
+///
+///
+//////////////////////////////////////////////////////////////////////
+VOID Power::SetPowerServiceState(SS_PSState f_NewState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Changing State from '%s' to '%s'",
+ m_PPStateStrMap[m_PowerState].c_str(),
+ m_PPStateStrMap[f_NewState].c_str());
+
+ m_PowerState = f_NewState;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnPowerOnOffNotification
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnPowerOnOffNotification(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ T_SS_SM_UserModeOnOffNotification_StructType l_userModeOnOffStruct;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<T_SS_SM_UserModeOnOffNotification_StructType>(h_app, l_userModeOnOffStruct))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " User Mode is '%s', User Mode Change Reason is '%s'",
+ GetStr(l_userModeOnOffStruct.isUserModeOn).c_str(),
+ GetStr(l_userModeOnOffStruct.userModeChangeReason).c_str());
+ SetPowerServiceState(
+ l_userModeOnOffStruct.isUserModeOn ?
+ SS_PS_POWER_ON_COMPLETE : SS_PS_POWER_OFF_COMPLETE);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// ProcessSystemWakeUp
+/// On receipt of this notification send wake up notification to
+/// System Manager to wake up (START) all modules
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnSetPowerState(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ Pwr_ServiceSetInterface l_serviceSetIf;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, l_serviceSetIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ switch (l_serviceSetIf.data.wake.powerupType) {
+ case epswsPWRON:
+ case epswsPWROFF:
+ m_WakeUpData = l_serviceSetIf.data.wake;
+
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO, __FUNCTION__, " Received Power %s from %s, level 0x%X",
+ l_serviceSetIf.data.wake.powerupType == epswsPWRON ? "On" : "Off",
+ FrameworkunifiedGetMsgSrc(h_app), m_WakeUpData.up.level);
+ // Send to System Manager to WakeUp Modules
+ l_eStatus = SendWakeUpToSystemManager(&m_WakeUpData);
+ if (l_eStatus == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ SetPowerServiceState(SS_PS_WAKEUP_INITIATED);
+ LOG_SUCCESS("SendWakeUpToSystemManager()");
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("SendWakeUpToSystemManager()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ break;
+ default:
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Invalid PowerOnOff State received: 0x%X",
+ l_serviceSetIf.data.wake.powerupType);
+ break;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+/// Session Request Handlers
+///
+//////////////////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus Power::OnOpenSession(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app);
+ l_eStatus = m_oSessionHandler.OpenSesion(h_app);
+
+ /// < Test Code TODO: Remove ME!!!
+ // m_oSessionHandler.Print();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnCloseSession(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app);
+ l_eStatus = m_oSessionHandler.CloseSession(h_app);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnWakeUpComplete(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ wakeInfo l_Wake;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<wakeInfo>(h_app, l_Wake))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else if (l_Wake.up.level == m_WakeUpData.up.level) {
+ SetPowerServiceState(SS_PS_WAKEUP_COMPLETE);
+
+ /// < send the state machine a wakeup event.
+ m_oStateMachine.onEvent(h_app, m_oSessionHandler,
+ PowerStateMachine::epsmeWAKEUP);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Sending SS_POWER_STATE_CHANGE_RESP(%s) to PSM",
+ l_Wake.powerupType == epswsPWRON ? "User_On" : "User_Off");
+
+ // send Wake-up complete response to Supervisor
+ m_oSessionHandler.SendToSupervisor(SS_POWER_STATE_CHANGE_RESP,
+ sizeof(l_Wake), (PVOID) &l_Wake);
+ SS_PWR_LOG_HIST("SS_POWER_STATE_CHANGE_RESP", m__CWORD56_RepHist, m__CWORD56_RepIter,
+ "SS_PS_WAKEUP_COMPLETE", l_eStatus);
+
+ /// < Test Code TODO: Remove ME!!!
+ // m_oSessionHandler.Print();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Error: Power WakeUp Threshold (%d) and SM WakeUp Threshold (%d) Mismatch",
+ m_WakeUpData.up.level, l_Wake.up.level);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnShutdownComplete(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ SetPowerServiceState(SS_PS_SHUTDOWN_COMPLETE);
+
+ m_oStateMachine.onEvent(h_app, m_oSessionHandler,
+ PowerStateMachine::epsmeSHUTDOWN);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending SS_POWER_SHUTDOWN_RESP to PSM");
+ // send Shutdown complete response to Power Shadow / Supervisor
+ m_oSessionHandler.SendToSupervisor(SS_POWER_SHUTDOWN_RESP, 0, (PVOID) NULL);
+
+ SS_PWR_LOG_HIST("SS_POWER_SHUTDOWN_RESP", m__CWORD56_RepHist, m__CWORD56_RepIter,
+ "SS_PS_SHUTDOWN_COMPLETE", l_eStatus);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnShutdownComplete(HANDLE h_app)
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnPrintConnections(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_oSessionHandler.Print();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnPrintStack(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_oSessionHandler.Print();
+ // m_oStateMachine.Print();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnHysteresisTimeout(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_oStateMachine.onEvent(h_app, m_oSessionHandler,
+ PowerStateMachine::epsmeLVI1_HYSTERESIS_TM_OUT);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus PowerStateMachine::initialize(HANDLE h_app,
+ PowerConfigParams & refConfigParms) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ /// Set all hysteresis objects with the configuration data obtained from PowerService.xml
+ m_oShutdownHysteresis.set(refConfigParms.shutdown);
+ m_oLowVoltage1Hysteresis.set(refConfigParms.lvi1);
+ m_oLowVoltage2Hysteresis.set(refConfigParms.lvi2);
+
+ /// Copy the list of required modules.
+ m_lstWakeupModules = refConfigParms.wakeup_modules;
+ m_lstShutdownModules = refConfigParms.shutdown_modules;
+ m_lstLvi2Modules = refConfigParms.lvi2_modules;
+
+ m_hHysteresisTimer = FrameworkunifiedAttachTimerCallback(
+ h_app, 0, 0, PowerCallback<Power, &Power::OnHysteresisTimeout>);
+ if (NULL == m_hHysteresisTimer) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FrameworkunifiedAttachTimerCallback() returned NULL");
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PowerSessionHandler::OpenSesion(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // check if the subscriber is already in map
+ PwSessionIter iter = m_mapSessions.find(FrameworkunifiedGetMsgSrc(h_app));
+
+ // the iter is set to the end then the subscriber is not in the map
+ if (m_mapSessions.end() == iter) {
+ string subscriber(FrameworkunifiedGetMsgSrc(h_app));
+ PwSessionInfo newEntry;
+ newEntry.frunning = FALSE;
+ newEntry.hsession = FrameworkunifiedMcOpenSender(h_app, subscriber.c_str());
+ newEntry.sz_name = subscriber;
+ newEntry.sz_servicename = ""; // we will get this on the start complete.
+ newEntry.esessiontype = epsstBASIC;
+ newEntry.ui_groupid = 0;
+
+ if (NULL != newEntry.hsession) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ //
+ // Set the Session Handle for Framework so FrameworkunifiedSendResponse won't error due to a null
+ // session handle.
+ //
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK
+ // [in] PCSTR - Name of the associated service name
+ // [in] HANDLE - Session handle
+ != (l_eStatus = FrameworkunifiedSetSessionHandle(h_app, subscriber.c_str(), newEntry.hsession))) { // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: NSFW error case.
+ LOG_ERROR("FrameworkunifiedSetSessionHandle()");
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ OpenSessionAck openSessionAck;
+ memset(&openSessionAck, 0, sizeof(openSessionAck));
+ strcpy(openSessionAck.cSessionName, SERVICE_POWER); // NOLINT (runtime/printf)
+ openSessionAck.eStatus = eFrameworkunifiedStatusOK;
+ openSessionAck.sessionId = 0; /// Only one session handles all the heartbeat clients
+
+ // Send Ack to subscriber
+ l_eStatus = FrameworkunifiedSendMsg(newEntry.hsession, PROTOCOL_OPEN_SESSION_ACK,
+ sizeof(OpenSessionAck), (PVOID) &openSessionAck);
+ char l_cBuf[100];
+ snprintf(l_cBuf, sizeof(l_cBuf),
+ "FrameworkunifiedSendMsg(%s, PROTOCOL_OPEN_SESSION_ACK)", subscriber.c_str());
+ LOG_STATUS(l_eStatus, l_cBuf);
+ }
+
+ // If this is not a basic module then we will need to register some other protocols
+ if (0 != FrameworkunifiedGetMsgLength(h_app)) {
+ EPWR_SESSION_TYPE tOpenSessionReq;
+ if (sizeof(EPWR_SESSION_TYPE) == FrameworkunifiedGetMsgLength(h_app)) {
+ if (eFrameworkunifiedStatusOK
+ == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tOpenSessionReq,
+ sizeof(EPWR_SESSION_TYPE)))) {
+ switch (tOpenSessionReq) {
+ case epsstBASIC: {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Subscriber : %s , open a session using type: BASIC",
+ subscriber.c_str());
+ FrameworkunifiedProtocolCallbackHandler ss_power_session_basic_handlers[] = { {
+ PROTOCOL_OPEN_SESSION_REQ, PowerCallback<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> } };
+
+ // Attach callback : Power Session Requests
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, subscriber.c_str(), ss_power_session_basic_handlers, _countof(ss_power_session_basic_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR(
+ "FrameworkunifiedAttachCallbacksToDispatcher(ss_power_session_basic_handlers)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Subscriber '%s' opened a type 'BASIC' session",
+ subscriber.c_str());
+ }
+ break;
+ case epsstSUPERVISOR: {
+ FrameworkunifiedProtocolCallbackHandler ss_power_sprv_session_handlers[] = { {
+ PROTOCOL_OPEN_SESSION_REQ, PowerCallback<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> }, {
+ SS_POWER_FWD_START_CONFIRMATION_MSG_REQ, PowerCallback<Power,
+ &Power::OnSendStartupConfirmationRequest> }, {
+ SS_POWER_STATE_CHANGE_REQ, PowerCallback<Power,
+ &Power::OnSetPowerState> }, { SS_POWER_SHUTDOWN_REQ,
+ PowerCallback<Power, &Power::OnShutdownRequestMsg> }
+ , { SS_POWER_SYSTEM_MODE_INFO_REQ, PowerCallback<Power,
+ &Power::OnSystemModeInfoRequest> }, {
+ SS_POWER_PUBLISH_SHUTDOWN_CONDITION_REQ, PowerCallback<
+ Power, &Power::OnPublishShutdownPopupRequest> }, {
+ SS_POWER_PUBLISH_POWER_POPUP_REQ, PowerCallback<Power,
+ &Power::OnPublishPowerPopupRequest> }, {
+ SS_POWER_POWER_REQUEST_MSG, PowerCallback<Power,
+ &Power::OnPowerRequestMsg> } };
+
+ // Attach callback : Power Supervisor Session Requests
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, subscriber.c_str(), ss_power_sprv_session_handlers, _countof(ss_power_sprv_session_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR(
+ "FrameworkunifiedAttachCallbacksToDispatcher(ss_power_sprv_session_handlers)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Subscriber '%s' opened a 'SUPERVISOR' session",
+ subscriber.c_str());
+ newEntry.esessiontype = tOpenSessionReq;
+
+ static BOOL first_supervisor = TRUE;
+ if (first_supervisor) {
+ AttachCallbackToSystemManager( // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ h_app, SS_SM_SYSTEM_MODE_INFO_RSPN,
+ PowerCallback<Power, &Power::OnSystemModeInfoResponse>);
+ first_supervisor = FALSE;
+ }
+ }
+ break;
+ case epsstSYSTEM: {
+ FrameworkunifiedProtocolCallbackHandler ss_power_system_session_handlers[] = {
+ { PROTOCOL_OPEN_SESSION_REQ, PowerCallback<Power,
+ &Power::OnOpenSession> }, { PROTOCOL_CLOSE_SESSION_REQ,
+ PowerCallback<Power, &Power::OnCloseSession> }, {
+ SS_POWER_SYSTEM_LAUNCH_COMPLETE, PowerCallback<Power,
+ &Power::OnSystemLaunchComplete> }, {
+ SS_POWER_SHUTDOWN_RESP, PowerCallback<Power,
+ &Power::OnSystemShutdownComplete> } };
+
+ // Attach callback : Power System Session Requests
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, subscriber.c_str(), ss_power_system_session_handlers, _countof(ss_power_system_session_handlers)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR(
+ "FrameworkunifiedAttachCallbacksToDispatcher(ss_power_session_handlers)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ // LCOV_EXCL_STOP 4: NSFW error case.
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Subscriber '%s' opened a 'SYSTEM' session",
+ subscriber.c_str());
+ newEntry.esessiontype = tOpenSessionReq;
+ }
+ break;
+ case epsstUNKNOWN: {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Subscriber '%s' tried to open a type 'UNKNOWN' session",
+ subscriber.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // insert this newEntry into the map
+ m_mapSessions.insert(make_pair(subscriber, newEntry));
+ } else {
+ // This Subscriber is already in our map, just send and ack to keep them quote.
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO, __FUNCTION__,
+ "Subscriber : %s , is already in the map, will Just send back an ACK",
+ iter->second.sz_name.c_str());
+ if (NULL != iter->second.hsession) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ OpenSessionAck openSessionAck;
+ memset(&openSessionAck, 0, sizeof(openSessionAck));
+ strcpy(openSessionAck.cSessionName, SERVICE_POWER); // NOLINT (runtime/printf)
+ openSessionAck.eStatus = eFrameworkunifiedStatusOK;
+ // I can't think of a reason why we would need more that one session per subscriber.
+ openSessionAck.sessionId = 0;
+
+ // Send Ack to subscriber
+ l_eStatus = FrameworkunifiedSendMsg(iter->second.hsession, PROTOCOL_OPEN_SESSION_ACK,
+ sizeof(OpenSessionAck), (PVOID) &openSessionAck);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "FrameworkunifiedSendMsg Success to : %s , status: 0x%x",
+ iter->second.sz_name.c_str(), l_eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "What! NULL == iter->second.hsession TODO: Need to handle this!");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+///
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus PowerSessionHandler::StopComplete(HANDLE h_app) { // LCOV_EXCL_START 8: can not be called
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // ToDo Jay 2012 November 02 Can this be deleted ?
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " No-op function - It's here, but it doesn't do anything");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP 8: can not be called
+
+///////////////////////////////////////////////////////////////////////
+/// ProcessVoltageNotifyRequest
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::PublishVoltageStateChange(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ PowerSrvLVIStatus l_LVIStatus;
+ PowerSrvLevelType l_PowerLevel;
+
+ switch (m_VoltageState) { // LCOV_EXCL_BR_LINE 6: double check
+ case epsvsNORMAL:
+ l_PowerLevel = epspltNORMAL;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLevel, &l_PowerLevel, sizeof(PowerSrvLevelType));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLevel ", epspltNORMAL)");
+
+ l_LVIStatus = ePwSrvLVI_Status_InActive;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI1, &l_LVIStatus, sizeof(PowerSrvLVIStatus));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI1 ", ePwSrvLVI_Status_InActive)");
+
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI2, &l_LVIStatus, sizeof(PowerSrvLVIStatus));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI2 ", ePwSrvLVI_Status_InActive)");
+ break;
+
+ case epsvsLVI1:
+ l_PowerLevel = epspltEMERGENCY;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLevel, &l_PowerLevel, sizeof(PowerSrvLevelType));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLevel ", epspltEMERGENCY)");
+
+ l_LVIStatus = ePwSrvLVI_Status_Active;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI1, &l_LVIStatus, sizeof(PowerSrvLVIStatus));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI1 ", ePwSrvLVI_Status_Active)");
+
+ l_LVIStatus = ePwSrvLVI_Status_InActive;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI2, &l_LVIStatus, sizeof(PowerSrvLVIStatus));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI2 ", ePwSrvLVI_Status_InActive)");
+ break;
+
+ case epsvsLVI2:
+ l_PowerLevel = epspltEMERGENCY;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLevel, &l_PowerLevel, sizeof(PowerSrvLevelType));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLevel ", epspltEMERGENCY)");
+
+ l_LVIStatus = ePwSrvLVI_Status_InActive;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI1, &l_LVIStatus, sizeof(PowerSrvLVIStatus));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI1 ", ePwSrvLVI_Status_InActive)");
+
+ l_LVIStatus = ePwSrvLVI_Status_Active;
+l_eStatus = FrameworkunifiedNPPublishNotification(h_app, szNTFY_PowerLVI2, &l_LVIStatus, sizeof(PowerSrvLVIStatus));
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus,
+ "FrameworkunifiedNPPublishNotification(" szNTFY_PowerLVI2 ", ePwSrvLVI_Status_Active)");
+ break;
+
+ case epsvsINVALID:
+ // LCOV_EXCL_START 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR(" epsvsINVALID == m_VoltageState");
+ break;
+ // LCOV_EXCL_STOP 6: double check
+
+ default:
+ // LCOV_EXCL_START 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Invalid 'm_VoltageState' value detected: 0x%X/%d",
+ m_VoltageState, m_VoltageState);
+ break;
+ // LCOV_EXCL_STOP 6: double check
+ }
+
+ SS_PWR_LOG_HIST("PublishVoltageStateChange()", m_PubCmdHist, m_PubHistIter,
+ "", l_eStatus);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////
+/// OnSystemModeInfoResponse
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnSystemModeInfoResponse(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SystemModeInfo l_SystemModeInfo;
+
+ std::memset(&l_SystemModeInfo, 0, sizeof(SystemModeInfo));
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<SystemModeInfo>(h_app, l_SystemModeInfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Sending SS_POWER_SYSTEM_MODE_INFO_RESP to PSM");
+ // send Wake-up complete response to System Power Manager
+ l_eStatus = m_oSessionHandler.SendToSupervisor(
+ SS_POWER_SYSTEM_MODE_INFO_RESP, sizeof(SystemModeInfo),
+ (PVOID) &l_SystemModeInfo);
+
+ SS_PWR_LOG_HIST("SS_POWER_SYSTEM_MODE_INFO_RESP", m__CWORD56_RepHist,
+ m__CWORD56_RepIter, "", l_eStatus);
+
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus, "m_oSessionHandler.SendToSupervisor( "
+ "SS_POWER_SYSTEM_MODE_INFO_RESP)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnSystemModeInfoRequest
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnSystemModeInfoRequest(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = SendSystemModeRequestToSystemManager())) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("SendSystemModeRequestToSystemManager()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnInitCompReport
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnInitCompReport(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = SendInitCompReportToSystemManager())) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("SendInitCompReportToSystemManager()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnCurrentPowerStateQuery
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnCurrentPowerStateQuery(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SS_PSCurrentState l_CurrentState;
+ std::memset(&l_CurrentState, 0, sizeof(SS_PSCurrentState));
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<SS_PSCurrentState>(h_app, l_CurrentState))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = ConstructPwrStateResponse(l_CurrentState.printRespmsg))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 8: dead code.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ConstructPwrStateResponse(l_CurrentState.printRespmsg)");
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Response is %s",
+ l_CurrentState.printRespmsg);
+ // Send Power State to client
+
+ HANDLE l_handle = FrameworkunifiedOpenService(h_app, FrameworkunifiedGetMsgSrc(h_app));
+ if (NULL != l_handle) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ l_eStatus = FrameworkunifiedSendMsg(l_handle, SS_POWER_CRNT_STATE_QUERY_RSPN,
+ sizeof(SS_PSCurrentState),
+ (PVOID) &l_CurrentState);
+
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus, "FrameworkunifiedSendMsg(SS_POWER_CRNT_STATE_QUERY_RSPN)");
+
+ l_eStatus = FrameworkunifiedCloseService(h_app, l_handle);
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(l_eStatus,
+ "FrameworkunifiedCloseService()");
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. FrameworkunifiedOpenService(%s) returned NULL",
+ FrameworkunifiedGetMsgSrc(h_app));
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnSetVoltageState
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnSetVoltageState(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string stLvl = "INVALID";
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ Pwr_ServiceSetInterface l_VoltageState;
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, l_VoltageState))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ m_VoltageState = static_cast<ePowerSrvVoltageStates>(l_VoltageState.data
+ .voltage.state);
+ if (eFrameworkunifiedStatusOK != (l_eStatus = PublishVoltageStateChange(h_app))) { // LCOV_EXCL_BR_LINE 4:NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("PublishVoltageStateChange()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ SS_PWR_LOG_HIST("OnSetVoltageState", m_PubCmdHist, m_PubHistIter,
+ "PublishVoltageStateChange()", l_eStatus);
+
+ switch (l_VoltageState.data.voltage.state) {
+ case epsvsINVALID: {
+ stLvl = "INVALID";
+ }
+ break;
+
+ case epsvsNORMAL: {
+ stLvl = "NORMAL";
+ }
+ break;
+
+ case epsvsLVI1: {
+ stLvl = "LVI1";
+ }
+ break;
+
+ case epsvsLVI2: {
+ stLvl = "LVI2";
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ SS_PWR_LOG_HIST("OnSetVoltageState()", m_VCmdHist, m_VHistIter, stLvl,
+ l_eStatus);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnSetCrankState
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::OnSetCrankState(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ Pwr_ServiceSetInterface l_CrankState;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, l_CrankState))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ m_CrankState = static_cast<ePowerSrvCrankStates>(l_CrankState.data.crank
+ .state);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus Power::OnSystemMgrConnectionEstablished(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = FrameworkunifiedPublishServiceAvailability(h_app, TRUE);
+
+ SS_PWR_LOG_HIST("FrameworkunifiedPublishServiceAvailability()", m_PubCmdHist,
+ m_PubHistIter, "", l_eStatus);
+
+ LOG_STATUS(l_eStatus,
+ "FrameworkunifiedPublishServiceAvailability(" szNTFY_PowerAvailability ",TRUE)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus Power::OnUserModeResponse(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ EPWR_USER_MODE_TYPE l_eUserModeState = epsumINVALID;
+ Pwr_ServiceSetInterface tServiceSetIf;
+
+ l_eStatus = ValidateUserModeMessage(h_app, l_eUserModeState);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("ValidateUserModeMessage(&l_eUserModeState)");
+ } else {
+ PCSTR p_sStateName = l_eUserModeState == epsumON ? "epsumON" : "epsumOFF";
+ tServiceSetIf.data.user_mode.mode = l_eUserModeState;
+
+ l_eStatus = m_oSessionHandler.SendToSupervisor(
+ SS_POWER_USER_MODE_SET_RESP, sizeof(Pwr_ServiceSetInterface),
+ (PVOID) &tServiceSetIf);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Error: m_oSessionHandler.SendToSupervisor(" " SS_POWER_USER_MODE_SET_RESP, %s) errored: %d/'%s'",
+ p_sStateName, l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ SS_PWR_LOG_HIST("SS_POWER_USER_MODE_SET_RESP", m__CWORD56_RepHist,
+ m__CWORD56_RepIter, p_sStateName, l_eStatus);
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ " m_oSessionHandler.SendToSupervisor(" " SS_POWER_USER_MODE_SET_RESP, %s) successful ",
+ p_sStateName);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnUserModeResponse( HANDLE h_app )
+
+EFrameworkunifiedStatus Power::ValidateUserModeMessage(
+ HANDLE h_app, EPWR_USER_MODE_TYPE &l_eUserModeState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ Pwr_ServiceSetInterface tServiceSetIf;
+ EPWR_USER_MODE_TYPE l_my_eUserModeState;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ l_my_eUserModeState = tServiceSetIf.data.user_mode.mode;
+ switch (l_my_eUserModeState) {
+ case epsumINVALID:
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("l_eUserModeState == epsumINVALID");
+ break;
+
+ case epsumOFF:
+ case epsumON:
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Validated '%s'",
+ l_my_eUserModeState == epsumON ? "epsumON" : "epsumOFF");
+ l_eUserModeState = l_my_eUserModeState;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Unknown 'l_my_eUserModeState' value: 0x%x",
+ l_my_eUserModeState);
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+ } // End switch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::ValidateUserModeMessage( HANDLE h_app, EPWR_USER_MODE_TYPE &l_eUserModeState )
+
+//*****************************************************************************
+// Start Confirmation Protocol callback functions
+//
+EFrameworkunifiedStatus Power::OnSendStartupConfirmationRequest(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ EFrameworkunifiedStatus l_responseStatus = eFrameworkunifiedStatusOK;
+ Pwr_ServiceSetInterface tServiceSetIf;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ StartupConfirmationMsgStrut l_startupConfirmationMsg = tServiceSetIf.data
+ .startupConfirmationMsg;
+ l_eStatus = SendStartupConfirmationToSystemManager(
+ l_startupConfirmationMsg);
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus, "SendStartupConfirmationToSystemManager()");
+ }
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:interface_unified if can not be error.
+ // LCOV_EXCL_START 200:interface_unified if can not be error.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_responseStatus = l_eStatus; // Save the current status as-is to
+ // send in the message response to the
+ // requester.
+ l_eStatus = m_oSessionHandler.SendToSupervisor(
+ SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, sizeof(EFrameworkunifiedStatus),
+ (PVOID) &l_responseStatus);
+
+ SS_PWR_LOG_HIST("SS_POWER_FWD_START_CONFIRMATION_MSG_RESP", m__CWORD56_RepHist,
+ m__CWORD56_RepIter, "", l_eStatus);
+
+ LOG_STATUS(
+ l_eStatus,
+ "m_oSessionHandler.SendToSupervisor( " "SS_POWER_FWD_START_CONFIRMATION_MSG_RESP)");
+ // LCOV_EXCL_STOP 200:interface_unified if can not be error.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " SendStartupConfirmationToSystemManager() successful");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnSendStartupConfirmationRequest( HANDLE h_app )
+
+EFrameworkunifiedStatus Power::OnSendStartupConfirmationResponse(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ EFrameworkunifiedStatus l_responseStatus;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<EFrameworkunifiedStatus>(h_app, l_responseStatus))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ l_eStatus = m_oSessionHandler.SendToSupervisor(
+ SS_POWER_FWD_START_CONFIRMATION_MSG_RESP, sizeof(EFrameworkunifiedStatus),
+ (PVOID) &l_responseStatus);
+
+ SS_PWR_LOG_HIST("SS_POWER_FWD_START_CONFIRMATION_MSG_RESP", m__CWORD56_RepHist,
+ m__CWORD56_RepIter, "", l_eStatus);
+
+ LOG_STATUS(
+ l_eStatus,
+ "m_oSessionHandler.SendToSupervisor(" " SS_POWER_FWD_START_CONFIRMATION_MSG_RESP)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnSendStartupConfirmationResponse( HANDLE h_app )
+//
+// End of Start Confirmation Protocol callback functions
+//*****************************************************************************
+
+//*****************************************************************************
+// Start HeartBeat Protocol callback functions
+// Theory of operation: Forward HB request to SM. If SM crashes, then the HB
+// will cease between SM and the _CWORD56_. Consequently, the _CWORD56_ will reset the
+// system.
+EFrameworkunifiedStatus Power::On_CWORD56_HeartBeatRequest(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EPWR_HB_REQ_MSG_STRUCT l_HbReq;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "_CWORD56_ HeartBeat Request received.");
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<EPWR_HB_REQ_MSG_STRUCT>(h_app, l_HbReq))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = Send_CWORD56_HeartBeatRequestToSystemManager(l_HbReq))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("Send_CWORD56_HeartBeatRequestToSystemManager()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus Power::OnSM_CWORD56_HeartBeatResponse(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from SM.");
+
+ l_eStatus = m_oSessionHandler.SendToSupervisor(SS_POWER_HEARTBEAT_RESP, 0,
+ NULL);
+
+ SS_PWR_LOG_HIST("SS_POWER_HEARTBEAT_RESP", m__CWORD56_RepHist, m__CWORD56_RepIter, "",
+ l_eStatus);
+
+ LOG_STATUS(l_eStatus,
+ "m_oSessionHandler.SendToSupervisor( SS_POWER_HEARTBEAT_RESP)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+//
+// End of Heartbeat Protocol callback functions
+//*****************************************************************************
+
+//*****************************************************************************
+// Start CPU Reset Request Protocol callback functions
+//
+EFrameworkunifiedStatus Power::OnCpuResetRequest(HANDLE h_app) { // SS_SM_CPU_RESET_REQ
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSystemManagerCpuResetInfo l_SmCpuResetInfo; // SS Type
+ SS_Pwr_CpuResetMsgStruct l_PsCpuResetInfo; // SS Type translated to PSM type.
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<TSystemManagerCpuResetInfo>(h_app, l_SmCpuResetInfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CPU Reset Type: %d",
+ l_SmCpuResetInfo.resetReason);
+
+ switch (l_SmCpuResetInfo.resetReason) {
+ case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR:
+ case e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR:
+ l_PsCpuResetInfo.resetReason = epsCpuResetReasonGeneric;
+ break;
+
+ case e_SS_SM_CPU_RESET_REASON_DSP_ERR:
+ l_PsCpuResetInfo.resetReason = epsCpuResetReasonFatalError;
+ break;
+
+ case e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET:
+ l_PsCpuResetInfo.resetReason = epsCpuResetReasonUserForceReset;
+ break;
+
+ case e_SS_SM_CPU_RESET_REASON_NORMAL:
+ l_PsCpuResetInfo.resetReason = epsCpuResetReasonNormalReset;
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Reset reason '%d' not defined",
+ l_SmCpuResetInfo.resetReason);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (eFrameworkunifiedStatusInvldParam);
+ }
+
+ snprintf(l_PsCpuResetInfo.messageStr, PWR_RESET_MSG_STR_SIZE, "%s",
+ l_SmCpuResetInfo.messageStr);
+
+ l_eStatus = m_oSessionHandler.SendToSupervisor(SS_POWER_HARD_RESET_REQ,
+ sizeof(l_PsCpuResetInfo),
+ (PVOID) &l_PsCpuResetInfo);
+
+ SS_PWR_LOG_HIST("SS_POWER_HARD_RESET_REQ", m__CWORD56_RepHist, m__CWORD56_RepIter, "",
+ l_eStatus);
+
+ LOG_STATUS_IF_ERRORED_PWR_SM_WITH_HIST_LOGGING(
+ l_eStatus, "m_oSessionHandler.SendToSupervisor( "
+ "SS_POWER_HARD_RESET_REQ)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//
+// End of CPU Reset Request Protocol callback functions
+//*****************************************************************************
+
+///////////////////////////////////////////////////////////////////////
+/// SetCmdHist
+///
+///
+//////////////////////////////////////////////////////////////////////
+void Power::SetCmdHist(std::string cmd, cmdHist &hist, cmdHistIter &it,
+ std::string sender) {
+ pthread_mutex_lock(&pwr_hist_mutex);
+
+ UI_64 l_clkcycles = ClockCycle();
+ /* find out how many cycles per millisecond */
+ UI_64 l_totalmsec = l_clkcycles / 1000;
+
+ it->m_time = l_totalmsec;
+ it->m_cmd = cmd;
+ it->m_sender = sender;
+ it++;
+
+ if (it == hist.end()) {
+ it = hist.begin();
+ }
+
+ pthread_mutex_unlock(&pwr_hist_mutex);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SSPowerDebugDump
+/// implement post mortem function
+///
+/// \param
+///
+/// \return void
+///////////////////////////////////////////////////////////////////////////////
+VOID Power::SSPowerDebugDump(HANDLE h_app) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ char l_debugDumpData[SS_PWR_DEBUG_DUMP_MAX_SIZE];
+ UI_16 l_byteCount = 0;
+ cmdHistIter i;
+ memset((void*) l_debugDumpData, 0x00, sizeof(l_debugDumpData)); // NOLINT (readability/casting)
+
+ l_byteCount = snprintf(l_debugDumpData, SS_PWR_DEBUG_DUMP_MAX_SIZE,
+ ("\n <SS POWER DUMP DATA> \n"));
+
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n ***Error history***\n");
+
+ for (i = m_ErrHist.begin(); i != m_ErrHist.end(); ++i) {
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n %s @ %llums EC:%s \n", i->m_cmd.c_str(),
+ i->m_time, i->m_sender.c_str());
+ }
+
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n ***_CWORD56_ Reply history***\n");
+
+ for (i = m__CWORD56_RepHist.begin(); i != m__CWORD56_RepHist.end(); ++i) {
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n %s @ %llums\n", i->m_cmd.c_str(), i->m_time);
+ }
+
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n ***Voltage history***\n");
+
+ for (i = m_VCmdHist.begin(); i != m_VCmdHist.end(); ++i) {
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n %s @ %llums %s \n", i->m_cmd.c_str(), i->m_time,
+ i->m_sender.c_str());
+ }
+
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n ***Publishshing history***\n");
+
+ for (i = m_PubCmdHist.begin(); i != m_PubCmdHist.end(); ++i) {
+ l_byteCount += snprintf(l_debugDumpData + l_byteCount,
+ SS_PWR_DEBUG_DUMP_MAX_SIZE - l_byteCount,
+ "\n %s @ %llums \n", i->m_cmd.c_str(), i->m_time);
+ }
+
+ SSDEBUGDUMP("%s", (const char *) &l_debugDumpData);
+}
+// LCOV_EXCL_STOP 7:debug code
+
+//*****************************************************************************
+// Start Remote Data Reset Protocol callback functions
+// From SM to PS
+EFrameworkunifiedStatus Power::OnRemoteDataResetRequest(HANDLE h_app) { // SS_SM_REMOTE_DATA_RESET_REQ
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ESMDataResetType l_eSmDataResetType; // SS Type
+ epsCpuResetReason l_ePsCpuResetReason; // SS Type translated to PSM CPU reset reason.
+ BOOL l_bResetRequired;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<ESMDataResetType>(h_app, l_eSmDataResetType))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Remote Data Reset Type: %d",
+ l_eSmDataResetType);
+ l_bResetRequired = FALSE;
+ switch (l_eSmDataResetType) {
+ case e_SS_SM_DATA_RESET_TYPE_USER:
+ l_ePsCpuResetReason = epsCpuResetReasonUserDataReset;
+ l_bResetRequired = TRUE;
+ break;
+
+ case e_SS_SM_DATA_RESET_TYPE_FACTORY:
+ l_ePsCpuResetReason = epsCpuResetReasonFactoryDataReset;
+ l_bResetRequired = TRUE;
+ break;
+
+ case e_SS_SM_DATA_RESET_TYPE_CONFIGURATION: // No reset action required.
+ l_bResetRequired = FALSE;
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Remote Reset Data type : %d not defined",
+ l_eSmDataResetType);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (eFrameworkunifiedStatusInvldParam);
+ }
+
+ if (TRUE == l_bResetRequired) {
+ SS_Pwr_CpuResetMsgStruct l_PsCpuResetInfo = { };
+ l_PsCpuResetInfo.resetReason = l_ePsCpuResetReason;
+ l_eStatus = m_oSessionHandler.SendToSupervisor(SS_POWER_HARD_RESET_REQ,
+ sizeof(l_PsCpuResetInfo),
+ (PVOID) &l_PsCpuResetInfo);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Error: m_oSessionHandler.SendToSupervisor( " "SS_POWER_HARD_RESET_REQ, Reason '%d') errored:%d/'%s'",
+ l_ePsCpuResetReason, l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_POWER_HARD_RESET_REQ Reason '%d' sent to PSMShadow",
+ l_ePsCpuResetReason);
+ }
+ SS_PWR_LOG_HIST("SS_POWER_HARD_RESET_REQ", m__CWORD56_RepHist, m__CWORD56_RepIter,
+ "", l_eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//
+// End of Remote Data Reset Protocol callback functions
+//*****************************************************************************
+
+// EOF of /SS_PowerService/src/ss_power.cpp
+
diff --git a/systemservice/power_service/server/src/ss_power_config.cpp b/systemservice/power_service/server/src/ss_power_config.cpp
new file mode 100755
index 0000000..3975b56
--- /dev/null
+++ b/systemservice/power_service/server/src/ss_power_config.cpp
@@ -0,0 +1,188 @@
+/*
+ * @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_PowerService
+/// \brief This file supports power service configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include "ss_power_config.h"
+
+// define all the configuration parmeters that will be used to get data
+const char * PowerConfiguration::kPowerLogicPlugin = "PowerLogicPlugin.dll";
+const char * PowerConfiguration::kLVI1Timeout = "LVI1.Timeouts_Timeout";
+const char * PowerConfiguration::kLVI1HysteresisTimeout =
+ "LVI1.Hysteresis_Timeout";
+const char * PowerConfiguration::kLVI1HysteresisEnabled =
+ "LVI1.Hysteresis_Enabled";
+const char * PowerConfiguration::kLVI1HysteresisTries = "LVI1.Hysteresis_Tries";
+const char * PowerConfiguration::kLVI2Timeout = "LVI2.Timeouts_Timeout";
+const char * PowerConfiguration::kLVI2HysteresisTimeout =
+ "LVI2.Hysteresis_Timeout";
+const char * PowerConfiguration::kLVI2HysteresisEnabled =
+ "LVI2.Hysteresis_Enabled";
+const char * PowerConfiguration::kLVI2HysteresisTries = "LVI2.Hysteresis_Tries";
+const char * PowerConfiguration::kShutdownTimeout = "Shutdown.Timeouts_Timeout";
+const char * PowerConfiguration::kShutdownHysteresisTimeout =
+ "Shutdown.Hysteresis_Timeout";
+const char * PowerConfiguration::kShutdownHysteresisEnabled =
+ "Shutdown.Hysteresis_Enabled";
+const char * PowerConfiguration::kShutdownHysteresisTries =
+ "Shutdown.Hysteresis_Tries";
+/// < defines the names in the cfg file that are used to get required modules names
+const char * PowerConfiguration::kRequiredWakeupModules =
+ "Wakeup.RequiredModules."; /// < once all the modules have been wakened up send wake-up complete
+const char * PowerConfiguration::kRequiredShutdownModules =
+ "Shutdown.RequiredModules."; /// < once all the modules have been shutdown send shutdown complete
+const char * PowerConfiguration::kRequiredLvi2Modules =
+ "LVI2.RequiredModules."; /// < once all the modules have been wakened up send wake-up complete
+
+PowerConfiguration::PowerConfiguration(std::string f_configfilename)
+ : m_ConfigFileName(f_configfilename) {
+}
+
+PowerConfiguration::~PowerConfiguration() {
+}
+
+BOOL PowerConfiguration::LoadParameters(PowerConfigParams & params) {
+ EFrameworkunifiedStatus l_eStatus;
+ BOOL l_rtnCode = FALSE;
+
+ CNSConfigReader *l_pReaderCfg = new CNSConfigReader();
+ if (NULL == l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5:new error case
+ // LCOV_EXCL_START 5:new error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. new CNSConfigReader() returned NULL pointer.");
+ // LCOV_EXCL_STOP 5:new error case
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(m_ConfigFileName))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->Open(%s) returned NULL pointer.",
+ m_ConfigFileName.c_str());
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kShutdownTimeout,
+ params.shutdown.timeout))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(ShutdownTimeout)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kLVI1Timeout, params.lvi1.timeout))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(LVI1Timeout)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kLVI2Timeout, params.lvi2.timeout))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(LVI2Timeout)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kShutdownHysteresisTimeout,
+ params.shutdown.hysteresis.timeout))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(ShutdownHysteresisTimeout)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kLVI1HysteresisTimeout,
+ params.lvi1.hysteresis.timeout))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(LVI1HysteresisTimeout)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kLVI2HysteresisTimeout,
+ params.lvi2.hysteresis.timeout))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(LVI2HysteresisTimeout)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kShutdownHysteresisTries,
+ params.shutdown.hysteresis.tries))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(ShutdownHysteresisTries)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kLVI1HysteresisTries,
+ params.lvi1.hysteresis.tries))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(LVI1HysteresisTries)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(kLVI2HysteresisTries,
+ params.lvi2.hysteresis.tries))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(LVI2HysteresisTries)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetBool(
+ kShutdownHysteresisEnabled, params.shutdown.hysteresis.enabled))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(ShutdownHysteresisEnabled)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetBool(kLVI1HysteresisEnabled,
+ params.lvi1.hysteresis.enabled))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(LVI1HysteresisEnabled)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetBool(kLVI2HysteresisEnabled,
+ params.lvi2.hysteresis.enabled))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "l_pReaderCfg->GetInt(LVI2HysteresisEnabled)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetString(kPowerLogicPlugin,
+ params.power_logic_plugin))) {
+ LOG_STATUS_IF_ERRORED(l_eStatus, "l_pReaderCfg->GetInt(PowerLogicPlugin)");
+ } else {
+ l_rtnCode = TRUE;
+ }
+
+ delete l_pReaderCfg;
+ }
+
+ return (l_rtnCode);
+}
+
+void PowerConfiguration::LoadDefaultParameters(PowerConfigParams & params) {
+ params.power_logic_plugin = "ss_powerlogic.dll";
+ params.shutdown.timeout = 600; // thats 5mins
+ params.shutdown.hysteresis.enabled = FALSE; // There should be hysteresis for Shutdown
+ params.shutdown.hysteresis.timeout = 0; // Don't Care since disabled.
+ params.shutdown.hysteresis.tries = 0; // Don't Care since disabled.
+ params.lvi1.timeout = 2; // thats 2secs
+ params.lvi1.hysteresis.enabled = TRUE; // Enable LVI1 hysteresis
+ params.lvi1.hysteresis.tries = 2; // check twice before switching to LVI1
+ params.lvi1.hysteresis.timeout = 500; // thats 500 msecs
+ params.lvi2.timeout = 2; // thats 2secs
+ params.lvi2.hysteresis.enabled = TRUE; // Enable LVI2 hysteresis
+ params.lvi2.hysteresis.tries = 2; // check twice before switching to LVI2
+ params.lvi2.hysteresis.timeout = 100; // thats 100 msecs
+}
+
+void PowerConfiguration::PrintConfigInfo(PowerConfigParams & f_params) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.timeout: %d",
+ f_params.shutdown.timeout);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.timeout: %d", f_params.lvi1.timeout);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi2.timeout: %d", f_params.lvi2.timeout);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.hysteresis.timeout: %d",
+ f_params.shutdown.hysteresis.timeout);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.timeout: %d",
+ f_params.lvi1.hysteresis.timeout);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi2.hysteresis.timeout: %d",
+ f_params.lvi2.hysteresis.timeout);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.hysteresis.tries: %d",
+ f_params.shutdown.hysteresis.tries);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.tries: %d",
+ f_params.lvi1.hysteresis.tries);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.tries: %d",
+ f_params.lvi1.hysteresis.tries);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown.hysteresis.enabled: %d",
+ f_params.shutdown.hysteresis.enabled);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi1.hysteresis.enabled: %d",
+ f_params.lvi1.hysteresis.enabled);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "lvi2.hysteresis.enabled: %d",
+ f_params.lvi2.hysteresis.enabled);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "power_logic_plugin: %s",
+ f_params.power_logic_plugin.c_str());
+ return;
+}
diff --git a/systemservice/power_service/server/src/ss_power_session.cpp b/systemservice/power_service/server/src/ss_power_session.cpp
new file mode 100755
index 0000000..20db4a9
--- /dev/null
+++ b/systemservice/power_service/server/src/ss_power_session.cpp
@@ -0,0 +1,276 @@
+/*
+ * @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_Power
+/// \brief This file supports power service session management.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_power_session.h"
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service_local.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+#include "ss_power_powerservicelog.h"
+
+
+PowerSessionHandler::PowerSessionHandler() {
+ // TODO(my_username) Auto-generated constructor stub
+}
+
+PowerSessionHandler::~PowerSessionHandler() { // LCOV_EXCL_START 14 Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // TODO(my_username) Auto-generated destructor stub
+}
+// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
+
+EFrameworkunifiedStatus PowerSessionHandler::CloseSession(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(h_app);
+
+ // find the subscriber...
+ PwSessionIter iter = m_mapSessions.find(FrameworkunifiedGetMsgSrc(h_app));
+
+ // the iter is set to the end then the subscriber is not in the map
+ if (m_mapSessions.end() == iter) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error: Subscriber '%s' was not found in the map; the Close " "Session Request is being ignored!",
+ FrameworkunifiedGetMsgSrc(h_app));
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ } else if (NULL == iter->second.hsession) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("Client's PwSessionInfo handle");
+ // LCOV_EXCL_STOP 11:unexpected branch
+ } else {
+ CloseSessionAck closeSessionAck;
+ closeSessionAck.sessionId = FrameworkunifiedGetSessionId(iter->second.hsession);
+ closeSessionAck.eStatus = eFrameworkunifiedStatusOK;
+
+ // Send Ack to subscriber
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(iter->second.hsession, PROTOCOL_CLOSE_SESSION_ACK, sizeof(CloseSessionAck), (PVOID) &closeSessionAck))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error: FrameworkunifiedSendMsg(%s, PROTOCOL_CLOSE_SESSION_ACK) " "errored: %d/'%s'",
+ iter->second.sz_name.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " FrameworkunifiedSendMsg(%s, PROTOCOL_CLOSE_SESSION_ACK) successful",
+ iter->second.sz_name.c_str());
+ iter->second.frunning = FALSE;
+
+ //
+ // ToDo Jay 2012 November 05 1) Can't detach just basic callbacks;
+ // client could be Supervisor or System. This has been solved
+ // in another Power Service Change Set. Need to get all
+ // Change Sets merged and delivered.
+ UI_32 ss_power_basic_session_ids[] = { PROTOCOL_CLOSE_SESSION_REQ };
+
+ // Detach callback : Power System Session Requests
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(h_app, iter->second.sz_name.c_str(), ss_power_basic_session_ids, _countof(ss_power_basic_session_ids)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedDetachCallbacksFromDispatcher()");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " FrameworkunifiedDetachCallbacksFromDispatcher() successful");
+ }
+
+ CALL_AND_LOG_STATUS(FrameworkunifiedDestroySession(h_app, iter->second.hsession));
+ iter->second.hsession = NULL;
+ m_mapSessions.erase(iter);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus PowerSessionHandler::StartComplete(HANDLE h_app) { // LCOV_EXCL_START 8: can not be called
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ StartCompleteAck ack;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<StartCompleteAck>(h_app, ack))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ } else {
+ // find the subscriber...
+ PwSessionIter iter = m_mapSessions.find(FrameworkunifiedGetMsgSrc(h_app));
+
+ // the iter is set to the end then the subscriber is not in the map
+ if (m_mapSessions.end() != iter) {
+ iter->second.sz_servicename = ack.szServiceName;
+ iter->second.frunning = TRUE;
+
+ if (AllClientsInGroupStarted(iter->second.ui_groupid)) {
+ // NOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Subscriber: %s , was not found in the map, the close session is being ignored!",
+ FrameworkunifiedGetMsgSrc(h_app));
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP 8: can not be called
+VOID PowerSessionHandler::Print() {
+ // find the subscriber...
+ PwSessionIter iter = m_mapSessions.begin();
+ for (; iter != m_mapSessions.end(); iter++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG_DUMP, __FUNCTION__,
+ " Power Service is session-connected to '%s'; running: %s",
+ iter->second.sz_name.data(), (iter->second.frunning ? "YES" : "NO"));
+ }
+}
+
+// LCOV_EXCL_START 8: can not be called
+BOOL PowerSessionHandler::WakeupComplete(RequiredModuleList & wakeup_modules) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL rtn = TRUE; // set the return TRUE until we find a missing module
+ RequiredModuleListIter iter = wakeup_modules.begin();
+ for (; iter != wakeup_modules.end(); iter++) {
+ PwSessionIter psi = m_mapSessions.find(*iter);
+ if (m_mapSessions.end() == psi) {
+ rtn = FALSE; // Module Not Found in Power Service Session Handler
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Required Wakeup: %s has not connected to Power Service, Wakeup NOT COMPLETE!",
+ iter->data());
+ } else if (FALSE == psi->second.frunning) {
+ rtn = FALSE; // Module Found in Power Service Session Handler but hasn't started yet
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Required Wakeup: %s has connected to Power Service but is not running (FrameworkunifiedStart Response missing),"
+ " Wakeup NOT COMPLETE!",
+ iter->data());
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return rtn;
+}
+// LCOV_EXCL_STOP 8: can not be called
+
+BOOL PowerSessionHandler::ShutdownComplete(
+ RequiredModuleList & shutdown_modules) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL rtn = TRUE; // set the return TRUE until we find a missing module
+ RequiredModuleListIter iter = shutdown_modules.begin();
+ for (; iter != shutdown_modules.end(); iter++) {
+ PwSessionIter psi = m_mapSessions.find(*iter);
+ if (m_mapSessions.end() == psi) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Required Shutdown: %s is not in Power Service session list, Shutdown pending!",
+ iter->data());
+ } else if (TRUE == psi->second.frunning) {
+ rtn = FALSE; // Module Found in Power Service Session Handler but hasn't stopped yet
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Required Shutdown: %s is connected to Power Service but is running (Stop Response missing),"
+ " Shutdown NOT COMPLETE!",
+ iter->data());
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return rtn;
+}
+
+EFrameworkunifiedStatus PowerSessionHandler::SendToSupervisor(UI_32 cmd, UI_32 length,
+ PVOID data) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL == data && length > 0) { // LCOV_EXCL_BR_LINE 6: it will not be true at the other place
+ // LCOV_EXCL_START 6: it will not be true at the other place
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("NULL == data && length > 0");
+ l_eStatus = eFrameworkunifiedStatusInvldBuf;
+ // LCOV_EXCL_STOP 6: it will not be true at the other place
+ } else {
+ // get first client from the map...
+ PwSessionIter iter = m_mapSessions.begin();
+ BOOL l_bFoundSupervisor = FALSE;
+
+ for (; iter != m_mapSessions.end() && !l_bFoundSupervisor; iter++) {
+ l_bFoundSupervisor = (epsstSUPERVISOR == iter->second.esessiontype);
+ if (l_bFoundSupervisor) {
+ l_eStatus = FrameworkunifiedSendMsg(iter->second.hsession, cmd, length, data);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg()");
+ }
+ }
+ if (!l_bFoundSupervisor) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ "Error: Did not find a Supervisor session; did not " "send cmd %d !",
+ cmd);
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+BOOL PowerSessionHandler::AllClientsInGroupStarted(UI_32 f_ungrpid) { // LCOV_EXCL_START 8: can not be called
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL fStatus = TRUE;
+ BOOL fGrpFnd = FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ PwSessionIter iter = m_mapSessions.begin();
+
+ if (iter == m_mapSessions.end())
+ fStatus = TRUE;
+
+ for (; iter != m_mapSessions.end() && fStatus; iter++) {
+ if (f_ungrpid == iter->second.ui_groupid) {
+ fGrpFnd = TRUE;
+ if (FALSE == iter->second.frunning) {
+ fStatus = FALSE;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- return flag: %s",
+ ((fStatus && fGrpFnd) ? "TRUE" : "FALSE"));
+ return (fStatus && fGrpFnd);
+}
+// LCOV_EXCL_STOP 8: can not be called
diff --git a/systemservice/power_service/server/src/ss_power_state_machine.cpp b/systemservice/power_service/server/src/ss_power_state_machine.cpp
new file mode 100755
index 0000000..28291e5
--- /dev/null
+++ b/systemservice/power_service/server/src/ss_power_state_machine.cpp
@@ -0,0 +1,924 @@
+/*
+ * @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_PowerService
+/// \brief This file supports the power service state machine.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "ss_power_state_machine.h"
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service_local.h>
+#include <system_service/ss_power_service_notifications_local.h>
+#include <system_service/ss_services.h>
+#include <native_service/ns_timer_if.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+
+#include "ss_power_session.h"
+#include "ss_power_powerservicelog.h"
+
+/// Define static members of the class.
+PowerStateMachine::Wakeup PowerStateMachine::WakeupState;
+PowerStateMachine::WakeupActive PowerStateMachine::WakeupActiveState;
+PowerStateMachine::WakeupPending PowerStateMachine::WakeupPendingState;
+PowerStateMachine::LowVoltage1 PowerStateMachine::LowVoltage1State;
+PowerStateMachine::LowVoltage1Active PowerStateMachine::LowVoltage1ActiveState;
+PowerStateMachine::LowVoltage2 PowerStateMachine::LowVoltage2State;
+PowerStateMachine::LowVoltage2Active PowerStateMachine::LowVoltage2ActiveState;
+PowerStateMachine::Shutdown PowerStateMachine::ShutdownState;
+PowerStateMachine::ShutdownActive PowerStateMachine::ShutdownActiveState;
+PowerStateMachine::NormalVoltage PowerStateMachine::NormalVoltageState;
+PowerStateMachine::SoftwareUpdate PowerStateMachine::SoftwareUpdateState;
+
+/// Constructor
+PowerStateMachine::PowerStateMachine()
+ : m_pCurrentState(&WakeupState),
+ m_pPreviousState(NULL),
+ m_pOnHysteresisTimeoutState(NULL),
+ m_oShutdownHysteresis(),
+ m_oLowVoltage1Hysteresis(),
+ m_oLowVoltage2Hysteresis(),
+ m_hHysteresisTimer(NULL),
+ m_tStateInfo() {
+}
+
+/// Deconstructor
+PowerStateMachine::~PowerStateMachine() { // LCOV_EXCL_START 14 Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
+
+void PowerStateMachine::onEvent(HANDLE h_app, PowerSessionHandler & oSession,
+ ePowerStateMachineEvents evt) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "(ENTRY) Power StateMachine Current State: %s, Previous State: %s",
+ m_pCurrentState->name(),
+ (m_pPreviousState == NULL ? "Ivalid" : m_pPreviousState->name()));
+
+ switch (evt) { // LCOV_EXCL_BR_LINE 8: dead code
+ case PowerStateMachine::epsmeWAKEUP:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeWAKEUP");
+ m_pCurrentState->onWakeup(*this, h_app, oSession);
+ break;
+ case PowerStateMachine::epsmeSTART_COMPLETE: // LCOV_EXCL_START 8: no one send the event
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSTART_COMPLETE");
+ m_pCurrentState->onStartComplete(*this, h_app, oSession);
+ break;
+ // LCOV_EXCL_STOP 8: no one send the event
+ case PowerStateMachine::epsmeSHUTDOWN:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSHUTDOWN");
+ m_pCurrentState->onShutdown(*this, h_app, oSession);
+ break;
+ case PowerStateMachine::epsmeSTOP_COMPLETE: // LCOV_EXCL_START 8: no one send the event
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSTOP_COMPLETE");
+ m_pCurrentState->onStopComplete(*this, h_app, oSession);
+ break;
+ case PowerStateMachine::epsmeLVI1_ENCOUNTERED:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_ENCOUNTERED");
+ m_pCurrentState->onLowVoltage1Encountered(*this, h_app, oSession);
+ break;
+ case PowerStateMachine::epsmeLVI2_ENCOUNTERED:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_ENCOUNTERED");
+ m_pCurrentState->onLowVoltage2Encountered(*this, h_app, oSession);
+ break;
+ case PowerStateMachine::epsmeNORMAL_VOLTAGE_ENCOUNTERED:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "Power StateMachine Event Received: epsmeNORMAL_VOLTAGE_ENCOUNTERED");
+ m_pCurrentState->onNormalVoltageEncountered(*this, h_app, oSession);
+ break;
+ case PowerStateMachine::epsmeSOFTWARE_UPDATE:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeSOFTWARE_UPDATE");
+ m_pCurrentState->onSoftwareUpdate(*this, h_app, oSession);
+ break;
+ case PowerStateMachine::epsmeSHUTDOWN_HYSTERESIS_ABORTED:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "Power StateMachine Event Received: epsmeSHUTDOWN_HYSTERESIS_ABORTED");
+ case PowerStateMachine::epsmeLVI1_HYSTERESIS_ABORTED:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_HYSTERESIS_ABORTED");
+ case PowerStateMachine::epsmeLVI2_HYSTERESIS_ABORTED:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_HYSTERESIS_ABORTED");
+ m_pCurrentState->onHysteresisAborted(*this, h_app, oSession);
+ break;
+ // LCOV_EXCL_STOP 8: no one send the event
+ case PowerStateMachine::epsmeSHUTDOWN_HYSTERESIS_TM_OUT:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ "Power StateMachine Event Received: epsmeSHUTDOWN_HYSTERESIS_TM_OUT"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ case PowerStateMachine::epsmeLVI1_HYSTERESIS_TM_OUT:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI1_HYSTERESIS_TM_OUT"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ case PowerStateMachine::epsmeLVI2_HYSTERESIS_TM_OUT:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: epsmeLVI2_HYSTERESIS_TM_OUT"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ m_pCurrentState->onHysteresisTimeout(*this, h_app, oSession);
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "Power StateMachine Event Received: WAS INVALID"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ break;
+ } // ZONE_POWER_STATEMACHINE
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "(EXIT) Power StateMachine Current State: %s, Previous State: %s",
+ m_pCurrentState->name(),
+ (m_pPreviousState == NULL ? "Ivalid" : m_pPreviousState->name()));
+}
+
+PCSTR PowerStateMachine::name() { // LCOV_EXCL_START 8: do not be called
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (NULL != m_pCurrentState) {
+ return m_pCurrentState->name();
+ }
+
+ return "Invalid Current State is NULL...";
+}
+// LCOV_EXCL_STOP 8: do not be called
+
+/// Switch to the next State and save the previous state.
+void PowerStateMachine::NextState(Base_State & refState, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ m_pPreviousState = m_pCurrentState;
+ m_pPreviousState->onExit(*this, h_app, oSession);
+ m_pCurrentState = &refState;
+ m_pCurrentState->onEntry(*this, h_app, oSession);
+}
+
+// LCOV_EXCL_START 8: do not be called
+void PowerStateMachine::OnVoltage(Base_State * pState, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (sizeof(Pwr_ServiceSetInterface) == FrameworkunifiedGetMsgLength(h_app)) {
+ Pwr_ServiceSetInterface tServiceIf;
+
+ if (eFrameworkunifiedStatusOK
+ == FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tServiceIf,
+ sizeof(Pwr_ServiceSetInterface))) {
+ /// Need to store the voltage information
+ m_tStateInfo.voltage = tServiceIf.data.voltage.state;
+
+ if (NULL != pState) {
+ NextState(*pState, h_app, oSession);
+ }
+ }
+ }
+}
+// LCOV_EXCL_STOP 8: do not be called
+void PowerStateMachine::GotoStateOnHysteresisTimeout(Base_State & refState) {
+ m_pOnHysteresisTimeoutState = &refState;
+}
+
+void PowerStateMachine::startHysteresisTimer(PowerStateHysteresis & hys_info) {
+ /// clear the try counter.
+ hys_info.clearTryCounter();
+
+ /// bump the hysteresis try counter (prime the counter).
+ hys_info.bumbTryCounter();
+
+ /// setup the hysteresis timer
+ NSTimerInfo turn_on_hysteresis = { WholeSeconds(hys_info.getTimeout()),
+ MSToNS(RemainderMs(hys_info.getTimeout())), 0, 0, 0 };
+
+ /// start the hysteresis timer
+ NS_TimerSetTime(m_hHysteresisTimer, turn_on_hysteresis);
+}
+
+void PowerStateMachine::reStartHysteresisTimer(
+ PowerStateHysteresis & hys_info) {
+ /// bump the hysteresis try counter.
+ hys_info.bumbTryCounter();
+
+ /// setup the hysteresis timer (one shot)
+ NSTimerInfo turn_on_hysteresis = { WholeSeconds(hys_info.getTimeout()),
+ MSToNS(RemainderMs(hys_info.getTimeout())), 0, 0, 0 };
+ /// start the hysteresis timer
+ NS_TimerSetTime(m_hHysteresisTimer, turn_on_hysteresis);
+}
+
+void PowerStateMachine::stopHysteresisTimer(PowerStateHysteresis & hys_info) {
+ NSTimerInfo turn_off_hysteresis = { 0, 0, 0, 0, 0 };
+ NS_TimerSetTime(m_hHysteresisTimer, turn_off_hysteresis);
+ /// clear the try counter.
+ hys_info.clearTryCounter();
+}
+
+// LCOV_EXCL_START 8: can not be called
+void PowerStateMachine::publishPowerLVIStatus(HANDLE h_app, PCSTR nNotifNm,
+ UI_32 value) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ PowerSrvLVIStatus eLviStatus = static_cast<PowerSrvLVIStatus>(value);
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedNPPublishNotification(h_app, nNotifNm, &eLviStatus,
+ sizeof(eLviStatus)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedNPPublishNotification( %s ) errored: 0x%X", nNotifNm,
+ eStatus);
+ }
+}
+// LCOV_EXCL_STOP 8: can not be called
+void PowerStateMachine::publishPowerLevelType(HANDLE h_app, UI_32 value) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ PowerSrvLevelType eLevelType = static_cast<PowerSrvLevelType>(value);
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPPublishNotification (h_app, szNTFY_PowerLevel, &eLevelType, sizeof (eLevelType)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedNPPublishNotification %s Failed Status:0x%x ",
+ szNTFY_PowerLevel, eStatus);
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Base_State::onStartComplete(
+ PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ oSession.StartComplete(h_app);
+}
+// LCOV_EXCL_STOP 8: do not be called
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Base_State::onStopComplete(
+ PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ oSession.StopComplete(h_app);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: no one call this function
+void PowerStateMachine::Base_State::onLaunchComplete(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FrameworkunifiedDeferMessage(h_app);
+}
+// LCOV_EXCL_STOP 8: do not be called
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Base_State::onShutdownComplete(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FrameworkunifiedDeferMessage(h_app);
+}
+// LCOV_EXCL_STOP 8: no one call this function
+PCSTR PowerStateMachine::Wakeup::name() {
+ return "Wakeup";
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Wakeup::onLowVoltage1Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&LowVoltage1State, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: do not be called
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Wakeup::onLowVoltage2Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&LowVoltage2State, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::Wakeup::onNormalVoltageEncountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(NULL, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "NORMAL ENCOUNTERED %s (no switch)", FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+void PowerStateMachine::Wakeup::onShutdown(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ u.NextState(ShutdownState, h_app, oSession);
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Wakeup::onSoftwareUpdate(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.NextState(SoftwareUpdateState, h_app, oSession);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Wakeup::onWakeup(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ Pwr_ServiceSetInterface tServiceIf;
+ if (sizeof(Pwr_ServiceSetInterface) == FrameworkunifiedGetMsgLength(h_app)) {
+ if (eFrameworkunifiedStatusOK
+ == FrameworkunifiedGetMsgDataOfSize(h_app, (PVOID) &tServiceIf,
+ sizeof(Pwr_ServiceSetInterface))) {
+ if (epswsPWRON == tServiceIf.data.wake.powerupType) {
+ /// Need to store the wakeup \ shutdown information
+ u.m_tStateInfo.wake = tServiceIf.data.wake.powerupType;
+ u.m_tStateInfo.level = tServiceIf.data.wake.up.level;
+ u.m_tStateInfo.factor = tServiceIf.data.wake.up.factor;
+
+ u.NextState(WakeupPendingState, h_app, oSession);
+ }
+ }
+ }
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+PCSTR PowerStateMachine::WakeupActive::name() {
+ return "Wakeup Active";
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::WakeupActive::onLowVoltage1Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&LowVoltage1State, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::WakeupActive::onLowVoltage2Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&LowVoltage2State, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+void PowerStateMachine::WakeupActive::onShutdown(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ u.NextState(ShutdownState, h_app, oSession);
+}
+
+PCSTR PowerStateMachine::WakeupPending::name() {
+ return "Wakeup Pending";
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::WakeupPending::onNormalVoltageEncountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&NormalVoltageState, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::WakeupPending::onStartComplete(
+ PowerStateMachine &, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ oSession.StartComplete(h_app);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: no one call this function
+void PowerStateMachine::WakeupPending::onLaunchComplete(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ oSession.SendToSupervisor(SS_POWER_WAKEUP_COMPLETE, 0, NULL);
+ if (epsvsNORMAL == u.m_tStateInfo.voltage) {
+ u.NextState(NormalVoltageState, h_app, oSession);
+ }
+}
+// LCOV_EXCL_STOP 8: no one call this function
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::WakeupPending::onWakeup(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (oSession.WakeupComplete(u.m_lstWakeupModules)) {
+ oSession.SendToSupervisor(SS_POWER_WAKEUP_COMPLETE, 0, NULL);
+ }
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+void PowerStateMachine::WakeupPending::onEntry(PowerStateMachine &u,
+ HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ if (!FrameworkunifiedIsDeferQueueEmpty(h_app)) {
+ FrameworkunifiedRetrieveDeferMessage(h_app);
+ }
+}
+
+PCSTR PowerStateMachine::Shutdown::name() {
+ return "Shutdown";
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Shutdown::onLowVoltage1Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.GotoStateOnHysteresisTimeout(LowVoltage1State);
+ u.OnVoltage(NULL, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "LOW VOLTAGE 1 ENCOUNTERED %s (no switch waiting for hysteresis to)",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::Shutdown::onLowVoltage2Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.GotoStateOnHysteresisTimeout(LowVoltage2State);
+ u.OnVoltage(NULL, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "LOW VOLTAGE 2 ENCOUNTERED %s (no switch waiting for hysteresis to)",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::Shutdown::onHysteresisAborted(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.NextState(*(u.m_pPreviousState), h_app, oSession);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+void PowerStateMachine::Shutdown::onHysteresisTimeout(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ if (!u.m_oShutdownHysteresis.maxTries()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "epsmeSHUTDOWN_TM_OUT tries: %d", u.m_oShutdownHysteresis.getTries());
+
+ u.reStartHysteresisTimer(u.m_oShutdownHysteresis);
+ } else {
+ // Move directorly to next state.
+ u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession);
+ }
+}
+
+void PowerStateMachine::Shutdown::onEntry(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ if (u.m_oShutdownHysteresis.getEnabled()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "Starting epsmeSHUTDOWN_HYSTERESIS_TM_OUT timeout: %d tries: %d",
+ u.m_oShutdownHysteresis.getTimeout(),
+ u.m_oShutdownHysteresis.getTries());
+ // Set the goto state state.
+ u.GotoStateOnHysteresisTimeout(ShutdownActiveState);
+ // Start the hysteresis timer for low voltage 2
+ u.startHysteresisTimer(u.m_oShutdownHysteresis);
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "SHUTDOWN_HYSTERESIS is not enabled. Going directly to ShutdownActiveState");
+ // Move directly to next state.
+ u.NextState(ShutdownActiveState, h_app, oSession);
+ }
+}
+
+void PowerStateMachine::Shutdown::onExit(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ u.stopHysteresisTimer(u.m_oShutdownHysteresis);
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) Shutdown State");
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::Shutdown::onWakeup(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.GotoStateOnHysteresisTimeout(WakeupPendingState);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+PCSTR PowerStateMachine::ShutdownActive::name() {
+ return "Shutdown Active";
+}
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::ShutdownActive::onLowVoltage1Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&LowVoltage1State, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::ShutdownActive::onLowVoltage2Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&LowVoltage2State, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+void PowerStateMachine::ShutdownActive::onEntry(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ u.publishPowerLevelType(h_app, epspltSHUTDOWN);
+
+ if (oSession.ShutdownComplete(u.m_lstShutdownModules)) {
+ oSession.SendToSupervisor(SS_POWER_SHUTDOWN_COMPLETE, 0, NULL);
+ }
+}
+
+void PowerStateMachine::ShutdownActive::onShutdown(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ if (oSession.ShutdownComplete(u.m_lstShutdownModules)) {
+ oSession.SendToSupervisor(SS_POWER_SHUTDOWN_COMPLETE, 0, NULL);
+ }
+}
+
+PCSTR PowerStateMachine::LowVoltage1::name() { // LCOV_EXCL_START 8: can not be LowVoltage1status
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "Low Voltage I";
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage1status
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::LowVoltage1::onHysteresisAborted(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.NextState(*(u.m_pPreviousState), h_app, oSession);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be LowVoltage1status
+void PowerStateMachine::LowVoltage1::onHysteresisTimeout(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (!u.m_oLowVoltage1Hysteresis.maxTries()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT tries: %d",
+ u.m_oLowVoltage1Hysteresis.getTries());
+
+ u.reStartHysteresisTimer(u.m_oLowVoltage1Hysteresis);
+ } else {
+ // Move directorly to next state.
+ u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession);
+ }
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage1::onWakeup(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.GotoStateOnHysteresisTimeout(NormalVoltageState);
+ u.OnVoltage(NULL, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage1status
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::LowVoltage1::onLowVoltage2Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.GotoStateOnHysteresisTimeout(LowVoltage2State);
+ u.OnVoltage(NULL, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "LOW VOLTAGE 2 ENCOUNTERED %s (no switch waiting for hysteresis to)",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage1::onNormalVoltageEncountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.GotoStateOnHysteresisTimeout(NormalVoltageState);
+ u.OnVoltage(NULL, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be LowVoltage1status
+void PowerStateMachine::LowVoltage1::onEntry(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (u.m_oLowVoltage1Hysteresis.getEnabled()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "Starting epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT timeout: %d tries: %d",
+ u.m_oLowVoltage1Hysteresis.getTimeout(),
+ u.m_oLowVoltage1Hysteresis.getTries());
+ // Set the goto state state.
+ u.GotoStateOnHysteresisTimeout(LowVoltage1ActiveState);
+ // Start the hysteresis timer for low voltage 1
+ u.startHysteresisTimer(u.m_oLowVoltage1Hysteresis);
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "LOW_VOLTAGE_HYSTERESIS is not enabled. Going directly to LowVoltage1ActiveState");
+ // Move directly to next state.
+ u.NextState(LowVoltage1ActiveState, h_app, oSession);
+ }
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage1::onExit(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.stopHysteresisTimer(u.m_oLowVoltage1Hysteresis);
+ FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) LowVoltage1 State");
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+PCSTR PowerStateMachine::LowVoltage1Active::name() {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "Low Voltage I Active";
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage1status
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::LowVoltage1Active::onLowVoltage2Encountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&LowVoltage2State, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage1Active::onNormalVoltageEncountered(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.OnVoltage(&NormalVoltageState, h_app, oSession);
+ FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL VOLTAGE ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be LowVoltage1Activestatus
+void PowerStateMachine::LowVoltage1Active::onEntry(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ u.publishPowerLevelType(h_app, epspltEMERGENCY);
+u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI1, ePwSrvLVI_Status_Active);
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage1Active::onExit(
+ PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI1, ePwSrvLVI_Status_InActive);
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage1Activestatus
+
+PCSTR PowerStateMachine::LowVoltage2::name() { // LCOV_EXCL_START 8: can not be LowVoltage2status
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+return "Low Voltage II";
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage2status
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::LowVoltage2::onHysteresisAborted(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.NextState(*(u.m_pPreviousState), h_app, oSession);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be LowVoltage2status
+void PowerStateMachine::LowVoltage2::onHysteresisTimeout(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+if (!u.m_oLowVoltage2Hysteresis.maxTries()) {
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "epsmeLOW_VOLTAGE2_HYSTERESIS_TM_OUT tries: %d",
+ u.m_oLowVoltage2Hysteresis.getTries());
+
+u.reStartHysteresisTimer(u.m_oLowVoltage2Hysteresis);
+} else {
+// Move directorly to next state.
+u.NextState(*(u.m_pOnHysteresisTimeoutState), h_app, oSession);
+}
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage2::onEntry(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+if (u.m_oLowVoltage2Hysteresis.getEnabled()) {
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "Starting epsmeLOW_VOLTAGE_HYSTERESIS_TM_OUT timeout: %d tries: %d",
+ u.m_oLowVoltage2Hysteresis.getTimeout(),
+ u.m_oLowVoltage2Hysteresis.getTries());
+// Set the goto state state.
+u.GotoStateOnHysteresisTimeout(LowVoltage2ActiveState);
+// Start the hysteresis timer for low voltage 2
+u.startHysteresisTimer(u.m_oLowVoltage2Hysteresis);
+} else {
+FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "LOW_VOLTAGE2_HYSTERESIS is not enabled. Going directly to LowVoltage2ActiveState");
+// Move directly to next state.
+u.NextState(LowVoltage2ActiveState, h_app, oSession);
+}
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage2::onExit(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.stopHysteresisTimer(u.m_oLowVoltage2Hysteresis);
+FRAMEWORKUNIFIEDLOG0(ZONE_POWER_STATEMACHINE, __FUNCTION__, "(EXITING) LowVoltage2 State");
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage2::onWakeup(PowerStateMachine &u, HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.GotoStateOnHysteresisTimeout(WakeupPendingState);
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage2status
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::LowVoltage2::onLowVoltage1Encountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.GotoStateOnHysteresisTimeout(LowVoltage1State);
+u.OnVoltage(NULL, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "LOW VOLTAGE 1 ENCOUNTERED %s (no switch waiting for hysteresis to)",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage2::onNormalVoltageEncountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.GotoStateOnHysteresisTimeout(NormalVoltageState);
+u.OnVoltage(NULL, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__,
+ "NORMAL VOLTAGE ENCOUNTERED %s (no switch waiting for hysteresis to)",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+PCSTR PowerStateMachine::LowVoltage2Active::name() { // LCOV_EXCL_START 8: can not be LowVoltage2Activestatus
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+return "Low Voltage II Active";
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage2Activestatus
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::LowVoltage2Active::onLowVoltage1Encountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.OnVoltage(&LowVoltage1State, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage2Active::onNormalVoltageEncountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.OnVoltage(&NormalVoltageState, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "NORMAL VOLTAGE ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be LowVoltage2Activestatus
+void PowerStateMachine::LowVoltage2Active::onEntry(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.publishPowerLevelType(h_app, epspltEMERGENCY);
+u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI2, ePwSrvLVI_Status_Active);
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::LowVoltage2Active::onExit(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.publishPowerLVIStatus(h_app, szNTFY_PowerLVI2, ePwSrvLVI_Status_InActive);
+oSession.SendToSupervisor(SS_POWER_LVI2_SHUTDOWN_COMPLETE, 0, NULL);
+}
+// LCOV_EXCL_STOP 8: can not be LowVoltage2Activestatus
+
+PCSTR PowerStateMachine::NormalVoltage::name() { // LCOV_EXCL_START 8: can not be NormalVoltageState
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+return "Normal Voltage";
+}
+// LCOV_EXCL_STOP 8: can not be NormalVoltageState
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::NormalVoltage::onLowVoltage1Encountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.OnVoltage(&LowVoltage1State, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::NormalVoltage::onLowVoltage2Encountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.OnVoltage(&LowVoltage2State, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be NormalVoltageState
+void PowerStateMachine::NormalVoltage::onShutdown(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.NextState(ShutdownState, h_app, oSession);
+}
+// LCOV_EXCL_STOP 8: can not be NormalVoltageState
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::NormalVoltage::onSoftwareUpdate(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.NextState(SoftwareUpdateState, h_app, oSession);
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be NormalVoltageState
+void PowerStateMachine::NormalVoltage::onEntry(PowerStateMachine &u,
+ HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.publishPowerLevelType(h_app, epspltNORMAL);
+}
+// LCOV_EXCL_STOP 8: can not be NormalVoltageState
+
+PCSTR PowerStateMachine::SoftwareUpdate::name() { // LCOV_EXCL_START 8: can not be SoftwareUpdatestatus
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+return "Software Update";
+}
+// LCOV_EXCL_STOP 8: can not be SoftwareUpdatestatus
+
+// LCOV_EXCL_START 8: no one send the event
+void PowerStateMachine::SoftwareUpdate::onLowVoltage1Encountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.OnVoltage(&LowVoltage1State, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 1 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::SoftwareUpdate::onLowVoltage2Encountered(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+u.OnVoltage(&LowVoltage2State, h_app, oSession);
+FRAMEWORKUNIFIEDLOG(ZONE_POWER_STATEMACHINE, __FUNCTION__, "LOW VOLTAGE 2 ENCOUNTERED %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+}
+// LCOV_EXCL_STOP 8: no one send the event
+
+// LCOV_EXCL_START 8: can not be SoftwareUpdatestatus
+void PowerStateMachine::SoftwareUpdate::onShutdown(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::SoftwareUpdate::onEntry(
+PowerStateMachine &u, HANDLE h_app, PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP 8: no one send the event to call this function
+
+// LCOV_EXCL_START 8: no one send the event to call this function
+void PowerStateMachine::SoftwareUpdate::onExit(PowerStateMachine &u,
+ HANDLE h_app,
+ PowerSessionHandler & oSession) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP 8: can not be SoftwareUpdatestatus
diff --git a/systemservice/power_service/server/src/ss_pwr_test_client_handlers.cpp b/systemservice/power_service/server/src/ss_pwr_test_client_handlers.cpp
new file mode 100755
index 0000000..1542281
--- /dev/null
+++ b/systemservice/power_service/server/src/ss_pwr_test_client_handlers.cpp
@@ -0,0 +1,204 @@
+/*
+ * @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_PowerService
+/// \brief This file supports the power service test client.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "ss_power.h"
+#include <system_service/ss_power_service_local.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <other_service/itoa.h>
+#include <map>
+#include <string>
+#include "ss_power_powerservicelog.h"
+
+using namespace std; // NOLINT (build/namespaces)
+
+#define SS_CRANK_STATE_STRING_LENGTH 5
+#define SS_VOLTAGE_STATE_STRING_LENGTH 5
+#define SS_MODULE_STATE_STRING_LENGTH 5
+#define SS_HEX_BASE_VALUE 16
+
+const CHAR ReeadyToWakeUpDescription[] = "_READY_TO_WAKEUP:";
+const CHAR WakeUpInitiatedDescription[] = "_WAKEUP_INITIATED:";
+const CHAR WakeUpCompletedDescription[] = "_WAKEUP_COMPLETED:";
+const CHAR PowerOnCompletedDescription[] = "_POWER_ON_COMPLETED:";
+const CHAR PowerOffInitiatedDescription[] = "_POWER_OFF_INITIATED:";
+const CHAR PowerOffCompletedDescription[] = "_POWER_OFF_COMPLETED:";
+const CHAR ShutdownInitiatedDescription[] = "_SHUTDOWN_INITIATED:";
+const CHAR ShutdownCompletedDescription[] = "_SHUTDOWN_COMPLETED:";
+
+const CHAR CrankInvalidDescription[] = "_INVALID:";
+const CHAR CrankEntryDescription[] = "_ENTRY:";
+const CHAR CrankExitDescription[] = "_EXIT:";
+
+const CHAR VoltageInvalidDescription[] = "_INVALID:";
+const CHAR VoltageNormalDescription[] = "_NORMAL:";
+const CHAR VoltageLVI1Description[] = "_LVI1:";
+const CHAR VoltageLVI2Description[] = "_LVI2:";
+
+///////////////////////////////////////////////////////////////////////
+/// AddCrankInformationToResponse
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::AddCrankInformationToResponse(CHAR *f_MessageResponse) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ CHAR l_Buffer[SS_CRANK_STATE_STRING_LENGTH] = { 0 };
+ UI_32 l_Index = 0;
+
+ std::map<ePowerSrvCrankStates, std::string> CrankMap;
+ CrankMap[epscsINVALID] = CrankInvalidDescription;
+ CrankMap[epscsENTRY] = CrankEntryDescription;
+ CrankMap[epscsEXIT] = CrankExitDescription;
+
+ // confirm that CrankState value would fit in buffer array
+ if (m_CrankState < 0xFFFF) { // LCOV_EXCL_BR_LINE 8: dead code
+ itoa(m_CrankState, l_Buffer, SS_HEX_BASE_VALUE);
+ while (l_Buffer[l_Index]) {
+ l_Buffer[l_Index] = toupper(l_Buffer[l_Index]);
+ l_Index++;
+ }
+ }
+
+ if (MaxRespMsg > (strlen(f_MessageResponse) + strlen(CrankMap[m_CrankState].c_str()) + strlen(l_Buffer))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length]
+ strcat(f_MessageResponse, l_Buffer); // NOLINT (runtime/printf)
+ strcat(f_MessageResponse, CrankMap[m_CrankState].c_str()); // NOLINT (runtime/printf)
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Buffer Overrun Condition : Failed to add Crank State description to response");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////
+/// AddVoltageInformationToResponse
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::AddVoltageInformationToResponse(CHAR *f_MessageResponse) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ CHAR l_Buffer[SS_VOLTAGE_STATE_STRING_LENGTH] = { 0 };
+ UI_32 l_Index = 0;
+
+ std::map<ePowerSrvVoltageStates, std::string> VoltageMap;
+ VoltageMap[epsvsINVALID] = VoltageInvalidDescription;
+ VoltageMap[epsvsNORMAL] = VoltageNormalDescription;
+ VoltageMap[epsvsLVI1] = VoltageLVI1Description;
+ VoltageMap[epsvsLVI2] = VoltageLVI2Description;
+
+ // confirm that VoltageState value would fit in buffer array
+ if (m_VoltageState < 0xFFFF) { // LCOV_EXCL_BR_LINE 8: dead code
+ itoa(m_VoltageState, l_Buffer, SS_HEX_BASE_VALUE);
+ while (l_Buffer[l_Index]) {
+ l_Buffer[l_Index] = toupper(l_Buffer[l_Index]);
+ l_Index++;
+ }
+ }
+
+ if (MaxRespMsg > (strlen(f_MessageResponse) + strlen(VoltageMap[m_VoltageState].c_str()) + strlen(l_Buffer))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length]
+ strcat(f_MessageResponse, l_Buffer); // NOLINT (runtime/printf)
+ strcat(f_MessageResponse, VoltageMap[m_VoltageState].c_str()); // NOLINT (runtime/printf)
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Buffer Overrun Condition : Failed to add Voltage State description to response");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////
+/// AddStateInformationToResponse
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::AddStateInformationToResponse(CHAR *f_MessageResponse) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ CHAR l_Buffer[SS_MODULE_STATE_STRING_LENGTH] = { 0 };
+ UI_32 l_Index = 0;
+
+ std::map<SS_PSState, std::string> StateMap; // State Map
+ StateMap[SS_PS_READY_TO_WAKEUP] = ReeadyToWakeUpDescription;
+ StateMap[SS_PS_WAKEUP_INITIATED] = WakeUpInitiatedDescription;
+ StateMap[SS_PS_WAKEUP_COMPLETE] = WakeUpCompletedDescription;
+ StateMap[SS_PS_POWER_ON_COMPLETE] = PowerOnCompletedDescription;
+ StateMap[SS_PS_POWER_OFF_INITIATED] = PowerOffInitiatedDescription;
+ StateMap[SS_PS_POWER_OFF_COMPLETE] = PowerOffCompletedDescription;
+ StateMap[SS_PS_SHUTDOWN_INITIATED] = ShutdownInitiatedDescription;
+ StateMap[SS_PS_SHUTDOWN_COMPLETE] = ShutdownCompletedDescription;
+
+ // confirm that PowerState value would fit in buffer array
+ if (m_PowerState < 0xFFFF) { // LCOV_EXCL_BR_LINE 8: dead code
+ itoa(m_PowerState, l_Buffer, SS_HEX_BASE_VALUE);
+ while (l_Buffer[l_Index]) {
+ l_Buffer[l_Index] = toupper(l_Buffer[l_Index]);
+ l_Index++;
+ }
+ }
+
+ if (MaxRespMsg > (strlen(f_MessageResponse) + strlen(StateMap[m_PowerState].c_str()) + strlen(l_Buffer))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length]
+ strcat(f_MessageResponse, l_Buffer); // NOLINT (runtime/printf)
+ strcat(f_MessageResponse, StateMap[m_PowerState].c_str()); // NOLINT (runtime/printf)
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Buffer Overrun Condition : Failed to add Module State description to response");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// ConstructPwrStateResponse
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus Power::ConstructPwrStateResponse(CHAR *f_MessageResponse) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_MessageResponse == NULL) { // LCOV_EXCL_BR_LINE 8: dead code
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ if (eFrameworkunifiedStatusOK == (l_eStatus = AddStateInformationToResponse(f_MessageResponse))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == (l_eStatus = AddVoltageInformationToResponse(f_MessageResponse))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == (l_eStatus = AddCrankInformationToResponse(f_MessageResponse))) { // LCOV_EXCL_BR_LINE 8: dead code // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Response Constructed");
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/systemservice/power_service/server/src/ss_supervisor_handlers.cpp b/systemservice/power_service/server/src/ss_supervisor_handlers.cpp
new file mode 100755
index 0000000..4bd88d9
--- /dev/null
+++ b/systemservice/power_service/server/src/ss_supervisor_handlers.cpp
@@ -0,0 +1,498 @@
+/*
+ * @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_PowerService
+/// \brief Handles SSM message for Wakeup State, Crank State, and Voltage
+/// State.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "ss_power.h"
+#include <stdio.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service.h>
+#include <system_service/ss_power_service_notifications_local.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_services.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <map>
+
+#include "ss_power_powerservicelog.h"
+
+
+EFrameworkunifiedStatus Power::OnPowerRequestMsg(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // ToDo Jay 2012 December 05 Would like to provide better general overall
+ // solution then this local hack - but, for the time being...
+ std::map<EPWR_USER_MODE_TYPE, EPWR_POWER_STATE_TYPE> UserModeToPowerTypeMap;
+ UserModeToPowerTypeMap[epsumON] = epswsPWRON;
+ UserModeToPowerTypeMap[epsumOFF] = epswsPWROFF;
+ // End of ToDo Jay 2012 December 05 Would like to provide better general
+
+ Pwr_ServiceSetInterface tServiceIf;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ BOOL b_isValid = FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "StartupReason is '%s'",
+ GetStr(tServiceIf.data.powerRequestMsg.startupReason).c_str());
+
+ switch (tServiceIf.data.powerRequestMsg.startupReason) {
+ case epswfINVALID:
+ case epswfTESTACC:
+ case epswfUSER_DATA_RESET:
+ // Not startup conditions; don't log
+ b_isValid = TRUE;
+ break;
+
+ case epswfON_KEY:
+ LOG_POWERSERVICELOG_EVT(epswfON_KEY, Ei_StartUp_HK_On, epseisuedHK_ON_Key);
+ b_isValid = TRUE;
+ break;
+
+ case epswfIGN_ACC:
+ LOG_POWERSERVICELOG_EVT(epswfIGN_ACC, Ei_StartUp_Cansignal, epseisuedIGNITION);
+ LOG_POWERSERVICELOG_CNT(epswfIGN_ACC, CT_Startup_CanSignal);
+ b_isValid = TRUE;
+ break;
+
+ case epswfDR_OPEN_CLOSE:
+ LOG_POWERSERVICELOG_EVT(epswfDR_OPEN_CLOSE, Ei_StartUp_Cansignal,
+ epseisuedDOOR_MODULES);
+ LOG_POWERSERVICELOG_CNT(epswfDR_OPEN_CLOSE, CT_Startup_CanSignal);
+ b_isValid = TRUE;
+ break;
+
+ case epswfDX_ACTIVATION:
+ LOG_POWERSERVICELOG_EVT(epswfDX_ACTIVATION, Ei_StartUp_DiagMsg, epseisuedHU);
+ LOG_POWERSERVICELOG_CNT(epswfDX_ACTIVATION, CT_Startup_DiagMsg);
+ b_isValid = TRUE;
+ break;
+
+ case epswfPASS_ACTIVATION:
+ LOG_POWERSERVICELOG_EVT(epswfPASS_ACTIVATION, Ei_StartUp_Cansignal,
+ epseisuedPASS);
+ LOG_POWERSERVICELOG_CNT(epswfPASS_ACTIVATION, CT_Startup_CanSignal);
+ b_isValid = TRUE;
+ break;
+
+ case epswfSPVACTIVATION:
+ LOG_POWERSERVICELOG_EVT(epswfSPVACTIVATION, Ei_StartUp_Cansignal, epseisuedSNA);
+ LOG_POWERSERVICELOG_CNT(epswfSPVACTIVATION, CT_Startup_CanSignal);
+ b_isValid = TRUE;
+ break;
+
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ } // End switch(tServiceIf.data.powerRequestMsg.startupReason)
+
+ if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error: Unknown 'powerRequestMsg.startupReason' value: " "0x%X / %d",
+ tServiceIf.data.powerRequestMsg.startupReason,
+ tServiceIf.data.powerRequestMsg.startupReason);
+ // LCOV_EXCL_STOP 11:unexpected branch
+ } else {
+ m_WakeUpData.powerupType = UserModeToPowerTypeMap[tServiceIf.data
+ .powerRequestMsg.userMode];
+ m_WakeUpData.up.factor = tServiceIf.data.powerRequestMsg.startupReason;
+ m_WakeUpData.up.level = epswlFULLRUN;
+ m_WakeUpData.up.userModeChangeReason = tServiceIf.data.powerRequestMsg.userModeChangeReason;
+
+ l_eStatus = FrameworkunifiedSendMsg(GetSystemManagerSessionHandle(),
+ SS_SM_POWER_REQUEST_MSG, sizeof(tServiceIf),
+ &tServiceIf);
+ char l_cBuf[200];
+ snprintf(
+ l_cBuf, sizeof(l_cBuf),
+ "FrameworkunifiedSendMsg( SS_SM_POWER_REQUEST_MSG, %s, %s)",
+ GetStr(tServiceIf.data.powerRequestMsg.userMode).c_str(),
+ GetStr(tServiceIf.data.powerRequestMsg.userModeChangeReason).c_str());
+ LOG_STATUS(l_eStatus, l_cBuf);
+ }
+ } // End else a good ReadMsg()
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnpowerRequestMsg( HANDLE h_app )
+
+EFrameworkunifiedStatus Power::OnShutdownRequestMsg(HANDLE h_app) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ Pwr_ServiceSetInterface tServiceIf;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ BOOL b_isValid = FALSE;
+ EPWR_SHUTDOWN_TRIGGER_TYPE l_shutdownTrigger = tServiceIf.data
+ .shutdownRequestMsg.shutdownTrigger;
+ switch (l_shutdownTrigger) {
+ case epssdmsdtINVALID:
+ case epssdmsdtTESTACC_OFF:
+ // Not shutdown conditions; don't log
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtON_KEY:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtON_KEY, Ei_shutdown_HkOFF, 0x00);
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtIGN_LOCK:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtIGN_LOCK, Ei_shutdown_CANsignal,
+ epseisdcsIGN_STATE);
+ LOG_POWERSERVICELOG_CNT(epssdmsdtIGN_LOCK, CT_Shutdown_CanSignal);
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtPWR_SAVE: // test from peripheralservice/power_supply_manager_shadow
+ LOG_POWERSERVICELOG_CNT(epssdmsdtPWR_SAVE, CT_Shutdown_Timeout); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtTMP_STARTUP:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtTMP_STARTUP, CT_Shutdown_Timeout); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtDIAG_DEACTIVATION:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtDIAG_DEACTIVATION, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtABNORMAL_VOLTAGE:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtABNORMAL_VOLTAGE, Ei_shutdown_Voltage, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ epseisdnvoltUNKNOWN);
+ LOG_POWERSERVICELOG_CNT(epssdmsdtABNORMAL_VOLTAGE, CT_Shutdown_Voltage); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtABNORMAL_TEMP:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtABNORMAL_TEMP, Ei_shutdown_Temperature, 0x00); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ LOG_POWERSERVICELOG_CNT(epssdmsdtABNORMAL_TEMP, CT_Shutdown_Temperature); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtBATTERYCUTOFF:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtBATTERYCUTOFF, Ei_shutdown_Voltage, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ epseisdnvoltBATTERY_CUT_OFF);
+ LOG_POWERSERVICELOG_CNT(epssdmsdtBATTERYCUTOFF, CT_Shutdown_Voltage); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtLIMPHOME:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtLIMPHOME, Ei_shutdown_Voltage, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ epseisdnvoltLIMP_HOME);
+ LOG_POWERSERVICELOG_CNT(epssdmsdtLIMPHOME, CT_Shutdown_Voltage); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtHU_CAN_ERROR:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtHU_CAN_ERROR, Ei_shutdown_NetworkError, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ epseisdneHU_CAN);
+ LOG_POWERSERVICELOG_CNT(epssdmsdtHU_CAN_ERROR, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtBODY_CAN_ERROR:
+ LOG_POWERSERVICELOG_EVT(epssdmsdtBODY_CAN_ERROR, Ei_shutdown_NetworkError, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ epseisdneHMI_CAN);
+ LOG_POWERSERVICELOG_CNT(epssdmsdtBODY_CAN_ERROR, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtTRANSPORT_MODE:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtTRANSPORT_MODE, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtPRODUCTION_MODE:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtPRODUCTION_MODE, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtIGN_OFF:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtIGN_OFF, CT_Shutdown_CanSignal); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtGENERIC_ERROR_RESET:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtGENERIC_ERROR_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtFATAL_ERROR_RESET:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtFATAL_ERROR_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtUSER_DATA_RESET:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtUSER_DATA_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtFACTORY_DATA_RESET:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtFACTORY_DATA_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtFAST_SLEEP_MODE:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtFAST_SLEEP_MODE, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtNORMAL_RESET:
+ LOG_POWERSERVICELOG_CNT(epssdmsdtNORMAL_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+
+ case epssdmsdtPROGUPDATE_RESET: // this is dead code
+ LOG_POWERSERVICELOG_CNT(epssdmsdtPROGUPDATE_RESET, CT_Shutdown_Error); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ b_isValid = TRUE;
+ break;
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ } // End switch(l_shutdownTrigger)
+ if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error: Unknown 'shutdownRequestMsg.shutdownTrigger' " "value: 0x%X/%d",
+ l_shutdownTrigger, l_shutdownTrigger);
+ // LCOV_EXCL_STOP 11:unexpected branch
+ } else {
+ l_eStatus = SendShutdownToSystemManager(&tServiceIf);
+ LOG_STATUS(l_eStatus, "SendShutdownToSystemManager()");
+ if (l_eStatus == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ SetPowerServiceState(SS_PS_SHUTDOWN_INITIATED);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnShutdownRequestMsg( HANDLE h_app )
+
+//*****************************************************************************
+// Shutdown Condition Notification Protocol function
+//
+EFrameworkunifiedStatus Power::OnPublishShutdownPopupRequest(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ Pwr_ServiceSetInterface tServiceIf;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ BOOL b_isValid = FALSE;
+ EPWR_SHUTDOWN_POPUP_TYPE l_eShutdownPopup = tServiceIf.data.shutdownPopup
+ .shutdownPopupEvent;
+ switch (l_eShutdownPopup) {
+ case epsspPowerSave1:
+ case epsspPowerSave2:
+ case epsspPowerSave3:
+ case epsspPowerSaveClr:
+ case epsspLowVoltage1:
+ case epsspLowVoltage2:
+ case epsspLowVoltage3:
+ case epsspLowVoltageClr:
+ case epsspBattCouplingSW1:
+ case epsspBattCouplingSW2:
+ case epsspBattCouplingSW3:
+ case epsspBattCouplingSWClr:
+ case epsspAbnormalTemp_1st:
+ case epsspAbnormalTemp_Clr:
+ case epsspLimpHome_1st:
+ case epsspLimpHome_2nd:
+ case epsspLimpHome_3rd:
+ case epsspLimpHome_Clr:
+ case epsspProdMd_1st:
+ case epsspProdMd_Clr:
+ case epsspTransMd_1st:
+ case epsspTransMd_Clr:
+ case epsspAllClr:
+ l_eStatus = FrameworkunifiedNPPublishNotification(h_app
+ , szNTFY_ShutdownPopup
+ , &l_eShutdownPopup
+ , sizeof(EPWR_SHUTDOWN_POPUP_TYPE));
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedNPPublishNotification(%s, %d) errored: %d/'%s'",
+ szNTFY_ShutdownPopup, l_eShutdownPopup, l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ SS_PWR_LOG_HIST("szNTFY_ShutdownPopup()", m_PubCmdHist, m_PubHistIter,
+ "", l_eStatus);
+
+ b_isValid = TRUE;
+ break;
+
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ } // End switch
+
+ if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Unknown 'l_eShutdownPopup' value: 0x%X / %d",
+ l_eShutdownPopup, l_eShutdownPopup);
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP 11:unexpected branch
+ } else {
+ EFrameworkunifiedStatus l_responseStatus = l_eStatus; // Save the current status as-is to
+ // send in the message response to the
+ // requester.
+ l_eStatus = FrameworkunifiedSendResponse(h_app,
+ SS_POWER_PUBLISH_SHUTDOWN_CONDITION_RESP,
+ sizeof(EFrameworkunifiedStatus),
+ (PVOID) &l_responseStatus);
+
+ char l_cBuf[200];
+ snprintf(l_cBuf, sizeof(l_cBuf),
+ "FrameworkunifiedSendResponse(%s, %s, status: %d/'%s')", FrameworkunifiedGetMsgSrc(h_app),
+ "SS_POWER_PUBLISH_SHUTDOWN_CONDITION_RESP", l_responseStatus,
+ GetStr(l_responseStatus).c_str());
+ LOG_STATUS(l_eStatus, l_cBuf);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnPublishShutdownPopupRequest( HANDLE h_app )
+//
+// End of Shutdown Condition Notification Protocol function
+//*****************************************************************************
+
+//*****************************************************************************
+// Power Popup Notification Protocol function
+//
+EFrameworkunifiedStatus Power::OnPublishPowerPopupRequest(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ Pwr_ServiceSetInterface tServiceIf;
+
+ // ReadMsg(): *
+ // Check h_app ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<Pwr_ServiceSetInterface>(h_app, tServiceIf))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ BOOL b_isValid = FALSE;
+ EPWR_POWER_POPUP_TYPE l_ePowerPopup = tServiceIf.data.powerPopup
+ .powerPopupEvent;
+ switch (l_ePowerPopup) {
+ case epssppNormal:
+ case epssppCritical:
+ case epssppAppCritical:
+ case epssppAllClr:
+ l_eStatus = FrameworkunifiedNPPublishNotification(h_app
+ , szNTFY_PowerPopup
+ , &l_ePowerPopup
+ , sizeof(EPWR_POWER_POPUP_TYPE));
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedNPPublishNotification(%s, %d) errored: %d/'%s'",
+ szNTFY_PowerPopup, l_ePowerPopup, l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ SS_PWR_LOG_HIST("OnPublishPowerPopupRequest()", m_PubCmdHist,
+ m_PubHistIter, "", l_eStatus);
+
+ b_isValid = TRUE;
+ break;
+
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ } // End switch
+
+ if (FALSE == b_isValid) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Unknown 'l_ePowerPopup' value: 0x%X/%d", l_ePowerPopup,
+ l_ePowerPopup);
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP 11:unexpected branch
+ } else {
+ EFrameworkunifiedStatus l_responseStatus = l_eStatus; // Save the current status as-is to
+ // send in the message response to the
+ // requester.
+ l_eStatus = FrameworkunifiedSendResponse(h_app, SS_POWER_PUBLISH_POWER_POPUP_RESP,
+ sizeof(EFrameworkunifiedStatus),
+ (PVOID) &l_responseStatus);
+ char l_cBuf[200];
+ snprintf(l_cBuf, sizeof(l_cBuf),
+ "FrameworkunifiedSendResponse(%s, %s, status: %d/'%s')", FrameworkunifiedGetMsgSrc(h_app),
+ "SS_POWER_PUBLISH_POWER_POPUP_RESP", l_responseStatus,
+ GetStr(l_responseStatus).c_str());
+ LOG_STATUS(l_eStatus, l_cBuf);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus Power::OnPublishPowerPopupRequest( HANDLE h_app )
+//
+// End of Power Popup Notification Protocol function
+//*****************************************************************************
+
+// EOF of /SS_PowerService/src/ss_supervisor_handlers.cpp
diff --git a/systemservice/power_service/server/src/ss_system_handlers.cpp b/systemservice/power_service/server/src/ss_system_handlers.cpp
new file mode 100755
index 0000000..60a9980
--- /dev/null
+++ b/systemservice/power_service/server/src/ss_system_handlers.cpp
@@ -0,0 +1,52 @@
+/*
+ * @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_PowerService
+/// \brief Handles Power Service Business logic
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "ss_power.h"
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_power_service.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include "ss_power_powerservicelog.h"
+
+EFrameworkunifiedStatus Power::OnSystemLaunchComplete(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Power Service received SS_POWER_SYSTEM_LAUNCH_COMPLETE from: %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- return EFrameworkunifiedStatus: 0x%X", eStatus);
+ return eStatus;
+}
+
+// test from peripheralservice/power_supply_manager_shadow
+EFrameworkunifiedStatus Power::OnSystemShutdownComplete(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Power Service received SS_POWER_SYSTEM_SHUTDOWN_COMPLETE from: %s",
+ FrameworkunifiedGetMsgSrc(h_app));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- return EFrameworkunifiedStatus: 0x%X", eStatus);
+ return eStatus;
+}
diff --git a/systemservice/resource_manager/LICENSE b/systemservice/resource_manager/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/resource_manager/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/resource_manager/Makefile.client b/systemservice/resource_manager/Makefile.client
new file mode 100755
index 0000000..2f9b64b
--- /dev/null
+++ b/systemservice/resource_manager/Makefile.client
@@ -0,0 +1,21 @@
+#
+# @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.
+#
+
+MODULE_NAME=resmgr
+
+SUBDIRS := client mock
+
+include ../system_service.mk
diff --git a/systemservice/resource_manager/Makefile.server b/systemservice/resource_manager/Makefile.server
new file mode 100755
index 0000000..2257507
--- /dev/null
+++ b/systemservice/resource_manager/Makefile.server
@@ -0,0 +1,23 @@
+#
+# @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.
+#
+
+MODULE_NAME=resmgr
+
+SUBDIRS := server
+
+SUBDIRS += drop_caches
+
+include ../system_service.mk
diff --git a/systemservice/resource_manager/client/Makefile b/systemservice/resource_manager/client/Makefile
new file mode 100755
index 0000000..a2bde46
--- /dev/null
+++ b/systemservice/resource_manager/client/Makefile
@@ -0,0 +1,58 @@
+#
+# @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.
+#
+
+######### add source path #############
+VPATH += ./
+VPATH += ./src
+VPATH += ./include
+VPATH += ../server/include
+VPATH += ../server/include/system_service
+
+######### install headers(*.h) #############
+INST_HEADERS += resm.h
+INST_HEADERS += resm_type.h
+INST_HEADERS += resource_manager.h
+
+######### installed program #############
+
+
+######### installed library(*.a) #############
+INST_LIBS =
+
+######### installed shared library(*.so) #############
+INST_SHLIBS = libresm
+RPC_API := RESMGR
+
+######### compiled sources #############
+libresm_SRCS += resmgr_api_stub.c
+libresm_SRCS += resmgr_api_lib.c
+
+######### add include path #############
+CPPFLAGS += -I./
+CPPFLAGS += -I./include
+CPPFLAGS += -I../server/include
+
+######## add compile option ########
+
+######### add library path #############
+LDFLAGS += -Wl,--no-as-needed
+
+######### linked library (dynamic) #############
+LDLIBS += -lrpc
+LDLIBS += -Wl,-Bdynamic -lev
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+
+include ../../system_service.mk
diff --git a/systemservice/resource_manager/client/RESMGR.api b/systemservice/resource_manager/client/RESMGR.api
new file mode 100755
index 0000000..7bd9734
--- /dev/null
+++ b/systemservice/resource_manager/client/RESMGR.api
@@ -0,0 +1,12 @@
+/*
+ * Resource Manager API
+ */
+
+INCLUDE <system_service/resm.h>
+
+RPC_Result RESM_ReqEvent(uint32_t ssnld, const RESM_REQ_EVENT_t* p_reqEvent);
+RPC_Result RESM_GetStatus(uint32_t ssnld, RESM_STATUS_t* p_status);
+RPC_Result RESM_SV_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnld);
+RPC_Result RESM_SV_Close(uint32_t ssnld);
+RPC_Result RESM_SV_ChkSsnId(uint32_t ssnld);
+
diff --git a/systemservice/resource_manager/client/include/resmgr_api_resourcemanagerlog.h b/systemservice/resource_manager/client/include/resmgr_api_resourcemanagerlog.h
new file mode 100755
index 0000000..b9d66fa
--- /dev/null
+++ b/systemservice/resource_manager/client/include/resmgr_api_resourcemanagerlog.h
@@ -0,0 +1,78 @@
+/*
+ * @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.
+ */
+
+#ifndef _resmgr_api_resourcemanagerlog_h_ // NOLINT
+#define _resmgr_api_resourcemanagerlog_h_
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10) // LIB common definition
+#define ZONE_FUNC ZONEMASK(11) // LIB common definition
+#define ZONE_MEM ZONEMASK(12) // LIB common definition
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29) // LIB common definition
+#define ZONE_WARN ZONEMASK(30) // LIB common definition
+#define ZONE_ERR ZONEMASK(31) // LIB common definition
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LSHAREDMEM) // LPRINT, LSHAREDMEM
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN, ZONE_ERR, ZONE_INFO
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+#endif /* !_resmgr_api_resourcemanagerlog_h_ */ // NOLINT
diff --git a/systemservice/resource_manager/client/libresm.ver b/systemservice/resource_manager/client/libresm.ver
new file mode 100755
index 0000000..fc56632
--- /dev/null
+++ b/systemservice/resource_manager/client/libresm.ver
@@ -0,0 +1,28 @@
+/*
+ * @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.
+ */
+
+#
+# libresm version script
+#
+{
+ global:
+ ### .text section ###
+ RESM_*;
+ ### .data section ###
+ local:
+ *;
+};
+
diff --git a/systemservice/resource_manager/client/src/#resmgr_api_lib.c# b/systemservice/resource_manager/client/src/#resmgr_api_lib.c#
new file mode 100755
index 0000000..02e84e4
--- /dev/null
+++ b/systemservice/resource_manager/client/src/#resmgr_api_lib.c#
@@ -0,0 +1,142 @@
+/*
+ * @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.
+ */
+
+#include <other_service/rpc.h>
+#include "resm_internal.h"
+#include "resmgr_api.h"
+#include "resmgr_api_resourcemanagerlog.h"
+
+/**********************************************
+ * External variable definitions
+ **********************************************/
+RPC_ID __thread rpcId;
+
+/*******************************************************************************
+ * RPC public API
+ *******************************************************************************/
+/* Connection */
+RESM_ERR_t
+RESM_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnId)
+{
+
+ RESM_ERR_t resmRet;
+ EV_ERR evRet;
+
+ // Argument check
+ if( p_ssnId == NULL ) {
+ return RESM_E_PAR;
+ }
+
+ // RPC resources
+ if( RPC_OK != RPC_START_CLIENT(&rpcId) ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: RPC_START Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return RESM_E_NG;
+ }
+
+
+ // Session connection
+ resmRet = RESM_SV_Open(p_prim, p_ssnId);
+ if( resmRet != RESM_E_OK ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: Open Session Error. ret[%d]", resmRet); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return RESM_E_NG;
+ }
+
+ // Create Event Flag
+ evRet = EV_create_flag(Resm_Flag_ID_Base + *p_ssnId);
+ if( evRet != EV_OK ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: create_flag Error. ret[%d]", evRet);
+ return RESM_E_NG;
+ }
+
+ return RESM_E_OK;
+}
+
+/* Disconnection */
+RESM_ERR_t
+RESM_Close(uint32_t ssnId)
+{
+
+ RESM_ERR_t resmRet;
+
+ // Disconnect session
+ resmRet = RESM_SV_Close(ssnId);
+ if( resmRet != RESM_E_OK ) {
+ return resmRet;
+ }
+
+ // Destroy RPC Resources
+ RPC_end(rpcId);
+
+ return RESM_E_OK;
+}
+
+/* Get event FD */
+RESM_ERR_t
+RESM_GetEventFd(uint32_t ssnId, int32_t* p_fd)
+{
+
+ RESM_ERR_t resmRet;
+
+ // Argument check
+ if( p_fd == NULL ) {
+ return RESM_E_PAR;
+ }
+ // Session ID check
+ resmRet = RESM_SV_ChkSsnId(ssnId);
+ if( resmRet != RESM_E_OK ) {
+ return RESM_E_PAR;
+ }
+
+ if( EV_OK != EV_get_flag_fd(Resm_Flag_ID_Base + ssnId, p_fd) ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr GetEventFd Error");
+ return RESM_E_NG;
+ }
+
+ return RESM_E_OK;
+}
+
+/* Get event */
+RESM_ERR_t
+RESM_GetEvent(uint32_t ssnId, RESM_EV_t* p_evFlag)
+{
+
+ RESM_ERR_t resmRet;
+ EV_Flag flag;
+
+ // Argument check
+ if( p_evFlag == NULL ) {
+ return RESM_E_PAR;
+ }
+ // Session ID Check
+ resmRet = RESM_SV_ChkSsnId(ssnId);
+ if( resmRet != RESM_E_OK ) {
+ return RESM_E_PAR;
+ }
+
+ if( EV_OK != EV_get_flag(Resm_Flag_ID_Base + ssnId, &flag)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr GetEvent(get_flag) Error");
+ return RESM_E_NG;
+ }
+
+ if( flag.bits == 0 ) {
+ // No event
+ return RESM_E_NG;
+ }
+
+ *p_evFlag = flag.bits;
+
+ return RESM_E_OK;
+}
diff --git a/systemservice/resource_manager/client/src/resmgr_api_lib.c b/systemservice/resource_manager/client/src/resmgr_api_lib.c
new file mode 100755
index 0000000..02e84e4
--- /dev/null
+++ b/systemservice/resource_manager/client/src/resmgr_api_lib.c
@@ -0,0 +1,142 @@
+/*
+ * @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.
+ */
+
+#include <other_service/rpc.h>
+#include "resm_internal.h"
+#include "resmgr_api.h"
+#include "resmgr_api_resourcemanagerlog.h"
+
+/**********************************************
+ * External variable definitions
+ **********************************************/
+RPC_ID __thread rpcId;
+
+/*******************************************************************************
+ * RPC public API
+ *******************************************************************************/
+/* Connection */
+RESM_ERR_t
+RESM_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnId)
+{
+
+ RESM_ERR_t resmRet;
+ EV_ERR evRet;
+
+ // Argument check
+ if( p_ssnId == NULL ) {
+ return RESM_E_PAR;
+ }
+
+ // RPC resources
+ if( RPC_OK != RPC_START_CLIENT(&rpcId) ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: RPC_START Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return RESM_E_NG;
+ }
+
+
+ // Session connection
+ resmRet = RESM_SV_Open(p_prim, p_ssnId);
+ if( resmRet != RESM_E_OK ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: Open Session Error. ret[%d]", resmRet); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return RESM_E_NG;
+ }
+
+ // Create Event Flag
+ evRet = EV_create_flag(Resm_Flag_ID_Base + *p_ssnId);
+ if( evRet != EV_OK ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: create_flag Error. ret[%d]", evRet);
+ return RESM_E_NG;
+ }
+
+ return RESM_E_OK;
+}
+
+/* Disconnection */
+RESM_ERR_t
+RESM_Close(uint32_t ssnId)
+{
+
+ RESM_ERR_t resmRet;
+
+ // Disconnect session
+ resmRet = RESM_SV_Close(ssnId);
+ if( resmRet != RESM_E_OK ) {
+ return resmRet;
+ }
+
+ // Destroy RPC Resources
+ RPC_end(rpcId);
+
+ return RESM_E_OK;
+}
+
+/* Get event FD */
+RESM_ERR_t
+RESM_GetEventFd(uint32_t ssnId, int32_t* p_fd)
+{
+
+ RESM_ERR_t resmRet;
+
+ // Argument check
+ if( p_fd == NULL ) {
+ return RESM_E_PAR;
+ }
+ // Session ID check
+ resmRet = RESM_SV_ChkSsnId(ssnId);
+ if( resmRet != RESM_E_OK ) {
+ return RESM_E_PAR;
+ }
+
+ if( EV_OK != EV_get_flag_fd(Resm_Flag_ID_Base + ssnId, p_fd) ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr GetEventFd Error");
+ return RESM_E_NG;
+ }
+
+ return RESM_E_OK;
+}
+
+/* Get event */
+RESM_ERR_t
+RESM_GetEvent(uint32_t ssnId, RESM_EV_t* p_evFlag)
+{
+
+ RESM_ERR_t resmRet;
+ EV_Flag flag;
+
+ // Argument check
+ if( p_evFlag == NULL ) {
+ return RESM_E_PAR;
+ }
+ // Session ID Check
+ resmRet = RESM_SV_ChkSsnId(ssnId);
+ if( resmRet != RESM_E_OK ) {
+ return RESM_E_PAR;
+ }
+
+ if( EV_OK != EV_get_flag(Resm_Flag_ID_Base + ssnId, &flag)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr GetEvent(get_flag) Error");
+ return RESM_E_NG;
+ }
+
+ if( flag.bits == 0 ) {
+ // No event
+ return RESM_E_NG;
+ }
+
+ *p_evFlag = flag.bits;
+
+ return RESM_E_OK;
+}
diff --git a/systemservice/resource_manager/drop_caches/Makefile b/systemservice/resource_manager/drop_caches/Makefile
new file mode 100755
index 0000000..03b31cf
--- /dev/null
+++ b/systemservice/resource_manager/drop_caches/Makefile
@@ -0,0 +1,38 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = drop_caches
+
+######### install headers(*.h) #############
+INST_HEADERS =
+
+######### compiled sources #############
+drop_caches_SRCS = ./src/drop_caches.cpp
+
+######### add include path #############
+CPPFLAGS = -I../server/include
+
+######## define options ########
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 \
+ -DFRAMEWORKUNIFIEDLOGAPPZONES=31
+CPPFLAGS += -fno-exceptions
+LDFLAGS += -Wl,--no-as-needed
+######### linked library (dynamic) #############
+LDLIBS += -Wl,--no-as-needed
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+
+include ../../system_service.mk
diff --git a/systemservice/resource_manager/drop_caches/src/drop_caches.cpp b/systemservice/resource_manager/drop_caches/src/drop_caches.cpp
new file mode 100755
index 0000000..d192705
--- /dev/null
+++ b/systemservice/resource_manager/drop_caches/src/drop_caches.cpp
@@ -0,0 +1,183 @@
+/*
+ * @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.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <time.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "ss_resm_resourcemanagerlog.h"
+
+#define DROP_CACHES "/proc/sys/vm/drop_caches"
+
+// FRAMEWORKUNIFIEDLOG
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
+ FRAMEWORKUNIFIEDLOGOPTIONS,
+ {
+ ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ ZONE_TEXT_31
+ },
+ FRAMEWORKUNIFIEDLOGZONES
+};
+
+// echo 1 > /proc/sys/vm/drop_caches
+#define DROP_CACHES_INTVAL_TIMESEC (1 * 10) // 10 sec
+
+#define MEMINFO_FILE "/proc/meminfo"
+
+/* memFree threshold */
+#define MEMFREE_THRETHOLD (100*1024)
+/* LowFree - CmaFree threshold */
+#define LOWFREE_THRETHOLD (50*1024)
+
+static uint32_t mainFree_kib;
+static uint32_t lowFree_kib;
+static uint32_t cmaFree_kib;
+// meminfo table
+typedef struct {
+ const char* name;
+ uint32_t* value;
+} meminfo_tbl;
+
+static int32_t get_meminfo(void);
+static int32_t comp_meminfo_tbl(const void* data1, const void* data2);
+static bool judge_cachedrop(void);
+
+static void
+exec_drop_caches(void) {
+ int fd;
+
+ fd = open(DROP_CACHES, O_RDWR);
+ if (fd >= 0) {
+ write(fd, (const void *)"1", 1);
+ close(fd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "%s open error (fd:%d, errno:%d)", DROP_CACHES, fd, errno);
+ }
+}
+
+int
+main(int argc, char* argv[]) {
+ const struct timespec drop_caches_intval = {DROP_CACHES_INTVAL_TIMESEC, 0};
+
+ FRAMEWORKUNIFIED_SET_ZONES();
+
+ while (1) {
+ /* Get meminfo */
+ get_meminfo();
+ if (judge_cachedrop()) {
+ exec_drop_caches();
+ }
+ nanosleep(&drop_caches_intval, NULL);
+ }
+
+ return 0;
+}
+
+/* Compare memory information */
+static int32_t
+comp_meminfo_tbl(const void* data1, const void* data2) {
+ return strcmp(((const meminfo_tbl*)data1)->name,
+ ((const meminfo_tbl*)data2)->name);
+}
+
+/* Get memory information */
+static int32_t
+get_meminfo(void) {
+ int32_t meminfo_fd = -1;
+ char srch_name[16];
+ char buf[2048];
+ meminfo_tbl target = {srch_name, NULL};
+ meminfo_tbl* found;
+ char* head;
+ char* tail;
+ int32_t read_byte;
+ /* Strings must be in ascending order when adding entries to this table (for bsearch) */
+ static const meminfo_tbl mem_table[] = {
+ {"CmaFree", &cmaFree_kib},
+ {"LowFree", &lowFree_kib},
+ {"MemFree", &mainFree_kib},
+ };
+ const int32_t mem_table_count = sizeof(mem_table)/sizeof(meminfo_tbl);
+
+ if (meminfo_fd == -1) {
+ meminfo_fd = open(MEMINFO_FILE, O_RDONLY);
+ if (meminfo_fd == -1) {
+ fflush(NULL);
+ return -1;
+ }
+ }
+
+ lseek(meminfo_fd, 0L, SEEK_SET);
+ read_byte = read (meminfo_fd, buf, sizeof(buf) - 1);
+ if (read_byte < 0) {
+ fflush(NULL);
+ close(meminfo_fd);
+ return -1;
+ }
+ buf[read_byte] = '\0';
+
+ head = buf;
+ while (1) {
+ tail = strchr(head, ':');
+ if (!tail) {
+ break;
+ }
+ *tail = '\0';
+ if (strlen (head) >= sizeof(srch_name)) {
+ head = tail + 1;
+ } else {
+ strcpy(srch_name, head); // NOLINT
+ found = reinterpret_cast<meminfo_tbl *>(bsearch(&target, mem_table, mem_table_count,
+ sizeof(meminfo_tbl), comp_meminfo_tbl));
+ head = tail + 1;
+ if (found) {
+ *(found->value) = strtoul(head, &tail, 10);
+ }
+ }
+ tail = strchr(head, '\n');
+ if (!tail)
+ break;
+ head = tail + 1;
+ }
+ close(meminfo_fd);
+
+ return 0;
+}
+
+static bool
+judge_cachedrop(void) {
+ if (mainFree_kib < MEMFREE_THRETHOLD) {
+ return true;
+ }
+
+ if ((lowFree_kib - cmaFree_kib) < LOWFREE_THRETHOLD) {
+ return true;
+ }
+
+ return false;
+}
diff --git a/systemservice/resource_manager/server/Makefile b/systemservice/resource_manager/server/Makefile
new file mode 100755
index 0000000..cae9191
--- /dev/null
+++ b/systemservice/resource_manager/server/Makefile
@@ -0,0 +1,55 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = resm
+
+######### compiled sources #############
+resm_SRCS += resm.cpp
+resm_SRCS += proc_watch.cpp
+resm_SRCS += resourcemanager_application.cpp
+resm_SRCS += cpuload_custom.cpp
+resm_SRCS += resmgr_srvr_stub.cpp
+
+######### add source path #############
+VPATH += ./src
+VPATH += ./include/$(COMPONENT_NAME)
+VPATH += ../client
+
+######### add include path #############
+CPPFLAGS += -I./include
+CPPFLAGS += -I../client
+
+######## add compile option ########
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGAPPZONES=104,64,31,30,29,28
+CPPFLAGS += -DTARGET_SOC_$(TARGET_SOC)
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+CPPFLAGS += -fno-exceptions
+
+######### linked library (dynamic) #############
+LDFLAGS += -Wl,--no-as-needed
+LDLIBS += -Wl,--no-as-needed
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lsoc_temperature_hal
+LDLIBS += -Wl,-Bdynamic -lcommon
+LDLIBS += -Wl,-Bdynamic -lrpc
+
+LDLIBS += -Wl,-Bdynamic -lev
+
+include ../../system_service.mk
diff --git a/systemservice/resource_manager/server/include/proc_watch.h b/systemservice/resource_manager/server/include/proc_watch.h
new file mode 100755
index 0000000..8a98afd
--- /dev/null
+++ b/systemservice/resource_manager/server/include/proc_watch.h
@@ -0,0 +1,25 @@
+/*
+ * @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.
+ */
+
+#ifndef RESOURCE_MANAGER_SERVER_INCLUDE_PROC_WATCH_H_
+#define RESOURCE_MANAGER_SERVER_INCLUDE_PROC_WATCH_H_
+
+/**********************************************
+ * Prototype declaration
+ **********************************************/
+void *PRCW_main(void *p);
+
+#endif // RESOURCE_MANAGER_SERVER_INCLUDE_PROC_WATCH_H_
diff --git a/systemservice/resource_manager/server/include/resm_cfg.h b/systemservice/resource_manager/server/include/resm_cfg.h
new file mode 100755
index 0000000..e48cdce
--- /dev/null
+++ b/systemservice/resource_manager/server/include/resm_cfg.h
@@ -0,0 +1,132 @@
+/*
+ * @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.
+ */
+
+/******************************************************************************
+File name : resm_cfg.h
+******************************************************************************/
+#ifndef RESOURCE_MANAGER_SERVER_INCLUDE_RESM_CFG_H_
+#define RESOURCE_MANAGER_SERVER_INCLUDE_RESM_CFG_H_
+
+/******************************************************************************
+Configuration
+******************************************************************************/
+/*************************************************
+ * Delay time from process start to monitoring start (sec)
+ * def:60 max:- min:0
+ * (0: stop timer)
+ *************************************************/
+#define MONITORING_START_DELAT_TIME (60)
+
+
+/*************************************************
+ * Delay time until authentication service monitoring start (sec)
+ * def:30 max:- min:0
+ * (0: stop timer)
+ * MONITORING_START_DELAT_TIME > set to this value
+ *************************************************/
+#define EUA_MONITORING_START_DELAT_TIME (30)
+
+
+/*************************************************
+ * Delay from drop_caches process startup (sec)
+ * def:20 max:- min:0
+ * (0: stop timer)
+ *************************************************/
+#define DROP_CACHES_START_DELAT_TIME (20)
+
+
+///*************************************************
+// * CPU load threshold (%)
+// * def:70 max:100 min:0
+// *************************************************/
+//#define CPU_LOAD_THRESHOLD (70)
+/*************************************************
+ * CPU load threshold(%:XX.X)
+ * threshold:875 max:1000 min:0
+ *************************************************/
+#define CPU_LOAD_THRESHOLD (875)
+
+
+/*************************************************
+ * Number of CPU overload processes to be logged (rows)
+ * def:5 max:- min:0
+ *************************************************/
+#define CPU_HIGH_LOAD_P_LOG_NUM (5)
+
+
+///*************************************************
+// * Log output frequency during CPU overload continuation (sec)
+// * def:30 max:- min:0
+// *
+// * Specify as a multiple of the polling interval(WTC_CPU_INTERVAL) for CPU load monitoring
+// *************************************************/
+//#define CPU_HIGH_LOAD_LOG_FREQ (30)
+/*************************************************
+ * Log output frequency during CPU overload continuation (sec)
+ * def:60 max:- min:0
+ *
+ * Specify as a multiple of the polling interval(WTC_CPU_INTERVAL) for CPU load monitoring
+ *************************************************/
+#define CPU_HIGH_LOAD_LOG_FREQ (60)
+
+
+/*************************************************
+ * perf Profiling/Measurement Processes
+ * def:1 max:- min:1
+ *************************************************/
+#define PERF_MAX_PROCS (1)
+
+/*************************************************
+ * perf profiling/Output rows (functions)
+ * def:5 max:- min:1
+ *************************************************/
+#define PERF_MAX_LINES (5)
+
+/*************************************************
+ * perf pofiling/perf-record running time (sec)
+ * def:1 max:- min:1
+ *************************************************/
+#define PERF_RECORD_SPAN (1)
+
+#define TOP_TIMEOUT (60)
+
+#define RESET_SEC (60)
+
+
+#define WTC_CPU_INTERVAL (6)
+
+#define TASK_STAT_THRESHOLD (70)
+#define FIFO_TIMER_LIMIT (6)
+#define TSS_TIMER_LIMIT (60)
+
+#define CPU_TASK_INIT (1)
+#define CPU_TASK_SHOW_BF (2)
+#define CPU_TASK_SHOW_AF (3)
+#define FIFO_TASK_SHOW (4)
+#define TSS_TASK_SHOW (5)
+#define CPU_FIFO_TASK_GET_ID (6)
+#define CPU_TSS_TASK_GET_ID (7)
+#define CPU_FIFO_TASK_GET_OCCUPANCY (8)
+#define CPU_TSS_TASK_GET_OCCUPANCY (9)
+
+#define STATUS_IDOL (1)
+#define STATUS_CHECK_CPU (2)
+#define STATUS_WATCH_PROCESS (3)
+
+#define TASK_STAT_RANK_NUM (5)
+
+
+#endif // RESOURCE_MANAGER_SERVER_INCLUDE_RESM_CFG_H_
diff --git a/systemservice/resource_manager/server/include/resm_internal.h b/systemservice/resource_manager/server/include/resm_internal.h
new file mode 100755
index 0000000..090814e
--- /dev/null
+++ b/systemservice/resource_manager/server/include/resm_internal.h
@@ -0,0 +1,40 @@
+/*
+ * @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.
+ */
+
+#ifndef RESOURCE_MANAGER_SERVER_INCLUDE_RESM_INTERNAL_H_
+#define RESOURCE_MANAGER_SERVER_INCLUDE_RESM_INTERNAL_H_
+
+#include <agldd/moduleid.h>
+#include <agldd/ev_common.h>
+
+#include <other_service/ev_lib.h>
+#include "system_service/resm_type.h"
+
+#define Resm_Flag_ID_Base EV_Flag_ID_Base(RESMGR_MID)
+
+/*******************************************************************************
+ * User defined
+ *******************************************************************************/
+#define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
+
+/***********************************************************
+ * Internal API definitions
+ ***********************************************************/
+RESM_ERR_t RESM_SV_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnld);
+RESM_ERR_t RESM_SV_Close(uint32_t ssnld);
+RESM_ERR_t RESM_SV_ChkSsnId(uint32_t ssnld);
+
+#endif // RESOURCE_MANAGER_SERVER_INCLUDE_RESM_INTERNAL_H_
diff --git a/systemservice/resource_manager/server/include/ss_resm_resourcemanagerlog.h b/systemservice/resource_manager/server/include/ss_resm_resourcemanagerlog.h
new file mode 100755
index 0000000..94c16b3
--- /dev/null
+++ b/systemservice/resource_manager/server/include/ss_resm_resourcemanagerlog.h
@@ -0,0 +1,82 @@
+/*
+ * @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.
+ */
+
+#ifndef RESOURCE_MANAGER_SERVER_INCLUDE_SS_RESM_RESOURCEMANAGERLOG_H_
+#define RESOURCE_MANAGER_SERVER_INCLUDE_SS_RESM_RESOURCEMANAGERLOG_H_
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10) // LIB common definition
+#define ZONE_FUNC ZONEMASK(11) // LIB common definition
+#define ZONE_MEM ZONEMASK(12) // LIB common definition
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_RESM_DEBUG ZONEMASK(28) // DEBUG
+#define ZONE_INFO ZONEMASK(29) // LIB common definition
+#define ZONE_WARN ZONEMASK(30) // LIB common definition
+#define ZONE_ERR ZONEMASK(31) // LIB common definition
+
+#define ZONE_SOC_TEMP ZONEMASK(104)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 "ResmDebug"
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LSHAREDMEM) // LPRINT,LSHAREDMEM
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN, ZONE_ERR, ZONE_INFO
+// #define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN,ZONE_ERR,ZONE_INFO,ZONE_RESM_DEBUG //DEBUG
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+#endif // RESOURCE_MANAGER_SERVER_INCLUDE_SS_RESM_RESOURCEMANAGERLOG_H_
diff --git a/systemservice/resource_manager/server/include/system_service/resm.h b/systemservice/resource_manager/server/include/system_service/resm.h
new file mode 100755
index 0000000..d3b8850
--- /dev/null
+++ b/systemservice/resource_manager/server/include/system_service/resm.h
@@ -0,0 +1,325 @@
+/*
+ * @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.
+ */
+/**
+ * @file resm.h
+ * @brief \~english This file contains declaration of APIs for resm library
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup resource_manager
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESM_H_
+#define RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESM_H_
+
+#include "system_service/resm_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RESM_Open
+/// \~english @par Summary
+/// Opens the session with resource manager.
+/// \~english @param [in] p_prim
+/// RESM_RSV_t* - Unused, NULL
+/// \~english @param [out] p_ssnId
+/// uint32_t* - Pointer to session ID
+/// \~english @par
+/// RESM_RSV_t Variables
+/// \~english @code
+/// #define RESM_RSV_t int32_t
+/// #define RESM_RSV_NULL (0x00) // NULL
+/// @endcode
+/// \~english @retval RESM_E_OK Succeeded
+/// \~english @retval RESM_E_PAR %Parameter error
+/// \~english @retval RESM_E_NG Unexpected error
+/// \~english @par Preconditions
+/// - Availability of ResourceManager must be TRUE.
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - p_ssnId is NULL. [RESM_E_PAR]
+/// - The global variable for getting RPC_ID of program (rpcId) is NULL. [RESM_E_NG]
+/// - The area for RPC ID(rpcId) is not gotten. [RESM_E_NG]
+/// - The number of the thread able to register in a process exceeds limit. [RESM_E_NG]
+/// - It failed to get the area for thread information. [RESM_E_NG]
+/// - It failed to get the area for ID information storage. [RESM_E_NG]
+/// - It failed to generate the datagram socket for API request receiving. [RESM_E_NG]
+/// - It failed to bind a socket. [RESM_E_NG]
+/// - It failed to get a socket name. [RESM_E_NG]
+/// - The number of sessions exceeds the maximum value. [RESM_E_NG]
+/// - There is no space in the thread information area for event registration. [RESM_E_NG]
+/// - It failed to get the thread information area for event registration. [RESM_E_NG]
+/// - The file descriptor for getting an event is created. [RESM_E_NG]
+/// - The generated session ID exists (EEXIST error at ioctl). [RESM_E_NG]
+/// - Any error occurred during registering an event flag (EEXIST error at ioctl). [RESM_E_NG]
+/// - Any error occurred during processing poling setting (error at ioctl). [RESM_E_NG]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// None
+/// \~english @par Detail
+/// Opens a session. \n
+/// An application can use another API by using the gotten ssnID.
+/// \~english @see RESM_Close
+////////////////////////////////////////////////////////////////////////////////////
+RESM_ERR_t RESM_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnld);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RESM_Close
+/// \~english @par Summary
+/// Closes the session with resource manager.
+/// \~english @param [in] ssnld
+/// uint32_t - Session ID
+/// \~english @retval RESM_E_OK Succeeded
+/// \~english @retval RESM_E_PAR %Parameter error
+/// \~english @par Preconditions
+/// - An application must finish getting a session ID by RESM_Open().
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - ssnId exceeds the maximum value (EV_MAX_IDS_IN_THREAD). [RESM_E_PAR]
+/// - The in-use flag of a global variable (g_resmgr.ssnInfo[ssnId].useFlag) is FALSE. [RESM_E_PAR]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// None
+/// \~english @par Detail
+/// Closes a session.
+/// \~english @see RESM_Open
+////////////////////////////////////////////////////////////////////////////////////
+RESM_ERR_t RESM_Close(uint32_t ssnld);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RESM_ReqEvent
+/// \~english @par Summary
+/// Requests to issue an event.
+/// \~english @param [in] ssnld
+/// uint32_t - Session ID
+/// \~english @param [in] p_reqEvent
+/// RESM_REQ_EVENT_t* - Pointer to event
+/// \~english @par
+/// RESM_REQ_EVENT_t Structure
+/// \~english @code
+/// typedef struct {
+/// RESM_EV_t reqEvent; /* Event flag necessary to report */
+/// struct {
+/// uint32_t restMemThresh; /* Threshold of the remaining capacity of system memory */
+/// } prm;
+/// }RESM_REQ_EVENT_t;
+/// @endcode
+/// \~english @par
+/// RESM_EV_t Variables
+/// \~english @code
+/// #define RESM_EV_t uint32_t
+/// #define RESM_EV_NOP (0x00)
+/// #define RESM_EV_MEM (0x01)
+/// #define RESM_EV_NAND_STATUS (0x02)
+/// @endcode
+/// \~english @par
+/// - RESM_EV_NOP : No event notification
+/// - RESM_EV_MEM : Event notification for memory
+/// - RESM_EV_NAND_STATUS : Eventnotification for NAND state
+/// \~english @par
+/// Notes
+/// - restMemThresh is valid only when RESM_EV_MEM is set to reqEvent. \n
+/// ResourceManager issues RESM_EV_MEM event at the timing
+/// when the remaining capacity of system memory fell below the value (unit is BYTE)
+/// which an application specifies.
+/// \~english @retval RESM_E_OK Succeeded
+/// \~english @retval RESM_E_PAR %Parameter error
+/// \~english @par Preconditions
+/// - An application must finish getting a session ID by RESM_Open().
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - p_reqEvent is NULL. [RESM_E_PAR]
+/// - ssnId exceeds the maximum value (EV_MAX_IDS_IN_THREAD). [RESM_E_PAR]
+/// - The in-use flag of a global variable (g_resmgr.ssnInfo[ssnId].useFlag) is FALSE. [RESM_E_PAR]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// None
+/// \~english @par Detail
+/// Requests to issue an event.
+/// This API is called from the RPC library.
+/// \~english @see RESM_GetEvent
+////////////////////////////////////////////////////////////////////////////////////
+RESM_ERR_t RESM_ReqEvent(uint32_t ssnld, const RESM_REQ_EVENT_t* p_reqEvent);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RESM_GetEventFd
+/// \~english @par Summary
+/// Gets FD of the event to receive from resource manager.
+/// \~english @param [in] ssnld
+/// uint32_t - Session ID
+/// \~english @param [out] p_fd
+/// int* - Pointer to file descriptor
+/// \~english @retval RESM_E_OK Succeeded
+/// \~english @retval RESM_E_PAR %Parameter error
+/// \~english @retval RESM_E_NG Unexpected error
+/// \~english @par Preconditions
+/// - An application must finish getting a session ID by RESM_Open().
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - p_fd is NULL. [RESM_E_PAR]
+/// - ssnId exceeds the maximum value (EV_MAX_IDS_IN_THREAD). [RESM_E_PAR]
+/// - The in-use flag of a global variable (g_resmgr.ssnInfo[ssnId].useFlag) is FALSE. [RESM_E_PAR]
+/// - ssnId rewrites bit for an event flag decision by invalid values. [RESM_E_NG]
+/// - The file descriptor corresponding to ssnId is not found. [RESM_E_NG]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// None
+/// \~english @par Detail
+/// Gets FD of the event to receive from resource manager. \n
+/// An application can do simultaneous wait of other events with the event of ResourceManager
+/// by oversighting the gotten FD by select,poll etc.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+RESM_ERR_t RESM_GetEventFd(uint32_t ssnld, int* p_fd);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RESM_GetEvent
+/// \~english @par Summary
+/// Gets the event from resource manager.
+/// \~english @param [in] ssnld
+/// uint32_t - Session ID
+/// \~english @param [out] p_evFlag
+/// RESM_EV_t* - Pointer to event
+/// \~english @par
+/// RESM_EV_t Variables
+/// \~english @code
+/// #define RESM_EV_t uint32_t
+/// #define RESM_EV_NOP (0x00)
+/// #define RESM_EV_MEM (0x01)
+/// #define RESM_EV_NAND_STATUS (0x02)
+/// @endcode
+/// \~english @par
+/// - RESM_EV_NOP : No event notification
+/// - RESM_EV_MEM : Event notification for memory
+/// - RESM_EV_NAND_STATUS : Event notification for NAND state
+/// \~english @retval RESM_E_OK Succeeded
+/// \~english @retval RESM_E_PAR %Parameter error
+/// \~english @retval RESM_E_NG Unexpected error
+/// \~english @par Preconditions
+/// - An application must finish getting a session ID by RESM_Open().
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - p_evFlag is NULL. [RESM_E_PAR]
+/// - ssnId exceeds the maximum value (EV_MAX_IDS_IN_THREAD). [RESM_E_PAR]
+/// - The in-use flag of a global variable (g_resmgr.ssnInfo[ssnId].useFlag) is FALSE. [RESM_E_PAR]
+/// - ssnId rewrites bit for an event flag decision by invalid values. [RESM_E_NG]
+/// - The file descriptor corresponding to ssnId is not found. [RESM_E_NG]
+/// - The flag of ssnId is not registered. (The returned value of ioctl is EOENT.) [RESM_E_NG]
+/// - Any interruption occurred during getting an event. (The returned value of ioctl is EINTR.) [RESM_E_NG]
+/// - Any error occurred during getting an event. (The returned value of ioctl is the error value
+/// except for EOENT and EINTR.) [RESM_E_NG]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// None
+/// \~english @par Detail
+/// When an event flag is not set, this is blocked. \n
+/// If an event flag is set, this stores event contents to p_evFlag and this ends. \n
+/// If this ends, it clears all of event flags.
+/// \~english @see RESM_ReqEvent
+////////////////////////////////////////////////////////////////////////////////////
+RESM_ERR_t RESM_GetEvent(uint32_t ssnld, RESM_EV_t* p_evFlag);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RESM_GetStatus
+/// \~english @par Summary
+/// Gets system state.
+/// \~english @param [in] ssnld
+/// uint32_t - Session ID
+/// \~english @param [out] p_status
+/// RESM_STATUS_t* - Pointer to system state
+/// \~english @par
+/// RESM_STATUS_t Structure
+/// \~english @code
+/// typedef struct {
+/// uint32_t restMemSize; /* Remaining memory length (KB) */
+/// RESM_NAND_WRITE_STATUS_t nandWriteStatus; /* Access permission / Prohibition state to NAND flash */
+/// RESM_INET_STATUS_t inetStatus; /* Network IF statistical information after start */
+/// } RESM_STATUS_t;
+/// @endcode
+/// \~english @par
+/// enum RESM_NAND_WRITE_STATUS_t Variables
+/// - RESM_NAND_WRITE_ENABLE : NAND access permission
+/// - RESM_NAND_WRITE_DISABLE : NAND access prohibition
+/// \~english @par
+/// Notes
+/// - When system records in NAND flash and it influences the lifetime of a device,
+/// STATUS(nandWriteStatus) becomes RESM_NAND_WRITE_DISABLE. It is not in the state where WRITE fails. \n
+/// \~english @par
+/// RESM_INET_STATUS_t Structure
+/// \~english @code
+/// typedef struct {
+/// uint32_t ifNum; /* Valid array at the number of interface and ifInfo */
+/// struct {
+/// char name[64]; /* Interface name */
+/// uint64_t rxSize; /* Receiving data length (KiB) */
+/// uint64_t txSize; /* Transmission data length (KiB) */
+/// uint8_t hwaddr[HWADDR_LEN]; /* Hardware address (MAC address) */
+/// } ifInfo[RESM_INET_IF_MAX];
+/// }RESM_INET_STATUS_t;
+/// @endcode
+/// \~english @retval RESM_E_OK Succeeded
+/// \~english @retval RESM_E_PAR %Parameter error
+/// \~english @retval RESM_E_NG Unexpected error
+/// \~english @par Preconditions
+/// - An application must finish getting a session ID by RESM_Open().
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - p_evFlag is NULL. [RESM_E_PAR]
+/// - ssnId exceeds the maximum value (EV_MAX_IDS_IN_THREAD). [RESM_E_PAR]
+/// - The in-use flag of a global variable (g_resmgr.ssnInfo[ssnId].useFlag) is FALSE. [RESM_E_PAR]
+/// - It failed to open the device file for network. [RESM_E_NG]
+/// - The number of the gotten network IF is 0. [RESM_E_NG]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// None
+/// \~english @par Detail
+/// Gets system state.
+/// This API is called from the RPC library.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+RESM_ERR_t RESM_GetStatus(uint32_t ssnld, RESM_STATUS_t* p_status);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESM_H_
+
+/** @}*/ // end of ResourceManager
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/resource_manager/server/include/system_service/resm_type.h b/systemservice/resource_manager/server/include/system_service/resm_type.h
new file mode 100755
index 0000000..1adbf37
--- /dev/null
+++ b/systemservice/resource_manager/server/include/system_service/resm_type.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.
+ */
+/**
+ * @file resm_type.h
+ * @brief \~english This file contains declaration of common enum and structures for resm library
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup resource_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESM_TYPE_H_
+#define RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESM_TYPE_H_
+
+#include <agl_thread.h>
+
+#define NTFY_ResourceMgr_Availability MN_SS_RESOURCEMGR"/Availability"
+
+#define RESM_ERR_t int32_t
+#define RESM_E_OK (0)
+#define RESM_E_PAR (-1)
+#define RESM_E_NG (-2)
+
+// Event flags (bit pattern)
+#define RESM_EV_t uint32_t
+#define RESM_EV_NOP (0x00)
+#define RESM_EV_MEM (0x01)
+#define RESM_EV_NAND_STATUS (0x02)
+
+#define RESM_RSV_t int32_t
+
+typedef enum {
+ RESM_NAND_WRITE_ENABLE = 0,
+ RESM_NAND_WRITE_DISABLE = -1
+} RESM_NAND_WRITE_STATUS_t;
+
+typedef struct {
+ RESM_EV_t reqEvent;
+ struct {
+ uint32_t restMemThresh;
+ } prm;
+} RESM_REQ_EVENT_t;
+
+#define RESM_INET_IF_MAX 5 /* tentative */
+#define HWADDR_LEN (6)
+typedef struct {
+ uint32_t ifNum;
+ struct {
+ char name[64];
+ uint64_t rxSize;
+ uint64_t txSize;
+ uint8_t hwaddr[HWADDR_LEN];
+ } ifInfo[RESM_INET_IF_MAX];
+} RESM_INET_STATUS_t;
+
+typedef struct {
+ uint32_t restMemSize;
+ RESM_NAND_WRITE_STATUS_t nandWriteStatus;
+ RESM_INET_STATUS_t inetStatus;
+} RESM_STATUS_t;
+
+#endif // RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESM_TYPE_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/resource_manager/server/include/system_service/resource_manager.h b/systemservice/resource_manager/server/include/system_service/resource_manager.h
new file mode 100755
index 0000000..48c7a4c
--- /dev/null
+++ b/systemservice/resource_manager/server/include/system_service/resource_manager.h
@@ -0,0 +1,43 @@
+/*
+ * @copyright Copyright (c) 2017-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.
+ */
+
+/**
+ * @file resource_manager.h
+ * @brief \~english include all resm_library head files
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup resource_manager
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESOURCE_MANAGER_H_
+#define RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESOURCE_MANAGER_H_
+
+#include "system_service/resm.h"
+#include "system_service/resm_type.h"
+
+#endif // RESOURCE_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_RESOURCE_MANAGER_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/resource_manager/server/src/cpuload_custom.cpp b/systemservice/resource_manager/server/src/cpuload_custom.cpp
new file mode 100755
index 0000000..c6a8e75
--- /dev/null
+++ b/systemservice/resource_manager/server/src/cpuload_custom.cpp
@@ -0,0 +1,512 @@
+/*
+ * @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.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <string.h>
+#include <errno.h>
+#include <sched.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "ss_resm_resourcemanagerlog.h"
+
+#include "resm_cfg.h"
+
+typedef struct _task_stat {
+ struct _task_stat *next;
+ char path[64];
+ pid_t pid_nr_ns;
+ char tcomm[64];
+ char state;
+ pid_t ppid;
+ pid_t pgid;
+ unsigned long utime; // NOLINT
+ unsigned long stime; // NOLINT
+ int priority;
+ int nice;
+ int task_cpu;
+ unsigned int task_rt_priority;
+ unsigned int task_policy;
+} TASK_STAT;
+
+
+typedef struct _task_rank
+{
+ pid_t pid_nr_ns;
+ char state;
+ unsigned long taskOccupancy;
+ unsigned long utime;
+ unsigned long stime;
+ int priority;
+ unsigned int task_policy;
+ int task_cpu;
+ char tcomm[64];
+} TASK_RANK;
+
+
+static TASK_STAT *g_task_stat = NULL;
+
+static int32_t g_fifo_task_pid = -1;
+static int32_t g_tss_task_pid = -1;
+static unsigned long g_fifo_task_occ = -1;
+static unsigned long g_tss_task_occ = -1;
+static int32_t g_fifo_show_timer = 0;
+static int32_t g_tss_show_timer = 0;
+static unsigned int g_startTime = 0;
+static char g_fifo_path[64];
+static char g_tss_path[64];
+static unsigned long g_fifo_utime;
+static unsigned long g_fifo_stime;
+static unsigned long g_tss_utime;
+static unsigned long g_tss_stime;
+
+
+static void cleanup_task_stat(void) {
+ TASK_STAT *p, *q;
+
+ p = g_task_stat;
+ while (p) {
+ q = p->next;
+ free(p);
+ p = q;
+ }
+ g_task_stat = NULL;
+}
+
+static int add_task_stat(TASK_STAT *tstat) {
+ TASK_STAT *p;
+
+ p = reinterpret_cast<TASK_STAT *>(malloc(sizeof(TASK_STAT)));
+ if (p == NULL) { // LCOV_EXCL_BR_LINE 5: malloc error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 5: malloc error case
+ }
+ memcpy(p, tstat, sizeof(TASK_STAT));
+ p->next = 0;
+
+ if (g_task_stat) {
+ p->next = g_task_stat;
+ }
+ g_task_stat = p;
+
+ return 0;
+}
+
+// No error : > 0
+static int get_task_stat(const char *path, TASK_STAT *tstat) {
+ pid_t sid;
+ int tty_nr, tty_pgrp;
+ unsigned long task_flags; // NOLINT
+ unsigned long min_flt, cmin_flt, maj_flt, cmaj_flt; // NOLINT
+ signed long cutime, cstime; // NOLINT
+ int num_threads, zero1;
+ unsigned long long start_time; // NOLINT
+ unsigned long vsize, mm_rss, rsslim, start_code, end_code, start_stack; // NOLINT
+ unsigned long esp, eip, task_pending_signal_sig, task_blocked_sig; // NOLINT
+ unsigned long sigign_sig, sigcatch_sig, wchan, zero2, zero3; // NOLINT
+ int exit_signal;
+ unsigned long long delayacct_blkio_ticks; // NOLINT
+ unsigned long guest_time; // NOLINT
+ signed long cguest_time; // NOLINT
+
+ int fd;
+ int ret = -1;
+#define READ_MAX_SIZE 4096
+ char buf[READ_MAX_SIZE];
+
+ fd = open(path, O_RDONLY);
+ if (fd != -1) {
+ if (read(fd, buf, sizeof(buf)) != -1) { // LCOV_EXCL_BR_LINE 5: read's error case
+ ret =
+ sscanf(
+ buf,
+ "%d %32s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %d %d %d %d %llu %lu %lu"
+ " %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld",
+ &(tstat->pid_nr_ns), tstat->tcomm, &(tstat->state),
+ &(tstat->ppid), &(tstat->pgid), &sid, &tty_nr, &tty_pgrp,
+ &task_flags, &min_flt, &cmin_flt, &maj_flt, &cmaj_flt,
+ &(tstat->utime), &(tstat->stime), &cutime, &cstime,
+ &(tstat->priority), &(tstat->nice), &num_threads, &zero1,
+ &start_time, &vsize, &mm_rss, &rsslim, &start_code, &end_code,
+ &start_stack, &esp, &eip, &task_pending_signal_sig,
+ &task_blocked_sig, &sigign_sig, &sigcatch_sig, &wchan, &zero2,
+ &zero3, &exit_signal, &(tstat->task_cpu),
+ &(tstat->task_rt_priority), &(tstat->task_policy),
+ &delayacct_blkio_ticks, &guest_time, &cguest_time);
+ }
+ close(fd);
+ }
+ return ret;
+}
+
+static void get_current_task_stat(void) {
+ TASK_STAT tstat;
+ DIR *dirp;
+ struct dirent entry;
+ struct dirent *result;
+ char path[64];
+
+ struct timespec tp;
+
+ dirp = opendir("/proc");
+ if (dirp == NULL) { // LCOV_EXCL_BR_LINE 5: opendir error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return; // LCOV_EXCL_LINE 5: opendir error case
+ }
+
+ if (clock_gettime (CLOCK_MONOTONIC, &tp) == 0) {
+ g_startTime = ((tp.tv_sec * 1000) + (tp.tv_nsec / 1000000)); // Unit is msec
+ } else {
+ g_startTime = 0;
+ }
+
+ while ((readdir_r(dirp, &entry, &result) == 0) && (result != NULL)) {
+ if ((entry.d_name[0] >= '1') && (entry.d_name[0] <= '9')) {
+ DIR *dirp2;
+ struct dirent entry2;
+ struct dirent *result2;
+
+ sprintf(path, "/proc/%s/task", entry.d_name); // NOLINT
+ dirp2 = opendir(path);
+ if (dirp2 == NULL) { // LCOV_EXCL_BR_LINE 5: opendir error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ continue; // LCOV_EXCL_LINE 5: opendir error case
+ }
+
+ while ((readdir_r(dirp2, &entry2, &result2) == 0) && (result2 != NULL)) {
+ if ((entry2.d_name[0] >= '1') && (entry2.d_name[0] <= '9')) {
+ char path2[64];
+ int ret;
+ struct timespec req = { 0, 1000000 }; // 1msec
+
+ sprintf(path2, "%s/%s/stat", path, entry2.d_name); // NOLINT
+ ret = get_task_stat(path2, &tstat);
+
+// if ((ret > 0) && (tstat.task_policy == SCHED_FIFO)) {
+ if (ret > 0) { // LCOV_EXCL_BR_LINE 200: ret must be bigger than 0
+
+ strcpy(tstat.path, path2); // NOLINT
+ add_task_stat(&tstat);
+ }
+ nanosleep(&req, NULL);
+ }
+ }
+ closedir(dirp2);
+ }
+ }
+ closedir(dirp);
+}
+
+static void show_cpuload(void) {
+ int ret;
+ TASK_STAT tstat;
+ TASK_STAT *p = g_task_stat;
+
+ TASK_RANK ttaskRankData[TASK_STAT_RANK_NUM+1];
+ TASK_RANK t_eva_taskRank;
+ int setRankDatanum = 0;
+ int checkCounter;
+
+ unsigned long dtime; // NOLINT
+ unsigned long dtime_urank;
+ unsigned long dtime_drank;
+ struct timespec tp;
+ unsigned int endTime = 0;
+
+// if (p) {
+// FRAMEWORKUNIFIEDLOG(
+// ZONE_INFO,
+// __FUNCTION__,
+// "[CpuHighLoad]Please check User backtrace of following processes in kernel.log");
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+// "[CpuHighLoad] PID ST PRI POLICY cpuX %%CPU (ut:st) comm");
+// }
+ if (clock_gettime (CLOCK_MONOTONIC, &tp) == 0) {
+ endTime = ((tp.tv_sec * 1000) + (tp.tv_nsec / 1000000)); // Unit is msec
+ } else {
+ endTime = (WTC_CPU_INTERVAL * 1000) + g_startTime;
+ }
+ if (endTime - g_startTime <= 0) { // LCOV_EXCL_BR_LINE 200: (endTime - g_startTime) must be bigger than 0
+ // LCOV_EXCL_START 200: (endTime - g_startTime) must be bigger than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG (ZONE_WARN, __FUNCTION__, "[CpuHighLoad] Timer abnormality.");
+ endTime = g_startTime + 1;
+ // LCOV_EXCL_STOP
+ }
+
+ while (p) {
+ ret = get_task_stat(p->path, &tstat);
+ if (ret >= 0) {
+
+#if 0
+ dtime = (tstat.utime + tstat.stime) - (p->utime + p->stime);
+ if (dtime > 0) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "[CpuHighLoad]%5d %c %3d %5s cpu%d %4lu (%lu:%lu) %s",
+ p->pid_nr_ns,
+ p->state,
+ p->priority,
+ p->task_policy == SCHED_FIFO ? "FIFO" :
+ p->task_policy == SCHED_RR ? "RR" : "OTHER",
+ p->task_cpu, dtime, tstat.utime - p->utime, tstat.stime - p->stime,
+ p->tcomm);
+ if ((dtime >= 70) // %%CPU 70% over only
+ && (getpid() != p->pid_nr_ns) // except current process
+ && (strcmp(p->tcomm, "(NS_BackupMgr)"))) { // except "BackupMgr"
+// print_backtrace_pid (p->pid_nr_ns); // backtrace in kernel.log
+ }
+ }
+ }
+ p = p->next;
+ }
+#endif
+ dtime = (((tstat.utime + tstat.stime) - (p->utime + p->stime)) * 1000) / (endTime - g_startTime);
+ if (((tstat.utime + tstat.stime) - (p->utime + p->stime)) > 0) {
+ if (setRankDatanum <= TASK_STAT_RANK_NUM) {
+ ttaskRankData[setRankDatanum].pid_nr_ns = p->pid_nr_ns;
+ ttaskRankData[setRankDatanum].state = p->state;
+ ttaskRankData[setRankDatanum].priority = p->priority;
+ ttaskRankData[setRankDatanum].task_policy = p->task_policy;
+ ttaskRankData[setRankDatanum].task_cpu = p->task_cpu;
+ ttaskRankData[setRankDatanum].taskOccupancy = dtime;
+ ttaskRankData[setRankDatanum].utime = tstat.utime - p->utime;
+ ttaskRankData[setRankDatanum].stime = tstat.stime - p->stime;
+ strcpy(ttaskRankData[setRankDatanum].tcomm, p->tcomm);
+ setRankDatanum++;
+ } else {
+ ttaskRankData[TASK_STAT_RANK_NUM].pid_nr_ns = p->pid_nr_ns;
+ ttaskRankData[TASK_STAT_RANK_NUM].state = p->state;
+ ttaskRankData[TASK_STAT_RANK_NUM].priority = p->priority;
+ ttaskRankData[TASK_STAT_RANK_NUM].task_policy = p->task_policy;
+ ttaskRankData[TASK_STAT_RANK_NUM].task_cpu = p->task_cpu;
+ ttaskRankData[TASK_STAT_RANK_NUM].taskOccupancy = dtime;
+ ttaskRankData[TASK_STAT_RANK_NUM].utime = tstat.utime - p->utime;
+ ttaskRankData[TASK_STAT_RANK_NUM].stime = tstat.stime - p->stime;
+ strcpy(ttaskRankData[TASK_STAT_RANK_NUM].tcomm, p->tcomm);
+ }
+ for (checkCounter = (setRankDatanum - 1); checkCounter > 0; checkCounter--) {
+ dtime_urank = ttaskRankData[checkCounter - 1].utime + ttaskRankData[checkCounter - 1].stime;
+ dtime_drank = ttaskRankData[checkCounter].utime + ttaskRankData[checkCounter].stime;
+ if (dtime_urank < dtime_drank) {
+ t_eva_taskRank.pid_nr_ns = ttaskRankData[checkCounter].pid_nr_ns;
+ t_eva_taskRank.state = ttaskRankData[checkCounter].state;
+ t_eva_taskRank.priority = ttaskRankData[checkCounter].priority;
+ t_eva_taskRank.task_policy = ttaskRankData[checkCounter].task_policy;
+ t_eva_taskRank.task_cpu = ttaskRankData[checkCounter].task_cpu;
+ t_eva_taskRank.taskOccupancy = ttaskRankData[checkCounter].taskOccupancy;
+ t_eva_taskRank.utime = ttaskRankData[checkCounter].utime;
+ t_eva_taskRank.stime = ttaskRankData[checkCounter].stime;
+ strcpy(t_eva_taskRank.tcomm, ttaskRankData[checkCounter].tcomm);
+
+ ttaskRankData[checkCounter].pid_nr_ns = ttaskRankData[checkCounter - 1].pid_nr_ns;
+ ttaskRankData[checkCounter].state = ttaskRankData[checkCounter - 1].state;
+ ttaskRankData[checkCounter].priority = ttaskRankData[checkCounter - 1].priority;
+ ttaskRankData[checkCounter].task_policy = ttaskRankData[checkCounter - 1].task_policy;
+ ttaskRankData[checkCounter].task_cpu = ttaskRankData[checkCounter - 1].task_cpu;
+ ttaskRankData[checkCounter].taskOccupancy = ttaskRankData[checkCounter - 1].taskOccupancy;
+ ttaskRankData[checkCounter].utime = ttaskRankData[checkCounter - 1].utime;
+ ttaskRankData[checkCounter].stime = ttaskRankData[checkCounter - 1].stime;
+ strcpy(ttaskRankData[checkCounter].tcomm, ttaskRankData[checkCounter - 1].tcomm);
+
+ ttaskRankData[checkCounter - 1].pid_nr_ns = t_eva_taskRank.pid_nr_ns;
+ ttaskRankData[checkCounter - 1].state = t_eva_taskRank.state;
+ ttaskRankData[checkCounter - 1].priority = t_eva_taskRank.priority;
+ ttaskRankData[checkCounter - 1].task_policy = t_eva_taskRank.task_policy;
+ ttaskRankData[checkCounter - 1].task_cpu = t_eva_taskRank.task_cpu;
+ ttaskRankData[checkCounter - 1].taskOccupancy = t_eva_taskRank.taskOccupancy;
+ ttaskRankData[checkCounter - 1].utime = t_eva_taskRank.utime;
+ ttaskRankData[checkCounter - 1].stime = t_eva_taskRank.stime;
+ strcpy(ttaskRankData[checkCounter - 1].tcomm, t_eva_taskRank.tcomm);
+ } else {
+ break;
+ }
+ }
+ if ((dtime >= TASK_STAT_THRESHOLD) && // %%CPU over only
+ (getpid() != p->pid_nr_ns) && // except current process
+ (strcmp (p->tcomm, "(NS_BackupMgr)"))) { // except "BackupMgr"
+ if (p->task_policy == SCHED_FIFO) {
+ if ((g_fifo_task_occ < dtime) && (g_fifo_show_timer == 0)) { // first time only
+ g_fifo_task_pid = p->pid_nr_ns;
+ g_fifo_task_occ = dtime;
+ g_fifo_utime = tstat.utime;
+ g_fifo_stime = tstat.stime;
+ strcpy(g_fifo_path,p->path);
+ } else if (g_fifo_task_pid == p->pid_nr_ns) {
+ g_fifo_task_occ = dtime;
+ g_fifo_utime = tstat.utime;
+ g_fifo_stime = tstat.stime;
+ strcpy(g_fifo_path,p->path);
+ }
+ } else {
+ if ((g_tss_task_occ < dtime) && (g_tss_show_timer == 0)) { // first time only
+ g_tss_task_pid = p->pid_nr_ns;
+ g_tss_task_occ = dtime;
+ g_tss_utime = tstat.utime;
+ g_tss_stime = tstat.stime;
+ strcpy(g_tss_path,p->path);
+ } else if (g_tss_task_pid == p->pid_nr_ns) {
+ g_tss_task_occ = dtime;
+ g_tss_utime = tstat.utime;
+ g_tss_stime = tstat.stime;
+ strcpy(g_tss_path,p->path);
+ }
+ }
+ }
+ }
+ }
+ p = p->next;
+ }
+
+ if (setRankDatanum != 0) {
+ FRAMEWORKUNIFIEDLOG (ZONE_WARN, __FUNCTION__, "[CpuHighLoad] PID ST PRI POLICY cpuX %%CPU (%%ut:%%st) comm");
+ for (checkCounter = 0;
+ checkCounter < (setRankDatanum < TASK_STAT_RANK_NUM ? setRankDatanum : TASK_STAT_RANK_NUM); checkCounter++) {
+ FRAMEWORKUNIFIEDLOG (ZONE_WARN, __FUNCTION__, "[CpuHighLoad]%5d %c %3d %5s cpu%d %4lu (%2lu.%03lu:%2lu.%03lu) %s",
+ ttaskRankData[checkCounter].pid_nr_ns,
+ ttaskRankData[checkCounter].state,
+ ttaskRankData[checkCounter].priority,
+ ttaskRankData[checkCounter].task_policy == SCHED_FIFO ? "FIFO"
+ : ttaskRankData[checkCounter].task_policy == SCHED_RR ? "RR" : "TSS",
+ ttaskRankData[checkCounter].task_cpu,
+ ttaskRankData[checkCounter].taskOccupancy,
+ ttaskRankData[checkCounter].utime * 100 / ((endTime - g_startTime)/10),
+ ttaskRankData[checkCounter].utime * 100 % ((endTime - g_startTime)/10),
+ ttaskRankData[checkCounter].stime * 100 / ((endTime - g_startTime)/10),
+ ttaskRankData[checkCounter].stime * 100 % ((endTime - g_startTime)/10),
+ ttaskRankData[checkCounter].tcomm);
+ }
+ FRAMEWORKUNIFIEDLOG (ZONE_WARN, __FUNCTION__, "[CpuHighLoad] -------------------------------------------------");
+ }
+
+}
+
+
+static void
+show_cpuload_onetask(int loadType) {
+ int ret;
+ TASK_STAT tstat;
+ unsigned long dtime;
+ struct timespec tp;
+ unsigned int endTime = 0;
+ char loadPath[64];
+ unsigned long beforeUtime;
+ unsigned long beforeStime;
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
+ endTime = ((tp.tv_sec * 1000) + (tp.tv_nsec / 1000000)); // Unit is msec
+ } else {
+ endTime = (WTC_CPU_INTERVAL * 1000) + g_startTime;
+ }
+ if (endTime - g_startTime <= 0) { // LCOV_EXCL_BR_LINE 200: (endTime - g_startTime) must be bigger than 0
+ // LCOV_EXCL_START 200: (endTime - g_startTime) must be bigger than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG (ZONE_WARN, __FUNCTION__, "[CpuHighLoad] Timer abnormality.");
+ endTime = g_startTime + 1;
+ // LCOV_EXCL_STOP
+ }
+ if (loadType == FIFO_TASK_SHOW) { // LCOV_EXCL_BR_LINE 200: loadType can't be FIFO_TASK_SHOW
+ // LCOV_EXCL_START 200: loadType can't be FIFO_TASK_SHOW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ strcpy(loadPath,g_fifo_path);
+ beforeUtime = g_fifo_utime;
+ beforeStime = g_fifo_stime;
+ // LCOV_EXCL_STOP
+ } else {
+ strcpy(loadPath,g_tss_path);
+ beforeUtime = g_tss_utime;
+ beforeStime = g_tss_stime;
+ }
+ if (strlen(loadPath) > 0) {
+ ret = get_task_stat(loadPath, &tstat);
+ if (ret >= 0) {
+ dtime = (((tstat.utime + tstat.stime) - (beforeUtime + beforeStime)) * 1000) / (endTime - g_startTime);
+ if (tstat.task_policy == SCHED_FIFO) {
+ g_fifo_task_occ = dtime;
+ g_fifo_utime = tstat.utime;
+ g_fifo_stime = tstat.stime;
+ } else {
+ g_tss_task_occ = dtime;
+ g_tss_utime = tstat.utime;
+ g_tss_stime = tstat.stime;
+ }
+ }
+ }
+}
+
+
+
+//void logging_cpuload_custom(void) {
+// struct timespec req = { 1, 0 }; // 1sec
+//
+// cleanup_task_stat();
+// get_current_task_stat();
+//
+// nanosleep(&req, NULL);
+//
+// show_cpuload();
+//}
+unsigned long
+logging_cpuload_custom(int32_t tmode) {
+ int32_t res = 0;
+ if (tmode == CPU_TASK_INIT) {
+ g_fifo_task_pid = -1;
+ g_tss_task_pid = -1;
+ g_fifo_task_occ = 0;
+ g_tss_task_occ = 0;
+ g_fifo_utime = 0;
+ g_fifo_stime = 0;
+ g_tss_utime = 0;
+ g_tss_stime = 0;
+ memset(g_fifo_path, 0x00, sizeof(g_fifo_path));
+ memset(g_tss_path, 0x00, sizeof(g_tss_path));
+ cleanup_task_stat();
+ get_current_task_stat();
+ } else if (tmode == CPU_TASK_SHOW_BF) {
+ cleanup_task_stat();
+ get_current_task_stat();
+ } else if (tmode == CPU_TASK_SHOW_AF) {
+ show_cpuload();
+ } else if (tmode == FIFO_TASK_SHOW) { // LCOV_EXCL_BR_LINE 200: tmode can't be FIFO_TASK_SHOW
+ // LCOV_EXCL_START 200: tmode can't be FIFO_TASK_SHOW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ show_cpuload_onetask(FIFO_TASK_SHOW);
+ // LCOV_EXCL_STOP
+ } else if (tmode == TSS_TASK_SHOW) {
+ show_cpuload_onetask(TSS_TASK_SHOW);
+ } else if (tmode == CPU_FIFO_TASK_GET_ID) {
+ res = g_fifo_task_pid;
+ g_fifo_show_timer = 0;
+ } else if (tmode == CPU_TSS_TASK_GET_ID) {
+ res = g_tss_task_pid;
+ g_tss_show_timer = 0;
+ } else if (tmode == CPU_FIFO_TASK_GET_OCCUPANCY) {
+ g_fifo_show_timer = g_fifo_show_timer + WTC_CPU_INTERVAL;
+ res = g_fifo_task_occ;
+ g_fifo_task_occ = 0;
+ } else if (tmode == CPU_TSS_TASK_GET_OCCUPANCY) { // LCOV_EXCL_BR_LINE 200: tmode can't be other value
+ g_tss_show_timer = g_tss_show_timer + WTC_CPU_INTERVAL;
+ res = g_tss_task_occ;
+ g_tss_task_occ = 0;
+ }
+ return res;
+}
+
diff --git a/systemservice/resource_manager/server/src/proc_watch.cpp b/systemservice/resource_manager/server/src/proc_watch.cpp
new file mode 100755
index 0000000..c432af1
--- /dev/null
+++ b/systemservice/resource_manager/server/src/proc_watch.cpp
@@ -0,0 +1,285 @@
+/*
+ * @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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/timerfd.h>
+#include <sys/vfs.h> /* or <sys/statfs.h> */
+#include <dirent.h>
+#include <stdlib.h>
+
+#include <soc_temperature_hal.h>
+
+#include "ss_resm_resourcemanagerlog.h"
+#include "proc_watch.h"
+#include "resm_cfg.h"
+#include "resm_internal.h"
+
+#define WTC_TMPFS_INTERVAL (5)
+#define WTC_MEM_INTERVAL (5)
+#define DEBUG_INFO_OUTPUT_FREQ (1)
+
+extern int isNfs;
+extern void watchMem(void);
+extern void outputResouceInfo(void);
+extern EFrameworkunifiedStatus resourcemanagerlog_flag_check(UI_8 *mode);
+
+#define _SOC_TEMP_MONITOR_
+
+#if defined(_SOC_TEMP_MONITOR_)
+
+/*********************************************************************************
+ * Soc Temperature
+ register THSSR : T = CTEMP[5-0] x 5 - 65 [Celsius]
+ *********************************************************************************/
+#define SOC_TEMP_WATCH_INTVAL_TIMESEC (3 * 60) // 3 minutes
+// #define SOC_TEMP_WATCH_INTVAL_TIMESEC (1 * 5) // for debug
+#define THSSR_TEMP_MASK 0x0000003F
+#define TEMP_120 (120)
+
+static float last_temp;
+
+static void soc_temp_init(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_SOC_TEMP, __FUNCTION__, "start");
+ last_temp = 0.0f;
+}
+
+static void soc_temp(void) {
+ float temp = 0.0f;
+ EFrameworkunifiedStatus e_status = GetSoCTemperature(&temp);
+ if (eFrameworkunifiedStatusOK != e_status) {
+ FRAMEWORKUNIFIEDLOG(ZONE_SOC_TEMP, __FUNCTION__,
+ "THSSR:GetSoCTemperature e_status(%d)", e_status);
+ return;
+ }
+
+ if (TEMP_120 <= temp) {
+ // FRAMEWORKUNIFIEDLOG
+ FRAMEWORKUNIFIEDLOG(ZONE_SOC_TEMP, __FUNCTION__, "%f", temp); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ } else {
+ // FRAMEWORKUNIFIEDLOG
+ if (TEMP_120 <= last_temp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_SOC_TEMP, __FUNCTION__, "%f", temp); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ }
+ last_temp = temp;
+}
+#endif // defined ( _SOC_TEMP_MONITOR_ )
+
+//
+// Monitor /tmp
+//
+#define TMP_USED_SIZE (100*1024) // 100MB
+#define TMPFS_PATH "/tmp"
+static int watch_tmpfs_enable = 1;
+
+static void printdir(const char* path) {
+ DIR *dirp;
+ struct dirent entry, *next;
+ char buf[512];
+
+ dirp = opendir(path);
+ if (dirp == NULL) { // LCOV_EXCL_BR_LINE 5: opendir's error case.
+ // LCOV_EXCL_START 5: opendir's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "opendir(%s) error.(%d)\n", path, errno);
+ return;
+ // LCOV_EXCL_STOP 5: opendir's error case.
+ }
+ while ((readdir_r(dirp, &entry, &next) == 0) && next != NULL) {
+ if (((strlen(entry.d_name) == 1) && (strcmp(entry.d_name, ".") == 0))
+ || ((strlen(entry.d_name) == 2) && (strcmp(entry.d_name, "..") == 0))) {
+ continue;
+ }
+ if ((strlen(path) + strlen(entry.d_name) + 2) <= sizeof(buf)) {/* 2: '/','\0' */
+ struct stat stat_buf;
+
+ strcpy(buf, path); // NOLINT
+ strcat(buf, "/"); // NOLINT
+ strcat(buf, entry.d_name); // NOLINT
+ if (stat(buf, &stat_buf) == -1) { // LCOV_EXCL_BR_LINE 5: stat error case
+ // LCOV_EXCL_START 5: stat error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s stat error! (%d)\n", buf, errno);
+ // LCOV_EXCL_STOP 5: stat's error case.
+ } else if (S_ISDIR(stat_buf.st_mode)) {
+ printdir(buf);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s %ld bytes", buf, stat_buf.st_size);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "path(%s) name(%s) length over!\n", path,
+ entry.d_name);
+ }
+ }
+ closedir(dirp);
+
+ return;
+}
+
+static void watchtmpfs(void) {
+ int ret;
+ struct statfs buf;
+ long used; // NOLINT
+
+ if (!watch_tmpfs_enable) {
+ return;
+ }
+ ret = statfs(TMPFS_PATH, &buf);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: statfs error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return; // LCOV_EXCL_LINE 5: statfs error case
+ }
+ used = (buf.f_blocks - buf.f_bavail) * buf.f_bsize / 1024; // KB
+ if (used > TMP_USED_SIZE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s Used %ld KB > %d KB",
+ TMPFS_PATH,
+ used, TMP_USED_SIZE);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "----- print %s start -----", TMPFS_PATH);
+ printdir(TMPFS_PATH);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "----- print %s end -----", TMPFS_PATH);
+ watch_tmpfs_enable = 0;
+ }
+}
+
+/*********************************************************************************
+ * proc_watch thread main
+ *********************************************************************************/
+void *
+PRCW_main(void *p) {
+ fd_set fds;
+ int32_t maxFd = 0;
+ int32_t timerFd;
+ struct itimerspec tm;
+ int32_t sec = 0;
+ EFrameworkunifiedStatus flagRet;
+ uint64_t exp;
+ int ret;
+ UI_8 mode;
+#if defined(_SOC_TEMP_MONITOR_)
+ int32_t timerFd2;
+ struct itimerspec tm2;
+#endif // defined(_SOC_TEMP_MONITOR_)
+
+ /* Memory monitoring and display debug information */
+ timerFd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
+ if (timerFd == -1) { // LCOV_EXCL_BR_LINE 5: timerfd_create error case
+ // LCOV_EXCL_START 5: timerfd_create error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Create timerFd Failed. errno[%d]", errno);
+ // LCOV_EXCL_STOP 5: timerfd_create error case
+ } else {
+ tm.it_value.tv_sec = MONITORING_START_DELAT_TIME;
+ tm.it_value.tv_nsec = 0;
+ tm.it_interval.tv_sec = 1;
+ tm.it_interval.tv_nsec = 0;
+ if (timerfd_settime(timerFd, 0, &tm, NULL) == -1) { // LCOV_EXCL_BR_LINE 5: timerfd_create error case
+ // LCOV_EXCL_START 5: timerfd_settime error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Set timerFd Failed. errno[%d]", errno);
+ // LCOV_EXCL_STOP 5: timerfd_settime error case
+ }
+ }
+
+#if defined(_SOC_TEMP_MONITOR_)
+ /* Soc temperature monitoring */
+ timerFd2 = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
+ if (timerFd2 == -1) { // LCOV_EXCL_BR_LINE 5: timerfd_create error case
+ // LCOV_EXCL_START 5: timerfd_create error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Create timerFd2 Failed. errno[%d]", errno);
+ // LCOV_EXCL_STOP 5: timerfd_create error case
+ } else {
+ tm2.it_value.tv_sec = 1;
+ tm2.it_value.tv_nsec = 0;
+ tm2.it_interval.tv_sec = SOC_TEMP_WATCH_INTVAL_TIMESEC;
+ tm2.it_interval.tv_nsec = 0;
+ if (timerfd_settime(timerFd2, 0, &tm2, NULL) == -1) { // LCOV_EXCL_BR_LINE 5: timerfd_settime error case
+ // LCOV_EXCL_START 5: timerfd_settime error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Set timerFd2 Failed. errno[%d]", errno);
+ // LCOV_EXCL_STOP 5: timerfd_settime error case
+ }
+ soc_temp_init();
+ }
+#endif // defined(_SOC_TEMP_MONITOR_)
+
+ while (1) {
+ FD_ZERO(&fds);
+ if (timerFd != -1) { // LCOV_EXCL_BR_LINE 5: timerfd_create's error case
+ FD_SET(timerFd, &fds);
+ maxFd = MY_MAX(maxFd, timerFd);
+ }
+#if defined(_SOC_TEMP_MONITOR_)
+ if (timerFd2 != -1) { // LCOV_EXCL_BR_LINE 5: timerfd_create's error case
+ FD_SET(timerFd2, &fds);
+ maxFd = MY_MAX(maxFd, timerFd2);
+ }
+#endif // defined(_SOC_TEMP_MONITOR_)
+
+ ret = select(maxFd + 1, &fds, NULL, NULL, NULL);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: select error case
+ // LCOV_EXCL_START 5: select error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno != EINTR) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Handle Error");
+ exit(EXIT_FAILURE);
+ }
+ continue;
+ // LCOV_EXCL_STOP 5: select error case
+ }
+
+ if ((timerFd != -1) && FD_ISSET(timerFd, &fds)) {
+ read(timerFd, &exp, sizeof(uint64_t));
+ /* Memory monitoring */
+ if ((sec % WTC_MEM_INTERVAL) == 0) {
+ watchMem();
+ }
+ /* tmpfs monitoring */
+ if (!isNfs && ((sec % WTC_TMPFS_INTERVAL) == 0)) {
+ watchtmpfs();
+ }
+ /* Display debug information */
+ if ((sec % DEBUG_INFO_OUTPUT_FREQ) == 0) {
+ flagRet = resourcemanagerlog_flag_check(&mode);
+ if ((flagRet == eFrameworkunifiedStatusOK) && (mode == FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG)) {
+ outputResouceInfo();
+ }
+ }
+ if (sec >= RESET_SEC) {
+ sec = 0;
+ }
+ sec++;
+ }
+#if defined(_SOC_TEMP_MONITOR_)
+ if ((timerFd2 != -1) && FD_ISSET(timerFd2, &fds)) {
+ read(timerFd2, &exp, sizeof(uint64_t));
+ soc_temp();
+ }
+#endif // defined(_SOC_TEMP_MONITOR_)
+ }
+ return p;
+}
diff --git a/systemservice/resource_manager/server/src/resm.cpp b/systemservice/resource_manager/server/src/resm.cpp
new file mode 100755
index 0000000..41caa19
--- /dev/null
+++ b/systemservice/resource_manager/server/src/resm.cpp
@@ -0,0 +1,2667 @@
+/*
+ * @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.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdint.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/timerfd.h>
+#include <sys/wait.h>
+#include <sched.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <signal.h>
+
+// NSFW
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_version_if.h>
+#include <system_service/ss_services.h>
+#include <native_service/frameworkunified_application.h>
+#include <system_service/ss_system_if.h>
+#include <system_service/ss_version.h>
+#include <native_service/cl_process.h>
+#include <system_service/ss_system_process.h>
+#include <other_service/rpc.h>
+#include "resmgr_srvr.h"
+#include "resm_internal.h"
+#include "resmgr_api.h"
+#include "ss_resm_resourcemanagerlog.h"
+#include "resm_cfg.h"
+#include "proc_watch.h"
+
+
+// NSFW
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
+/**********************************************
+ * Constant definitions
+ **********************************************/
+#define Resm_Flag_ID_Base EV_Flag_ID_Base(RESMGR_MID)
+#define RESM_SUB_PRIORITY (0)
+
+// #define WTC_CPU_INTERVAL (3)
+
+#define CPULOAD_INVALID (-2)
+#define CPULOAD_READY (-1)
+#define CPULOG_TIMER_CLEAR (1)
+#define CPULOG_LOGGING (0)
+#define CPULOG_NO_LOGGING (-1)
+
+#define PROCNET_DEV_FILE "/proc/net/dev"
+#define MEMINFO_FILE "/proc/meminfo"
+#define PROC_STAT_FILE "/proc/stat"
+
+#define BYTE_TO_KIBIBYTE (1024)
+#define KIBIBYTE_TO_BYTE (1024)
+#define PERF_PNAME_MAX 128 // Max path name of process
+#define PERF_PATH "/usr/bin/perf"
+#define PERF_FILE "/tmp/perf"
+#define PERF_DUMP "/tmp/perf_dump"
+#define PERF_REPORT_DELAY 1 // 1 sec
+#define PERF_REPORT_RETRY 3 // retry 3 times
+#define CPULOAD_NICEVAL 10 // value of nice() to lower priority
+
+#define DEBUG_INFO_DIRPATH "/tmp/diag_analysis"
+#define DEBUG_INFO_FPATH DEBUG_INFO_DIRPATH"/dispinfo_resource.dbg"
+#define DEBUG_INFO_TMPPATH DEBUG_INFO_DIRPATH"/dispinfo_resource.tmp"
+#define DEBUG_INFO_MEM_LETTERS (25)
+#define DEBUG_INFO_CPU_TOP_LINES (10)
+#define DEBUG_INFO_CMA_MIN (160000) // in KB
+#define DEBUG_INFO_CMA_LETTERS (20)
+#define DEBUG_INFO_DSP_PG_PATH "/usr/agl/bin/bs_analysis_dispinfo_debug"
+
+#define DROP_CACHES_PG_PATH "/usr/agl/bin/drop_caches"
+
+#define READLINE_MAX_SIZE 512
+#define READ_MAX_SIZE 4096
+#define LF (0x0A)
+
+/**********************************************
+ * Structure definitions
+ **********************************************/
+// App session information
+typedef struct {
+ BOOL useFlag;
+ RESM_REQ_EVENT_t reqEv; // event request
+} SSN_INFO_t;
+
+// CPU usage information
+typedef struct {
+ char cpuname[8];
+ int32_t user;
+ int32_t nice;
+ int32_t system;
+ int32_t idle;
+ int32_t iowait;
+ int32_t irq;
+ int32_t softirq;
+ int32_t steal;
+ int32_t guest;
+ int32_t guest_nice;
+} CPU_INFO_t;
+
+//Context
+typedef struct {
+ char procName[128];
+ HANDLE hApp; // DispatcherHandle
+ int32_t nsFd; // For receiving from the NSFW
+
+ // Session information
+ SSN_INFO_t ssnInfo[EV_MAX_IDS_IN_THREAD];
+
+ // Memory information
+ uint32_t restMem; // Remaining memory information
+ BOOL restMemFlag;
+
+ // CMA information
+ uint32_t restCma;
+ BOOL restCmaFlag;
+
+
+ // CPU load information
+// int32_t cpuloadRate;
+} SVC_COMMON_t;
+
+// meminfo table
+typedef struct {
+ const char* name;
+ uint32_t* value;
+} meminfo_tbl;
+
+/**********************************************
+ * External variable definitions
+ **********************************************/
+// FRAMEWORKUNIFIEDLOG
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
+ FRAMEWORKUNIFIEDLOGOPTIONS, {
+ ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ ZONE_TEXT_31
+ }, FRAMEWORKUNIFIEDLOGZONES
+};
+
+int isNfs; // NFS env : 1
+
+static SVC_COMMON_t g_resmgr; // NOLINT (readability/nolint)
+static int32_t g_sock = -1;
+static uint32_t inactFile_kib;
+static uint32_t mainFree_kib;
+static uint32_t memTotal_kib;
+static uint32_t cmaFree_kib;
+static uint32_t cmaTotal_kib;
+static uint32_t minRestMem; // Minimum memory available
+static uint32_t minRestCma; // Minimum CMA available
+static int32_t g_cpuloadRate1000;
+static int g_cpu_num;
+static CPU_INFO_t *g_cpuload_pre;
+static CPU_INFO_t *g_cpuload;
+
+static int32_t g_fifo_status = STATUS_IDOL;
+static int32_t g_tss_status = STATUS_IDOL;
+static int32_t g_fifo_timer = 0;
+static int32_t g_tss_timer = 0;
+
+
+/**********************************************
+ * Local function definition
+ **********************************************/
+static void ctxCreate(SVC_COMMON_t* p_ctx, int32_t argc, char* argv[]);
+
+// Session related
+static int32_t get_new_id(uint32_t* ssnId);
+
+// Memory monitoring
+void watchMem(void);
+static int32_t comp_meminfo_tbl(const void* a, const void* b);
+static int32_t get_meminfo(void);
+
+// Network monitoring
+static int32_t getInetStatus(RESM_INET_STATUS_t* p_iStatus);
+static char* get_aliasName(char* name, char* line);
+static int32_t get_hwaddr(char* name, char* hwaddr);
+
+// CPU monitoring
+
+static void watchCPUStatus(void);
+static void watchCPU(void);
+static int32_t get_cpuload(CPU_INFO_t* p_cpu);
+static int32_t calc_cpuloadRate(void);
+static int32_t calc_cpuloadRate_each(int num);
+
+// static int32_t chk_logging(int32_t cpuload, int32_t timer);
+// static void logging_cpuload(void);
+
+static void trim_end(char* buf);
+
+// static void escape_percent(char* in, char* out);
+static void init_cpuload(void);
+
+// extern void logging_cpuload_custom(void);
+static void exec_perf(int32_t t_pid);
+extern unsigned long logging_cpuload_custom(int32_t tmode);
+
+
+// Debug information output
+void outputResouceInfo(void);
+static int write_meminfo_work(FILE *wfp);
+static int write_cpuinfo_work(FILE *wfp);
+static int write_cmainfo_work(FILE *wfp);
+static int write_resourcemanagerloginfo_work(void);
+
+/*******************************************************************************
+ * RPC public API
+ *******************************************************************************/
+/* Event issuance request */
+RESM_ERR_t RESM_ReqEvent(uint32_t ssnId, const RESM_REQ_EVENT_t* p_reqEvent) {
+ // Argument check
+ if (p_reqEvent == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr ReqEvent Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ if (ssnId >= EV_MAX_IDS_IN_THREAD) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr ReqEvent Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ if (!g_resmgr.ssnInfo[ssnId].useFlag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr ReqEvent Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ // Event type check
+ if (p_reqEvent->reqEvent == RESM_EV_MEM) {
+ // Record event issuance request
+ memcpy(&g_resmgr.ssnInfo[ssnId].reqEv, p_reqEvent,
+ sizeof(RESM_REQ_EVENT_t));
+ }
+
+ return RESM_E_OK;
+}
+
+/* Get system status */
+RESM_ERR_t RESM_GetStatus(uint32_t ssnId, RESM_STATUS_t* p_status) {
+ int32_t ret;
+
+ // Argument check
+ if (p_status == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr GetStatus Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ if (ssnId >= EV_MAX_IDS_IN_THREAD) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr GetStatus Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ if (!g_resmgr.ssnInfo[ssnId].useFlag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr GetStatus Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ if (!g_resmgr.restMemFlag) {
+ // No remaining memory information
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr GetStatus get restmem Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ return RESM_E_NG;
+ }
+ p_status->restMemSize = g_resmgr.restMem;
+ p_status->nandWriteStatus = RESM_NAND_WRITE_ENABLE; //[]Always possible
+
+ ret = getInetStatus(&p_status->inetStatus);
+ if (ret != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr GetStatus getInetStatus Error");
+ return RESM_E_NG;
+ }
+
+ return RESM_E_OK;
+}
+
+/*******************************************************************************
+ * Internal API
+ *******************************************************************************/
+/* Session connection */
+RESM_ERR_t RESM_SV_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnId) {
+ int32_t ret;
+
+ ret = get_new_id(p_ssnId);
+ if (ret != 0) {
+ return RESM_E_NG;
+ }
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "ResMgr Open Session:ID=[%d]", *p_ssnId);
+
+ return RESM_E_OK;
+}
+
+/* Session disconnection */
+RESM_ERR_t RESM_SV_Close(uint32_t ssnId) {
+ // Argument check
+ if (ssnId >= EV_MAX_IDS_IN_THREAD) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr Close Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ if (!g_resmgr.ssnInfo[ssnId].useFlag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr Close Invalid Arg");
+ return RESM_E_PAR;
+ }
+
+ // Turn off used flag
+ g_resmgr.ssnInfo[ssnId].useFlag = FALSE;
+
+ // Clear event request
+ memset(&g_resmgr.ssnInfo[ssnId].reqEv, 0, sizeof(RESM_REQ_EVENT_t));
+
+ return RESM_E_OK;
+}
+
+/* Session ID check */
+RESM_ERR_t RESM_SV_ChkSsnId(uint32_t ssnId) {
+ if (ssnId >= EV_MAX_IDS_IN_THREAD) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr ssnId[%d] over MAX", ssnId);
+ return RESM_E_NG;
+ }
+
+ if (!g_resmgr.ssnInfo[ssnId].useFlag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr ssnId[%d] is unidentified",
+ ssnId);
+ return RESM_E_NG;
+ }
+
+ return RESM_E_OK;
+}
+
+/**********************************************
+ * Initialization function
+ **********************************************/
+/* Context Initialization */
+static void ctxCreate(SVC_COMMON_t* p_ctx, int32_t argc, char* argv[]) {
+ EFrameworkunifiedStatus resourcemanagerRet;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cbFuncs);
+ FRAMEWORKUNIFIED_SET_ZONES();
+
+ memset(p_ctx, 0, sizeof(SVC_COMMON_t));
+ strcpy(p_ctx->procName, SS_RESOURCE_MANAGER); // NOLINT
+
+ // Create a Dispatcher
+ resourcemanagerRet = FrameworkunifiedCreateDispatcherWithoutLoop(p_ctx->procName, p_ctx->hApp, argc,
+ argv, &cbFuncs, TRUE);
+ if (resourcemanagerRet != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Create Dispatcher Failed. ret[%d]", resourcemanagerRet);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ resourcemanagerRet = FrameworkunifiedGetDispatcherFD(p_ctx->hApp, &p_ctx->nsFd);
+ if (resourcemanagerRet != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Get Dispatcher FD Failed. ret[%d]", resourcemanagerRet);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ // Initialize session
+ memset(p_ctx->ssnInfo, 0, sizeof(p_ctx->ssnInfo));
+
+
+// // Initialize CPU Information
+// g_resmgr.cpuloadRate = CPULOAD_INVALID;
+
+
+ return;
+}
+
+/**********************************************
+ * Get FRAMEWORKUNIFIEDLOG BasePF Flag
+ **********************************************/
+static EFrameworkunifiedStatus resourcemanagerlog_output_debug_info;
+#define RESOURCEMANAGERLOG_BASEPF_FLAG_ID (11)
+
+EFrameworkunifiedStatus resourcemanagerlog_flag_check(UI_8 *mode) {
+ if (resourcemanagerlog_output_debug_info != eFrameworkunifiedStatusOK)
+ return eFrameworkunifiedStatusFail;
+
+ return NsLogGetFrameworkunifiedLogFlag(RESOURCEMANAGERLOG_BASEPF_FLAG_ID, mode);
+}
+
+/* drop_caches Start update Task */
+static void start_drop_caches(void) {
+ pid_t pid = fork();
+ if (pid == 0) {
+ if (setuid(0) == -1) { // LCOV_EXCL_BR_LINE 5: setuid's error case
+ // LCOV_EXCL_START 5: setuid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to setuid(0)-1, errno=%d", errno);
+ // LCOV_EXCL_STOP
+ } else {
+ struct sched_param param;
+ // Exec drop_caches
+ param.sched_priority = 0;
+ if (sched_setscheduler(getpid(), SCHED_OTHER, &param) < 0) { // LCOV_EXCL_BR_LINE 5: sched_setscheduler's error case
+ // LCOV_EXCL_START 5: sched_setscheduler's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to sched_setscheduler errno=%d",
+ errno);
+ // LCOV_EXCL_STOP
+ } else {
+ execl(DROP_CACHES_PG_PATH, basename(DROP_CACHES_PG_PATH), NULL);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to execl %s errno=%d",
+ DROP_CACHES_PG_PATH,
+ errno);
+ }
+ }
+ exit(1);
+ }
+ if (pid == (pid_t) -1) { // LCOV_EXCL_BR_LINE 5: fork's error case
+ // LCOV_EXCL_START 5: fork's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to fork=-1, errno=%d", errno);
+ // LCOV_EXCL_STOP
+ }
+}
+
+/**********************************************
+ * Main Function
+ **********************************************/
+int32_t main(int32_t argc, char* argv[]) {
+ int32_t mainRet = -1;
+ int32_t rpcFd;
+ int32_t timerFd;
+ struct itimerspec tm;
+ int32_t timerFd2;
+ struct itimerspec tm2;
+ uint64_t exp;
+ int32_t maxFd = 0;
+ fd_set fds;
+ struct sched_param prcwParam;
+ pthread_t ptPRCW;
+ int32_t sec = 0;
+ int32_t ret;
+
+ int32_t cpu_ret;
+ bool fork_dsp_task = false;
+ CL_ProcessAttr_t attr;
+ const char *prName;
+ const char *args[iProcess_MAXIMUM_NUMBER_OF_PROCESS_ARGUMENTS];
+ UI_8 mode;
+ EFrameworkunifiedStatus eRet;
+ struct stat statbuf;
+
+ RPC_ID rpcId = RESMGR_RPC_ID;
+ SVC_COMMON_t* p_ctx = &g_resmgr;
+ EFrameworkunifiedStatus resourcemanagerRet = eFrameworkunifiedStatusOK;
+
+ {
+ const char* nfsenv = getenv("AGL_NFS");
+ isNfs = (nfsenv && strcmp(nfsenv, "y") == 0) ? 1 : 0;
+ }
+
+ /* Clear context */
+ ctxCreate(p_ctx, argc, argv);
+
+ /* Start debug information display task */
+ {
+ char *tmp;
+ tmp = getenv("AGL_DEVDIAG_FLAG");
+ if ((tmp == NULL) || strcmp(tmp, "ON")) { // != "ON"
+ resourcemanagerlog_output_debug_info = eFrameworkunifiedStatusFail;
+ } else {
+ resourcemanagerlog_output_debug_info = eFrameworkunifiedStatusOK;
+ }
+ }
+ eRet = resourcemanagerlog_flag_check(&mode);
+ if (eRet == eFrameworkunifiedStatusOK && mode == FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG) {
+ fork_dsp_task = true;
+ }
+ if (fork_dsp_task) {
+ // LCOV_EXCL_START 8: there is no bs_analysis_dispinfo_debug
+ if (0 == stat(DEBUG_INFO_DSP_PG_PATH, &statbuf)) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (0 != CL_ProcessCreateAttrInit(&attr)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CL_ProcessCreateAttrInit Error"); // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ prName = basename(DEBUG_INFO_DSP_PG_PATH);
+ if (0 != CL_ProcessCreateAttrSetName(&attr, prName)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Set Name Error"); // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ args[0] = prName;
+ args[1] = NULL;
+ if (CL_ProcessCreate(DEBUG_INFO_DSP_PG_PATH, (char* const *) args, NULL,
+ &attr) < 0) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CL_ProcessCreate Error"); // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ }
+ // LCOV_EXCL_STOP 8: there is no bs_analysis_dispinfo_debug
+ }
+
+ /* Create socket */
+ g_sock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (g_sock < 0) { // LCOV_EXCL_BR_LINE 5: socket error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[RESM_ERR]ResMgr Create Socket Failed"); // LCOV_EXCL_LINE 5: socket error case
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "[%s:%d] ResMgr Wakeup", p_ctx->procName,
+ getpid());
+
+ RPC_START_SERVER(rpcId); // Start RPC Server
+ RPC_get_fd(rpcId, &rpcFd); // Event reception FD of RPC
+
+ /* Create proc_watch thread */
+ ret = pthread_create(&ptPRCW, NULL, &PRCW_main, reinterpret_cast<void*>(NULL));
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: pthread_create error case
+ // LCOV_EXCL_START 5: pthread_create error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Create Thread Failed. code[%d]", ret);
+ // LCOV_EXCL_STOP 5: pthread_create error case
+ } else {
+ prcwParam.sched_priority = RESM_SUB_PRIORITY;
+ ret = pthread_setschedparam(ptPRCW, SCHED_OTHER, &prcwParam);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: pthread_setschedparam error case
+ // LCOV_EXCL_START 5: pthread_setschedparam error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Set Thread Schedparam Failed. code[%d]", ret);
+ // LCOV_EXCL_STOP 5: pthread_setschedparam error case
+ }
+ }
+
+ /* Create timer */
+ if ((timerFd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Create timerFd Failed. errno[%d]", errno);
+ exit(EXIT_FAILURE);
+ }
+ // for drop_caches
+ {
+ if ((timerFd2 = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Create timerFd2 Failed. errno[%d]", errno);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ // Initialize remaining memory acquisition
+ mainFree_kib = 0;
+ inactFile_kib = 0;
+ memTotal_kib = 0;
+ cmaFree_kib = 0;
+ cmaTotal_kib = 0;
+ get_meminfo();
+ g_resmgr.restMem = mainFree_kib + inactFile_kib;
+ minRestMem = g_resmgr.restMem;
+ g_resmgr.restMemFlag = TRUE;
+ g_resmgr.restCma = cmaFree_kib;
+ minRestCma = g_resmgr.restCma;
+ g_resmgr.restCmaFlag = TRUE;
+
+ tm.it_value.tv_sec = MONITORING_START_DELAT_TIME;
+ tm.it_value.tv_nsec = 0;
+ tm.it_interval.tv_sec = 1;
+ tm.it_interval.tv_nsec = 0;
+ if (timerfd_settime(timerFd, 0, &tm, NULL) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Set timerFd Failed. errno[%d]", errno);
+ exit(EXIT_FAILURE);
+ }
+
+ tm2.it_value.tv_sec = DROP_CACHES_START_DELAT_TIME;
+ tm2.it_value.tv_nsec = 0;
+ tm2.it_interval.tv_sec = 0;
+ tm2.it_interval.tv_nsec = 0;
+ if (timerfd_settime(timerFd2, 0, &tm2, NULL) == -1) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (coverage measurement revision by DeathTest)
+ // LCOV_EXCL_START 11:Gcov constraints (coverage measurement revision by DeathTest)
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM_ERR]ResMgr Set timerFd2 Failed. errno[%d]", errno);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_END 11:Gcov constraints (coverage measurement revision by DeathTest)
+ }
+
+ /* API to Publish Service Availability Notification. */
+ resourcemanagerRet = FrameworkunifiedPublishServiceAvailability(p_ctx->hApp, TRUE);
+ if (eFrameworkunifiedStatusOK != resourcemanagerRet) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to Publish Service Availability Notification:0x%x", resourcemanagerRet);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+
+ /* CPU Load init */
+ g_fifo_status = STATUS_CHECK_CPU;
+ g_tss_status = STATUS_CHECK_CPU;
+ g_cpuloadRate1000 = 0;
+ init_cpuload();
+ cpu_ret = get_cpuload(g_cpuload);
+ if ( cpu_ret != 0 ) { // LCOV_EXCL_BR_LINE 200: cpu_ret must be 0
+ // LCOV_EXCL_START 200: cpu_ret must be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "Get cpuload Failed");
+ g_cpuloadRate1000 = 0;
+ // LCOV_EXCL_STOP
+ }
+
+
+ while (1) {
+ FD_ZERO(&fds);
+ FD_SET(rpcFd, &fds);
+ maxFd = MY_MAX(maxFd, rpcFd);
+
+ FD_SET(p_ctx->nsFd, &fds);
+ maxFd = MY_MAX(maxFd, p_ctx->nsFd);
+
+ FD_SET(timerFd, &fds);
+ maxFd = MY_MAX(maxFd, timerFd);
+
+ if (timerFd2 != -1) {
+ FD_SET(timerFd2, &fds);
+ maxFd = MY_MAX(maxFd, timerFd2);
+ }
+ ret = select(maxFd + 1, &fds, NULL, NULL, NULL);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: select error case
+ // LCOV_EXCL_START 5: select error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno != EINTR) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Handle Error");
+ exit(EXIT_FAILURE);
+ }
+ continue;
+ // LCOV_EXCL_STOP 5: select error case
+ }
+ /* API CALL from RPC */
+ if ((timerFd2 != -1) && FD_ISSET(timerFd2, &fds)) {
+ start_drop_caches();
+ timerFd2 = -1;
+ }
+
+ /* API CALL from RPC */
+ if (FD_ISSET(rpcFd, &fds)) {
+ RPC_process_API_request(rpcId);
+ }
+ /* Events from the NSFW */
+ if (FD_ISSET(p_ctx->nsFd, &fds)) {
+ FrameworkunifiedDispatchProcessWithoutLoop(p_ctx->hApp);
+ }
+
+ /* Timer expiration */
+ if (FD_ISSET(timerFd, &fds)) {
+ read(timerFd, &exp, sizeof(uint64_t));
+ /* CPU load monitoring */
+ if ((sec % WTC_CPU_INTERVAL) == 0) {
+ watchCPUStatus();
+ }
+
+ if (sec >= RESET_SEC) {
+ sec = 0;
+ }
+ sec++;
+ }
+ }
+
+ // Close socket
+ close(g_sock);
+
+ mainRet = 0;
+ RPC_end(rpcId);
+
+ return mainRet;
+}
+
+/*********************************************************************************
+ * Session Related
+ *********************************************************************************/
+/* Numbering session ID */
+static int32_t get_new_id(uint32_t* ssnId) {
+ int32_t i;
+ SSN_INFO_t* p_ssnInfo;
+
+ for (i = 0; i < EV_MAX_IDS_IN_THREAD; i++) {
+ p_ssnInfo = &g_resmgr.ssnInfo[i];
+
+ if (p_ssnInfo->useFlag) {
+ // in-use
+ continue;
+ }
+ *ssnId = i;
+ p_ssnInfo->useFlag = TRUE;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+/*********************************************************************************
+ * Memory monitoring
+ *********************************************************************************/
+/* Memory monitoring */
+void watchMem(void) {
+ uint32_t restMem_b;
+ SSN_INFO_t* p_ssnInfo;
+ uint32_t ssnId;
+ int32_t i;
+ int32_t ret;
+
+ // Get remaining memory
+ mainFree_kib = 0;
+ inactFile_kib = 0;
+ memTotal_kib = 0;
+ cmaFree_kib = 0;
+ cmaTotal_kib = 0;
+ g_resmgr.restMemFlag = FALSE;
+ g_resmgr.restCmaFlag = FALSE;
+ ret = get_meminfo();
+ // KiB -> Byte
+ // [Note] Unit of the value gotten by the meminfo is KiB
+ restMem_b = (mainFree_kib + inactFile_kib) * KIBIBYTE_TO_BYTE;
+
+ if (ret != 0) {
+ // Failed to get remaining memory info
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr get_meminfo Failed");
+ return;
+ }
+ g_resmgr.restMem = mainFree_kib + inactFile_kib;
+ g_resmgr.restMemFlag = TRUE;
+ g_resmgr.restCma = cmaFree_kib;
+ g_resmgr.restCmaFlag = TRUE;
+
+ if (g_resmgr.restMem < minRestMem) {
+ // Update minimum available memory
+ minRestMem = g_resmgr.restMem;
+ }
+ if (g_resmgr.restCma < minRestCma) {
+ // Update minimum available CMA
+ minRestCma = g_resmgr.restCma;
+ }
+
+ for (i = 0; i < RESM_INET_IF_MAX; i++) {
+ p_ssnInfo = &g_resmgr.ssnInfo[i];
+ if (!p_ssnInfo->useFlag) {
+ // Unused sessions
+ continue;
+ }
+ ssnId = i;
+
+ // Check event type
+ if (p_ssnInfo->reqEv.reqEvent != RESM_EV_MEM) {
+ // Other than memory monitoring
+ continue;
+ }
+ // Check free memory
+ if (p_ssnInfo->reqEv.prm.restMemThresh > restMem_b) {
+ // Issue event
+ ret = EV_set_flag(Resm_Flag_ID_Base + ssnId, RESM_EV_MEM);
+ if (ret != EV_OK) { // LCOV_EXCL_BR_LINE 200: EV_set_flag will not return ng
+ // LCOV_EXCL_START 200: EV_set_flag will not return ng
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr EV_set_flag Failed. ssnId[%d]", ssnId);
+ // LCOV_EXCL_STOP 200: EV_set_flag will not return ng
+ }
+ }
+ }
+
+ return;
+}
+
+void FlushMemInfo(void) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "MEMORY Info(KB):<PEAK>REST(%d) [Memtotal(%d)] / CMA Info(KB):<PEAK>REST(%d) [CMAtotal(%d)]",
+ minRestMem, memTotal_kib, minRestCma, cmaTotal_kib);
+}
+
+/* Compare memory information */
+static int32_t comp_meminfo_tbl(const void* data1, const void* data2) {
+ return strcmp(((const meminfo_tbl*) data1)->name,
+ ((const meminfo_tbl*) data2)->name);
+}
+
+/* Get memory information */
+static int32_t get_meminfo(void) {
+ int32_t meminfo_fd = -1;
+ char srch_name[16];
+ char buf[2048];
+ meminfo_tbl target = { srch_name, NULL };
+ meminfo_tbl* found;
+ char* head;
+ char* tail;
+ int32_t read_byte;
+ /* Strings must be in ascending order when adding entries to this table (for bsearch) */
+ static const meminfo_tbl mem_table[] = {
+ { "CmaFree", &cmaFree_kib },
+ { "CmaTotal", &cmaTotal_kib },
+ { "Inactive(file)", &inactFile_kib },
+ { "MemFree", &mainFree_kib },
+ { "MemTotal", &memTotal_kib },
+ };
+ const int32_t mem_table_count = sizeof(mem_table) / sizeof(meminfo_tbl);
+
+ if (meminfo_fd == -1) {
+ meminfo_fd = open(MEMINFO_FILE, O_RDONLY);
+ if (meminfo_fd == -1) {
+ fflush(NULL);
+ return -1;
+ }
+ }
+
+ lseek(meminfo_fd, 0L, SEEK_SET);
+ read_byte = read(meminfo_fd, buf, sizeof buf - 1);
+ if (read_byte < 0) { // LCOV_EXCL_BR_LINE 200: if file exist, it will not be -1
+ // LCOV_EXCL_START 200: if file exist, it will not be -1
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ fflush(NULL);
+ close(meminfo_fd);
+ return -1;
+ // LCOV_EXCL_STOP 200: if file exis, it will not be -1
+ }
+ buf[read_byte] = '\0';
+
+ head = buf;
+ while (1) {
+ tail = strchr(head, ':');
+ if (!tail) {
+ break;
+ }
+
+ *tail = '\0';
+ if (strlen(head) >= sizeof(srch_name)) {
+ head = tail + 1;
+ } else {
+ strcpy(srch_name, head); // NOLINT
+ found = reinterpret_cast<meminfo_tbl *>(bsearch(&target, mem_table, mem_table_count,
+ sizeof(meminfo_tbl), comp_meminfo_tbl));
+ head = tail + 1;
+ if (found) {
+ *(found->value) = strtoul(head, &tail, 10);
+ }
+ }
+ tail = strchr(head, '\n');
+ if (!tail)
+ break;
+ head = tail + 1;
+ }
+ close(meminfo_fd);
+
+ return 0;
+}
+
+/*********************************************************************************
+ * Network monitoring
+ *********************************************************************************/
+/* Get system information */
+static int32_t getInetStatus(RESM_INET_STATUS_t* p_iStatus) {
+ FILE* fh;
+ char buf[READLINE_MAX_SIZE];
+ char* tmp;
+ char name[IFNAMSIZ];
+ char hwaddr[HWADDR_LEN];
+ uint32_t rx_b;
+ uint32_t rx_pckt;
+ uint32_t rx_err;
+ uint32_t rx_drp;
+ uint32_t rx_fifo;
+ uint32_t rx_frm;
+ uint32_t rx_mlt;
+ uint32_t tx_b;
+ uint32_t tx_pckt;
+ uint32_t tx_err;
+ uint32_t tx_drp;
+ uint32_t tx_fifo;
+ uint32_t tx_cll;
+ uint32_t tx_crr;
+ int32_t ret;
+
+ // Open file
+ fh = fopen(PROCNET_DEV_FILE, "r");
+ if (fh == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr getInetStatus() File Open Error. errno[%d]", errno);
+ return -1;
+ }
+
+ // Initialize interface count
+ p_iStatus->ifNum = 0;
+
+ while (fgets(buf, sizeof(buf), fh)) {
+ // Get Alias name
+ tmp = get_aliasName(name, buf);
+ if (tmp == NULL) {
+ // No alias name
+ continue;
+ }
+ // Get amount of receive/transmit data
+ ret = sscanf(tmp, "%u%u%u%u%u%u%u%*u%u%u%u%u%u%u%u", &rx_b, &rx_pckt,
+ &rx_err, &rx_drp, &rx_fifo, &rx_frm, &rx_mlt, &tx_b, &tx_pckt,
+ &tx_err, &tx_drp, &tx_fifo, &tx_cll, &tx_crr);
+ if (ret != 14) { // LCOV_EXCL_BR_LINE 200: ret is always 14
+ // LCOV_EXCL_START 200: ret is always 14
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr getInetStatus() GET Rx and Tx size Failed");
+ continue;
+ // LCOV_EXCL_STOP 200: ret is always 14
+ }
+ // Get hardware address
+ ret = get_hwaddr(name, hwaddr);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: get_hwaddr will not return !0
+ // LCOV_EXCL_START 5: get_hwaddr will not return !0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr getInetStatus() GET hwaddr Failed");
+ continue;
+ // LCOV_EXCL_STOP 5: get_hwaddr will not return !0
+ }
+
+ // Set values in the system information structure
+ strcpy(p_iStatus->ifInfo[p_iStatus->ifNum].name, name); // NOLINT
+ p_iStatus->ifInfo[p_iStatus->ifNum].rxSize = rx_b / BYTE_TO_KIBIBYTE;
+ p_iStatus->ifInfo[p_iStatus->ifNum].txSize = tx_b / BYTE_TO_KIBIBYTE;
+ memcpy(p_iStatus->ifInfo[p_iStatus->ifNum].hwaddr, hwaddr, HWADDR_LEN);
+
+ p_iStatus->ifNum++;
+
+ if (p_iStatus->ifNum >= RESM_INET_IF_MAX) {
+ break;
+ }
+ }
+
+ // Termination processing
+ fclose(fh);
+
+ if (p_iStatus->ifNum == 0) {
+ return -1;
+ }
+ return 0;
+}
+
+/* Get Alias name */
+static char *get_aliasName(char* name, char* line) {
+ char* dot;
+ char* dotname;
+
+ while (isspace(*line)) {
+ line++;
+ }
+ while (*line) {
+ if (isspace(*line)) {
+ *name++ = '\0';
+ return NULL;
+ }
+
+ if (*line == ':') {
+ dot = line, dotname = name;
+ *name++ = *line++;
+
+ while (isdigit(*line)) {
+ *name++ = *line++;
+ }
+ if (*line != ':') {
+ line = dot;
+ name = dotname;
+ }
+ if (*line == '\0') {
+ return NULL;
+ }
+ line++;
+ break;
+ }
+ *name++ = *line++;
+ }
+ *name++ = '\0';
+
+ return line;
+}
+
+/* Get hardware address */
+static int32_t get_hwaddr(char* name, char* hwaddr) {
+ struct ifreq ifr;
+ int32_t ret;
+
+ if (g_sock < 0) { // LCOV_EXCL_BR_LINE 6: g_sock is not -1
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 6: g_sock is not -1
+ }
+ // Initialization
+ memset(&ifr, 0, sizeof(ifr));
+
+ // Set alias name
+ strncpy(ifr.ifr_name, name, (sizeof(ifr.ifr_name) - 1));
+
+ // Get hardware address
+ ret = ioctl(g_sock, SIOCGIFHWADDR, &ifr);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: ioctl error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 5: ioctl error case
+ }
+ memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, HWADDR_LEN);
+
+ return 0;
+}
+
+/*********************************************************************************
+ * CPU monitoring
+ *********************************************************************************/
+// // CPU monitoring
+// static void watchCPU() {
+// Main processing of CPU monitoring
+static void watchCPUStatus() {
+ unsigned long fifo_task_occ = 0;
+ unsigned long tss_task_occ = 0;
+ int32_t fifo_status = g_fifo_status;
+ int32_t tss_status = g_tss_status;
+ int32_t cpu_load_status = CPU_TASK_INIT;
+
+// int32_t ret;
+// static int32_t cpuLogTimer = 0;
+ if ((g_fifo_status == STATUS_CHECK_CPU) || (g_tss_status == STATUS_CHECK_CPU)) {
+ watchCPU();
+
+// if (cpuLogTimer > 0) { // LCOV_EXCL_BR_LINE 6:Because the condition cannot be set
+// // Make to progress the timer
+// cpuLogTimer -= WTC_CPU_INTERVAL; // LCOV_EXCL_LINE 6:Because the condition cannot be set
+// }
+ if (g_cpuloadRate1000 >= CPU_LOAD_THRESHOLD) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CPU TOTAL:(%d.%d%%)",g_cpuloadRate1000/10, g_cpuloadRate1000%10);
+ int i;
+ int32_t cpuloadRate1000;
+ for (i = 1; i < g_cpu_num; i++) {
+ char buf[16];
+ cpuloadRate1000 = calc_cpuloadRate_each(i);
+ sprintf (buf, "%s(%d.%d%%) ", g_cpuload[i].cpuname, cpuloadRate1000/10, cpuloadRate1000%10);
+ FRAMEWORKUNIFIEDLOG (ZONE_INFO, __FUNCTION__, "%s", buf);
+ }
+ if (g_fifo_status == STATUS_CHECK_CPU) { // LCOV_EXCL_BR_LINE 6: g_fifo_status must be STATUS_CHECK_CPU
+ fifo_status = STATUS_WATCH_PROCESS;
+ g_fifo_timer = 0;
+ }
+ if (g_tss_status == STATUS_CHECK_CPU) { // LCOV_EXCL_BR_LINE 6: g_tss_status must be STATUS_CHECK_CPU
+ tss_status = STATUS_WATCH_PROCESS;
+ g_tss_timer = 0;
+ }
+ if ((g_fifo_status != STATUS_WATCH_PROCESS ) && ( g_tss_status != STATUS_WATCH_PROCESS)) { // LCOV_EXCL_BR_LINE 6: g_fifo_status must be STATUS_CHECK_CPU and g_tss_status must be STATUS_CHECK_CPU // NOLINT[whitespace/line_length]
+ logging_cpuload_custom(CPU_TASK_INIT);
+ }
+ }
+ }
+
+#if 0
+ // Get CPU usage
+ if (g_resmgr.cpuloadRate == CPULOAD_INVALID) {
+ // First time
+ init_cpuload();
+ ret = get_cpuload(g_cpuload);
+ if (ret == 0) { // LCOV_EXCL_BR_LINE 5: get_cpuload will not return -1
+ g_resmgr.cpuloadRate = CPULOAD_READY;
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "watchCPU() Get cpuload Failed"); // LCOV_EXCL_LINE 5: get_cpuload will not return -1 // NOLINT[whitespace/line_length]
+ }
+#endif
+ if ((g_fifo_status == STATUS_WATCH_PROCESS) || (g_tss_status == STATUS_WATCH_PROCESS)) {
+ if (g_fifo_status == STATUS_WATCH_PROCESS) {
+ g_fifo_timer = g_fifo_timer + WTC_CPU_INTERVAL;
+ if ((g_fifo_timer == WTC_CPU_INTERVAL) || (g_fifo_timer >= FIFO_TIMER_LIMIT)) { // LCOV_EXCL_BR_LINE 200: g_fifo_timer must be bigger than WTC_CPU_INTERVAL/FIFO_TIMER_LIMIT // NOLINT[whitespace/line_length]
+ cpu_load_status = CPU_TASK_SHOW_AF;
+ } else {
+ // LCOV_EXCL_START 200: g_fifo_timer must be bigger than WTC_CPU_INTERVAL/FIFO_TIMER_LIMIT
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ logging_cpuload_custom(FIFO_TASK_SHOW);
+ // LCOV_EXCL_STOP
+ }
+ }
+#if 0
+ return;
+ } else {
+ memcpy(g_cpuload_pre, g_cpuload, sizeof(*g_cpuload_pre)*g_cpu_num);
+ ret = get_cpuload(g_cpuload);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: get_cpuload will not return -1
+ // LCOV_EXCL_START 5: get_cpuload will not return -1
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "watchCPU() Get cpuload Failed");
+ return;
+ // LCOV_EXCL_STOP 5: get_cpuload will not return -1
+#endif
+ if (g_tss_status == STATUS_WATCH_PROCESS) {
+ g_tss_timer = g_tss_timer + WTC_CPU_INTERVAL;
+ if ((g_tss_timer == WTC_CPU_INTERVAL) || (g_tss_timer >= TSS_TIMER_LIMIT)) {
+ cpu_load_status = CPU_TASK_SHOW_AF;
+ } else {
+ logging_cpuload_custom(TSS_TASK_SHOW);
+ }
+ }
+#if 0
+ }
+ // Calculate CPU usage (Notes! Return as a thousandth rate(10 times of %)
+ g_cpuloadRate1000 = calc_cpuloadRate();
+ g_resmgr.cpuloadRate = g_cpuloadRate1000 / 10;
+
+ ret = chk_logging(g_resmgr.cpuloadRate, cpuLogTimer);
+ if (ret == CPULOG_LOGGING) {
+ // Logging
+#endif
+ if (cpu_load_status == CPU_TASK_SHOW_AF) {
+#if 0
+ int i;
+ int32_t cpuloadRate1000;
+ char *cpunames = (char *) malloc( // NOLINT
+ sizeof("[CpuHighLoad]") + (sizeof("cpuXX(xxx%) ") * g_cpu_num));
+ cpuloadRate1000 = calc_cpuloadRate();
+ sprintf(cpunames, "[CpuHighLoad]%s(%d%%) ", g_cpuload[0].cpuname, cpuloadRate1000/10); // NOLINT
+ for (i = 1; i < g_cpu_num; i++) {
+ char buf[16];
+ cpuloadRate1000 = calc_cpuloadRate_each(i);
+ sprintf(buf, "%s(%d%%) ", g_cpuload[i].cpuname, cpuloadRate1000 / 10); // NOLINT
+ strcat(cpunames, buf); // NOLINT
+ }
+ free(cpunames);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", cpunames);
+ }
+#endif
+ logging_cpuload_custom(cpu_load_status);
+ }
+ if (g_fifo_status == STATUS_WATCH_PROCESS) {
+ fifo_task_occ = logging_cpuload_custom(CPU_FIFO_TASK_GET_OCCUPANCY);
+ if ((fifo_task_occ >= TASK_STAT_THRESHOLD) && (g_fifo_timer >= FIFO_TIMER_LIMIT)) {
+ fifo_status = STATUS_IDOL;
+ g_fifo_timer = 0;
+ exec_perf(logging_cpuload_custom(CPU_FIFO_TASK_GET_ID));
+ } else if (fifo_task_occ < TASK_STAT_THRESHOLD) {
+ fifo_status = STATUS_CHECK_CPU;
+ g_fifo_timer = 0;
+ logging_cpuload_custom(CPU_FIFO_TASK_GET_ID);
+ }
+ }
+ if (g_tss_status == STATUS_WATCH_PROCESS) {
+ tss_task_occ = logging_cpuload_custom(CPU_TSS_TASK_GET_OCCUPANCY);
+ if ((tss_task_occ >= TASK_STAT_THRESHOLD) && (g_tss_timer >= TSS_TIMER_LIMIT)) {
+ tss_status = STATUS_IDOL;
+ g_tss_timer = 0;
+ exec_perf(logging_cpuload_custom(CPU_TSS_TASK_GET_ID));
+ } else if(tss_task_occ < TASK_STAT_THRESHOLD) {
+ tss_status = STATUS_CHECK_CPU;
+ g_tss_timer = 0;
+ logging_cpuload_custom(CPU_TSS_TASK_GET_ID);
+ }
+ }
+#if 0
+ logging_cpuload_custom();
+ logging_cpuload();
+ // Set timer
+ cpuLogTimer = CPU_HIGH_LOAD_LOG_FREQ;
+ } else if (ret == CPULOG_TIMER_CLEAR) {
+ // Clear Timer
+ cpuLogTimer = 0;
+ }
+
+ return;
+#endif
+ logging_cpuload_custom(CPU_TASK_SHOW_BF);
+ }
+ if ((g_fifo_status == STATUS_IDOL) || (g_tss_status == STATUS_IDOL)) {
+ if (g_fifo_status == STATUS_IDOL) {
+ g_fifo_timer = g_fifo_timer + WTC_CPU_INTERVAL;
+ if (g_fifo_timer >= CPU_HIGH_LOAD_LOG_FREQ) {
+ fifo_status = STATUS_CHECK_CPU;
+ g_fifo_timer = 0;
+ }
+ }
+ if (g_tss_status == STATUS_IDOL) {
+ g_tss_timer = g_tss_timer + WTC_CPU_INTERVAL;
+ if (g_tss_timer >= CPU_HIGH_LOAD_LOG_FREQ) {
+ tss_status = STATUS_CHECK_CPU;
+ g_tss_timer = 0;
+ }
+ }
+ }
+ g_fifo_status = fifo_status;
+ g_tss_status = tss_status;
+
+ return;
+}
+
+
+
+// CPU monitoring
+static void
+watchCPU() {
+ int32_t ret;
+
+ memcpy(g_cpuload_pre, g_cpuload, sizeof(*g_cpuload_pre)*g_cpu_num);
+ ret = get_cpuload(g_cpuload);
+ if ( ret != 0 ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "watchCPU() Get cpuload Failed");
+ g_cpuloadRate1000 = 0;
+ } else {
+ // Calculate CPU usage (Notes! Return as a thousandth rate(10 times of percentage)
+ g_cpuloadRate1000 = calc_cpuloadRate();
+ }
+
+ return;
+}
+
+
+static void init_cpuload(void) {
+ int fd;
+ char buf[READ_MAX_SIZE];
+ int32_t ret;
+ CPU_INFO_t p_cpu;
+ ssize_t rsize;
+ char *p, *ep;
+ struct timespec req = { 0, 1000000 }; // 1msec
+
+ g_cpu_num = 0;
+ g_cpuload_pre = NULL;
+
+ fd = open(PROC_STAT_FILE, O_RDONLY);
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: open error case
+ // LCOV_EXCL_START 5: open error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr File Open Error. errno[%d]",
+ errno);
+ return;
+ // LCOV_EXCL_STOP 5: open error case
+ }
+ rsize = read(fd, buf, sizeof(buf));
+ if (rsize == -1) { // LCOV_EXCL_BR_LINE 5: read error case
+ // LCOV_EXCL_START 5: read error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr File Read Error. errno[%d]",
+ errno);
+ close(fd);
+ return;
+ // LCOV_EXCL_STOP 5: read error case
+ }
+ nanosleep(&req, NULL);
+ p = buf;
+ ep = buf + rsize;
+ while (p < ep) {
+ if (strncmp(p, "cpu", 3) == 0) {
+ ret = sscanf(p, "%8s %d %d %d %d %d %d %d %d %d %d", &p_cpu.cpuname[0],
+ &p_cpu.user, &p_cpu.nice, &p_cpu.system, &p_cpu.idle,
+ &p_cpu.iowait, &p_cpu.irq, &p_cpu.softirq, &p_cpu.steal,
+ &p_cpu.guest, &p_cpu.guest_nice);
+ if (ret < 11) { // LCOV_EXCL_BR_LINE 200: ret will always 11
+ // LCOV_EXCL_START 200: ret will always 11
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr get_cpuload() File Read Error");
+ close(fd);
+ return;
+ // LCOV_EXCL_STOP 200: ret will always 11
+ }
+ g_cpu_num++;
+ while (++p < ep) {
+ if (*p == LF) {
+ p++;
+ break;
+ }
+ }
+ } else {
+ break;
+ }
+ }
+ close(fd);
+
+ g_cpuload_pre = reinterpret_cast<CPU_INFO_t *>(malloc(sizeof(CPU_INFO_t) * g_cpu_num));
+ g_cpuload = reinterpret_cast<CPU_INFO_t *>(malloc(sizeof(CPU_INFO_t) * g_cpu_num));
+ if ((g_cpuload_pre == NULL) || (g_cpuload == NULL)) { // LCOV_EXCL_BR_LINE 5: malloc error case
+ // LCOV_EXCL_START 5: malloc error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr malloc Error. g_cpu_num[%d] errno[%d]", g_cpu_num, errno);
+ return;
+ // LCOV_EXCL_STOP 5: malloc error case
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr cpu_num:%d", g_cpu_num);
+
+ return;
+}
+
+// Get CPU usage
+static int32_t get_cpuload(CPU_INFO_t* p_cpu) {
+ int fd;
+ char buf[READ_MAX_SIZE];
+ int32_t ret;
+ int i = 0;
+ ssize_t rsize;
+ char *p, *ep;
+ struct timespec req = { 0, 1000000 }; // 1msec
+
+ // Open file
+ fd = open(PROC_STAT_FILE, O_RDONLY);
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: open's error case
+ // LCOV_EXCL_START 5: open's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr get_cpuload() File Open Error. errno[%d]", errno);
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+ rsize = read(fd, buf, sizeof(buf));
+ if (rsize == -1) { // LCOV_EXCL_BR_LINE 5: read error case
+ // LCOV_EXCL_START 5: read error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr File Read Error. errno[%d]",
+ errno);
+ close(fd);
+ return -1;
+ // LCOV_EXCL_STOP 5: read error case
+ }
+ nanosleep(&req, NULL);
+ p = buf;
+ ep = buf + rsize;
+ while (p < ep) {
+ if (strncmp(p, "cpu", 3) == 0) {
+ ret = sscanf(p, "%8s %d %d %d %d %d %d %d %d %d %d", &p_cpu[i].cpuname[0],
+ &p_cpu[i].user, &p_cpu[i].nice, &p_cpu[i].system,
+ &p_cpu[i].idle, &p_cpu[i].iowait, &p_cpu[i].irq,
+ &p_cpu[i].softirq, &p_cpu[i].steal, &p_cpu[i].guest,
+ &p_cpu[i].guest_nice);
+ if (ret < 11) { // LCOV_EXCL_BR_LINE 200: ret will always 11
+ // LCOV_EXCL_START 200: ret will always 11
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr get_cpuload() File Read Error");
+ close(fd);
+ return -1;
+ // LCOV_EXCL_STOP 200: ret will always 11
+ }
+ i++;
+ while (++p < ep) {
+ if (*p == LF) {
+ p++;
+ break;
+ }
+ }
+ } else {
+ break;
+ }
+ }
+ close(fd);
+
+ return 0;
+}
+
+// Calcurate CPU usage
+static int32_t calc_cpuloadRate(void) {
+ int val;
+ int val_others;
+ int total;
+ int rate;
+ CPU_INFO_t* info;
+ CPU_INFO_t* info_pre;
+
+ info = &g_cpuload[0];
+ info_pre = &g_cpuload_pre[0];
+
+ val = (info->user - info_pre->user)
+ + (info->system - info_pre->system)
+ + (info->irq - info_pre->irq)
+ + (info->softirq - info_pre->softirq);
+
+ val_others = (info->idle - info_pre->idle)
+ + (info->iowait - info_pre->iowait);
+
+ total = val + val_others;
+ rate = (total > 0) ? (val*1000 / total) : 0;
+
+ return rate;
+}
+
+// Calcurate CPU usage for each CPU
+static int32_t calc_cpuloadRate_each(int num) {
+ int val, valn;
+ int rate;
+ CPU_INFO_t* info;
+ CPU_INFO_t* info_pre;
+
+ // cpu
+ info = &g_cpuload[0];
+ info_pre = &g_cpuload_pre[0];
+ val = (info->user - info_pre->user)
+ + (info->system - info_pre->system)
+ + (info->irq - info_pre->irq)
+ + (info->softirq - info_pre->softirq);
+
+ // cpu-num
+ info = &g_cpuload[num];
+ info_pre = &g_cpuload_pre[num];
+ valn = (info->user - info_pre->user)
+ + (info->system - info_pre->system)
+ + (info->softirq - info_pre->softirq);
+
+ rate = valn * 1000 / val;
+ return rate;
+}
+
+
+//// Logging check at CPU overload
+//static int32_t chk_logging(int32_t cpuload, int32_t timer) {
+// if (cpuload >= CPU_LOAD_THRESHOLD) {
+// if (timer > 0) {
+// return CPULOG_NO_LOGGING;
+// }
+// return CPULOG_LOGGING;
+// }
+//
+// return CPULOG_TIMER_CLEAR;
+//}
+
+
+// Check if cmd to perf
+ // LCOV_EXCL_START 8: dead code
+bool valid_perf_cmd(char *buf) { // LCOV_EXCL_BR_LINE 8: dead code
+ const char *cmd2exclude[] = { "top", "init", "bash", NULL };
+ char cmdstr[64];
+
+ for (int i = 0;; i++) {
+ if (cmd2exclude[i] == NULL) {
+ break;
+ }
+ sprintf(cmdstr, " %s ", cmd2exclude[i]); // NOLINT
+ if (strstr(buf, cmdstr) == NULL) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+}
+ // LCOV_EXCL_STOP 8: dead code
+
+//// exec perf to pids
+//static pid_t pids[PERF_MAX_PROCS];
+
+
+static bool lower_sched_priority(int niceval) {
+ struct sched_param sparam = { };
+ sparam.sched_priority = 0;
+ if (sched_setscheduler(0, SCHED_OTHER, &sparam) == -1) { // LCOV_EXCL_BR_LINE 5: sched_setscheduler's error case
+ // LCOV_EXCL_START 5: sched_setscheduler's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed change scheduler to TSS, errno=%d",
+ errno);
+ return false;
+ // LCOV_EXCL_STOP
+ }
+ if (nice(niceval) == -1) { // LCOV_EXCL_BR_LINE 5: nice's error case
+ // LCOV_EXCL_START 5: nice's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to add nice val %d, errno=%d",
+ niceval, errno);
+ return false;
+ // LCOV_EXCL_STOP
+ }
+ return true;
+}
+
+/*********************************************************************************
+ * exec_perf sub function RECORD perf data processing
+ *********************************************************************************/
+static void exec_perf_Record_Perf_Data(
+ pid_t* c_pids, char* perf_file, char* pidstr, int* status,
+
+// char pnames[PERF_MAX_PROCS][PERF_PNAME_MAX]) {
+ pid_t pids[PERF_MAX_PROCS]) {
+
+ int i;
+ int fd;
+ pid_t term_pid;
+ int waitret;
+ bool do_sigkill = false;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "+");
+
+ /* RECORD perf data */
+ for (i = 0; i < PERF_MAX_PROCS; i++) {
+ if (pids[i] <= 0) {
+ break;
+ }
+ sprintf(perf_file, PERF_FILE"%06d", pids[i]); // NOLINT
+ sprintf(pidstr, "%d", pids[i]); // NOLINT
+ if ((c_pids[i] = fork()) == 0) {
+ if (lower_sched_priority(CPULOAD_NICEVAL) == false) { // LCOV_EXCL_BR_LINE 200: lower_sched_priority() must be true
+ // LCOV_EXCL_START 200: lower_sched_priority() must be true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to lower scheduler-1");
+ exit(1);
+ // LCOV_EXCL_STOP
+ }
+ if (setuid(0) == -1) { // LCOV_EXCL_BR_LINE 5: setuid's error case
+ // LCOV_EXCL_START 5: setuid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to setuid(0)-1, errno=%d",
+ errno);
+ exit(1);
+ // LCOV_EXCL_STOP
+ }
+ // Redirect STDERR
+ fd = open("/dev/null", O_WRONLY);
+ if (fd > 0) { // LCOV_EXCL_BR_LINE 5: open's error case
+ dup2(fd, 2);
+ }
+ // Exec perf
+ execl(PERF_PATH, basename(PERF_PATH), "record", "-p", pidstr, "-o",
+ perf_file, NULL);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to execl %s record, errno=%d",
+ PERF_PATH,
+ errno);
+ exit(1);
+ }
+ if (c_pids[i] == (pid_t) -1) { // LCOV_EXCL_BR_LINE 5: fork's error case
+ // LCOV_EXCL_START 5: fork's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to fork-1, errno=%d", errno);
+ continue;
+ // LCOV_EXCL_STOP
+ }
+ // Kill perf after PERF_RECORD_SPAN sec
+ // (Killed by child process to avoid making resm process super-user with setuid.)
+ if ((term_pid = fork()) == 0) {
+ const struct timespec delay = { PERF_RECORD_SPAN, 0 };
+ if (setuid(0) == -1) { // LCOV_EXCL_BR_LINE 5: setuid's error case
+ // LCOV_EXCL_START 5: setuid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to setuid(0)-2, errno=%d",
+ errno);
+ exit(1);
+ // LCOV_EXCL_STOP
+ }
+ nanosleep(&delay, NULL); // Let perf record run for a while before kill it.
+ if (kill(c_pids[i], SIGINT) == -1) { // LCOV_EXCL_BR_LINE 5: kill's error case
+ // LCOV_EXCL_START 5: kill's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to kill(SIGINT), pid=%d, errno=%d", (int) c_pids[i],
+ errno);
+ // LCOV_EXCL_STOP
+ }
+ nanosleep(&delay, NULL); // Allow perf to do ending procedure.
+ exit(0);
+ } else if (term_pid == (pid_t) -1) { // LCOV_EXCL_BR_LINE 5: fork's error case
+ // LCOV_EXCL_START 5: fork's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to fork-2, errno=%d", errno);
+ continue;
+ // LCOV_EXCL_STOP
+ } else {
+ if (waitpid(term_pid, status, 0) == -1) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to waitpid of killer %d, errno=%d", term_pid, errno);
+ continue;
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "");
+ // NOT block even if perf is not terminated
+ if ((waitret = waitpid(c_pids[i], status, WNOHANG)) == -1) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to waitpid of RECORD %d, errno=%d",
+ c_pids[i], errno);
+ // LCOV_EXCL_STOP
+ } else if (waitret == 0) {
+ // NOT exited
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to terminate perf record, pid=%d",
+ c_pids[i]);
+ pids[i] = -2; // Skip following sequences
+ do_sigkill = true;
+ } else if (WEXITSTATUS(*status) != 0 && WEXITSTATUS(*status) != 2) {
+
+// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+// "perf record %d exited abnormally, target=%s(%d), status=%d",
+// c_pids[i], pnames[i], pids[i], WEXITSTATUS(*status));
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "perf record %d exited abnormally, target=(%d), status=%d",
+ c_pids[i], pids[i], WEXITSTATUS(*status));
+
+ pids[i] = -2; // Skip following sequences
+ do_sigkill = false;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "");
+ if (pids[i] == -2) {
+ if ((term_pid = fork()) == 0) {
+ const struct timespec delay = { PERF_RECORD_SPAN, 0 };
+ if (setuid(0) == -1) { // LCOV_EXCL_BR_LINE 5: setuid's error case
+ // LCOV_EXCL_START 5: setuid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to setuid(0)-2B, errno=%d",
+ errno);
+ exit(1);
+ // LCOV_EXCL_STOP
+ }
+ // Kill "perf record" by SIGKILL signal
+ if (do_sigkill) {
+ int sigret = kill(c_pids[i], SIGKILL);
+ if (sigret == 0) { // LCOV_EXCL_BR_LINE 5: kill case
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SIGKILL has been sent to perf record process, pid=%d",
+ c_pids[i]);
+ } else {
+ // LCOV_EXCL_START 5: kill case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "sending SIGKILL to perf record failed, pid=%d, errno=%d",
+ c_pids[i], errno);
+ // LCOV_EXCL_STOP 5: kill case
+ }
+ }
+ nanosleep(&delay, NULL);
+ // remove perf data file possibly made
+ unlink(perf_file);
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "");
+ exit(0);
+ } else if (term_pid == (pid_t) -1) { // LCOV_EXCL_BR_LINE 5: fork's error case
+ // LCOV_EXCL_START 5: fork's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to fork-2B, errno=%d", errno);
+ // LCOV_EXCL_STOP
+ } else {
+ if (waitpid(term_pid, status, 0) == -1) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to waitpid of killer-2 %d, errno=%d", term_pid, errno);
+ // LCOV_EXCL_STOP
+ }
+ if (do_sigkill) {
+ if ((waitret = waitpid(c_pids[i], status, WNOHANG)) == -1) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to waitpid of RECORD(2) %d, errno=%d", c_pids[i],
+ errno);
+ // LCOV_EXCL_STOP
+ } else if (waitret == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to terminate perf record by SIGKILL, pid=%d",
+ c_pids[i]);
+ }
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "");
+}
+
+/*********************************************************************************
+ * exec_perf sub function make perf file available to default user processing
+ *********************************************************************************/
+
+//static int32_t exec_perf_Make_Perf_File(pid_t* c_pids, char* perf_file) {
+static int32_t exec_perf_Make_Perf_File(pid_t* c_pids, char* perf_file, pid_t pids[PERF_MAX_PROCS]) {
+
+ int i;
+
+ /* make perf file available to default user */
+ if ((c_pids[0] = fork()) == 0) {
+ if (setuid(0) == -1) { // LCOV_EXCL_BR_LINE 5: setuid's error case
+ // LCOV_EXCL_START 5: setuid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to setuid(0)-3, errno=%d", errno);
+ exit(1);
+ // LCOV_EXCL_STOP
+ }
+ for (i = 0; i < PERF_MAX_PROCS; i++) {
+ if (pids[i] == -2) {
+ // killed by SIGKILL
+ continue;
+ }
+ if (pids[i] <= 0) {
+ break;
+ }
+ sprintf(perf_file, PERF_FILE"%06d", pids[i]); // NOLINT
+ if (chmod(perf_file, 0666) != 0) { // LCOV_EXCL_BR_LINE 5: chmod's error case
+ // LCOV_EXCL_START 5: chmod's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to chmod %s, errno=%d\n",
+ perf_file, errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ exit(0);
+ }
+ if (c_pids[0] == (pid_t) -1) { // LCOV_EXCL_BR_LINE 5: fork's error case
+ // LCOV_EXCL_START 5: fork's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to fork-3, errno=%d", errno);
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+ if (waitpid(c_pids[0], NULL, 0) == -1) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to waitpid of CHMOD %d, errno=%d\n",
+ c_pids[0], errno);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "");
+ return 0;
+}
+
+/*********************************************************************************
+ * exec_perf sub function REPORT perf data into dump file processing
+ *********************************************************************************/
+static void exec_perf_Report_Perf_Data(pid_t* c_pids, char* perf_file,
+
+// char* perf_dump, int* status) {
+ char* perf_dump, int* status, pid_t pids[PERF_MAX_PROCS]) {
+
+ int i;
+ int fd;
+ int waitret;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "");
+ /* REPORT perf data into dump file */
+ for (i = 0; i < PERF_MAX_PROCS; i++) {
+ const struct timespec delay = { PERF_REPORT_DELAY, 0 };
+ if (pids[i] == -2) {
+ // killed by SIGKILL
+ continue;
+ }
+ if (pids[i] <= 0) {
+ break;
+ }
+ sprintf(perf_file, PERF_FILE"%06d", pids[i]); // NOLINT
+ sprintf(perf_dump, PERF_DUMP"%06d", pids[i]); // NOLINT
+ if ((c_pids[i] = fork()) == 0) {
+ if (lower_sched_priority(CPULOAD_NICEVAL) == false) { // LCOV_EXCL_BR_LINE 200: lower_sched_priority() will not return false
+ // LCOV_EXCL_START 200: lower_sched_priority() will not return false
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to lower scheduler-2");
+ exit(1);
+ // LCOV_EXCL_STOP
+ }
+ if ((fd = open(perf_dump, (O_CREAT | O_WRONLY), 0666)) < 0) { // LCOV_EXCL_BR_LINE 5: open error case
+ // LCOV_EXCL_START 5: open error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to open %s, errno=%d\n",
+ perf_dump, errno);
+ // LCOV_EXCL_STOP 5: open error case
+ } else {
+ // Redirect STDOUT
+ dup2(fd, 1);
+ close(fd);
+ // Redirect STDERR
+ fd = open("/dev/null", O_WRONLY);
+ if (fd > 0) { // redirect stderr // LCOV_EXCL_BR_LINE 5: open's error case
+ dup2(fd, 2);
+ close(fd);
+ }
+ // Exec perf
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "execl perf report");
+ execl(PERF_PATH, basename(PERF_PATH), "report", "-i", perf_file, NULL);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to execl %s report, errno=%d",
+ PERF_PATH,
+ errno);
+ }
+ exit(1);
+ }
+ if (c_pids[i] == (pid_t) -1) { // LCOV_EXCL_BR_LINE 5: fork's error case
+ // LCOV_EXCL_START 5: fork's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to fork-4, errno=%d", errno);
+ continue;
+ // LCOV_EXCL_STOP
+ }
+ int ii = 0;
+ for (; ii < PERF_REPORT_RETRY; ii++) {
+ nanosleep(&delay, NULL); // Make sure waitpid() to killer returns after perf process exited.
+ if ((waitret = waitpid(c_pids[i], status, WNOHANG)) == -1) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to waitpid for REPORT %d, errno=%d", c_pids[i], errno);
+ pids[i] = -2; // Skip FRAMEWORKUNIFIEDLOG perf data
+ break;
+ // LCOV_EXCL_STOP
+ } else if (waitret == c_pids[i]) {
+ break;
+ }
+ }
+ if (ii >= PERF_REPORT_RETRY) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "perf report Failed to exit, pid=%d",
+ c_pids[i]);
+ pids[i] = -2; // Skip FRAMEWORKUNIFIEDLOG perf data
+ }
+ if (pids[i] == -2) {
+ // Terminate perf report with SIGKILL
+ const struct timespec delay = { PERF_RECORD_SPAN, 0 };
+ int sigret = kill(c_pids[i], SIGKILL);
+ if (sigret != 0) { // LCOV_EXCL_BR_LINE 5: kill's error case
+ // LCOV_EXCL_START 5: kill's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed in sending SIGKILL to perf report, pid=%d, errno=%d",
+ c_pids[i], errno);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SIGKILL has been sent to perf report process, pid=%d",
+ c_pids[i]);
+ }
+ nanosleep(&delay, NULL); // Make sure waitpid() to killer returns after perf process exited.
+ if ((waitret = waitpid(c_pids[i], status, WNOHANG)) == -1) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to waitpid of REPORT(2) %d, errno=%d", c_pids[i], errno);
+ // LCOV_EXCL_STOP
+ } else if (waitret == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to terminate perf report by SIGKILL, pid=%d", c_pids[i]);
+ }
+ // Cleanup
+ unlink(perf_dump);
+ unlink(perf_file);
+ }
+ }
+}
+
+/*********************************************************************************
+ * exec_perf FRAMEWORKUNIFIEDLOG perf data processing
+ *********************************************************************************/
+static void exec_perf_Resourcemanagerlog_Perf_Data(
+ char* perf_file, char* perf_dump,
+
+// char pnames[PERF_MAX_PROCS][PERF_PNAME_MAX]) {
+ pid_t pids[PERF_MAX_PROCS]) {
+
+ int i;
+ int perf_lines;
+ char buf[READLINE_MAX_SIZE];
+ FILE *rfd;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "");
+ /* FRAMEWORKUNIFIEDLOG perf data */
+ for (i = 0; i < PERF_MAX_PROCS; i++) {
+ if (pids[i] == -2) {
+ // killed by SIGKILL
+ continue;
+ }
+ if (pids[i] <= 0) {
+ break;
+ }
+ sprintf(perf_file, PERF_FILE"%06d", pids[i]); // NOLINT
+ sprintf(perf_dump, PERF_DUMP"%06d", pids[i]); // NOLINT
+ if ((rfd = fopen(perf_dump, "r")) == NULL) { // LCOV_EXCL_BR_LINE 5: fopen error case
+ // LCOV_EXCL_START 5: fopen error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to open-2 %s, errno=%d\n",
+ perf_dump, errno);
+ continue;
+ // LCOV_EXCL_STOP 5: fopen error case
+ }
+ perf_lines = 0;
+ while (fgets(buf, sizeof(buf), rfd) > 0) {
+ if (perf_lines >= PERF_MAX_LINES) {
+ break;
+ }
+ /* skip header */
+ if (buf[0] == '#') {
+ continue;
+ }
+ if (buf[0] == '\n' || buf[0] == '\r') {
+ continue;
+ }
+ trim_end(buf);
+ if (perf_lines == 0) {
+
+// FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHLPerf:%s(%d)]report by result of 'perf record -p %d'",
+// pnames[i], pids[i], pids[i]);
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHLPerf:(%d)]report by result of 'perf record -p %d'",
+ pids[i], pids[i]);
+
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHLPerf]%s\n", buf);
+ perf_lines++;
+ }
+ fclose(rfd);
+ // Check if no line is acquired
+ if (perf_lines == 0) {
+
+// FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHLPerf:%s(%d)] NO_DATA_acquired",
+// pnames[i], pids[i]);
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHLPerf:(%d)] NO_DATA_acquired",
+ pids[i]);
+
+ }
+ // Cleanup
+ unlink(perf_dump);
+ unlink(perf_file);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "-");
+}
+
+/*********************************************************************************
+ * exec_perf Main processing
+ *********************************************************************************/
+
+//static void exec_perf(char pnames[PERF_MAX_PROCS][PERF_PNAME_MAX]) {
+static void exec_perf(int32_t t_pid) {
+
+ pid_t c_pids[PERF_MAX_PROCS]; // max process to exec perf(forked child pids)
+
+ pid_t pids[PERF_MAX_PROCS];
+ char perf_file[128];
+ char perf_dump[128];
+ char pidstr[64];
+ struct stat statbuf;
+ int status;
+
+ /* Check existance of perf exec file */
+ if (stat(PERF_PATH, &statbuf) == -1 || !(statbuf.st_mode & S_IXUSR)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "%s is not available", PERF_PATH);
+ return;
+ }
+
+ FRAMEWORKUNIFIEDLOG (ZONE_INFO, __FUNCTION__, "[CpuHighLoad]Please check User backtrace of following processes in kernel.log");
+// print_backtrace_pid(t_pid);
+ for (int i = 0; i < PERF_MAX_PROCS; i++) {
+ pids[i] = -1;
+ }
+
+ pids[0] = t_pid;
+
+
+ /* RECORD perf data */
+
+// exec_perf_Record_Perf_Data(c_pids, perf_file, pidstr, &status, pnames);
+ exec_perf_Record_Perf_Data(c_pids, perf_file, pidstr, &status, pids);
+
+
+ /* make perf file available to default user */
+
+// if (exec_perf_Make_Perf_File(c_pids, perf_file) != 0)
+ if (exec_perf_Make_Perf_File(c_pids, perf_file, pids) != 0)
+
+ return;
+
+ /* REPORT perf data into dump file */
+
+// exec_perf_Report_Perf_Data(c_pids, perf_file, perf_dump, &status);
+ exec_perf_Report_Perf_Data(c_pids, perf_file, perf_dump, &status, pids);
+
+
+ /* FRAMEWORKUNIFIEDLOG perf data */
+
+// exec_perf_Resourcemanagerlog_Perf_Data(perf_file, perf_dump, pnames);
+ exec_perf_Resourcemanagerlog_Perf_Data(perf_file, perf_dump, pids);
+
+}
+
+// Logging at CPU overload
+#define WAIT_RETRY 3 // 3sec
+
+
+#if 0
+static void logging_cpuload(void) {
+ int32_t pipe_fd[2]; // 0:stdin,1:stdout
+ pid_t c_pid;
+ char buf[READLINE_MAX_SIZE];
+ char buf2[READLINE_MAX_SIZE];
+ char tmp[READLINE_MAX_SIZE];
+ int32_t logLine = 0;
+ char* ptr;
+ int32_t ret;
+ int32_t status;
+ int32_t perfNum = 0;
+ char pnames[PERF_MAX_PROCS][PERF_PNAME_MAX] = { };
+ int save_0 = -1;
+ int kill_flag = 1;
+ int waitret;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "+");
+
+ // Create pipe
+ ret = pipe(pipe_fd);
+
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: pipe error case
+ // LCOV_EXCL_START 5: pipe error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr logging_cpuload() pipe Error");
+ return;
+ // LCOV_EXCL_STOP 5: pipe error case
+ }
+
+ // Create child process
+ c_pid = fork();
+ if (c_pid < 0) { // LCOV_EXCL_BR_LINE 5: fork error case
+ // LCOV_EXCL_START 5: fork error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__,
+ "ResMgr logging_cpuload() fork Error");
+ close(pipe_fd[0]);
+ close(pipe_fd[1]);
+
+ return;
+ // LCOV_EXCL_STOP 5: fork error case
+ }
+
+ if (c_pid == 0) {
+ /*******************************************************
+ * Child-process
+ * The use of dup() and Close() between fork()-> exec() has been
+ * confirmed no probrem.
+ *******************************************************/
+ if (lower_sched_priority(CPULOAD_NICEVAL) == false) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to lower scheduler");
+ exit(1);
+ }
+ close(pipe_fd[0]); // Unneeded pipes (close stdin)
+
+ close(1); // Close stdout
+ dup2(pipe_fd[1], 1); // Duplicate stdout to pipe_fd[1]
+ close(pipe_fd[1]);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "execl top");
+ execl("/usr/bin/top", "top", "-n", "1", "-b", NULL);
+ // error
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "ResMgr logging_cpuload() execl Error");
+ exit(1);
+ } else {
+ close(pipe_fd[1]); // Unneeded pipes(Close stdout)
+
+ save_0 = dup(0);
+ close(0); // Close stdin
+ dup2(pipe_fd[0], 0); // Duplicate stdin to pipe_fd[0]
+ close(pipe_fd[0]);
+
+ for (int i = 0; i < PERF_MAX_PROCS; i++) {
+ pids[i] = -1;
+ }
+
+ {
+ fd_set fds;
+ int32_t maxFd;
+ int ret;
+ struct timeval tmout = { TOP_TIMEOUT, 0 };
+
+ FD_ZERO(&fds);
+ FD_SET(STDIN_FILENO, &fds);
+ maxFd = STDIN_FILENO;
+ ret = select(maxFd + 1, &fds, NULL, NULL, &tmout);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: select error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "[RESM]Handle Error errno:%d", errno); // LCOV_EXCL_LINE 5: select error case
+ } else if (FD_ISSET(STDIN_FILENO, &fds)) {
+ kill_flag = 0;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM]'top': No response during %d seconds", TOP_TIMEOUT);
+ }
+ if (kill_flag) {
+ // Kill top after TOP_TIMEOUT sec
+ // (Killed by child process to avoid making resm process super-user with setuid.)
+ if (kill(c_pid, SIGKILL) == -1) { // LCOV_EXCL_BR_LINE 5: kill error case
+ // LCOV_EXCL_START 5: kill error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to kill(SIGKILL), pid=%d, errno=%d", (int) c_pid,
+ errno);
+ // LCOV_EXCL_STOP 5: kill error case
+ }
+ } else {
+ while (fgets(buf, sizeof(buf), stdin) > 0) {
+ // Save ProcessName and Process ID to exec perf
+ if (logLine >= 2 && perfNum < PERF_MAX_PROCS) {
+ buf2[0] = 0;
+ strncat(buf2, buf, sizeof(buf2) - 1);
+ buf2[sizeof(buf2) - 1] = 0;
+ if (valid_perf_cmd(buf2)) {
+ pids[perfNum] = atoi(buf2);
+ trim_end(buf2);
+ strncat(pnames[perfNum], rindex(buf2, ' ') + 1,
+ sizeof(pnames[0]) - 1);
+ if (pids[perfNum] >= 0
+ && strnlen(pnames[perfNum], sizeof(pnames[perfNum]) - 1)) {
+ perfNum++;
+ } else {
+ pids[perfNum] = -1;
+ }
+ }
+ }
+ if (logLine == 0) {
+ if ((buf[0] != 'C') && (buf[0] != '%')) {
+ continue;
+ }
+ ptr = strstr(buf, "sy");
+ if (ptr == NULL) {
+ continue;
+ }
+ while (isalpha(*ptr)) {
+ ptr++;
+ }
+ *ptr = '\0';
+ escape_percent(buf, tmp);
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHighLoad]%s", tmp);
+ logLine++;
+ } else if (logLine == 1) {
+ ptr = strstr(buf, "PID");
+ if (ptr == NULL) {
+ continue;
+ }
+ trim_end(buf);
+ escape_percent(buf, tmp);
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHighLoad]%s", tmp);
+ logLine++;
+ } else if (logLine < (CPU_HIGH_LOAD_P_LOG_NUM + 2)) {
+ trim_end(buf);
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "[CpuHighLoad]%s", buf);
+ logLine++;
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "wait pid(%d) kill_flag(%d)", c_pid, kill_flag);
+ if (kill_flag) {
+ const struct timespec delay = {1, 0};
+ int i;
+ for (i = 0; i < WAIT_RETRY; i++) {
+ nanosleep(&delay, NULL);
+ if ((waitret = waitpid(c_pid, &status, WNOHANG)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to waitpid for top %d, errno=%d", c_pid, errno);
+ break;
+ } else if (waitret == c_pid) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "waitpid OK");
+ break;
+ }
+ }
+ if (i >= WAIT_RETRY) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "top Failed to exit, pid=%d", c_pid);
+ }
+ } else {
+ if ((waitret = waitpid(static_cast<int>(c_pid), &status, 0)) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "waitpid(%d) Error errno(%d)", c_pid, errno);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "waitpid(%d) returned (%d) errno(%d) status=%d",
+ c_pid, waitret, errno, WEXITSTATUS(*status));
+ if (save_0 >= 0) {
+ dup2(save_0, 0); // Reset the stdin to 0
+ close(save_0);
+ }
+ if (!kill_flag) {
+ exec_perf(pnames);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "-");
+
+ return;
+}
+#endif
+
+
+// Tail adjustment
+static void trim_end(char* buf) {
+ int32_t len;
+
+ len = strlen(buf);
+ while (len > 0) {
+ if (isspace(buf[len - 1])) {
+ buf[len - 1] = '\0';
+ len--;
+ continue;
+ }
+ break;
+ }
+
+ return;
+}
+
+
+#if 0
+// Escape character "%"
+static void escape_percent(char* in, char* out) {
+ char* head;
+ char* tail;
+
+ head = in;
+
+ out[0] = '\0';
+
+ while (1) {
+ tail = strchr(head, '%');
+ if (tail == NULL) {
+ strcat(out, head); // NOLINT
+ break;
+ }
+ *tail = '\0';
+
+ strcat(out, head); // NOLINT
+ strcat(out, "%%"); // NOLINT
+
+ tail++;
+ head = tail;
+ }
+
+ return;
+}
+#endif
+
+
+/*********************************************************************************
+ * Output debug information display
+ *********************************************************************************/
+void outputResouceInfo(void) {
+ static bool madedir = false;
+ struct stat sbuf;
+ FILE *wfp;
+
+ // Create directory
+ if (!madedir) {
+ if (stat(DEBUG_INFO_DIRPATH, &sbuf) != 0) { // LCOV_EXCL_BR_LINE 5: stat's error case
+ if (mkdir(DEBUG_INFO_DIRPATH, 0777) != 0) { // LCOV_EXCL_BR_LINE 5: mkdir's error case
+ // LCOV_EXCL_START 5: mkdir's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to mkdir %s, errno=%d",
+ DEBUG_INFO_DIRPATH,
+ errno);
+ return;
+ // LCOV_EXCL_STOP
+ }
+ }
+ madedir = true;
+ }
+ // Open files to work
+ if ((wfp = fopen(DEBUG_INFO_TMPPATH, "w")) == NULL) { // LCOV_EXCL_BR_LINE 5: fopen error case
+ // LCOV_EXCL_START 5: fopen error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to open %s, errno=%d",
+ DEBUG_INFO_TMPPATH,
+ errno);
+ return;
+ // LCOV_EXCL_STOP 5: fopen error case
+ }
+ // Output memory information work
+ if (write_meminfo_work(wfp) != 0) { // LCOV_EXCL_BR_LINE 6: write_meminfo_work will not be error
+ // LCOV_EXCL_START 6: write_meminfo_work will not be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to edit and output in write_meminfo_work()");
+ fclose(wfp);
+ return;
+ // LCOV_EXCL_STOP 6: write_meminfo_work will not be error
+ }
+ // Get CMA MEMORY information and output working info
+ if (write_cmainfo_work(wfp) != 0) { // LCOV_EXCL_BR_LINE 6: write_cmainfo_work will not be error
+ // LCOV_EXCL_START 6: write_cmainfo_work will not be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to edit and output in write_cmainfo_work()");
+ fclose(wfp);
+ return;
+ // LCOV_EXCL_STOP 6: write_cmainfo_work will not be error
+ }
+ // Get top information and output work info
+ if (write_cpuinfo_work(wfp) != 0) { // LCOV_EXCL_BR_LINE 6: write_cpuinfo_work will not be error
+ // LCOV_EXCL_START 6: write_cpuinfo_work will not be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to edit and output in write_cpuinfo_work()");
+ fclose(wfp);
+ return;
+ // LCOV_EXCL_STOP 6: write_cpuinfo_work will not be error
+ }
+ fclose(wfp);
+ // Create output file
+ if (rename(DEBUG_INFO_TMPPATH, DEBUG_INFO_FPATH) != 0) { // LCOV_EXCL_BR_LINE 5:rename error case
+ // LCOV_EXCL_START 5:rename error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to make output file %s, errno=%d",
+ DEBUG_INFO_FPATH,
+ errno);
+ // LCOV_EXCL_STOP 5:rename error case
+ }
+ // Write information and output FRAMEWORKUNIFIEDLOG
+ if (write_resourcemanagerloginfo_work() != 0) { // LCOV_EXCL_BR_LINE 6: write_resourcemanagerloginfo_work will not be error
+ // LCOV_EXCL_START 6: write_resourcemanagerloginfo_work will not be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to output in write_resourcemanagerloginfo_work()");
+ // LCOV_EXCL_STOP 6: write_resourcemanagerloginfo_work will not be error
+ }
+}
+
+// Output memory information work
+static int write_meminfo_work(FILE *wfp) {
+ float total;
+ float avail;
+ float used;
+ float min_remain;
+ uint32_t used_rate;
+ uint32_t used_letters;
+ // Output meminfo: Getting info from the proc/meminfo is performed at 5-second intervals in watchMem, so it is diverted.
+ avail = static_cast<float>((mainFree_kib + inactFile_kib));
+ total = static_cast<float>(memTotal_kib);
+ used = total - avail;
+ min_remain = static_cast<float>(minRestMem);
+ // "*MEMORY @@@@@@ Warning!! @@@@@"
+ fprintf(wfp, "*MEMORY");
+ if (avail * 10 < total) { // (Less than 1/10)
+ fprintf(wfp, " @@@@@@ Warning!! @@@@@\n");
+ } else {
+ fprintf(wfp, " \n");
+ }
+ // "used/avail/total/used max xxx.xMB / xxx.xMB / xxx.xMB(xx.x%) / xxx.xMB
+ used /= 1024;
+ avail /= 1024;
+ total /= 1024;
+ min_remain /= 1024;
+ if (total == 0) {
+ used_rate = 0;
+ } else {
+ used_rate = (uint32_t) (used * 1000 / total);
+ if (used_rate >= 1000) {
+ used_rate = 999;
+ }
+ }
+ fprintf(
+ wfp,
+ " used/avail/total/min remain %5.1fMB / %5.1fMB / %5.1fMB(%2d.%d%%) / %5.1fMB\n",
+ used, avail, total, used_rate / 10, used_rate % 10, min_remain);
+ if (total == 0) {
+ used_letters = 0;
+ } else {
+ used_letters = (uint32_t) (DEBUG_INFO_MEM_LETTERS * used / total);
+ if (used_letters > DEBUG_INFO_MEM_LETTERS) {
+ used_letters = DEBUG_INFO_MEM_LETTERS;
+ }
+ }
+ // "------------------*******"
+ int i;
+ for (i = 0; i < static_cast<int>(used_letters); i++) {
+ fprintf(wfp, "-");
+ }
+ for (; i < DEBUG_INFO_MEM_LETTERS; i++) {
+ fprintf(wfp, "*");
+ }
+ fprintf(wfp, "\n\n");
+
+ return 0;
+}
+// Get top information and Output work
+static int write_cpuinfo_work(FILE *wfp) {
+ int32_t pipe_fd[2]; // 0:stdin,1:stdout
+ pid_t c_pid;
+ char buf[READLINE_MAX_SIZE];
+ int32_t logLine = 0;
+ char* ptr;
+ int32_t ret;
+ int32_t status;
+ int save_0 = -1;
+ int32_t cpu_rate;
+ char fields[12][128];
+ int kill_flag = 1;
+ int waitret;
+
+ // Output CPU load
+ cpu_rate = g_cpuloadRate1000 < 0 ? 0 : g_cpuloadRate1000;
+ fprintf(wfp, "*CPU %2d.%d%%\n", cpu_rate / 10, cpu_rate % 10);
+
+ // Create pipe
+ ret = pipe(pipe_fd);
+
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: pipe error case
+ // LCOV_EXCL_START 5: pipe error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "pipe Error");
+ return -1;
+ // LCOV_EXCL_STOP 5: pipe error case
+ }
+
+ // Create child process
+ c_pid = fork();
+ if (c_pid < 0) { // LCOV_EXCL_BR_LINE 5: fork error case
+ // LCOV_EXCL_START 5: fork error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "fork Error");
+ close(pipe_fd[0]);
+ close(pipe_fd[1]);
+
+ return -1;
+ // LCOV_EXCL_STOP 5: fork error case
+ }
+
+ if (c_pid == 0) {
+ /*******************************************************
+ * Child process
+ *******************************************************/
+ if (lower_sched_priority(CPULOAD_NICEVAL) == false) { // LCOV_EXCL_BR_LINE 200: lower_sched_priority can't be false
+ // LCOV_EXCL_START 200: lower_sched_priority can't be false
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to lower scheduler");
+ exit(1);
+ // LCOV_EXCL_STOP
+ }
+ close(pipe_fd[0]); // Unneeded pipes (close stdin)
+
+ close(1); // Close stdout
+ dup2(pipe_fd[1], 1); // Duplicate stdout to pipe_fd[1]
+ close(pipe_fd[1]);
+
+ execl("/usr/bin/top", "top", "-n", "1", "-b", NULL);
+ // error
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "execl top Error");
+ exit(1);
+ } else {
+ close(pipe_fd[1]); // Unneeded pipes(Close stdout)
+
+ save_0 = dup(0);
+ close(0); // Close stdin
+ dup2(pipe_fd[0], 0); // Duplicate stdin to pipe_fd[0]
+ close(pipe_fd[0]);
+
+ {
+ fd_set fds;
+ int32_t maxFd;
+ int ret;
+ struct timeval tmout = { TOP_TIMEOUT, 0 };
+
+ FD_ZERO(&fds);
+ FD_SET(STDIN_FILENO, &fds);
+ maxFd = STDIN_FILENO;
+ ret = select(maxFd + 1, &fds, NULL, NULL, &tmout);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: select error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "[RESM]Handle Error errno:%d", errno); // LCOV_EXCL_LINE 5: select error case
+ } else if (FD_ISSET(STDIN_FILENO, &fds)) { // LCOV_EXCL_BR_LINE 5: FD_ISSET's error case
+ kill_flag = 0;
+ } else {
+ // LCOV_EXCL_START 5: FD_ISSET's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "[RESM]'top': No response during %d seconds", TOP_TIMEOUT);
+ // LCOV_EXCL_STOP
+ }
+ if (kill_flag) { // LCOV_EXCL_BR_LINE 200: kill_flag must be 0
+ // LCOV_EXCL_START 200: kill_flag must be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // Kill top after TOP_TIMEOUT sec
+ // (Killed by child process to avoid making resm process super-user with setuid.)
+ if (kill(c_pid, SIGKILL) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to kill(SIGKILL), pid=%d, errno=%d", (int) c_pid,
+ errno);
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ while (fgets(buf, sizeof(buf), stdin) > 0) {
+ if (logLine == 0) {
+ if (buf[0] != 'C') {
+ continue;
+ }
+ if (strstr(buf, "Cpu(s)") == NULL || strstr(buf, "sy") == NULL) {
+ continue;
+ }
+ logLine++;
+ } else if (logLine == 1) {
+ ptr = strstr(buf, "PID");
+ if (ptr == NULL) {
+ continue;
+ }
+ logLine++;
+ } else if (logLine < (DEBUG_INFO_CPU_TOP_LINES + 2)) {
+ ret = sscanf(buf, "%128s %128s %128s %128s %128s %128s %128s %128s %128s %128s %128s %128s", fields[0],
+ fields[1], fields[2], fields[3], fields[4], fields[5],
+ fields[6], fields[7], fields[8], fields[9], fields[10],
+ fields[11]);
+ fprintf(wfp, "%4s%% %s\n", fields[8], fields[11]);
+ logLine++;
+ }
+ }
+ fprintf(wfp, "\n\n");
+ }
+ }
+ ret = 0;
+ if (kill_flag) { // LCOV_EXCL_BR_LINE 200: kill_flag must be 0
+ // LCOV_EXCL_START 200: kill_flag must be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ const struct timespec delay = {1, 0};
+ int i;
+ for (i = 0; i < WAIT_RETRY; i++) {
+ nanosleep(&delay, NULL);
+ if ((waitret = waitpid(c_pid, &status, WNOHANG)) == -1) {
+ ret = -1;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to waitpid for top %d, errno=%d", c_pid, errno);
+ break;
+ } else if (waitret == c_pid) {
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "waitpid OK");
+ break;
+ }
+ }
+ if (i >= WAIT_RETRY) {
+ ret = -1;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "top Failed to exit, pid=%d", c_pid);
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ if ((waitret = waitpid(static_cast<int>(c_pid), &status, 0)) < 0) { // LCOV_EXCL_BR_LINE 5: waitpid's error case
+ // LCOV_EXCL_START 5: waitpid's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = -1;
+ FRAMEWORKUNIFIEDLOG(ZONE_RESM_DEBUG, __FUNCTION__, "waitpid(%d) Error errno(%d)", c_pid, errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 200: ret must be 0
+ // LCOV_EXCL_START 200: ret must be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "wait Error");
+ if (save_0 >= 0) {
+ close(save_0);
+ }
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+ if (save_0 >= 0) {
+ dup2(save_0, 0); // Reset the stdin to 0
+ close(save_0);
+ }
+ }
+
+ return 0;
+}
+// Get CMA information and Output work
+static int write_cmainfo_work(FILE *wfp) {
+ float total;
+ float avail;
+ float used;
+ float min_remain;
+ uint32_t used_rate;
+ uint32_t used_letters;
+
+ avail = static_cast<float>(cmaFree_kib);
+ total = static_cast<float>(cmaTotal_kib);
+ used = total - avail;
+ min_remain = static_cast<float>(minRestCma);
+ // "*CMA MEMORY @@@@@@ Warning!! @@@@@"
+ fprintf(wfp, "*CMA MEMORY");
+ if (used * 5 > total * 4) { // (4/5 Or more)
+ fprintf(wfp, " @@@@@@ Warning!! @@@@@\n");
+ } else {
+ fprintf(wfp, " \n");
+ }
+ // "used/avail/total xxx.xMB / xxx.xMB / xxx.xMB(xx.x%)
+ used /= 1024;
+ avail /= 1024;
+ total /= 1024;
+ min_remain /= 1024;
+ if (total != 0) {
+ used_rate = (uint32_t) (used * 1000 / total);
+ } else {
+ used_rate = 0;
+ }
+ if (used_rate >= 1000) {
+ used_rate = 999;
+ }
+ fprintf(
+ wfp,
+ " used/avail/total/min remain %5.1fMB / %5.1fMB / %5.1fMB(%2d.%d%%) / %5.1fMB\n",
+ used, avail, total, used_rate / 10, used_rate % 10, min_remain);
+ if (total == 0) {
+ used_letters = 0;
+ } else {
+ used_letters = (uint32_t) (DEBUG_INFO_CMA_LETTERS * used / total);
+ if (used_letters > DEBUG_INFO_CMA_LETTERS) {
+ used_letters = DEBUG_INFO_CMA_LETTERS;
+ }
+ }
+ // "------------------*******"
+ int i;
+ for (i = 0; i < static_cast<int>(used_letters); i++) {
+ fprintf(wfp, "-");
+ }
+ for (; i < DEBUG_INFO_CMA_LETTERS; i++) {
+ fprintf(wfp, "*");
+ }
+ fprintf(wfp, "\n\n");
+
+ return 0;
+}
+// Write information and Output FRAMEWORKUNIFIEDLOG
+static int write_resourcemanagerloginfo_work(void) {
+ FILE *wfp;
+ char l_read[READLINE_MAX_SIZE];
+ int ret;
+
+ wfp = fopen(DEBUG_INFO_FPATH, "r");
+ if (wfp == NULL) { // LCOV_EXCL_BR_LINE 5: fopen error case
+ // LCOV_EXCL_START 5: fopen case error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to open %s, errno=%d",
+ DEBUG_INFO_FPATH,
+ errno);
+ return -1;
+ // LCOV_EXCL_STOP 5: fopen case error
+ }
+ while (1) {
+ if (fgets(l_read, READLINE_MAX_SIZE, wfp) == NULL) {
+ ret = feof(wfp);
+ if (ret == 0) { // LCOV_EXCL_BR_LINE 5: feof case error
+ // LCOV_EXCL_START 5: feof case error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "Failed to fgets %s",
+ DEBUG_INFO_FPATH);
+ // LCOV_EXCL_STOP 5: feof case error
+ }
+ break;
+ } else {
+ char *line;
+ line = strchr(l_read, '\n');
+ if (line != NULL) {
+ *line = '\0';
+ }
+ if (l_read[0] != '\0') {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "%s", l_read);
+ }
+ }
+ }
+ fclose(wfp);
+ return 0;
+}
diff --git a/systemservice/resource_manager/server/src/resourcemanager_application.cpp b/systemservice/resource_manager/server/src/resourcemanager_application.cpp
new file mode 100755
index 0000000..225160b
--- /dev/null
+++ b/systemservice/resource_manager/server/src/resourcemanager_application.cpp
@@ -0,0 +1,155 @@
+/*
+ * @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.
+ */
+
+#include <stdio.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+#include "ss_resm_resourcemanagerlog.h"
+#include "system_service/resm_type.h"
+
+extern void FlushMemInfo(void);
+
+// Called at process startup
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp)
+ *
+ * System callbacks that applications should address.
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // API to Register Notification for Service Availability.
+ eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hApp, NTFY_ResourceMgr_Availability);
+ if (eFrameworkunifiedStatusOK != eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to Register Service Availability Notification:%s",
+ NTFY_ResourceMgr_Availability);
+ return eStatus;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ // API to Publish Service Availability Notification.
+ eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE);
+ if (eFrameworkunifiedStatusOK != eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to Publish Service Availability Notification:0x%x", eStatus);
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+// Called at process termination
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnDestroy
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) { // LCOV_EXCL_START 14 Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnDebugDump
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp) { //LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//LCOV_EXCL_STOP 7:debug code
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FlushMemInfo();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/********************************************************
+ * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+ ********************************************************/
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) { // LCOV_EXCL_START 8: not use StateMachine
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP 8: not use StateMachine
+// EOF
diff --git a/systemservice/rom_access_library/LICENSE b/systemservice/rom_access_library/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/rom_access_library/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/rom_access_library/Makefile.client b/systemservice/rom_access_library/Makefile.client
new file mode 100755
index 0000000..adb1845
--- /dev/null
+++ b/systemservice/rom_access_library/Makefile.client
@@ -0,0 +1,19 @@
+#
+# @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.
+#
+
+SUBDIRS += library mock
+
+include ../system_service.mk
diff --git a/systemservice/rom_access_library/library/Makefile b/systemservice/rom_access_library/library/Makefile
new file mode 100755
index 0000000..e8c64b2
--- /dev/null
+++ b/systemservice/rom_access_library/library/Makefile
@@ -0,0 +1,19 @@
+#
+# @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.
+#
+
+SUBDIRS := nor rom
+
+include ../../system_service.mk
diff --git a/systemservice/rom_access_library/library/include/rom_access_library_nor.h b/systemservice/rom_access_library/library/include/rom_access_library_nor.h
new file mode 100755
index 0000000..417b78f
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/rom_access_library_nor.h
@@ -0,0 +1,43 @@
+//
+// @copyright Copyright (c) 2017-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.
+//
+
+/**
+ * @file rom_access_library_nor.h
+ * @brief This file include the head file of nor access
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup rom_access_library
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_ROM_ACCESS_LIBRARY_NOR_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_ROM_ACCESS_LIBRARY_NOR_H_
+
+#include "system_service/nor_backup.h"
+
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_ROM_ACCESS_LIBRARY_NOR_H_
+
+/** @}*/ // end of rom_access_library
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/rom_access_library/library/include/rom_access_library_rom.h b/systemservice/rom_access_library/library/include/rom_access_library_rom.h
new file mode 100755
index 0000000..1e02e6e
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/rom_access_library_rom.h
@@ -0,0 +1,45 @@
+//
+// @copyright Copyright (c) 2017-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.
+//
+
+/**
+ * @file rom_access_library_rom.h
+ * @brief This file include all head file of rom access
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup rom_access_library
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_ROM_ACCESS_LIBRARY_ROM_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_ROM_ACCESS_LIBRARY_ROM_H_
+
+#include "system_service/ss_sm_rom_access.h"
+#include "system_service/ss_sm_boot_access.h"
+#include "system_service/ss_sm_ram_access.h"
+
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_ROM_ACCESS_LIBRARY_ROM_H_
+
+/** @}*/ // end of rom_access_library
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/rom_access_library/library/include/ss_rom_access_define.h b/systemservice/rom_access_library/library/include/ss_rom_access_define.h
new file mode 100755
index 0000000..689fea2
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/ss_rom_access_define.h
@@ -0,0 +1,38 @@
+/*
+ * @copyright Copyright (c) 2017-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.
+ */
+
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_ROM_ACCESS_DEFINE_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_ROM_ACCESS_DEFINE_H_
+
+#include <errno.h>
+
+#define ROM_ACCESS_ASERT(x) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SS_ASSERT"); \
+ }
+
+#define ROM_ACCESS_ERRNO(x) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SS_ASSERT %d:%s", errno, strerror(errno)); \
+ }
+
+#define ROM_ACCESS_STATIC_ASERT(expr) \
+ { \
+ char STATIC_ASSERTION_FAILED[(expr) ? 1 : -1]; \
+ (void)STATIC_ASSERTION_FAILED; \
+ }
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_ROM_ACCESS_DEFINE_H_
diff --git a/systemservice/rom_access_library/library/include/ss_rom_access_if_romaccesslibrarylog.h b/systemservice/rom_access_library/library/include/ss_rom_access_if_romaccesslibrarylog.h
new file mode 100755
index 0000000..e62b5af
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/ss_rom_access_if_romaccesslibrarylog.h
@@ -0,0 +1,89 @@
+/*
+ * @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_SS_RomAccess
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_ROM_ACCESS_IF_ROMACCESSLIBRARYLOG_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_ROM_ACCESS_IF_ROMACCESSLIBRARYLOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+// #define ZONE_WARN ZONEMASK(30)
+// #define ZONE_ERR ZONEMASK(31)
+
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR, WARN
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern const CHAR kAppName[];
+
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_ROM_ACCESS_IF_ROMACCESSLIBRARYLOG_H_
diff --git a/systemservice/rom_access_library/library/include/ss_sm_checksum.h b/systemservice/rom_access_library/library/include/ss_sm_checksum.h
new file mode 100755
index 0000000..271964c
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/ss_sm_checksum.h
@@ -0,0 +1,34 @@
+/*
+ * @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 for checksum calculation.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_SM_CHECKSUM_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_SM_CHECKSUM_H_
+
+#include <native_service/frameworkunified_types.h>
+class CSMChecksum {
+ public:
+ CSMChecksum();
+ ~CSMChecksum();
+ UI_32 cal_checksum(const void* p_buf, size_t buf_size);
+
+ private:
+};
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SS_SM_CHECKSUM_H_
diff --git a/systemservice/rom_access_library/library/include/system_service/nor_backup.h b/systemservice/rom_access_library/library/include/system_service/nor_backup.h
new file mode 100755
index 0000000..8c95a10
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/system_service/nor_backup.h
@@ -0,0 +1,212 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file nor_backup.h
+ * @brief This file provides API for get nor flash information
+ */
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_NOR_BACKUP_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_NOR_BACKUP_H_
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup rom_access_library
+ * @ingroup system_service
+ * @{
+ */
+#if defined(__cplusplus)
+extern "C" {
+#endif // __cplusplus
+
+/**
+ * \~english Common return value: Normal return value of API
+ */
+#define RET_DEV_NORMAL 0
+
+/**
+ * \~english Common return value: Parameter error return value of API
+ */
+#define RET_DEV_ERR_PARAM 3
+
+/**
+ * \~english Common return value: Error of getting device info
+ */
+#define RET_DEV_ERROR 4
+
+/**
+ * \~english Read API return value: Internal error
+ */
+#define RET_DEV_RD_ERR_OTHER 1
+
+/**
+ * \~english Read API return value: Acquire buffer error(malloc)
+ */
+#define RET_DEV_RD_ERR 2
+
+/**
+ * \~english Read API return value: error type 1
+ */
+#define RET_DEV_RD_ERR_1 -1
+
+/**
+ * \~english Read API return value: error type 2
+ */
+#define RET_DEV_RD_ERR_2 -2
+
+/**
+ * \~english Read API return value: error type 3
+ */
+#define RET_DEV_RD_ERR_3 -3
+
+/**
+ * \~english Read API return value: error type 4
+ */
+#define RET_DEV_RD_ERR_4 -4
+
+/**
+ * \~english Write API return value: Other error
+ */
+#define RET_DEV_WT_ERR_OTHER 1
+
+/**
+ * \~english Write API return value: Internal error
+ */
+#define RET_DEV_WT_ERR 2
+
+/**\ingroup mtdn_backup_Read
+ * \~english @par Brief
+ * Read data from norflash device.
+ * \~english @param [in] path_name
+ * const char* - Device path to read(such as "/dev/mtd1ro")
+ * \~english @param [in] i_id
+ * int - Main block ID(0, 2, 4, ...)
+ * \~english @param [in] i_offset
+ * int - Data offset
+ * \~english @param [in] i_size
+ * int - Data size to read
+ * \~english @param [in] p_buff
+ * Void* - Buffer for storing read data
+ * \~english @retval RET_DEV_NORMAL OK
+ * \~english @retval RET_DEV_ERROR Get device error
+ * \~english @retval RET_DEV_ERR_PARAM Parameter error
+ * \~english @retval RET_DEV_RD_ERR_OTHER Internal error
+ * \~english @retval RET_DEV_RD_ERR Acquire buffer error(malloc)
+ * \~english @retval RET_DEV_RD_ERR_1 Error type 1
+ * \~english @retval RET_DEV_RD_ERR_2 Error type 2
+ * \~english @retval RET_DEV_RD_ERR_3 Error type 3
+ * \~english @retval RET_DEV_RD_ERR_4 Error type 4
+ * \~english @par Preconditions
+ * - There is no preconditions for this API.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - Parameter path_name is NULL. [RET_DEV_ERR_PARAM]
+ * - Parameter p_buff is NULL. [RET_DEV_ERR_PARAM]
+ * - Value of parameter i_id is less than 0. [RET_DEV_ERR_PARAM]
+ * - Value of parameter i_offset is less than 0 or value of parameter i_size
+ * is not greater than 0. [RET_DEV_ERR_PARAM]
+ * - Device specified by path_name is invalid. [RET_DEV_ERR_PARAM]
+ * - Sum value of i_offset and i_size is greater than block size - 16byte.
+ * [RET_DEV_ERR_PARAM]
+ * - Failed to get device info. [RET_DEV_ERROR]
+ * - Failed to acquire the send/receive buffer(malloc). [RET_DEV_RD_ERR]
+ * - Internal IO error(open, read, close, ioctl, lseek, other error).
+ * [RET_DEV_RD_ERR_OTHER]
+ * - Check text error of main block and backup block. [RET_DEV_RD_ERR_1]
+ * - Check text error of main block and checksum error of backup block.
+ * [RET_DEV_RD_ERR_2]
+ * - Checksum error of main block and check text error of backup block.
+ * [RET_DEV_RD_ERR_3]
+ * - Checksum error of main block and backup block. [RET_DEV_RD_ERR_4]
+ * \~english @par Detail
+ * - This API gets data from main or backup block according to specified\n
+ * norflash device pathname and main block ID.
+ * \~english @par
+ * - When this API is executed, read data from main block first. If failed to\n
+ * read main block, return RET_DEV_RD_ERR_OTHER. If read main block success,\n
+ * but check main block data error, turn to read data from backup block which\n
+ * block ID is i_id + 1.
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync Only
+ * \~english @see mtdn_backup_Write
+ */
+int mtdn_backup_Read(const char * path_name, int i_id, int i_offset, int i_size, void *p_buff);
+
+/**\ingroup mtdn_backup_Write
+ * \~english @par Brief
+ * Write data to norflash device.
+ * \~english @param [in] path_name
+ * const char* - Device path to write(such as "/dev/mtd")
+ * \~english @param [in] i_id
+ * int - Main block ID(0, 2, 4, ...)
+ * \~english @param [in] i_offset
+ * int - Data offset
+ * \~english @param [in] i_size
+ * int - Data size to write
+ * \~english @param [in] p_buff
+ * Void* - Buffer for storing written data
+ * \~english @retval RET_DEV_NORMAL OK
+ * \~english @retval RET_DEV_ERROR Get device error
+ * \~english @retval RET_DEV_ERR_PARAM Parameter error
+ * \~english @retval RET_DEV_WT_ERR_OTHER Other error
+ * \~english @retval RET_DEV_WT_ERR Internal error
+ * \~english @par Preconditions
+ * - There is no preconditions for this API.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - Parameter path_name is NULL. [RET_DEV_ERR_PARAM]
+ * - Parameter p_buff is NULL. [RET_DEV_ERR_PARAM]
+ * - Value of parameter i_id is less than 0. [RET_DEV_ERR_PARAM]
+ * - Value of parameter i_offset is less than 0 or value of parameter i_size
+ * is not greater than 0. [RET_DEV_ERR_PARAM]
+ * - Device specified by path_name is invalid. [RET_DEV_ERR_PARAM]
+ * - Sum value of i_offset and i_size is greater than block size - 16byte.
+ * [RET_DEV_ERR_PARAM]
+ * - Failed to get device info. [RET_DEV_ERROR]
+ * - Internal processing error(Other error). [RET_DEV_WT_ERR_OTHER]
+ * - Internal IO error(open, write, close, ioctl, malloc, lseek).
+ * [RET_DEV_WT_ERR]
+ * \~english @par Detail
+ * - This API writes data to main and backup blocks according to specified\n
+ * norflash device pathname and main block ID.
+ * \~english @par
+ * - When this API is executed, p_buff data will be write to main and backup\n
+ * blocks. If failed to write any block, return RET_DEV_WT_ERR.
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync Only
+ * \~english @see mtdn_backup_Read
+ */
+int mtdn_backup_Write(const char * path_name, int i_id, int i_offset, int i_size, void *p_buff);
+
+#if defined(__cplusplus)
+}
+#endif // __cplusplus
+
+/** @}*/ // end of rom_access_library
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_NOR_BACKUP_H_
diff --git a/systemservice/rom_access_library/library/include/system_service/rom_access_library.h b/systemservice/rom_access_library/library/include/system_service/rom_access_library.h
new file mode 100755
index 0000000..50e44b1
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/system_service/rom_access_library.h
@@ -0,0 +1,47 @@
+//
+// @copyright Copyright (c) 2017-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.
+//
+
+/**
+ * @file rom_access_library.h
+ * @brief This file include all head file of rom and nor access library
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup rom_access_library
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef SYSTEMSERVICE_ROMACCESSLIBRARY_H_ // NOLINT(build/header_guard)
+#define SYSTEMSERVICE_ROMACCESSLIBRARY_H_
+
+#include "system_service/nor_backup.h"
+
+#include "system_service/ss_sm_rom_access.h"
+#include "system_service/ss_sm_boot_access.h"
+#include "system_service/ss_sm_ram_access.h"
+
+#endif // SYSTEMSERVICE_ROMACCESSLIBRARY_H_
+
+/** @}*/ // end of rom_access_library
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/rom_access_library/library/include/system_service/ss_sm_boot_access.h b/systemservice/rom_access_library/library/include/system_service/ss_sm_boot_access.h
new file mode 100755
index 0000000..bac051c
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/system_service/ss_sm_boot_access.h
@@ -0,0 +1,362 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_sm_boot_access.h
+ * @brief This file provides API for get boot information from nor flash
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup rom_access_library
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_BOOT_ACCESS_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_BOOT_ACCESS_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+
+// Top memory map of LINUX management outside domain (SYS area)
+// Must not use it other than the model of C language specifications to refer to BOOT
+
+#define LBM_UINT32 unsigned int
+#define LBM_UINT16 uint16_t
+#define LBM_UINT8 unsigned char
+#define LBM_INT64 int64_t
+#define LBM_INT32 unsigned int
+#define LBM_INT16 uint16_t
+#define LBM_INT8 unsigned char
+
+// Each domain size
+#define LBM_NOR_MIRROR_SIZE 0x10000 // MIRROR area of NOR
+#define LBM_DRAM_SIZE 0x10000 // RAM area to share with BOOT in LINUX
+
+#define LBM_NOR_BOOT_SIZE 128
+#define LBM_NOR_TSKM_SIZE 128
+#define LBM_NOR_VUP_SIZE 1024
+#define LBM_NOR_ANA_SIZE 32
+#define LBM_NOR_VEHI_SIZE 32
+#define LBM_NOR_DEVMGR_SIZE 32
+
+
+//********* Value of the field ****************
+/* SDRAMstart identification */
+#define SYSUP_DRAM_NORMAL (LBM_UINT32)0x4E524E52 /* normal value NRNR*/
+#define SYSUP_DRAM_SFTERRSR (LBM_UINT32)0x73667366 /* abnormal Soft Reset(softwareabnormality) sfsf*/
+#define SYSUP_DRAM_DISCARD (LBM_UINT32)0x44434443 /* need to discard backup DCDC*/
+
+/* Start is in a state (navigator initial use)/System start state */
+#define SYSUP_CND_FACTRESET (LBM_UINT16)0x434c /* COLD START */
+#define SYSUP_CND_NORMAL (LBM_UINT16)0x4853 /* HOT START */
+
+/* Start mode preservation table level */
+#define SYSUP_MODE_NORMAL (LBM_UINT32)0x4E524E52 /* normal mode */
+#define SYSUP_MODE_VERUP (LBM_UINT32)0x56555655 /* versionup mode */
+
+/* Communication state between NAVI-SYS */
+#define SUBCPU_STS_NOMAL (LBM_UINT32)0x00000000 /* Communication normal */
+#define SUBCPU_STS_COMNG (LBM_UINT32)0x88888888 /* Communication abnormal */
+
+/* SDRAM power supply abnormality detection */
+#define SDRAM_STS_NOMAL (LBM_UINT32)0x11111111 /* backup power supply is normal */
+#define SDRAM_STS_BUPNG (LBM_UINT32)0x99999999 /* backup power supply is abnormal */
+
+/* HWDT Outbreak */
+#define HWDT_STS_NOMAL (LBM_UINT32)0x22222222 /* WDT normal */
+#define HWDT_STS_WDTTO (LBM_UINT32)0xAAAAAAAA /* WDT time-out outbreak */
+
+/* SWDT Outbreak */
+#define SWDT_STS_NOMAL HWDT_STS_NOMAL /* SWDT normal */
+#define SWDT_STS_WDTTO HWDT_STS_WDTTO /* SWDT time-out outbreak */
+
+/* Start side */
+#define IFS_PROG1_CODE (LBM_UINT8)0xAA /* Side PROG1 */
+#define IFS_PROG2_CODE (LBM_UINT8)0x55 /* Side PROG2 */
+
+/* Start infomation ID */
+#define UPTBLE_ID_MAX (LBM_UINT8)0x20 /* LBM_UPTBLINFO Maximum value */
+#define UPTBLE_ID_NORBOOT (LBM_UINT8)0x00 /* NOR-BOOT ID */
+#define UPTBLE_ID_SCRLDR (LBM_UINT8)0x01 /* SecureLoader ID */
+#define UPTBLE_ID_NANDBOOT (LBM_UINT8)0x02 /* NAND-BOOT ID */
+#define UPTBLE_ID_ROOTFS (LBM_UINT8)0x03 /* Rootfs1 ID */
+#define UPTBLE_ID_ROOTFS2 (LBM_UINT8)0x04 /* Rootfs2 ID */
+
+/* Start status */
+#define STUP_STS_NORMAL (LBM_UINT32)0x00000000 /* normal status */
+/* Rollback of protectionism is necessary by abnormal reset repetition */
+#define STUP_STS_ERROR_DETEC (LBM_UINT32)0x22222222
+#define STUP_STS_UPDATING (LBM_UINT32)0x33333333 /* updating status */
+/* not for use(will be removed) */
+#define STUP_STS_SIGNVRFY_ERROR (LBM_UINT32)0x11111111
+
+/* mdUpdate/sdUpdate */
+#define UPDATE_NOTI_NONE (LBM_UINT32)0x00000000 /* Notify is NOT required. */
+#define UPDATE_NOTI_EXIST (LBM_UINT32)0xEEEEEEEE /* Notify is required. */
+
+/* RAM Judge Flag */
+#define RAMJUDGE_STS_NOMAL (LBM_UINT32)0x44444444 /* RAM Judge Port is High */
+#define RAMJUDGE_STS_NG (LBM_UINT32)0xDDDDDDDD /* RAM Judge Port is Low */
+
+/* DRAM Self Refresh */
+#define SELF_REFRESH_OK (LBM_UINT32)0x55555555 /* DRAM Self Refresh is OK */
+#define SELF_REFRESH_NG (LBM_UINT32)0xCCCCCCCC /* DRAM Self Refresh is NG */
+
+/* Release ROM type */
+#define PRODUCTROM (LBM_UINT32)0x11111111
+#define RELEASEROM (LBM_UINT32)0x22222222
+#define RELEASEROM_REMAIN_USBBOOT (LBM_UINT32)0x44444444
+#define DEBUGROM (LBM_UINT32)0x88888888
+
+/* Boot write Nor */
+#define WRITE_NONE (LBM_UINT32)0x00000000
+#define WRITE_DONE (LBM_UINT32)0x11111111
+
+
+/* opdtLoadSatus */
+#define DEFAULT_OPIMAGE_DRAM_BACKUPED (LBM_UINT32)0x00000000
+#define DEFAULT_OPIMAGE_FROM_EMMC (LBM_UINT32)0xAAAAAAAA
+#define SPECIFIC_OPIMAGE_DRAM_BACKUPED (LBM_UINT32)0x11111111
+#define SPECIFIC_OPIMAGE_FROM_EMMC (LBM_UINT32)0xBBBBBBBB
+
+/* opdtLoadFactor */
+#define SPECIFIC_OPIMAGE_FLAG_NONE (LBM_UINT32)0x00000000
+#define SPECIFIC_OPIMAGE_FILE_NONE (LBM_UINT32)0x11111111
+#define SPECIFIC_OPIMAGE_FILESIZE_0 (LBM_UINT32)0x22222222
+#define SPECIFIC_OPIMAGE_FILE_EXIST (LBM_UINT32)0xEEEEEEEE
+
+
+#pragma pack(push, 4)
+
+// Memory map of the SYS area of the mem0
+
+#define SS_SYS_AREA_BOOT_MAX_SIZE (0x00010000UL)
+
+#define SS_SYS_AREA_ROM_OFFSET (0x00010000UL)
+#define SS_SYS_AREA_ROM_MAX_SIZE (0x00001000UL)
+
+#define SS_SYS_AREA_RAM_OFFSET (0x00011000UL)
+#define SS_SYS_AREA_RAM_MAX_SIZE (0x00001000UL)
+
+//********* NOR area ****************
+typedef struct LBM_boot_wpinfo_t {
+ LBM_UINT32 currentside; // IFS_PROG*_CODE
+ LBM_UINT32 stupStsA; // STUP_STS_*
+ LBM_UINT32 stupStsB; // STUP_STS_*
+}LBM_UPTBLINFO;
+
+typedef struct LBM_boot_t {
+ LBM_UINT32 sts1; // SYSUP_CND_*
+ LBM_UINT32 btmode; // SYSUP_MODE_*
+ LBM_UINT32 sts2; // SYSUP_CND_*
+ LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
+ LBM_UINT32 sts3; // SYSUP_CND_*
+}LBM_NOR_t;
+
+//********* DRAM area ****************
+typedef struct _tmb_ram_t {
+ LBM_UINT32 dram1; // SYSUP_DRAM_*
+ LBM_UINT32 sts; // SYSUP_CND_*
+ LBM_UINT32 upmode; // SYSUP_MODE_*
+ LBM_UINT32 dram2; // SYSUP_DRAM_*
+ LBM_UINT32 syscomSts; // SUBCPU_STS_*
+ LBM_UINT32 pwSts; // SDRAM_STS_*
+ LBM_UINT32 hwdtSts; // HWDT_STS_*
+ LBM_UINT32 dram3; // SYSUP_DRAM_*
+ LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
+ LBM_UINT32 sectorNo; // NOR Shared SectorNo
+ LBM_UINT32 mdUpdate; // UPDATE_NOTI_* LanServer Update Notification
+ LBM_UINT32 sdUpdate; // UPDATE_NOTI_* SettingService Update Notification
+ LBM_UINT32 ramjudgeSts; // RAMJUDGE_STS_*
+ LBM_UINT32 swdtSts; // SWDT_STS_*
+ LBM_UINT32 dram_self_refresh; // DRAM Self Refresh
+ LBM_UINT32 releaseNorType;
+ LBM_UINT32 socCpuType; // H2/E2/M2
+ LBM_UINT32 socEsNumber; // ES1x/ES2x/ES3x
+ LBM_UINT32 spiBootDevice; // NorDeviceID
+ LBM_UINT32 bootNorWrite; // uboot-api
+ LBM_UINT32 naviDetFactor;
+
+ LBM_UINT32 emmcTap; //emmcTap
+ LBM_UINT32 opdtUpdateReq;
+ LBM_UINT32 opdtLoadSatus;
+ LBM_UINT32 opdtLoadFactor;
+
+}LBM_RAM_t;
+
+#pragma pack(pop)
+
+
+/**
+* \~english Access type to the boot information
+*/
+typedef enum {
+ BAI_OPEN_RO, /* \~english Access type for the Read only*/
+ BAI_OPEN_RW /* \~english Access type for the Read and Write*/
+}BAI_OPEN_t;
+
+/**
+ * @class BOOT_AccessIf
+ * \~english @brief BOOT_AccessIf
+ * \~english @par Brief Introduction
+ * Class to provide the function of BOOT AccessIf
+ *
+ */
+class BOOT_AccessIf{
+ private:
+ static void* g_m_plock;
+ BAI_OPEN_t m_type;
+
+ public:
+ /**
+ * \ingroup BOOT_AccessIf
+ * \~english @par Summary:
+ * Obtain the access permission to the boot information (secondary storage area).
+ * \~english @param [in] type
+ * BAI_OPEN_t - Access type to the boot information\n
+ * \~english @par
+ * BAI_OPEN_t
+ * - BAI_MTD_DEV_RO Access type for the Read only \n
+ * - BAI_MTD_DEV_RW Access type for the Read and Write
+ * \~english @retval None
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - None
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * None
+ * \~english @par Detail:
+ * Obtain the access permission to the boot information \n
+ * When the access permission is locked, the API waits for Mutex until the access permission is released. \n
+ * This API is assumed to be called by SystemManager.
+ * \~english @see ~BOOT_AccessIf, CL_LockMap, CL_LockGet
+ */
+explicit BOOT_AccessIf(BAI_OPEN_t type);
+
+ /**
+ * \ingroup ~BOOT_AccessIf
+ * \~english @par Summary:
+ * Release the access permission to the boot information (secondary storage area).
+ * \~english @param None
+ * \~english @retval None
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - None
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * None
+ * \~english @par Detail:
+ * Release the access permission to the boot information.\n
+ * \~english @see BOOT_AccessIf, CL_LockRelease
+ */
+ ~BOOT_AccessIf();
+
+/**
+ * \ingroup getBootInfo
+ * \~english @par Summary:
+ * Read the boot information (secondary storage area).
+ * \~english @param [out] p_boot_info
+ * LBM_NOR_t * - Destination buffer to read the boot information
+ * \~english @par
+ * LBM_NOR_t Structure body
+ * \~english @code
+ * typedef struct LBM_boot_t{
+ * LBM_UINT32 sts1; //SYSUP_CND_*
+ * LBM_UINT32 btmode; //SYSUP_MODE_*
+ * LBM_UINT32 sts2; //SYSUP_CND_*
+ * LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
+ * LBM_UINT32 sts3; //SYSUP_CND_*
+ * }LBM_NOR_t;
+ * @endcode
+ * Refer to "ss_boot_map.h" for the parameters to be set to the member of struct LBM_NOR_t.
+ * \~english @retval eFrameworkunifiedStatusOK Reading success
+ * \~english @retval eFrameworkunifiedStatusFail Reading failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Copy the boot information stored in the secondary storage area to p_boot_info. \n
+ * \~english @see setBootInfo
+ */
+ EFrameworkunifiedStatus getBootInfo(LBM_NOR_t* p_boot_info);
+
+ /**
+ * \ingroup setBootInfo
+ * \~english @par Summary:
+ * Write the boot information (secondary storage area).
+ * \~english @param [in] p_boot_info
+ * LBM_NOR_t * - Original buffer to write the boot information
+ * \~english @par
+ * LBM_NOR_tStructure body
+ * \~english @code
+ * typedef struct LBM_boot_t{
+ * LBM_UINT32 sts1; //SYSUP_CND_*
+ * LBM_UINT32 btmode; //SYSUP_MODE_*
+ * LBM_UINT32 sts2; //SYSUP_CND_*
+ * LBM_UPTBLINFO upTbl[UPTBLE_ID_MAX];
+ * LBM_UINT32 sts3; //SYSUP_CND_*
+ * }LBM_NOR_t;
+ * @endcode
+ * Refer to "ss_boot_map.h" for the parameters to be set to the member of struct LBM_NOR_t.
+ * \~english @retval eFrameworkunifiedStatusOK Write success
+ * \~english @retval eFrameworkunifiedStatusFail Write failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
+ * - BOOT_AccessIf Opened secondary storage area with BAI_MTD_DEV_RO [eFrameworkunifiedStatusFail]
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Write the boot information stored in p_boot_info to the secondary storage area. \n
+ * \~english @see getBootInfo
+ */
+ EFrameworkunifiedStatus setBootInfo(LBM_NOR_t* p_boot_info);
+};
+
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_BOOT_ACCESS_H_
+
+/** @}*/ // end of rom_access_library
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/rom_access_library/library/include/system_service/ss_sm_ram_access.h b/systemservice/rom_access_library/library/include/system_service/ss_sm_ram_access.h
new file mode 100755
index 0000000..f96966b
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/system_service/ss_sm_ram_access.h
@@ -0,0 +1,235 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_sm_ram_access.h
+ * @brief This file provides API for get ram information from extension memory
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup rom_access_library
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_RAM_ACCESS_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_RAM_ACCESS_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+
+/**
+ * \~english max length of ram product private
+ */
+#define RAM_PRODUCT_PRIVATE_MAX (96)
+/**
+ * \~english max length of order file name
+ */
+#define SS_SM_ORDER_NAME_MAX (32)
+
+/**
+ * \~english System management information
+ */
+typedef struct {
+ char signature_in[4];
+ BOOL isImmediateReset;
+ BOOL needRenotifyStartPrm;
+ uint32_t lastWakeupType;
+ uint32_t lastDramBackupStatus;
+ uint32_t lastResetStatus;
+ char productPrivate[RAM_PRODUCT_PRIVATE_MAX];
+ char order_name[SS_SM_ORDER_NAME_MAX];
+ BOOL isErrorReset;
+ char signature_out[4];
+}RAM_SM_INFO_t;
+
+/**
+ * \~english System wakeup state type
+ */
+typedef enum {
+ RAM_WAKEUP_STATE_DONT_CARE = 0, /* \~english Don't care wakeup state*/
+ RAM_WAKEUP_STATE_BACKUP_NG, /* \~english Wakeup state is backup NG*/
+ RAM_WAKEUP_STATE_BATTERY_DOWN /* \~english Wakeup state is battery down*/
+}RAM_WAKEUP_STATE;
+
+/**
+ * @class RAM_AccessIf
+ * \~english @brief RAM_AccessIf
+ * \~english @par Brief Introduction
+ * Class to provide the function of RAM AccessIf
+ *
+ */
+class RAM_AccessIf{
+ private:
+ static void* g_m_plock;
+ static void* g_m_bakup_map;
+ static bool g_m_is_first_access;
+ RAM_SM_INFO_t m_buf;
+ bool m_dirty;
+ void initRamBackupEnable(RAM_WAKEUP_STATE wup_state);
+ void finalRamBackupEnable(void);
+
+ public:
+/**
+ * \ingroup RAM_AccessIf
+ * \~english @par Summary:
+ * Obtain the access permission to the system management information.
+ * \~english @param [in] wup_state
+ * RAM_WAKEUP_STATE - System maneger wakeup state type
+ * \~english @par
+ * RAM_WAKEUP_STATE
+ * - RAM_WAKEUP_STATE_DONT_CARE Don't care wakeup state\n
+ * - RAM_WAKEUP_STATE_BACKUP_NG Wakeup state is backup NG\n
+ * - RAM_WAKEUP_STATE_BATTERY_DOWN Wakeup state is battery down
+ * \~english @retval None
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - None
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * None
+ * \~english @par Detail:
+ * Obtain the access permission to the system management information \n
+ * When the access permission is locked, the API waits for Mutex until the access permission is released. \n
+ * This API is supposed to be called by SystemManager.
+ * \~english @see ~RAM_AccessIf, CL_LockMap, CL_LockGet
+ */
+explicit RAM_AccessIf(RAM_WAKEUP_STATE wup_state = RAM_WAKEUP_STATE_DONT_CARE);
+
+/**
+ * \ingroup ~RAM_AccessIf
+ * \~english @par Summary:
+ * Release the access permission to the system management information.
+ * \~english @param None
+ * \~english @retval None
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - None
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * None
+ * \~english @par Detail:
+ * Release the access permission to the system management information.\n
+ * \~english @see RAM_AccessIf, CL_LockRelease
+ */
+ ~RAM_AccessIf();
+
+/**
+ * \ingroup getRamInfo
+ * \~english @par Summary:
+ * Read the system management information.
+ * \~english @param [out] p_boot_info
+ * RAM_SM_INFO_t * - Destination buffer to read the system management information.
+ * \~english @par
+ * RAM_SM_INFO_t Structure body
+ * \~english @code
+ * typedef struct {
+ * char signature_in[4];
+ * BOOL isImmediateReset;
+ * BOOL needRenotifyStartPrm;
+ * uint32_t lastWakeupType;
+ * uint32_t lastDramBackupStatus;
+ * uint32_t lastResetStatus;
+ * char productPrivate[RAM_PRODUCT_PRIVATE_MAX];
+ * char order_name[SS_SM_ORDER_NAME_MAX];
+ * BOOL isErrorReset;
+ * char signature_out[4];
+ * }RAM_SM_INFO_t;
+ * @endcode
+ * \~english @retval eFrameworkunifiedStatusOK Reading success
+ * \~english @retval eFrameworkunifiedStatusFail Reading failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
+ * - If read data from secondary storage area or /nv/BS/ss/rom_access_library/rwdata/ramdata.dat
+ * failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Copy the system information stored in the secondary storage area or
+ * in /nv/BS/ss/rom_access_library/rwdata/ramdata.dat to p_boot_info. \n
+ * \~english @see setRamInfo
+ */
+ EFrameworkunifiedStatus getRamInfo(RAM_SM_INFO_t* p_boot_info);
+
+/**
+ * \ingroup setRamInfo
+ * \~english @par Summary:
+ * Write the system management information.
+ * \~english @param [in] p_boot_info
+ * RAM_SM_INFO_t * - Original buffer to write the system management information
+ * \~english @par
+ * RAM_SM_INFO_t Structure body
+ * \~english @code
+ * typedef struct {
+ * char signature_in[4];
+ * BOOL isImmediateReset;
+ * BOOL needRenotifyStartPrm;
+ * uint32_t lastWakeupType;
+ * uint32_t lastDramBackupStatus;
+ * uint32_t lastResetStatus;
+ * char productPrivate[RAM_PRODUCT_PRIVATE_MAX];
+ * char order_name[SS_SM_ORDER_NAME_MAX];
+ * BOOL isErrorReset;
+ * char signature_out[4];
+ * }RAM_SM_INFO_t;
+ * @endcode
+ * \~english @retval eFrameworkunifiedStatusOK Write success
+ * \~english @retval eFrameworkunifiedStatusFail Write failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
+ * - If write data to secondary storage area or /nv/BS/ss/rom_access_library/rwdata/ramdata.dat
+ * failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Write the system manegement information stored in p_boot_info to the
+ * secondary storage area or /nv/BS/ss/rom_access_library/rwdata/ramdata.dat. \n
+ * \~english @see getRamInfo
+ */
+ EFrameworkunifiedStatus setRamInfo(RAM_SM_INFO_t* p_boot_info);
+};
+
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_RAM_ACCESS_H_
+
+/** @}*/ // end of rom_access_library
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/rom_access_library/library/include/system_service/ss_sm_rom_access.h b/systemservice/rom_access_library/library/include/system_service/ss_sm_rom_access.h
new file mode 100755
index 0000000..4ba1a76
--- /dev/null
+++ b/systemservice/rom_access_library/library/include/system_service/ss_sm_rom_access.h
@@ -0,0 +1,1010 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file ss_sm_rom_access.h
+ * @brief This file provides API for get rom information from extension memory
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup rom_access_library
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_ROM_ACCESS_H_
+#define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_ROM_ACCESS_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+
+#include "system_service/ss_sm_boot_access.h"
+
+/**
+ * \~english boot mode information
+ */
+typedef enum {
+ APPLICATION_MODE = 0,
+ PROGRAMMING_MODE
+}EBOOT_MODE;
+
+/**
+ * \~english active flash load information
+ */
+typedef enum {
+ NEW_FLASHLOADER = 0,
+ OLD_FLASHLOADER
+}EACTIVE_FLASHLOADER;
+
+/**
+ * \~english user mode information
+ */
+typedef enum {
+ USER_OFF = 0,
+ USER_ON
+}EUSER_MODE;
+
+/**
+ * \~english control mode information
+ */
+typedef enum {
+ DISABLE_MODE = 0,
+ ENABLE_MODE
+}ECONTROL_MODE;
+
+/**
+ * \~english data reset mode information
+ */
+typedef enum {
+ DATARESET_NONE = 0,
+ DATARESET_USER,
+ DATARESET_FACTORY
+}EDATARESET_MODE;
+
+/**
+ * \~english last illegal reset mode information
+ */
+typedef enum {
+ LAST_ILGRESET_NORMAL = 0,
+ LAST_ILGRESET_NG
+}ELASTILGRESET_MODE;
+
+/**
+ * \~english Program update state information
+ */
+typedef uint32_t EPROGUPDATE_STATE;
+
+/**
+ * \~english next wakeup type
+ */
+typedef enum {
+ NEXT_WAKEUP_TYPE_NONE = 0,
+ NEXT_WAKEUP_TYPE_COLD,
+ NEXT_WAKEUP_TYPE_HOT,
+}ENEXT_WAKEUP_TYPE;
+
+/**
+ * \~english DRAM backup state
+ */
+typedef enum {
+ DRAM_BACKUP_STATE_OK = 0,
+ DRAM_BACKUP_STATE_NG
+}DRAM_BACKUP_STATE;
+
+/**
+ * \~english max length of rom product private
+ */
+#define ROM_PRODUCT_PRIVATE_MAX 128
+
+/**
+ * @class ROM_AccessIf
+ * \~english @brief ROM_AccessIf
+ * \~english @par Brief Introduction
+ * Class to provide the function of ROM AccessIf
+ *
+ */
+class ROM_AccessIf {
+ private:
+ BOOT_AccessIf* m_pBoot;
+ static void* g_m_plock;
+ static void* g_m_bakup_map;
+ static bool g_m_is_dram_valid;
+ LBM_NOR_t m_nor;
+ bool m_norIsDirty;
+
+ EFrameworkunifiedStatus LBA_Read(UI_32 offset, UI_32* buffer, UI_32 word_count);
+
+ EFrameworkunifiedStatus LBA_Write(UI_32 offset, UI_32 value);
+
+ EFrameworkunifiedStatus LBA_Write(UI_32 offset, UI_32* value, UI_32 size);
+
+ EFrameworkunifiedStatus GetDataResetMode_sub(EDATARESET_MODE* p_data_reset_mode);
+
+ public:
+/**
+ * \ingroup ROM_AccessIf
+ * \~english @par Summary:
+ * Obtain the access permission to SYS area (secondary storage area).
+ * \~english @param None
+ * \~english @retval None
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - None
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * None
+ * \~english @par Detail:
+ * Obtain the access permission to SYS area. \n
+ * When the access permission is locked, the API watis for Mutex until the access permission is released. \n
+ * This API is assumed to be called by the SystemManager.
+ * \~english @see ~ROM_AccessIf, CL_LockMap, CL_LockGet
+ */
+ ROM_AccessIf();
+
+/**
+ * \ingroup ~ROM_AccessIf
+ * \~english @par Summary:
+ * Release the access permission to SYS area (secondary storage area).
+ * \~english @param None
+ * \~english @retval None
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - None
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * None
+ * \~english @par Detail:
+ * Release the access permission to SYS area.
+ * \~english @see ROM_AccessIf, CL_LockRelease
+ */
+ ~ROM_AccessIf();
+
+/**
+ * \ingroup Initialize
+ * \~english @par Summary:
+ * Synchronize SYS area (secondary storage area) and the mirror data in DRAM
+ * \~english @param None
+ * \~english @retval eFrameworkunifiedStatusOK Synchronization success
+ * \~english @retval eFrameworkunifiedStatusFail Synchronization failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If system call mmap failed. [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Prepare the access to SYS area. \n
+ * \~english @see EL_mem_exram_mmap
+ */
+ EFrameworkunifiedStatus Initialize();
+
+/**
+ * \ingroup SetProductPrivate
+ * \~english @par Summary:
+ * Write data information depending on the product specification to the secondary storage area.
+ * \~english @param [in] buf[ROM_PRODUCT_PRIVATE_MAX]
+ * UI_8[] - Data information depending on the product specification
+ * \~english @par
+ * Definition of ROM_PRODUCT_PRIVATE_MAX
+ * \~english @code
+ * #define ROM_PRODUCT_PRIVATE_MAX 128
+ * @endcode
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Write data information depending on the product specification to the secondary storage area. \n
+ * \~english @see GetProductPrivate
+ */
+ EFrameworkunifiedStatus SetProductPrivate(UI_8 buf[ROM_PRODUCT_PRIVATE_MAX]);
+
+/**
+ * \ingroup GetProductPrivate
+ * \~english @par Summary:
+ * Read the data information depending on the product specification from the secondary storage area.
+ * \~english @param [out] buf[ROM_PRODUCT_PRIVATE_MAX]
+ * UI_8[] - Storing destination of data information depending on the product specification
+ * \~english @par
+ * Definition of ROM_PRODUCT_PRIVATE_MAX
+ * \~english @code
+ * #define ROM_PRODUCT_PRIVATE_MAX 128
+ * @endcode
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Read data information depending on the product specification from the secondary storage area. \n
+ * \~english @see SetProductPrivate
+ */
+ EFrameworkunifiedStatus GetProductPrivate(UI_8 buf[ROM_PRODUCT_PRIVATE_MAX]);
+
+/**
+ * \ingroup SystemInitialize
+ * \~english @par Summary:
+ * Initialize the handles used for ROM access.
+ * \~english @param [in] bkup_state
+ * \~english @par
+ * DRAM_BACKUP_STATE
+ * - DRAM_BACKUP_STATE_OK
+ * - DRAM_BACKUP_STATE_NG
+ * \~english @retval eFrameworkunifiedStatusOK Initialize the handles used for ROM access success
+ * \~english @retval eFrameworkunifiedStatusFail Initialize the handles used for ROM access failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If system call mmap failed. [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Initialize the handles used for ROM access. \n
+ * \~english @see EL_mem_exram_mmap
+ */
+ EFrameworkunifiedStatus SystemInitialize(DRAM_BACKUP_STATE bkup_state);
+
+/**
+ * \ingroup GetBootMode
+ * \~english @par Summary:
+ * Get boot mode information.
+ * \~english @param [out] p_boot_mode
+ * EBOOT_MODE* - Destination buffer to store information of boot mode.
+ * \~english @par
+ * EBOOT_MODE
+ * - APPLICATION_MODE
+ * - PROGRAMMING_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get boot mode information from the secondary storage area. \n
+ * \~english @see SetBootMode
+ */
+ EFrameworkunifiedStatus GetBootMode(EBOOT_MODE* p_boot_mode);
+
+/**
+ * \ingroup SetBootMode
+ * \~english @par Summary:
+ * Set boot mode information.
+ * \~english @param [in] boot_mode
+ * EBOOT_MODE - Boot mode information which write to the secondary storage area.
+ * \~english @par
+ * EBOOT_MODE
+ * - APPLICATION_MODE
+ * - PROGRAMMING_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set boot mode information to the secondary storage area. \n
+ * \~english @see GetBootMode
+ */
+ EFrameworkunifiedStatus SetBootMode(EBOOT_MODE boot_mode);
+
+/**
+ * \ingroup GetSignature
+ * \~english @par Summary:
+ * Get signature information.
+ * \~english @param [out] p_sig_value
+ * UI_32 - Destination buffer to store signature information
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write signature information to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get signature information from the secondary storage area. \n
+ * \~english @see SetSignature
+ */
+ EFrameworkunifiedStatus GetSignature(UI_32* p_sig_value);
+
+/**
+ * \ingroup SetSignature
+ * \~english @par Summary:
+ * Set signature information.
+ * \~english @param [in] sig_value
+ * UI_32 - Signature information which write to the secondary storage area.
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write signature information to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set signature information to the secondary storage area. \n
+ * \~english @see GetSignature
+ */
+ EFrameworkunifiedStatus SetSignature(UI_32 sig_value);
+
+/**
+ * \ingroup SetActiveFlashloader
+ * \~english @par Summary:
+ * Set active flash loader information.
+ * \~english @param [in] active_flash_loader
+ * EACTIVE_FLASHLOADER - Active flash loader information which write to secondary storage area.
+ * \~english @par
+ * EBOOT_MODE
+ * - APPLICATION_MODE
+ * - PROGRAMMING_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set active flash loader information to the secondary storage area. \n
+ * \~english @see GetBootMode
+ */
+ EFrameworkunifiedStatus SetActiveFlashloader(EACTIVE_FLASHLOADER active_flash_loader);
+
+/**
+ * \ingroup GetLastUserMode
+ * \~english @par Summary:
+ * Get last user mode information.
+ * \~english @param [out] p_user_mode
+ * EUSER_MODE* - Destination buffer to store information of user mode.
+ * \~english @par
+ * EUSER_MODE
+ * - USER_ON
+ * - USER_OFF
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get last user mode information from the secondary storage area. \n
+ * \~english @see SetLastUserMode
+ */
+ EFrameworkunifiedStatus GetLastUserMode(EUSER_MODE* p_user_mode);
+
+/**
+ * \ingroup SetLastUserMode
+ * \~english @par Summary:
+ * Set last user mode information.
+ * \~english @param [in] user_mode
+ * EUSER_MODE - User mode information which write to the secondary storage area.
+ * \~english @par
+ * EUSER_MODE
+ * - USER_ON
+ * - USER_OFF
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set last user mode information to the secondary storage area. \n
+ * \~english @see GetLastUserMode
+ */
+ EFrameworkunifiedStatus SetLastUserMode(EUSER_MODE user_mode);
+
+/**
+ * \ingroup GetTransportMode
+ * \~english @par Summary:
+ * Get transport mode information.
+ * \~english @param [out] p_control_mode
+ * ECONTROL_MODE* - Destination buffer to store information of transport mode.
+ * \~english @par
+ * ECONTROL_MODE
+ * - DISABLE_MODE
+ * - ENABLE_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get transport mode information from the secondary storage area. \n
+ * \~english @see SetTransportMode
+ */
+ EFrameworkunifiedStatus GetTransportMode(ECONTROL_MODE* p_control_mode);
+
+/**
+ * \ingroup SetTransportMode
+ * \~english @par Summary:
+ * Set transport mode information.
+ * \~english @param [in] control_mode
+ * ECONTROL_MODE - Transport mode information which write to the secondary storage area.
+ * \~english @par
+ * ECONTROL_MODE
+ * - DISABLE_MODE
+ * - ENABLE_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set transport mode information to the secondary storage area. \n
+ * \~english @see GetTransportMode
+ */
+ EFrameworkunifiedStatus SetTransportMode(ECONTROL_MODE control_mode);
+
+/**
+ * \ingroup GetProductionMode
+ * \~english @par Summary:
+ * Get production mode information.
+ * \~english @param [out] p_control_mode
+ * ECONTROL_MODE* - Destination buffer to store information of production mode.
+ * \~english @par
+ * ECONTROL_MODE
+ * - DISABLE_MODE
+ * - ENABLE_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get production mode information from the secondary storage area. \n
+ * \~english @see SetProductionMode
+ */
+ EFrameworkunifiedStatus GetProductionMode(ECONTROL_MODE* p_control_mode);
+
+/**
+ * \ingroup SetProductionMode
+ * \~english @par Summary:
+ * Set transport mode information.
+ * \~english @param [in] control_mode
+ * ECONTROL_MODE - Production mode information which write to the secondary storage area.
+ * \~english @par
+ * ECONTROL_MODE
+ * - DISABLE_MODE
+ * - ENABLE_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set production mode information to the secondary storage area. \n
+ * \~english @see GetProductionMode
+ */
+ EFrameworkunifiedStatus SetProductionMode(ECONTROL_MODE control_mode);
+
+/**
+ * \ingroup GetLimpHomeCutOffReqMode
+ * \~english @par Summary:
+ * Get limp home cut off request mode information.
+ * \~english @param [out] p_control_mode
+ * ECONTROL_MODE* - Destination buffer to store information of limp home cut off request mode.
+ * \~english @par
+ * ECONTROL_MODE
+ * - DISABLE_MODE
+ * - ENABLE_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get limp home cut off request mode information from the secondary storage area. \n
+ * \~english @see SetLimpHomeCutOffReqMode
+ */
+ EFrameworkunifiedStatus GetLimpHomeCutOffReqMode(ECONTROL_MODE* p_control_mode);
+
+/**
+ * \ingroup SetLimpHomeCutOffReqMode
+ * \~english @par Summary:
+ * Set limp home cut off request mode information.
+ * \~english @param [in] control_mode
+ * ECONTROL_MODE - Limp home cut off request mode information which write to the secondary storage area.
+ * \~english @par
+ * ECONTROL_MODE
+ * - DISABLE_MODE
+ * - ENABLE_MODE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set limp home cut off request mode information to the secondary storage area. \n
+ * \~english @see GetLimpHomeCutOffReqMode
+ */
+ EFrameworkunifiedStatus SetLimpHomeCutOffReqMode(ECONTROL_MODE control_mode);
+
+/**
+ * \ingroup GetDataResetMode
+ * \~english @par Summary:
+ * Get reserved data reset mode information.
+ * \~english @param [out] p_data_reset_mode
+ * EDATARESET_MODE* - Destination buffer to store information of reserved data reset mode.
+ * \~english @par
+ * EDATARESET_MODE
+ * - DATARESET_NONE
+ * - DATARESET_USER
+ * - DATARESET_FACTORY
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get reserved data reset mode information from the secondary storage area. \n
+ * \~english @see SetDataResetMode
+ */
+ EFrameworkunifiedStatus GetDataResetMode(EDATARESET_MODE* p_data_reset_mode);
+
+/**
+ * \ingroup GetDataResetModeFast
+ * \~english @par Summary:
+ * Get reserved data reset mode information faster.This api can get correct value before
+ * calling SetDataResetMode.So it shoud be used only immediately after boot.
+ * \~english @param [out] p_data_reset_mode
+ * EDATARESET_MODE* - Destination buffer to store information of reserved data reset mode faster.
+ * \~english @par
+ * EDATARESET_MODE
+ * - DATARESET_NONE
+ * - DATARESET_USER
+ * - DATARESET_FACTORY
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * - If system call mmap failed. [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get reserved data reset mode information faster from the secondary storage area.This api can get
+ * correct value before calling SetDataResetMode.So it shoud be used only immediately after boot.
+ * \~english @see SetDataResetMode
+ */
+ EFrameworkunifiedStatus GetDataResetModeFast(EDATARESET_MODE* p_data_reset_mode);
+
+/**
+ * \ingroup SetDataResetMode
+ * \~english @par Summary:
+ * Set reserve data reset mode information.
+ * \~english @param [in] data_reset_mode
+ * EDATARESET_MODE - Reserve data reset mode information which write to the secondary storage area.
+ * \~english @par
+ * EDATARESET_MODE
+ * - DATARESET_NONE
+ * - DATARESET_USER
+ * - DATARESET_FACTORY
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set reserve data reset mode information to the secondary storage area. \n
+ * \~english @see GetDataResetMode
+ */
+ EFrameworkunifiedStatus SetDataResetMode(EDATARESET_MODE data_reset_mode);
+
+/**
+ * \ingroup GetResetCount
+ * \~english @par Summary:
+ * Get reset count information.
+ * \~english @param [out] p_reset_count
+ * UI_32* - Destination buffer to store information of reset count.
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get reset count from the secondary storage area. \n
+ * \~english @see SetResetCount
+ */
+ EFrameworkunifiedStatus GetResetCount(UI_32* p_reset_count);
+
+/**
+ * \ingroup SetResetCount
+ * \~english @par Summary:
+ * Set reset count information.
+ * \~english @param [in] reset_count
+ * UI_32 - Reset count information which write to the secondary storage area.
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set reset count information to the secondary storage area. \n
+ * \~english @see GetResetCount
+ */
+ EFrameworkunifiedStatus SetResetCount(UI_32 reset_count);
+
+/**
+ * \ingroup GetLastIlgReset
+ * \~english @par Summary:
+ * Get last illegal reset information.
+ * \~english @param [out] p_last_ilg_reset
+ * ELASTILGRESET_MODE* - Destination buffer to store information of last illegal reset.
+ * \~english @par
+ * ELASTILGRESET_MODE
+ * - LAST_ILGRESET_NORMAL
+ * - LAST_ILGRESET_NG
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get last illegal reset information from the secondary storage area. \n
+ * \~english @see SetLastIlgReset
+ */
+ EFrameworkunifiedStatus GetLastIlgReset(ELASTILGRESET_MODE* p_last_ilg_reset);
+
+/**
+ * \ingroup SetLastIlgReset
+ * \~english @par Summary:
+ * Set last illegal reset information.
+ * \~english @param [in] last_ilg_reset
+ * ELASTILGRESET_MODE - Last illegal reset information which write to the secondary storage area.
+ * \~english @par
+ * ELASTILGRESET_MODE
+ * - LAST_ILGRESET_NORMAL
+ * - LAST_ILGRESET_NG
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set last illegal reset information to the secondary storage area. \n
+ * \~english @see GetLastIlgReset
+ */
+ EFrameworkunifiedStatus SetLastIlgReset(ELASTILGRESET_MODE last_ilg_reset);
+
+/**
+ * \ingroup GetProgUpdateState
+ * \~english @par Summary:
+ * Get program update status information.
+ * \~english @param [out] p_prog_update_state
+ * EPROGUPDATE_STATE* - Destination buffer to store information of program update status.
+ * \~english @par
+ * typedef uint32_t EPROGUPDATE_STATE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get program update status information from the secondary storage area. \n
+ * \~english @see SetProgUpdateState
+ */
+ EFrameworkunifiedStatus GetProgUpdateState(EPROGUPDATE_STATE* p_prog_update_state);
+
+/**
+ * \ingroup SetProgUpdateState
+ * \~english @par Summary:
+ * Set program update status information.
+ * \~english @param [in] prog_update_state
+ * EPROGUPDATE_STATE - Program update status information which write to the secondary storage area.
+ * \~english @par
+ * typedef uint32_t EPROGUPDATE_STATE
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If write data to secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Set program update status information to the secondary storage area. \n
+ * \~english @see GetProgUpdateState
+ */
+ EFrameworkunifiedStatus SetProgUpdateState(EPROGUPDATE_STATE prog_update_state);
+
+/**
+ * \ingroup GetErrLogCount
+ * \~english @par Summary:
+ * Get error logging count information.
+ * \~english @param [out] p_err_log_count
+ * UI_32* - Destination buffer to store information of error logging count.
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get error logging count information from the secondary storage area. \n
+ * \~english @see SetErrLogCount
+ */
+ EFrameworkunifiedStatus GetErrLogCount(UI_32* p_err_log_count);
+
+/**
+ * \ingroup SetErrLogCount
+ * \~english @par Summary:
+ * Get error logging count information.
+ * \~english @param [out] err_log_count
+ * UI_32* - Destination buffer to store information of error logging count.
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get error logging count information from the secondary storage area. \n
+ * \~english @see GetErrLogCount
+ */
+ EFrameworkunifiedStatus SetErrLogCount(UI_32 err_log_count);
+
+/**
+ * \ingroup GetNextWakeupType
+ * \~english @par Summary:
+ * Get next wakeup type information.
+ * \~english @param [out] p_next_wakeup_type
+ * ENEXT_WAKEUP_TYPE* - Destination buffer to store information of next wakeup type.
+ * \~english @par
+ * ENEXT_WAKEUP_TYPE
+ * - NEXT_WAKEUP_TYPE_NONE
+ * - NEXT_WAKEUP_TYPE_COLD
+ * - NEXT_WAKEUP_TYPE_HOT
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get next wakeup type information from the secondary storage area. \n
+ * \~english @see SetNextWakeupType
+ */
+ EFrameworkunifiedStatus GetNextWakeupType(ENEXT_WAKEUP_TYPE *p_next_wakeup_type);
+
+/**
+ * \ingroup SetNextWakeupType
+ * \~english @par Summary:
+ * Get next wakeup type information.
+ * \~english @param [out] next_wakeup_type
+ * ENEXT_WAKEUP_TYPE* - Destination buffer to store information of next wakeup type.
+ * \~english @par
+ * ENEXT_WAKEUP_TYPE
+ * - NEXT_WAKEUP_TYPE_NONE
+ * - NEXT_WAKEUP_TYPE_COLD
+ * - NEXT_WAKEUP_TYPE_HOT
+ * \~english @retval eFrameworkunifiedStatusOK Success
+ * \~english @retval eFrameworkunifiedStatusFail Failed
+ * \~english @par Precondition:
+ * - None
+ * \~english @par Change in the internal status:
+ * - The change in the internal status does not occur by this API.
+ * \~english @par Conditions of processing failure
+ * - If read data from secondary storage area failed [eFrameworkunifiedStatusFail]
+ * \~english @par Classification:
+ * Public
+ * \~ english @par Type
+ * Sync only(None communication)
+ * \~english @par Detail:
+ * Get next wakeup type information from the secondary storage area. \n
+ * \~english @see GetNextWakeupType
+ */
+ EFrameworkunifiedStatus SetNextWakeupType(ENEXT_WAKEUP_TYPE next_wakeup_type);
+};
+
+#endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_ROM_ACCESS_H_
+
+/** @}*/ // end of rom_access_library
+/** @}*/ // end of system_service
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/rom_access_library/library/nor/Makefile b/systemservice/rom_access_library/library/nor/Makefile
new file mode 100755
index 0000000..f30c271
--- /dev/null
+++ b/systemservice/rom_access_library/library/nor/Makefile
@@ -0,0 +1,46 @@
+#
+# @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.
+#
+
+######### search paths #############
+VPATH += src
+VPATH += ../include/$(COMPONENT_NAME)
+
+######### installed shared library(*.so) #############
+INST_SHLIBS = libssaccess
+
+######### headers to be installed(*.h) #############
+INST_HEADERS = nor_backup.h
+
+######### compiled sources #############
+libssaccess_SRCS = nor_backup.c
+
+######### add include path #############
+CPPFLAGS += -I../include/
+
+######### frameworkunifiedlog options #############
+LDFLAGS += -Wl,--no-undefined
+LDFLAGS += -Wl,--no-as-needed
+
+######### add compile option #############
+LINK_SHLIB_CXX := y
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+include ../../../system_service.mk
diff --git a/systemservice/rom_access_library/library/nor/libBlkDev_API.ver b/systemservice/rom_access_library/library/nor/libBlkDev_API.ver
new file mode 100755
index 0000000..5ebddcb
--- /dev/null
+++ b/systemservice/rom_access_library/library/nor/libBlkDev_API.ver
@@ -0,0 +1,30 @@
+/*
+ * @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.
+ */
+
+#
+# CommonLib version script
+#
+{
+ global:
+ ### .text section ###
+ blkDrv_DirectReadData;
+ blkDrv_DirectWriteData;
+ blkDrv_GetBlockInfo;
+ ### .data section ###
+ local:
+ *;
+};
+
diff --git a/systemservice/rom_access_library/library/nor/libssaccess.ver b/systemservice/rom_access_library/library/nor/libssaccess.ver
new file mode 100755
index 0000000..c4bd070
--- /dev/null
+++ b/systemservice/rom_access_library/library/nor/libssaccess.ver
@@ -0,0 +1,30 @@
+/*
+ * @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.
+ */
+
+#
+# CommonLib version script
+#
+{
+ global:
+ ### .text section ###
+ mtdn_backup_GetErCnt;
+ mtdn_backup_Read;
+ mtdn_backup_Write;
+ ### .data section ###
+ local:
+ *;
+};
+
diff --git a/systemservice/rom_access_library/library/nor/src/nor_backup.c b/systemservice/rom_access_library/library/nor/src/nor_backup.c
new file mode 100755
index 0000000..8a133b0
--- /dev/null
+++ b/systemservice/rom_access_library/library/nor/src/nor_backup.c
@@ -0,0 +1,807 @@
+/*
+ * @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.
+ */
+
+/*******************************************************************************
+* $Header:: $
+* $Revision:: $
+*******************************************************************************/
+
+/*******************************************************************************
+@file mtd_backup.c
+@system
+@process
+@detail
+ ******************************************************************************/
+#include "system_service/nor_backup.h"
+#include <stdio.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <asm/unistd.h>
+#include <mtd/mtd-user.h>
+
+#define BACKUP_RETRY_CNT 3
+
+/* Invalid Value */
+#define FLSBACKUP_SEMAPHORE_INVALID (0)
+
+
+#define BACKUP_SECTOR_SIZ 1024 // Secter Size
+
+#define BACKUP_CHECK_OFFSET 16
+#define BACKUP_CHECK_SIZE 12
+#define BACKUP_CHECK_TEXT "MTD_BACKUPDT"
+#define BACKUP_CHECK_DAT1 1 // Lower 8bit
+#define BACKUP_CHECK_DAT2 2 // Upper 8bit
+
+#define NOR_ERRLOG(fmt, args...) \
+ fprintf(stderr, "[ERR]%ld/%s/%d/= "fmt"\n", syscall(__NR_gettid), __func__, __LINE__, ##args)
+
+static pthread_mutex_t g_semid_flash = PTHREAD_MUTEX_INITIALIZER; /* Semaphore ID of dram area access */
+static int g_backup_init = FLSBACKUP_SEMAPHORE_INVALID;
+
+typedef enum {
+ RET_WT_CHK_OK = 0,
+ RET_WT_ERR_OTHER,
+ RET_WT_DEV_ERR,
+} NOR_WRITE_BLK_CHK;
+
+typedef enum {
+ RET_RD_CHK_OK = 0,
+ RET_RD_ERR_OTHER,
+ RET_RD_DEV_ERR,
+ RET_RD_ERR_1 = -1,
+ RET_RD_ERR_2 = -2,
+ RET_RD_ERR_3 = -3,
+ RET_RD_ERR_4 = -4,
+} NOR_READ_BLK_CHK;
+
+typedef enum {
+ RET_CHK_OK = 0,
+ RET_CHK_TEXT_ERR,
+ RET_CHK_BCC_ERR,
+} NOR_BLK_CHK;
+
+typedef enum {
+ NOR_IDLE = 0, // 0:Read-out of block data
+ NOR_ORG_TEXT, // 1:OrgText Error
+ NOR_ORG_BCC, // 2:OrgBcc error
+ NOR_READ_OK, // 3:Normal read-out
+ NOR_READ_END // 4:end state
+} NOR_R_STATE;
+
+typedef enum {
+ NOR_IDEL = 0, // 0:IDEL
+ NOR_READ_ERR, // 1:Read Error
+ NOR_ORG_READ, // 2:Org Read OK
+ NOR_BAK_WRT, // 3:Bak Write OK
+ NOR_BACK_READ, // 4:Bak Read OK
+ NOR_ORG_WRITE, // 5:Org Write OK
+ NOR_WRITE_END // 6:end state
+} NOR_W_STATE;
+
+NOR_READ_BLK_CHK MtdnBackupReadSub(
+ const char * path_name, int i_id, int i_offset, int i_size,
+ void *p_buff, mtd_info_t * mtd_info, int * get_state);
+NOR_WRITE_BLK_CHK MtdnBackupWriteSub(
+ const char * path_name, int i_id, int i_offset, int i_size,
+ void *p_buff, mtd_info_t * mtd_info);
+
+int MtdnBackupWriteBase(
+ const char * path_name, int i_id, int i_offset, int i_size,
+ void *p_buff, mtd_info_t * mtd_info);
+int MtdnBackupReadBase(
+ const char * path_name, int i_id, int i_offset, int i_size,
+ void *p_buff, mtd_info_t * mtd_info);
+
+int MtdBackupInfo(const char * path_name, mtd_info_t * mtd_info); // INFO Get
+
+NOR_BLK_CHK MtdBackupCheksumRead(char * p_buff, int erase_size, int * ret_sum); // check SUM
+int MtdBackupCheksumWrite(char * p_buff, int erase_size); // check SUM
+
+/***************************************************************************
+@brief mtdn_backup_Read
+@outline Read-out of specified block ID
+@type Completion return type
+@param[in] const char * path_name : (/dev/mtd Device)
+@param[in] int i_id : ID...0~
+@param[in] int i_offset : ( i_offset >= 0)
+@param[in] int i_size : ( i_size > 0)
+@param[in] void *p_buff : (p_buff != NULL)
+@return int
+@retval 0 : No error
+@retval Except : Error
+@usage It is Backup API of data read.
+*****************************************************************************/
+int mtdn_backup_Read(const char * path_name, int i_id, int i_offset, int i_size, void *p_buff ) {
+ int ret_status = RET_DEV_NORMAL;
+
+ if (path_name == NULL) {
+ NOR_ERRLOG("invalid path:%p", path_name);
+ return RET_DEV_ERR_PARAM;
+ }
+ if (p_buff == NULL) {
+ NOR_ERRLOG("invalid buf:%p", p_buff);
+ return RET_DEV_ERR_PARAM;
+ }
+ if (i_id < 0) {
+ NOR_ERRLOG("invalid id:%d", i_id);
+ return RET_DEV_ERR_PARAM;
+ }
+ if ((i_offset < 0) || (i_size <= 0)) {
+ NOR_ERRLOG("invalid size:%d offset:%d", i_size, i_offset);
+ return RET_DEV_ERR_PARAM;
+ }
+ if (g_backup_init == FLSBACKUP_SEMAPHORE_INVALID) { // LCOV_EXCL_BR_LINE 200: g_backup_init is static variable
+ pthread_mutex_init(&g_semid_flash, NULL);
+ g_backup_init = ~FLSBACKUP_SEMAPHORE_INVALID;
+ }
+ mtd_info_t mtd_info;
+ memset(&mtd_info, 0, sizeof(mtd_info_t));
+ ret_status = MtdBackupInfo((const char *)path_name, &mtd_info);
+ if (ret_status == RET_DEV_NORMAL) {
+ if (mtd_info.type != MTD_NORFLASH) {
+ NOR_ERRLOG("invalid type:%d", mtd_info.type);
+ ret_status = RET_DEV_ERR_PARAM;
+ } else {
+ if ((i_offset + i_size) > (int)(mtd_info.erasesize - BACKUP_CHECK_OFFSET)) {
+ NOR_ERRLOG("invalid size:%d offset:%d erasesize:%d", i_size, i_offset, mtd_info.erasesize);
+ ret_status = RET_DEV_ERR_PARAM;
+ }
+ }
+ if (ret_status == RET_DEV_NORMAL) {
+ /* Start Semaphore(flash) */
+ pthread_mutex_lock(&g_semid_flash);
+ int get_state; // Read status
+ ret_status = (int)MtdnBackupReadSub(path_name, i_id, i_offset, i_size,
+ p_buff, &mtd_info, &get_state);
+
+ /* End Semaphore(flash) */
+ pthread_mutex_unlock(&g_semid_flash);
+ }
+ }
+ if (ret_status != RET_DEV_NORMAL) {
+ NOR_ERRLOG("error return:%d", ret_status);
+ }
+ return ret_status;
+}
+
+/***************************************************************************
+@brief mtdn_backup_Write
+@outline Writing of specified block ID
+@type Completion return type
+@param[in] const char * path_name : (/dev/mtd Device)
+@param[in] int i_id : ID...0~
+@param[in] int i_offset : ( i_offset >= 0)
+@param[in] int i_size : ( i_size > 0)
+@param[in] void *p_buff : (p_buff != NULL)
+@return int
+@retval 0 : No error
+@retval Except: Error
+@usage It is Backup API of data read.
+*****************************************************************************/
+int mtdn_backup_Write(const char * path_name, int i_id, int i_offset, int i_size, void *p_buff) {
+ int ret_status = RET_DEV_NORMAL;
+
+ if (path_name == NULL) {
+ NOR_ERRLOG("invalid path:%p", path_name);
+ return RET_DEV_ERR_PARAM;
+ }
+ if (p_buff == NULL) {
+ NOR_ERRLOG("invalid buf:%p", p_buff);
+ return RET_DEV_ERR_PARAM;
+ }
+ if (i_id < 0) {
+ NOR_ERRLOG("invalid id:%d", i_id);
+ return RET_DEV_ERR_PARAM;
+ }
+ if ((i_offset < 0) || (i_size <= 0)) {
+ NOR_ERRLOG("invalid size:%d offset:%d", i_size, i_offset);
+ return RET_DEV_ERR_PARAM;
+ }
+ if (g_backup_init == FLSBACKUP_SEMAPHORE_INVALID) {
+ pthread_mutex_init(&g_semid_flash, NULL);
+ g_backup_init = ~FLSBACKUP_SEMAPHORE_INVALID;
+ }
+ mtd_info_t mtd_info;
+ memset(&mtd_info, 0, sizeof(mtd_info_t));
+ ret_status = MtdBackupInfo((const char *)path_name, &mtd_info);
+ if (ret_status == RET_DEV_NORMAL) {
+ if (mtd_info.type != MTD_NORFLASH) {
+ NOR_ERRLOG("invalid type:%d", mtd_info.type);
+ ret_status = RET_DEV_ERR_PARAM;
+ } else if (mtd_info.erasesize == 0) {
+ NOR_ERRLOG("invalid erasesize:%d", mtd_info.erasesize);
+ ret_status = RET_DEV_ERR_PARAM;
+ } else {
+ if ((i_offset + i_size) > (int)(mtd_info.erasesize - BACKUP_CHECK_OFFSET)) {
+ NOR_ERRLOG("invalid size:%d offset:%d erasesize:%d", i_size, i_offset, mtd_info.erasesize);
+ ret_status = RET_DEV_ERR_PARAM;
+ }
+ }
+ if (ret_status == RET_DEV_NORMAL) {
+ /* Start Semaphore(flash) */
+ pthread_mutex_lock(&g_semid_flash);
+ ret_status = (int)MtdnBackupWriteSub(path_name, i_id, i_offset, i_size, p_buff, &mtd_info);
+
+ /* End Semaphore(flash) */
+ pthread_mutex_unlock(&g_semid_flash);
+ }
+ }
+ if (ret_status != RET_DEV_NORMAL) {
+ NOR_ERRLOG("error return:%d", ret_status);
+ }
+ return ret_status;
+}
+
+/***************************************************************************
+@brief MtdnBackupReadSub
+@outline Read-out of specified block ID
+@type Completion return type
+@param[in] const char * path_name : (/dev/mtd Device)
+@param[in] int i_id : ID...0~
+@param[in] int i_offset : ( i_offset >= 0)
+@param[in] int i_size : ( i_size > 0)
+@param[in] void *p_buff : (p_buff != NULL)
+@param[in] mtd_info_t * mtd_info : info
+@param[in] int * get_state : 0:Rrg Normal 1:Bak Normal
+@return NOR_READ_BLK_CHK
+@retval RET_RD_CHK_OK : No error
+@retval Except : Error
+@usage It is Backup API of data read.
+*****************************************************************************/
+NOR_READ_BLK_CHK MtdnBackupReadSub(const char * path_name, int i_id, int i_offset, int i_size,
+ void *p_buff, mtd_info_t * mtd_info, int * get_state) {
+ NOR_READ_BLK_CHK ret_status = RET_RD_CHK_OK;
+ char * lp_buffer;
+
+ if (mtd_info->erasesize != 0) { // LCOV_EXCL_BR_LINE 6: double check
+ lp_buffer = (char *)malloc(mtd_info->erasesize);
+ if (lp_buffer == NULL) {
+ NOR_ERRLOG("malloc:%p", lp_buffer);
+ ret_status = RET_RD_DEV_ERR; // error
+ }
+ } else {
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ NOR_ERRLOG("invalid erasesize:%d", mtd_info->erasesize);
+ ret_status = RET_RD_DEV_ERR; // error
+ // LCOV_EXCL_STOP
+ }
+ if (ret_status == RET_RD_CHK_OK) {
+ memset(lp_buffer, 0x00, mtd_info->erasesize);
+ NOR_R_STATE cycle_state = NOR_IDLE;
+ int block_check_mode = 0;
+ int ret_sum = 0;
+ while ((cycle_state < NOR_READ_END)
+ &&(ret_status == RET_RD_CHK_OK)) {
+ switch (cycle_state) {
+ case NOR_IDLE:
+ // Read-out of block data
+ if (0 != MtdnBackupReadBase((const char *)path_name, i_id, 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info)) {
+ ret_status = RET_RD_ERR_OTHER; // Other abnormalities
+ } else {
+ NOR_BLK_CHK ret = MtdBackupCheksumRead(lp_buffer, (int)mtd_info->erasesize, (int *)&ret_sum);
+ if (ret == RET_CHK_TEXT_ERR) { // Text character sequence Abnormalities
+ cycle_state = NOR_ORG_TEXT;
+ } else if (ret == RET_CHK_BCC_ERR) { // (BCC)error
+ cycle_state = NOR_ORG_BCC;
+ } else {
+ block_check_mode = 0; // Org Normal
+ cycle_state = NOR_READ_OK;
+ }
+ }
+ break;
+ case NOR_ORG_TEXT: // OrgText Error
+ // Read-out of block data
+ if (0 != MtdnBackupReadBase((const char *)path_name, (i_id+1), 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info)) {
+ // other error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret_status = RET_RD_ERR_OTHER; // LCOV_EXCL_LINE 5: c API error case.
+ } else {
+ NOR_BLK_CHK ret = MtdBackupCheksumRead(lp_buffer, (int)mtd_info->erasesize,
+ (int *)&ret_sum); // check SUM
+ if (ret == RET_CHK_TEXT_ERR) { // Text character sequence Abnormalities
+ ret_status = RET_RD_ERR_1; // Uninitialized.
+ } else if (ret == RET_CHK_BCC_ERR) { // BCC error
+ ret_status = RET_RD_ERR_2; // write error
+ }
+ block_check_mode = 1; // Bak Normal
+ cycle_state = NOR_READ_OK;
+ }
+ break;
+ case NOR_ORG_BCC: // OrgBcc error
+ // Read-out of block data
+ if (0 != MtdnBackupReadBase((const char *)path_name, (i_id+1), 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info)) {
+ // other error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret_status = RET_RD_ERR_OTHER; // LCOV_EXCL_LINE 5: c API error case.
+ } else {
+ NOR_BLK_CHK ret = MtdBackupCheksumRead(lp_buffer, (int)mtd_info->erasesize,
+ (int *)&ret_sum); // check SUM
+ if (ret == RET_CHK_TEXT_ERR) { // Text character sequence Abnormalities
+ ret_status = RET_RD_ERR_3; // write error
+ } else if (ret == RET_CHK_BCC_ERR) { // BCC error
+ ret_status = RET_RD_ERR_4; // write error
+ }
+ block_check_mode = 1; // Bak Normal
+ cycle_state = NOR_READ_OK;
+ }
+ break;
+ case NOR_READ_OK: // Normal read-out
+ // The pickup of the read data
+ memcpy(p_buff, &lp_buffer[i_offset], (size_t)i_size);
+ cycle_state = NOR_READ_END;
+ break;
+ default:
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ NOR_ERRLOG("invalid state:%d", cycle_state);
+ // other error
+ ret_status = RET_RD_ERR_OTHER;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ }
+ *get_state = block_check_mode; // 0:OrgNormal 1:BakNormal
+ free(lp_buffer);
+ }
+ return ret_status; // Normal
+}
+
+static inline NOR_WRITE_BLK_CHK MtdnBackupWriteRetryCount(int *count, NOR_WRITE_BLK_CHK cur_state) {
+ NOR_WRITE_BLK_CHK ret_state = cur_state;
+ (*count)++;
+ if (*count > BACKUP_RETRY_CNT) {
+ NOR_ERRLOG("retry over!! state:%d count:%d", ret_state, *count);
+ ret_state = RET_WT_DEV_ERR;
+ }
+ return ret_state;
+}
+
+/***************************************************************************
+@brief MtdnBackupWriteSub
+@outline Writing of specified block ID
+@type Completion return type
+@param[in] const char * path_name : (/dev/mtd Device)
+@param[in] int i_id : ID...0~
+@param[in] int i_offset : ( i_offset >= 0)
+@param[in] int i_size : ( i_size > 0)
+@param[in] void *p_buff : (p_buff != NULL)
+@param[in] mtd_info_t * mtd_info : info
+@return NOR_WRITE_BLK_CHK
+@retval RET_WT_CHK_OK : No error
+@retval Except : Error
+@usage It is Backup API of data read.
+*****************************************************************************/
+NOR_WRITE_BLK_CHK MtdnBackupWriteSub(const char * path_name, int i_id, int i_offset,
+ int i_size, void *p_buff, mtd_info_t * mtd_info) {
+ NOR_WRITE_BLK_CHK ret_status = RET_WT_CHK_OK;
+ char* lp_buffer;
+
+ lp_buffer = (char *)malloc(mtd_info->erasesize);
+ if (lp_buffer == NULL) {
+ NOR_ERRLOG("malloc:%p", lp_buffer);
+ ret_status = RET_WT_DEV_ERR; // error
+ } else {
+ memset(lp_buffer, 0x00, mtd_info->erasesize);
+ NOR_W_STATE cycle_state = NOR_IDEL;
+ int retry_cnt = 0;
+ int get_state = 0; // Read status
+
+ while ((cycle_state < NOR_WRITE_END)
+ &&(ret_status == RET_WT_CHK_OK)) {
+ switch (cycle_state) {
+ case NOR_IDEL: // IDLE
+ if (RET_RD_CHK_OK != MtdnBackupReadSub((const char *)path_name, i_id, 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info, &get_state)) {
+ cycle_state = NOR_READ_ERR; // read error
+ } else {
+ // write data set
+ memcpy(&lp_buffer[i_offset], p_buff, (size_t)i_size);
+ if (get_state == 0) {
+ cycle_state = NOR_ORG_READ; // Org read Normal
+ } else {
+ // Bakread Normal
+ cycle_state = NOR_BACK_READ;
+ }
+ // Embedding of write-in data
+ memcpy(&lp_buffer[i_offset], p_buff, (size_t)i_size);
+ }
+ break;
+ case NOR_READ_ERR: // read error
+ memset((char *)lp_buffer, 0x00, mtd_info->erasesize);
+ // Embedding of write-in data
+ memcpy(&lp_buffer[i_offset], p_buff, (size_t)i_size);
+ cycle_state = NOR_ORG_READ; // Org read Normal
+ break;
+ case NOR_ORG_READ: // Orgread Normal
+ // LCOV_EXCL_BR_START 6: double check
+ if (0 != MtdBackupCheksumWrite(lp_buffer, (int)mtd_info->erasesize )) { // check SUM
+ // LCOV_EXCL_BR_STOP
+ // error(It does not generate.)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret_status = RET_WT_DEV_ERR; // LCOV_EXCL_LINE 8: dead code
+ } else {
+ // data write
+ if (0 == MtdnBackupWriteBase((const char *)path_name, (i_id+1), 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info)) {
+ cycle_state = NOR_BAK_WRT; // Bakwrite Success
+ retry_cnt = 0;
+ } else {
+ ret_status = MtdnBackupWriteRetryCount(&retry_cnt, ret_status);
+ }
+ }
+ break;
+ case NOR_BAK_WRT: // BakWriteSuccess
+ // Data write
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (0 == MtdnBackupWriteBase((const char *)path_name, i_id, 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info)) {
+ // LCOV_EXCL_BR_STOP
+ cycle_state = NOR_WRITE_END; // Normal end
+ } else {
+ // LCOV_EXCL_START 5: c API error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret_status = MtdnBackupWriteRetryCount(&retry_cnt, ret_status);
+ // LCOV_EXCL_STOP
+ }
+ break;
+ case NOR_BACK_READ: // Bak read normal
+ // LCOV_EXCL_BR_START 6: double check
+ if (0 != MtdBackupCheksumWrite(lp_buffer, (int)mtd_info->erasesize )) { // check SUM
+ // LCOV_EXCL_BR_STOP
+ // Retry over
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret_status = RET_WT_DEV_ERR; // LCOV_EXCL_LINE 8: dead code
+ } else {
+ // data write
+ if (0 == MtdnBackupWriteBase((const char *)path_name, i_id, 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info)) {
+ // Org write Succses
+ cycle_state = NOR_ORG_WRITE;
+ retry_cnt = 0;
+ } else {
+ // LCOV_EXCL_START 5: c API error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret_status = MtdnBackupWriteRetryCount(&retry_cnt, ret_status);
+ // LCOV_EXCL_STOP
+ }
+ }
+ break;
+ case NOR_ORG_WRITE: // Org write Succses
+ // data write
+ if (0 == MtdnBackupWriteBase((const char *)path_name, (i_id+1), 0,
+ (int)mtd_info->erasesize, lp_buffer, mtd_info)) {
+ // Normal end
+ cycle_state = NOR_WRITE_END;
+ } else {
+ // LCOV_EXCL_START 5: c API error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret_status = MtdnBackupWriteRetryCount(&retry_cnt, ret_status);
+ // LCOV_EXCL_STOP
+ }
+ break;
+ default:
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ NOR_ERRLOG("invalid state:%d", cycle_state);
+ // other error
+ ret_status = RET_WT_ERR_OTHER;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ }
+ free(lp_buffer);
+ }
+ return ret_status; // Normal
+}
+
+/***************************************************************************
+@brief MtdnBackupReadBase
+@outline Read-out of specified block ID
+@type Completion return type
+@param[in] const char * path_name : (/dev/mtd Device)
+@param[in] int i_id : ID...0~
+@param[in] int i_offset : ( i_offset >= 0)
+@param[in] int i_size : ( i_size > 0)
+@param[in] void *p_buff : (p_buff != NULL)
+@param[in] mtd_info_t * mtd_info :
+@return int
+@retval 0 : No error
+@retval Except : Error
+@usage It is Backup API of data read.
+*****************************************************************************/
+int MtdnBackupReadBase(const char * path_name, int i_id, int i_offset,
+ int i_size, void *p_buff, mtd_info_t * mtd_info) {
+ int ret_status = RET_DEV_NORMAL;
+
+ int mtd_fd = open(path_name, O_RDONLY|O_CLOEXEC);
+ // LCOV_EXCL_BR_START 5:It's impossible to mock open() function,so this line can not be passed.
+ if (mtd_fd == -1) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 5:It's impossible to mock open() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ NOR_ERRLOG("open(%s):%s", path_name, strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ // LCOV_EXCL_STOP
+ } else {
+ int seek_top = i_id * (int)mtd_info->erasesize + i_offset;
+ int sector_size = BACKUP_SECTOR_SIZ;
+ int block_size = (int)mtd_info->erasesize / sector_size; // Division number
+ int llpi;
+ int buff_top = 0;
+ int get_size = i_size;
+ char * work_buff = (char *)p_buff;
+ ssize_t read_size;
+
+ // It reads several sector minutes.
+ for (llpi=0; llpi < block_size; llpi++) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // It moves to a head.
+ if (-1 == (off_t)lseek(mtd_fd, seek_top, SEEK_SET)) {
+ NOR_ERRLOG("lseek():%s", strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ break;
+ }
+ if (get_size >= sector_size) { // LCOV_EXCL_BR_LINE 6:double check
+ read_size = read(mtd_fd, &work_buff[buff_top], (size_t)sector_size);
+ if (read_size < 0) {
+ NOR_ERRLOG("read():%zd %s", read_size, strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ break;
+ }
+
+ get_size -= sector_size;
+ if (get_size <= 0) {
+ break;
+ }
+ } else {
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ read_size = read(mtd_fd, &work_buff[buff_top], (size_t)get_size);
+ if (read_size < 0) {
+ NOR_ERRLOG("read():%zd %s", read_size, strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ break;
+ }
+ break;
+ // LCOV_EXCL_STOP
+ }
+ seek_top += (int)read_size;
+ buff_top += (int)read_size;
+ }
+ // LCOV_EXCL_BR_START 5:It's impossible to mock close() function,so this line can not be passed.
+ if (0 != close(mtd_fd)) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 5:It's impossible to mock close() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ NOR_ERRLOG("close():%s", strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+ return ret_status;
+}
+
+/***************************************************************************
+@brief MtdnBackupWriteBase
+@outline Writing of specified block ID
+@type Completion return type
+@param[in] const char * path_name : (/dev/mtd Device)
+@param[in] int i_id : ID...0~
+@param[in] int i_offset : ( i_offset >= 0)
+@param[in] int i_size : ( i_size > 0)
+@param[in] void *p_buff : (p_buff != NULL)
+@param[in] mtd_info_t * mtd_info :
+@return int
+@retval 0 : No error
+@retval Except : Error
+@usage It is Backup API of data read.
+*****************************************************************************/
+int MtdnBackupWriteBase(const char * path_name, int i_id, int i_offset,
+ int i_size, void *p_buff, mtd_info_t * mtd_info) {
+ int ret_status = RET_DEV_NORMAL;
+
+ int mtd_fd = open(path_name, O_RDWR|O_CLOEXEC);
+ if (mtd_fd == -1) {
+ NOR_ERRLOG("open(%s):%s", path_name, strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ } else {
+ erase_info_t s_mtd_erase;
+ s_mtd_erase.start = (__u32)i_id * mtd_info->erasesize;
+ s_mtd_erase.length = mtd_info->erasesize;
+ // erase
+ if (ioctl(mtd_fd, MEMERASE, &s_mtd_erase) < 0) {
+ NOR_ERRLOG("ioctl(MEMERASE):%s", strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ } else {
+ // write
+ int seek_top = i_id * (int)mtd_info->erasesize + i_offset;
+ int sector_size = BACKUP_SECTOR_SIZ; //
+ int block_size = (int)mtd_info->erasesize/sector_size;
+ int llpi;
+ int buff_top = 0;
+ int put_size = i_size;
+ char * work_buff = (char *)p_buff;
+ ssize_t write_size;
+
+ for (llpi=0; llpi < block_size; llpi++) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (-1 == (off_t)lseek(mtd_fd, seek_top, SEEK_SET)) {
+ NOR_ERRLOG("lseek():%s", strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ break;
+ }
+ if (put_size >= sector_size) { // LCOV_EXCL_BR_LINE 6:double check
+ write_size = write(mtd_fd, &work_buff[buff_top], (size_t)sector_size);
+ if (write_size < 0) {
+ NOR_ERRLOG("write():%zd %s", write_size, strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ break;
+ }
+ put_size -= sector_size;
+ if (put_size <= 0) {
+ break;
+ }
+ } else {
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ write_size = write(mtd_fd, &work_buff[buff_top], (size_t)put_size);
+ if (write_size < 0) {
+ NOR_ERRLOG("write():%zd %s", write_size, strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ break;
+ }
+ break;
+ // LCOV_EXCL_STOP
+ }
+ seek_top += (int)write_size;
+ buff_top += (int)write_size;
+ }
+ }
+ // LCOV_EXCL_BR_START 5:It's impossible to mock close() function,so this line can not be passed.
+ if (0 != close(mtd_fd)) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 5:It's impossible to mock close() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ NOR_ERRLOG("close():%s", strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+ return ret_status;
+}
+
+/***************************************************************************
+int backup_cheksum_read(char * p_buff, int erase_size ,int * ret_sum)
+ * A text character sequence and a sum value are checked.
+ IN: char * p_buff ...top address
+ int erase_size ...erase size
+ int * ret_sum ...return sum
+
+ OUT: NOR_BLK_CHK RET_CHK_OK:Normal
+ RET_CHK_TEXT_ERR:test error
+ RET_CHK_BCC_ERR:sum error Except:other error
+ Remarks:
+*****************************************************************************/
+NOR_BLK_CHK MtdBackupCheksumRead(char * p_buff, int erase_size, int * ret_sum) {
+ if (erase_size > BACKUP_CHECK_OFFSET) { // LCOV_EXCL_BR_LINE 6: double check
+ // The check of the compatibility of block data
+ if (0 != memcmp(&p_buff[(erase_size-BACKUP_CHECK_OFFSET)], BACKUP_CHECK_TEXT, BACKUP_CHECK_SIZE)) {
+ char tmp[BACKUP_CHECK_SIZE + 1];
+ memcpy(tmp, &p_buff[(erase_size-BACKUP_CHECK_OFFSET)], BACKUP_CHECK_SIZE);
+ tmp[BACKUP_CHECK_SIZE] = '\0';
+ NOR_ERRLOG("invalid check_text:%s", tmp);
+ return RET_CHK_TEXT_ERR;
+ }
+ // The check of the compatibility of block data
+ int llpi;
+ int get_sum;
+ int work_sum = 0;
+ get_sum = ((int)p_buff[(erase_size-BACKUP_CHECK_DAT2)] & 0xff) +
+ (((int)p_buff[(erase_size-BACKUP_CHECK_DAT1)]) << 8 & 0xff00);
+
+ for (llpi=0; llpi < (erase_size-BACKUP_CHECK_OFFSET); llpi++) {
+ work_sum += p_buff[llpi];
+ }
+ work_sum = (work_sum & 0xffff);
+ if (work_sum != get_sum) {
+ NOR_ERRLOG("invalid checksum: work:%d get:%d", work_sum, get_sum);
+ return RET_CHK_BCC_ERR; // checksum error
+ }
+ if (ret_sum != NULL) { // LCOV_EXCL_BR_LINE 6: double check
+ *ret_sum = work_sum; // chesum Storing
+ }
+ } else {
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ NOR_ERRLOG("invalid erase_size:%d", erase_size);
+ // checksum error
+ return RET_CHK_BCC_ERR;
+ // LCOV_EXCL_STOP
+ }
+ return RET_CHK_OK;
+}
+
+/***************************************************************************
+int backup_cheksum_write(char * p_buff, int erase_size )
+ * A text character sequence and a sum value are written in a buffer.
+ IN: char * p_buff ...top address
+ int erase_size ...erase size
+
+ OUT: int 0:normal Except:error
+ Remarks:
+*****************************************************************************/
+int MtdBackupCheksumWrite(char * p_buff, int erase_size ) {
+ int sum_add = 0;
+
+ if (erase_size > BACKUP_CHECK_OFFSET) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ int ret_status;
+ // The check of the compatibility of block data
+ ret_status = memcmp(&p_buff[(erase_size-BACKUP_CHECK_OFFSET)], BACKUP_CHECK_TEXT, BACKUP_CHECK_SIZE);
+ if (ret_status != 0) {
+ memcpy(&p_buff[(erase_size-BACKUP_CHECK_OFFSET)], BACKUP_CHECK_TEXT, BACKUP_CHECK_SIZE);
+ }
+ int llpi;
+ for (llpi=0; llpi < (erase_size-BACKUP_CHECK_OFFSET); llpi++) {
+ sum_add += p_buff[llpi];
+ }
+ }
+ p_buff[(erase_size-BACKUP_CHECK_DAT2)] = (char)(sum_add & 0xff);
+ p_buff[(erase_size-BACKUP_CHECK_DAT1)] = (char)((sum_add>>8) & 0xff);
+ return RET_DEV_NORMAL;
+}
+
+/***************************************************************************
+@brief MtdBackupInfo( mtd_info_t * mtd_info)
+@outline The information to obtain is obtained.
+@type Completion return type
+@param[in] mtd_info_t * mtd_info
+@return int
+@retval 0 : No error
+@retval Except : Error
+@usage It is Backup API of data read.
+*****************************************************************************/
+int MtdBackupInfo(const char * path_name, mtd_info_t * mtd_info) {
+ int ret_status = RET_DEV_NORMAL;
+
+ int mtd_fd = open(path_name, O_RDONLY|O_CLOEXEC);
+ if (mtd_fd == -1) {
+ NOR_ERRLOG("open(%s):%s", path_name, strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ } else {
+ // device control mtdchar_ioctl of mtdchar.c
+ if (ioctl(mtd_fd, MEMGETINFO, mtd_info) < 0) {
+ NOR_ERRLOG("ioctl(MEMGETINFO):%s", strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ }
+ if (0 != close(mtd_fd)) {
+ NOR_ERRLOG("close():%s", strerror(errno));
+ ret_status = RET_DEV_ERROR;
+ }
+ }
+ return ret_status;
+}
+
+/**************************************************************
+ End Of Files
+**************************************************************/
diff --git a/systemservice/rom_access_library/library/rom/Makefile b/systemservice/rom_access_library/library/rom/Makefile
new file mode 100755
index 0000000..81acd8a
--- /dev/null
+++ b/systemservice/rom_access_library/library/rom/Makefile
@@ -0,0 +1,62 @@
+#
+# @copyright Copyright (c) 2017-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.
+#
+
+######### search paths #############
+VPATH += src
+VPATH += ../include/$(COMPONENT_NAME)
+
+
+######### installed shared library(*.so) #############
+INST_SHLIBS = libSS_RomAccessIf
+
+######### headers to be installed(*.h) #############
+INST_HEADERS = rom_access_library.h ss_sm_boot_access.h ss_sm_ram_access.h ss_sm_rom_access.h
+
+######### compiled sources #############
+libSS_RomAccessIf_SRCS += ss_sm_rom_access.cpp ss_sm_boot_access.cpp ss_sm_ram_access.cpp ss_sm_checksum.cpp
+
+######### add include path #############
+CPPFLAGS += -I./../include
+
+######### frameworkunifiedlog options #############
+CPPFLAGS += -DLINUX
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+LDFLAGS += -Wl,--no-as-needed
+LDFLAGS += -Wl,--no-undefined
+
+######### add compile option #############
+LDFLAGS += -L./../nor/
+LINK_SHLIB_CXX := y
+LDFLAGS += -g -Wl,--gc-sections -shared
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lcommon
+LDLIBS += -Wl,-Bdynamic -lssaccess
+LDLIBS += -Wl,-Bdynamic -lextension
+
+CPPFLAGS_ss_sm_checksum.o += -fno-exceptions
+CPPFLAGS_ss_sm_checksum.os += -fno-exceptions
+CPPFLAGS_ss_sm_ram_access.o += -fno-exceptions
+CPPFLAGS_ss_sm_ram_access.os += -fno-exceptions
+
+include ../../../system_service.mk
diff --git a/systemservice/rom_access_library/library/rom/src/ss_sm_boot_access.cpp b/systemservice/rom_access_library/library/rom/src/ss_sm_boot_access.cpp
new file mode 100755
index 0000000..44e8a53
--- /dev/null
+++ b/systemservice/rom_access_library/library/rom/src/ss_sm_boot_access.cpp
@@ -0,0 +1,122 @@
+/*
+ * @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.
+ */
+
+#include "system_service/ss_sm_boot_access.h"
+#include <stdio.h>
+#include <native_service/cl_lock.h>
+#include <native_service/cl_lockid.h>
+#include "system_service/nor_backup.h"
+#include "ss_rom_access_if_romaccesslibrarylog.h"
+#include "ss_rom_access_define.h"
+
+#define BAI_MTD_DEV_RO "/dev/mtd1ro" // NOR device for RO
+#define BAI_MTD_DEV_RW "/dev/mtd1" // NOR device for RW
+
+#define BAI_SERCTOR_OFFSET 0
+#define BAI_DATA_OFFSET 0
+
+void* BOOT_AccessIf::g_m_plock = NULL;
+
+BOOT_AccessIf::BOOT_AccessIf(BAI_OPEN_t type)
+ : m_type(type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (!(m_type == BAI_OPEN_RO // LCOV_EXCL_BR_LINE 6: double check
+ || m_type == BAI_OPEN_RW)) { // LCOV_EXCL_BR_LINE 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ throw __LINE__; // LCOV_EXCL_LINE 6: double check
+ }
+
+ if (g_m_plock == NULL) {
+ g_m_plock = CL_LockMap(LOCK_BOOT_ACCESS_IF);
+
+ if (g_m_plock == MAP_FAILED) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_plock can not be changed
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ "CL_LockMap Error, please check whether you call CL_LockProcessInit");
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+
+ if (g_m_plock) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ ROM_ACCESS_ASERT(0 == CL_LockGet(g_m_plock)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+BOOT_AccessIf::~BOOT_AccessIf() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (g_m_plock) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ ROM_ACCESS_ASERT(0 == CL_LockRelease(g_m_plock)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus BOOT_AccessIf::getBootInfo(LBM_NOR_t* p_bootInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eRet = eFrameworkunifiedStatusOK;
+ try {
+ int ret;
+ if (p_bootInfo == NULL) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ throw __LINE__;
+ }
+ ret = mtdn_backup_Read((const char *) BAI_MTD_DEV_RO, BAI_SERCTOR_OFFSET,
+ BAI_DATA_OFFSET, sizeof(LBM_NOR_t), p_bootInfo); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ if (ret != 0) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ throw __LINE__;
+ }
+ } catch (...) {
+ eRet = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eRet;
+}
+
+EFrameworkunifiedStatus BOOT_AccessIf::setBootInfo(LBM_NOR_t* p_bootInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eRet = eFrameworkunifiedStatusOK;
+ try {
+ int ret;
+ if (p_bootInfo == NULL) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ throw __LINE__;
+ }
+ if (m_type != BAI_OPEN_RW) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ throw __LINE__;
+ }
+ ret = mtdn_backup_Write((const char *) BAI_MTD_DEV_RW, BAI_SERCTOR_OFFSET,
+ BAI_DATA_OFFSET, sizeof(LBM_NOR_t), p_bootInfo); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5:c API error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_LINE 5:c API error case
+ throw __LINE__; // LCOV_EXCL_LINE 5:c API error case
+ }
+ } catch (...) {
+ eRet = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eRet;
+}
+
diff --git a/systemservice/rom_access_library/library/rom/src/ss_sm_checksum.cpp b/systemservice/rom_access_library/library/rom/src/ss_sm_checksum.cpp
new file mode 100755
index 0000000..52cb114
--- /dev/null
+++ b/systemservice/rom_access_library/library/rom/src/ss_sm_checksum.cpp
@@ -0,0 +1,37 @@
+/*
+ * @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 for checksum calculation.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_sm_checksum.h"
+
+CSMChecksum::CSMChecksum() {}
+CSMChecksum::~CSMChecksum() {}
+UI_32 CSMChecksum::cal_checksum(const void* p_buf, size_t bufSize) {
+ size_t num;
+ UI_32 sum = 0;
+ const UI_32 *p_calcBuf = reinterpret_cast<const UI_32 *>(p_buf);
+ num = bufSize / sizeof(UI_32);
+
+ for (size_t i = 0; i < num; i++) {
+ sum += p_calcBuf[i];
+ }
+ return sum;
+}
+
diff --git a/systemservice/rom_access_library/library/rom/src/ss_sm_ram_access.cpp b/systemservice/rom_access_library/library/rom/src/ss_sm_ram_access.cpp
new file mode 100755
index 0000000..b5cf244
--- /dev/null
+++ b/systemservice/rom_access_library/library/rom/src/ss_sm_ram_access.cpp
@@ -0,0 +1,215 @@
+/*
+ * @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.
+ */
+
+#include "system_service/ss_sm_ram_access.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <native_service/cl_lock.h>
+#include <native_service/cl_lockid.h>
+#include <stub/el_mem.h>
+#include "system_service/ss_sm_boot_access.h"
+#include "ss_rom_access_if_romaccesslibrarylog.h"
+#include "ss_sm_checksum.h"
+#include "ss_rom_access_define.h"
+
+
+
+#define RAM_PATH "/nv/BS/ss/rom_access_library/rwdata/ramdata.dat"
+#define RAM_OLD_PATH RAM_PATH".old"
+static const uint8_t kSigNature[] = { 0xDE, 0xAD, 0xBE, 0xEF };
+static const uint8_t kMagic[] = { 0xDE, 0xAD, 0xBE, 0xEF };
+
+void* RAM_AccessIf::g_m_plock = NULL;
+void* RAM_AccessIf::g_m_bakup_map = MAP_FAILED;
+bool RAM_AccessIf::g_m_is_first_access = false;
+
+typedef struct {
+ char magic_in[4];
+ RAM_SM_INFO_t data0;
+ uint32_t checksum0;
+ RAM_SM_INFO_t data1;
+ uint32_t checksum1;
+ char magic_out[4];
+} RAM_SM_DRAM_INFO_t;
+
+void RAM_AccessIf::initRamBackupEnable(RAM_WAKEUP_STATE wupState) {
+ RAM_SM_DRAM_INFO_t* p_buf;
+ CSMChecksum l_checksum;
+
+ ROM_ACCESS_STATIC_ASERT(sizeof(RAM_SM_DRAM_INFO_t) <= SS_SYS_AREA_RAM_MAX_SIZE);
+ // Checking sizes because checksum calculations expect 4 bytes alignments
+ ROM_ACCESS_STATIC_ASERT((sizeof(RAM_SM_DRAM_INFO_t) % sizeof(UI_32)) == 0);
+
+ if (g_m_bakup_map == MAP_FAILED) {
+ g_m_bakup_map = EL_mem_exram_mmap( // LCOV_EXCL_BR_LINE 11:unexpected branch
+ EL_MEM_TYPE_REGION_SYS,
+ EL_mem_getOffset(EL_MEM_ID_SYS_BOOT) + SS_SYS_AREA_RAM_OFFSET, // LCOV_EXCL_BR_LINE 11:unexpected branch
+ SS_SYS_AREA_RAM_MAX_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
+ EL_MEM_CACHE_INVALID);
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_bakup_map can not be changed
+ if (g_m_bakup_map == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ERRNO(0); // LCOV_EXCL_LINE 6:impossible to confirm because g_m_bakup_map can not be changed
+ return; // LCOV_EXCL_LINE 6:impossible to confirm because g_m_bakup_map can not be changed
+ }
+ }
+ p_buf = static_cast<RAM_SM_DRAM_INFO_t*>(g_m_bakup_map);
+
+ // LCOV_EXCL_BR_START 6:impossible to confirm because wupState can not be changed
+ if ((RAM_WAKEUP_STATE_BACKUP_NG == wupState) ||
+ (RAM_WAKEUP_STATE_BATTERY_DOWN == wupState) ||
+ (memcmp(p_buf->magic_out, kMagic, sizeof(kMagic)) != 0) ||
+ (memcmp(p_buf->magic_in, p_buf->magic_out, sizeof(p_buf->magic_in)) != 0)) {
+ // LCOV_EXCL_BR_STOP
+ // BACKUP NG
+ g_m_is_first_access = false;
+ bzero(p_buf, sizeof(RAM_SM_DRAM_INFO_t));
+ }
+
+ if (!g_m_is_first_access) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if ((memcmp(p_buf->data0.signature_in, kSigNature, sizeof(kSigNature)) == 0)
+ && (memcmp(p_buf->data0.signature_out, kSigNature,
+ sizeof(kSigNature)) == 0)
+ && (l_checksum.cal_checksum(&(p_buf->data0), sizeof(p_buf->data0)) == p_buf->checksum0)) {
+ // LCOV_EXCL_BR_STOP
+ // Use data0 content
+ memcpy(&(p_buf->data1), &(p_buf->data0), sizeof(p_buf->data1));
+ p_buf->checksum1 = p_buf->checksum0;
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ } else if ((memcmp(p_buf->data1.signature_in, kSigNature, sizeof(kSigNature)) == 0)
+ && (memcmp(p_buf->data1.signature_out, kSigNature,
+ sizeof(kSigNature)) == 0)
+ && (l_checksum.cal_checksum(&(p_buf->data1), sizeof(p_buf->data1)) == p_buf->checksum1)) {
+ // LCOV_EXCL_BR_STOP
+ // Use data1 content
+ memcpy(&(p_buf->data0), &(p_buf->data1), sizeof(p_buf->data0));
+ p_buf->checksum0 = p_buf->checksum1;
+ } else {
+ // BACKUP NG or SIGNATURE CHECK or CHECK SUM NG
+ bzero(p_buf, sizeof(RAM_SM_DRAM_INFO_t));
+ memcpy(p_buf->magic_in, kMagic, sizeof(kMagic));
+ // data0
+ memcpy(p_buf->data0.signature_in, kSigNature, sizeof(kSigNature));
+ memcpy(p_buf->data0.signature_out, kSigNature, sizeof(kSigNature));
+ p_buf->checksum0 =
+ l_checksum.cal_checksum(&(p_buf->data0), sizeof(p_buf->data0)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // data1
+ memcpy(p_buf->data1.signature_in, kSigNature, sizeof(kSigNature));
+ memcpy(p_buf->data1.signature_out, kSigNature, sizeof(kSigNature));
+ p_buf->checksum1 =
+ l_checksum.cal_checksum(&(p_buf->data1), sizeof(p_buf->data1)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ memcpy(p_buf->magic_out, kMagic, sizeof(kMagic));
+ }
+ }
+ memcpy(&m_buf, &(p_buf->data0), sizeof(p_buf->data0));
+}
+
+void RAM_AccessIf::finalRamBackupEnable(void) {
+ RAM_SM_DRAM_INFO_t* p_buf;
+ CSMChecksum l_checksum;
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_bakup_map can not be changed
+ if (g_m_bakup_map == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_LINE 6:impossible to confirm because g_m_bakup_map can not be changed
+ return; // LCOV_EXCL_LINE 6:impossible to confirm because g_m_bakup_map can not be changed
+ }
+
+ p_buf = static_cast<RAM_SM_DRAM_INFO_t*>(g_m_bakup_map);
+
+ // kSigNature is cleared during writing
+ bzero(m_buf.signature_in, sizeof(kSigNature));
+
+ // data0
+ memcpy(&(p_buf->data0), &m_buf, sizeof(p_buf->data0));
+ memcpy(p_buf->data0.signature_in, kSigNature, sizeof(kSigNature));
+ p_buf->checksum0 = l_checksum.cal_checksum(&(p_buf->data0), // LCOV_EXCL_BR_LINE 11:unexpected branch
+ sizeof(p_buf->data0));
+
+ // data1
+ memcpy(&(p_buf->data1), &m_buf, sizeof(p_buf->data1));
+ memcpy(p_buf->data1.signature_in, kSigNature, sizeof(kSigNature));
+ p_buf->checksum1 = l_checksum.cal_checksum(&(p_buf->data1), // LCOV_EXCL_BR_LINE 11:unexpected branch
+ sizeof(p_buf->data1));
+
+ // Set kSigNature
+ memcpy(m_buf.signature_in, kSigNature,
+ sizeof(kSigNature));
+}
+
+RAM_AccessIf::RAM_AccessIf(
+ RAM_WAKEUP_STATE wupState /* = RAM_WAKEUP_STATE_DONT_CARE */)
+ : m_buf(),
+ m_dirty(false) {
+
+ if (g_m_plock == NULL) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ g_m_plock = CL_LockMap(LOCK_RAM_ACCESS_IF);
+ if (g_m_plock == MAP_FAILED) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_plock can not be changed
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ "CL_LockMap Error, please check whether you call CL_LockProcessInit");
+ // LCOV_EXCL_BR_STOP
+ g_m_plock = NULL;
+ }
+ }
+ if (g_m_plock) {
+ if (0 != CL_LockGet(g_m_plock)) {
+ ROM_ACCESS_ASERT(0);
+ }
+ }
+
+ if (RAM_WAKEUP_STATE_BATTERY_DOWN == wupState) { // LCOV_EXCL_BR_LINE 13:
+ // Models without DRAM backups are initialized when +B is down.
+ // Deletes files because models with DRAM backups are also backwards compatible
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ unlink(RAM_PATH); // LCOV_EXCL_LINE 13:
+ unlink(RAM_OLD_PATH); // LCOV_EXCL_LINE 13:
+ }
+
+ initRamBackupEnable(wupState);
+ g_m_is_first_access = true;
+}
+
+RAM_AccessIf::~RAM_AccessIf() {
+ if (m_dirty) {
+ finalRamBackupEnable();
+ }
+ if (g_m_plock) {
+ ROM_ACCESS_ASERT(0 == CL_LockRelease(g_m_plock));
+ }
+
+ return;
+}
+
+EFrameworkunifiedStatus RAM_AccessIf::getRamInfo(RAM_SM_INFO_t* p_bootInfo) {
+ *p_bootInfo = m_buf;
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus RAM_AccessIf::setRamInfo(RAM_SM_INFO_t* p_bootInfo) {
+ if (0 != memcmp(&m_buf, p_bootInfo, sizeof(m_buf))) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ m_buf = *p_bootInfo;
+ m_dirty = true;
+ }
+
+ return eFrameworkunifiedStatusOK;
+}
diff --git a/systemservice/rom_access_library/library/rom/src/ss_sm_rom_access.cpp b/systemservice/rom_access_library/library/rom/src/ss_sm_rom_access.cpp
new file mode 100755
index 0000000..53589c2
--- /dev/null
+++ b/systemservice/rom_access_library/library/rom/src/ss_sm_rom_access.cpp
@@ -0,0 +1,969 @@
+/*
+ * @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_SS_RomAccess
+/// \brief This file supports ROM Access.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "system_service/ss_sm_rom_access.h"
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+
+#include <stub/el_mem.h>
+#include <native_service/cl_lock.h>
+#include <native_service/cl_lockid.h>
+
+#include "ss_rom_access_if_romaccesslibrarylog.h"
+#include "ss_sm_checksum.h"
+#include "ss_rom_access_define.h"
+
+#define ROM_ACCESS_DIR "/nv/BS/ss/rom_access_library/rwdata"
+#define ROM_ACCESS_FILE "romdata.dat"
+const CHAR kDefaultRomDevice[] = ROM_ACCESS_DIR"/"ROM_ACCESS_FILE;
+const CHAR kRecoveryRomDevice[] = ROM_ACCESS_DIR"/"ROM_ACCESS_FILE".old";
+static const uint8_t kMagic[] = { 0xDE, 0xAD, 0xBE, 0xEF };
+
+typedef enum {
+ INDEX_BOOTFLAG = 0,
+ INDEX_ACTIVE_FLASHLOADER,
+ INDEX_PARTITIONS_RW_FLAG,
+ INDEX_LAST_USER_MODE,
+ INDEX_TRANSPORT_MODE,
+ INDEX_PRODUCTION_MODE,
+ INDEX_LIMP_HOME_CUT_OFF_REQUEST,
+ INDEX_DATARESET_MODE,
+ INDEX_RESET_COUNT,
+ INDEX_LAST_ILGRESET,
+ INDEX_PROGUPDATE_STATE,
+ INDEX_ERR_LOG_COUNT,
+ INDEX_NEXT_WAKEUP_TYPE,
+ INDEX_SIGNATURE = 15, // As far as possible, do not modify this index value!!!!!
+ INDEX_PROG_STATE = 20,
+ INDEX_PROG_STATE_END = 63,
+ INDEX_PRODUCT_PRIVATE, // 64
+ INDEX_PRODUCT_PRIVATE_END = (INDEX_PRODUCT_PRIVATE + ROM_PRODUCT_PRIVATE_MAX
+ - 1),
+ INDEX_MAX
+} eRomIndices;
+
+void* ROM_AccessIf::g_m_plock = NULL;
+void* ROM_AccessIf::g_m_bakup_map = MAP_FAILED;
+bool ROM_AccessIf::g_m_is_dram_valid = false;
+
+typedef struct {
+ char magic_in[4];
+ bool is_dirty;
+ UI_32 data[INDEX_MAX];
+ uint32_t checksum;
+ char magic_out[4];
+} ROM_SM_DRAM_INFO_t;
+
+ROM_AccessIf::ROM_AccessIf()
+ : m_pBoot(NULL),
+ m_norIsDirty(false) {
+ bzero(&m_nor, sizeof(m_nor));
+
+ if (g_m_plock == NULL) {
+ g_m_plock = CL_LockMap(LOCK_ROM_ACCESS_IF);
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_plock can not be changed
+ if (g_m_plock == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_plock can not be changed
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ "CL_LockMap Error, please check whether you call CL_LockProcessInit");
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_plock can not be changed
+ if (g_m_plock) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_plock can not be changed
+ if (0 != CL_LockGet(g_m_plock)) {
+ // LCOV_EXCL_BR_STOP
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 6:impossible to confirm because g_m_plock can not be changed
+ }
+ }
+}
+
+ROM_AccessIf::~ROM_AccessIf() {
+ if (m_pBoot) {
+ if (m_norIsDirty) {
+ ROM_ACCESS_ASERT(eFrameworkunifiedStatusOK == m_pBoot->setBootInfo(&m_nor)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ delete m_pBoot; // LCOV_EXCL_BR_LINE 11:unexpected branch
+ m_pBoot = NULL;
+ }
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_plock can not be changed
+ if (g_m_plock) {
+ ROM_ACCESS_ASERT(0 == CL_LockRelease(g_m_plock));
+ } // LCOV_EXCL_BR_STOP
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::LBA_Read(UI_32 offset, UI_32* buffer,
+ UI_32 word_count) {
+ ROM_SM_DRAM_INFO_t* p_buf;
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_bakup_map can not be changed
+ if (g_m_bakup_map == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " g_m_bakup_map uninitialize");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ p_buf = static_cast<ROM_SM_DRAM_INFO_t*>(g_m_bakup_map);
+ memcpy(buffer, &p_buf->data[offset], word_count * sizeof(UI_32));
+
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::LBA_Write(UI_32 offset, UI_32 value) {
+ UI_32 l_value = value;
+ return LBA_Write(offset, &l_value, sizeof(UI_32));
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::LBA_Write(UI_32 offset, UI_32* value, UI_32 size) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ const CHAR *l_file = kDefaultRomDevice;
+ SI_32 fd = -1;
+ ROM_SM_DRAM_INFO_t* p_buf;
+ if (g_m_bakup_map == MAP_FAILED) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " g_m_bakup_map uninitialize");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ p_buf = static_cast<ROM_SM_DRAM_INFO_t*>(g_m_bakup_map);
+
+ if (memcmp(&p_buf->data[offset], value, size) == 0) {
+ // Not Write when the value does not change
+ return eFrameworkunifiedStatusOK;
+ }
+
+ p_buf->is_dirty = true;
+ memcpy(&p_buf->data[offset], value, size);
+
+ CSMChecksum l_checksum;
+ p_buf->checksum = l_checksum.cal_checksum(&(p_buf->data), // LCOV_EXCL_BR_LINE 11:unexpected branch
+ sizeof(p_buf->data)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ if (0 != rename(kDefaultRomDevice, kRecoveryRomDevice)) {
+ ROM_ACCESS_ERRNO(0);
+ } else {
+ int sync_fd;
+ sync_fd = open(kRecoveryRomDevice, O_RDWR | O_DSYNC | O_CLOEXEC); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 5:It's impossible to mock open() function,so this line can not be passed.
+ if (sync_fd != -1) {
+ // LCOV_EXCL_BR_STOP
+ ROM_ACCESS_ERRNO(0 == fsync(sync_fd)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ ROM_ACCESS_ERRNO(0 == close(sync_fd)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ERRNO(0); // LCOV_EXCL_LINE 5:It's impossible to mock open() function,so this line can not be passed.
+ }
+ }
+ fd = open(l_file, O_CREAT | O_TRUNC | O_RDWR | O_DSYNC | O_CLOEXEC, 00664); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (fd == -1) {
+ ROM_ACCESS_ERRNO(0);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: open(%s) returned -1", l_file);
+ eStatus = eFrameworkunifiedStatusFail;
+ goto ERROR;
+ }
+
+ /** Write the value of 32-bits at offset location */
+ if (sizeof(p_buf->data) != write(fd, p_buf->data, sizeof(p_buf->data))) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_START 5:It's impossible to mock write() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ERRNO(0);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: write(%s) returned -1", l_file);
+ eStatus = eFrameworkunifiedStatusFail;
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ } else {
+ ROM_ACCESS_ERRNO(0 == close(fd)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ fd = -1;
+
+ if (0 != unlink(kRecoveryRomDevice)) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_START 5:It's impossible to mock unlink() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ERRNO(0);
+ // LCOV_EXCL_STOP
+ }
+
+ int sync_fd;
+ sync_fd = open(ROM_ACCESS_DIR, O_RDONLY); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 5:It's impossible to mock open() function,so this line can not be passed.
+ if (sync_fd != -1) {
+ // LCOV_EXCL_BR_STOP
+ ROM_ACCESS_ERRNO(0 == fsync(sync_fd)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ ROM_ACCESS_ERRNO(0 == close(sync_fd)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ERRNO(0); // LCOV_EXCL_LINE 5:It's impossible to mock open() function,so this line can not be passed.
+ }
+ }
+ p_buf->is_dirty = false;
+ ERROR: if (fd != -1) { // LCOV_EXCL_BR_LINE 5:It's impossible to mock open() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(fd); // LCOV_EXCL_LINE 5:It's impossible to mock write() function,so this line can not be passed.
+ }
+ // @todo memory value is not restored if non-volatile area writing fails after writing to memory
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetDataResetMode_sub(EDATARESET_MODE* pDataResetMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_DATARESET_MODE,
+ reinterpret_cast<UI_32 *>(pDataResetMode), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+// This function may be called in duplicate,
+// so it is necessary to operate normally even if it is called in duplicate.
+EFrameworkunifiedStatus ROM_AccessIf::SystemInitialize(DRAM_BACKUP_STATE bkupState) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ ROM_ACCESS_STATIC_ASERT(sizeof(ROM_SM_DRAM_INFO_t) <= SS_SYS_AREA_ROM_MAX_SIZE);
+
+ // Checksum calculations expect 4-bytes alignments
+ ROM_ACCESS_STATIC_ASERT((sizeof(ROM_SM_DRAM_INFO_t) % sizeof(UI_32)) == 0);
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_bakup_map can not be changed
+ if (g_m_bakup_map == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP
+ g_m_bakup_map = EL_mem_exram_mmap(
+ EL_MEM_TYPE_REGION_SYS,
+ EL_mem_getOffset(EL_MEM_ID_SYS_BOOT) + SS_SYS_AREA_ROM_OFFSET,
+ SS_SYS_AREA_ROM_MAX_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
+ EL_MEM_CACHE_INVALID);
+ if (g_m_bakup_map == MAP_FAILED) {
+ ROM_ACCESS_ERRNO(0);
+ return eFrameworkunifiedStatusFail;
+ }
+ }
+
+ if (bkupState
+ == DRAM_BACKUP_STATE_NG) {
+ // BACKUP NG
+ ROM_SM_DRAM_INFO_t* p_buf;
+ CSMChecksum l_checksum;
+
+ p_buf = static_cast<ROM_SM_DRAM_INFO_t*>(g_m_bakup_map);
+ bzero(&(p_buf->magic_in), sizeof(p_buf->magic_in));
+ bzero(&(p_buf->magic_out), sizeof(p_buf->magic_out));
+ g_m_is_dram_valid = false;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::Initialize() {
+ const CHAR *l_file = kDefaultRomDevice;
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CSMChecksum l_checksum;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (g_m_bakup_map == MAP_FAILED) {
+ g_m_bakup_map = EL_mem_exram_mmap( // LCOV_EXCL_BR_LINE 11:unexpected branch
+ EL_MEM_TYPE_REGION_SYS,
+ EL_mem_getOffset(EL_MEM_ID_SYS_BOOT) + SS_SYS_AREA_ROM_OFFSET, // LCOV_EXCL_BR_LINE 11:unexpected branch
+ SS_SYS_AREA_ROM_MAX_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
+ EL_MEM_CACHE_INVALID);
+ // LCOV_EXCL_BR_START 6:impossible to confirm because g_m_bakup_map can not be changed
+ if (g_m_bakup_map == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP
+ ROM_ACCESS_ERRNO(0);
+ return eFrameworkunifiedStatusFail;
+ }
+ }
+ if (!g_m_is_dram_valid) {
+ SI_32 fd = -1;
+ ROM_SM_DRAM_INFO_t* p_buf;
+ p_buf = static_cast<ROM_SM_DRAM_INFO_t*>(g_m_bakup_map);
+ if ((p_buf->is_dirty)
+ || (memcmp(kMagic, p_buf->magic_in, sizeof(kMagic)) != 0)
+ || (memcmp(kMagic, p_buf->magic_out, sizeof(kMagic)) != 0)
+ || ((l_checksum.cal_checksum(&(p_buf->data), sizeof(p_buf->data)) != p_buf->checksum))) {
+ // Need to synchronize the NVs with the data on the DRAM
+ struct stat stutInfo;
+ if (0 != stat(ROM_ACCESS_DIR, &stutInfo)) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 5:It's impossible to mock stat() function,so this line can not be passed.
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "%s not found", ROM_ACCESS_DIR);
+ // LCOV_EXCL_BR_STOP
+ ROM_ACCESS_ASERT(0 == mkdir(ROM_ACCESS_DIR, 0775)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ int expectSize = (INT32)(INDEX_MAX * sizeof(UI_32));
+ int sigSize = (INT32)((INDEX_SIGNATURE + 1) * sizeof(UI_32));
+
+ if (access(kRecoveryRomDevice, F_OK) == 0) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 5:It's impossible to mock access() function,so this line can not be passed.
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "%s is found", kRecoveryRomDevice);
+ // LCOV_EXCL_BR_STOP
+ if (0 != unlink(kDefaultRomDevice)) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 5:It's impossible to mock unlink() function,so this line can not be passed.
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Error:unlink(%s)", kDefaultRomDevice);
+ // LCOV_EXCL_BR_STOP
+ }
+ if (0 != rename(kRecoveryRomDevice, kDefaultRomDevice)) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ ROM_ACCESS_ERRNO(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ }
+ if (0 == stat(kDefaultRomDevice, &stutInfo) // LCOV_EXCL_BR_LINE 11:unexpected branch
+ && stutInfo.st_size >= sigSize) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // Use this value if there are more sizes than SIGNITURE
+ #define ROM_ACCESS_INFO_SIZE (sizeof(ROM_SM_DRAM_INFO_t) - (sizeof(UI_32)*INDEX_MAX))
+ #define ROM_ACCESS_MAX_SIZE (INT32)(SS_SYS_AREA_ROM_MAX_SIZE - ROM_ACCESS_INFO_SIZE)
+ // Maximum size of RAM area - An upper size limit of the management info size
+ if (stutInfo.st_size > ROM_ACCESS_MAX_SIZE) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ stutInfo.st_size = ROM_ACCESS_MAX_SIZE;
+ }
+ fd = open(l_file, // LCOV_EXCL_BR_LINE 11:unexpected branch
+ O_RDWR | O_DSYNC | O_CLOEXEC); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 5:It's impossible to mock open() function,so this line can not be passed.
+ if (fd != -1) {
+ int ret;
+ if (stutInfo.st_size < expectSize) {
+ // If the files are large, APPEND them
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "PADDING");
+ ret = ftruncate(fd, expectSize);
+ ROM_ACCESS_ERRNO(ret == 0);
+ fsync(fd);
+ } else if (stutInfo.st_size > expectSize) {
+ // If the files are small, TRANC them
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "CUT");
+ ret = ftruncate(fd, expectSize);
+ ROM_ACCESS_ERRNO(ret == 0);
+ fsync(fd);
+ }
+ }
+ // LCOV_EXCL_BR_STOP
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "%s size is not crrect",
+ kDefaultRomDevice);
+ // LCOV_EXCL_BR_STOP
+ fd = open(l_file, O_CREAT | O_TRUNC | O_RDWR | O_DSYNC | O_CLOEXEC,
+ 00664); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 5:It's impossible to mock open() function,so this line can not be passed.
+ if (fd != -1) {
+ UI_32 buf[INDEX_MAX];
+ bzero(buf, sizeof(buf));
+ ROM_ACCESS_ASERT(sizeof(buf) == write(fd, buf, sizeof(buf)))
+ fsync(fd);
+ }
+ // LCOV_EXCL_BR_STOP
+ }
+ // LCOV_EXCL_BR_START 5:It's impossible to mock open() function,so this line can not be passed.
+ if (fd != -1) {
+ // LCOV_EXCL_BR_STOP
+ UI_32 read_buf[INDEX_MAX];
+ if (-1 == lseek(fd, 0, SEEK_SET)) {
+ // LCOV_EXCL_START 5:It's impossible to mock lseek() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ERRNO(0);
+ // LCOV_EXCL_STOP
+ } else {
+ if (-1 == read(fd, read_buf, sizeof(read_buf))) {
+ // LCOV_EXCL_START 5:It's impossible to mock read() function,so this line can not be passed.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ERRNO(0);
+ // LCOV_EXCL_STOP
+ } else {
+ memcpy(p_buf->magic_in, kMagic, sizeof(kMagic));
+ memcpy(&p_buf->data, read_buf, sizeof(p_buf->data));
+ p_buf->checksum = l_checksum.cal_checksum(&(p_buf->data),
+ sizeof(p_buf->data));
+ memcpy(p_buf->magic_out, kMagic, sizeof(kMagic));
+ p_buf->is_dirty = false;
+
+ // Synchronization of NV data with data on the DRAM completed
+ g_m_is_dram_valid = true;
+ }
+ }
+ close(fd);
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error:open(%s)", l_file);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ // No need to synchronize NV data with data on the DRAM
+ g_m_is_dram_valid = true;
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " alreay initialized");
+ // LCOV_EXCL_BR_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetSignature(UI_32* pSigValue) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_SIGNATURE,
+ reinterpret_cast<UI_32 *>(pSigValue), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetSignature(UI_32 sigValue) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Write(INDEX_SIGNATURE,
+ sigValue))) {
+ // LCOV_EXCL_BR_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write(0x%X) errored: 0x%X",
+ sigValue, eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetBootMode(EBOOT_MODE* pBootMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_BOOTFLAG,
+ reinterpret_cast<UI_32 *>(pBootMode), 1))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: LBA_Read() errored: 0x%X", eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetBootMode(EBOOT_MODE bootMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Write(INDEX_BOOTFLAG, bootMode))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write(%d) errored: 0x%X",
+ bootMode, eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetLastUserMode(EUSER_MODE* pUserMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_LAST_USER_MODE,
+ reinterpret_cast<UI_32 *>(pUserMode), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetLastUserMode(EUSER_MODE userMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Write(INDEX_LAST_USER_MODE, userMode))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write(%s) errored: 0x%X",
+ userMode == USER_OFF ? "USER_OFF" : "USER_ON", eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetTransportMode(ECONTROL_MODE* pControlMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_TRANSPORT_MODE,
+ reinterpret_cast<UI_32 *>(pControlMode), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetTransportMode(ECONTROL_MODE controlMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_TRANSPORT_MODE, controlMode))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write(%s) errored: 0x%X",
+ controlMode == DISABLE_MODE ? "DISABLE_MODE" : "ENABLE_MODE",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+
+EFrameworkunifiedStatus ROM_AccessIf::GetProductionMode(ECONTROL_MODE* pControlMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_PRODUCTION_MODE,
+ reinterpret_cast<UI_32 *>(pControlMode), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetProductionMode(ECONTROL_MODE controlMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_PRODUCTION_MODE, controlMode))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write(%s) errored: 0x%X",
+ controlMode == DISABLE_MODE ? "DISABLE_MODE" : "ENABLE_MODE",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetLimpHomeCutOffReqMode(ECONTROL_MODE* pControlMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_LIMP_HOME_CUT_OFF_REQUEST,
+ reinterpret_cast<UI_32 *>(pControlMode), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetLimpHomeCutOffReqMode(ECONTROL_MODE controlMode) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_LIMP_HOME_CUT_OFF_REQUEST, controlMode))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write(%s) errored: 0x%X",
+ controlMode == DISABLE_MODE ? "DISABLE_MODE" : "ENABLE_MODE",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetDataResetMode(EDATARESET_MODE* pDataResetMode) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ try {
+ UI_32 sts;
+ if (m_pBoot == NULL) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because m_pBoot can not be changed
+ m_pBoot = new BOOT_AccessIf(BAI_OPEN_RW); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != m_pBoot->getBootInfo(&m_nor)) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ throw eFrameworkunifiedStatusFail;
+ }
+ }
+
+ if ((m_nor.sts1 == m_nor.sts2) || (m_nor.sts1 == m_nor.sts3)) {
+ sts = m_nor.sts1;
+ } else if (m_nor.sts2 == m_nor.sts3) {
+ sts = m_nor.sts2;
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ } else {
+ sts = SYSUP_CND_NORMAL;
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+
+ if (sts == SYSUP_CND_FACTRESET) {
+ *pDataResetMode = DATARESET_FACTORY;
+ } else {
+ eStatus = GetDataResetMode_sub(pDataResetMode); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ } catch (const EFrameworkunifiedStatus& e) {
+ eStatus = e;
+ } catch (...) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusFail;
+ } // LCOV_EXCL_STOP
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetDataResetModeFast(EDATARESET_MODE* pDataResetMode) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ void* p_map = MAP_FAILED;
+ size_t mapSize = 0;
+ try {
+ LBM_RAM_t* p_lbm = NULL;
+ mapSize = SS_SYS_AREA_BOOT_MAX_SIZE;
+
+ if (EL_mem_getLength(EL_MEM_ID_SYS_BOOT) < SS_SYS_AREA_BOOT_MAX_SIZE) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ mapSize = EL_mem_getLength(EL_MEM_ID_SYS_BOOT); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ p_map = reinterpret_cast<LBM_RAM_t*>(EL_mem_exram_mmap(EL_MEM_TYPE_REGION_SYS,
+ EL_mem_getOffset(EL_MEM_ID_SYS_BOOT),
+ mapSize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, EL_MEM_CACHE_INVALID));
+ // LCOV_EXCL_BR_STOP
+ if (p_map == MAP_FAILED) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because p_map can not be changed
+ ROM_ACCESS_ERRNO(0); // LCOV_EXCL_BR_LINE 6:impossible to confirm because p_map can not be changed
+ throw eFrameworkunifiedStatusFail;
+ }
+ p_lbm = static_cast<LBM_RAM_t*>(p_map);
+ if (p_lbm->sts == SYSUP_CND_FACTRESET) {
+ *pDataResetMode = DATARESET_FACTORY;
+ } else {
+ eStatus = GetDataResetMode_sub(pDataResetMode); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ } catch (const EFrameworkunifiedStatus& e) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ eStatus = e;
+ } catch (...) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ASERT(0);
+ eStatus = eFrameworkunifiedStatusFail;
+ } // LCOV_EXCL_STOP
+
+ if (p_map != MAP_FAILED) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because p_map can not be changed
+ ROM_ACCESS_ERRNO(0 == EL_mem_exram_munmap(p_map, // LCOV_EXCL_BR_LINE 11:unexpected branch
+ mapSize));
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:unexpected branch
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetDataResetMode(EDATARESET_MODE dataResetMode) {
+ EFrameworkunifiedStatus eStatus;
+ EDATARESET_MODE l_mode = dataResetMode;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ try {
+ if (m_pBoot == NULL) { // LCOV_EXCL_BR_LINE 6:impossible to confirm because m_pBoot can not be changed
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ m_pBoot = new BOOT_AccessIf(BAI_OPEN_RW);
+ // LCOV_EXCL_BR_STOP
+ if (eFrameworkunifiedStatusOK != m_pBoot->getBootInfo(&m_nor)) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ throw eFrameworkunifiedStatusFail;
+ }
+ }
+ m_norIsDirty = true;
+ if (dataResetMode == DATARESET_FACTORY) {
+ m_nor.sts1 = m_nor.sts2 = m_nor.sts3 = SYSUP_CND_FACTRESET;
+ l_mode = DATARESET_NONE;
+ } else {
+ m_nor.sts1 = m_nor.sts2 = m_nor.sts3 = SYSUP_CND_NORMAL;
+ }
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Write(INDEX_DATARESET_MODE, l_mode))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write() errored: 0x%X",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ } catch (const EFrameworkunifiedStatus& e) {
+ ROM_ACCESS_ASERT(0); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ eStatus = e;
+ } catch (...) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ROM_ACCESS_ASERT(0);
+ eStatus = eFrameworkunifiedStatusFail;
+ } // LCOV_EXCL_STOP
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetResetCount(UI_32* pResetCount) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_RESET_COUNT, reinterpret_cast<UI_32 *>(pResetCount),
+ 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+EFrameworkunifiedStatus ROM_AccessIf::SetResetCount(UI_32 resetCount) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (eFrameworkunifiedStatusOK != (eStatus = // LCOV_EXCL_BR_LINE 11:unexpected branch
+ LBA_Write(INDEX_RESET_COUNT, resetCount))) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write() errored: 0x%X", // LCOV_EXCL_LINE 11:unexpected branch
+ eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+EFrameworkunifiedStatus ROM_AccessIf::GetLastIlgReset(ELASTILGRESET_MODE* pLastIlgReset) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_LAST_ILGRESET,
+ reinterpret_cast<UI_32 *>(pLastIlgReset), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetLastIlgReset(ELASTILGRESET_MODE lastIlgReset) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_LAST_ILGRESET, lastIlgReset))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write() errored: 0x%X", // LCOV_EXCL_LINE 11:unexpected branch
+ eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetProgUpdateState(
+ EPROGUPDATE_STATE* pProgUpdateState) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_PROGUPDATE_STATE,
+ reinterpret_cast<UI_32 *>(pProgUpdateState), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetProgUpdateState(EPROGUPDATE_STATE progUpdateState) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_PROGUPDATE_STATE, progUpdateState))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write() errored: 0x%X", // LCOV_EXCL_LINE 11:unexpected branch
+ eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetErrLogCount(UI_32* pErrLogCount) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_ERR_LOG_COUNT,
+ reinterpret_cast<UI_32 *>(pErrLogCount), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetErrLogCount(UI_32 errLogCount) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (eFrameworkunifiedStatusOK != (eStatus = // LCOV_EXCL_BR_LINE 11:unexpected branch
+ LBA_Write(INDEX_ERR_LOG_COUNT, errLogCount))) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write() errored: 0x%X", // LCOV_EXCL_LINE 11:unexpected branch
+ eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetNextWakeupType(ENEXT_WAKEUP_TYPE *pNextWakeupType) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK != (eStatus = LBA_Read((UI_32) INDEX_NEXT_WAKEUP_TYPE,
+ reinterpret_cast<UI_32 *>(pNextWakeupType), 1))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Read() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetNextWakeupType(ENEXT_WAKEUP_TYPE nextWakeupType) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_NEXT_WAKEUP_TYPE, nextWakeupType))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_LINE 11:unexpected branch
+ " Error: LBA_Write() errored: 0x%X", eStatus); // LCOV_EXCL_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetActiveFlashloader(
+ EACTIVE_FLASHLOADER activeFlashloader) {
+ EFrameworkunifiedStatus eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_ACTIVE_FLASHLOADER, activeFlashloader))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error: LBA_Write(%s) errored: 0x%X",
+ activeFlashloader == NEW_FLASHLOADER ?
+ "NEW_FLASHLOADER" : "OLD_FLASHLOADER",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::SetProductPrivate(UI_8 buf[ROM_PRODUCT_PRIVATE_MAX]) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Write(INDEX_PRODUCT_PRIVATE, reinterpret_cast<UI_32*>(buf),
+ ROM_PRODUCT_PRIVATE_MAX / sizeof(UI_32)))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Write() errored: 0x%X",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus ROM_AccessIf::GetProductPrivate(UI_8 buf[ROM_PRODUCT_PRIVATE_MAX]) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = LBA_Read(INDEX_PRODUCT_PRIVATE, reinterpret_cast<UI_32 *>(buf),
+ ROM_PRODUCT_PRIVATE_MAX / sizeof(UI_32)))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 11:unexpected branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: LBA_Read() errored: 0x%X", eStatus);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return eStatus;
+}
diff --git a/systemservice/system_manager/LICENSE b/systemservice/system_manager/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/system_manager/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/system_manager/Makefile.server b/systemservice/system_manager/Makefile.server
new file mode 100755
index 0000000..83bc39b
--- /dev/null
+++ b/systemservice/system_manager/Makefile.server
@@ -0,0 +1,19 @@
+#
+# @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.
+#
+
+SUBDIRS += server
+
+include ../system_service.mk
diff --git a/systemservice/system_manager/server/Makefile b/systemservice/system_manager/server/Makefile
new file mode 100755
index 0000000..04185f9
--- /dev/null
+++ b/systemservice/system_manager/server/Makefile
@@ -0,0 +1,118 @@
+#
+# @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.
+#
+
+######### installed program #############
+INST_PROGS = SS_SystemManager
+
+######### installed library(*.a) #############
+
+
+######### installed shared library(*.so) #############
+
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+SS_SystemManager_SRCS += ./src/processlauncher/ProcessLauncher.cpp
+SS_SystemManager_SRCS += ./src/processlauncher/ProcessLauncher_if.cpp
+SS_SystemManager_SRCS += ./src/heartbeat/ss_hb_if.cpp
+SS_SystemManager_SRCS += ./src/heartbeat/ss_hb_service_protocol.cpp
+SS_SystemManager_SRCS += ./src/heartbeat/ss_hb_session.cpp
+SS_SystemManager_SRCS += ./src/heartbeat/ss_hb_thread.cpp
+SS_SystemManager_SRCS += ./src/systemmanager_application.cpp
+SS_SystemManager_SRCS += ./src/systemmanager_main.cpp
+SS_SystemManager_SRCS += ./src/ss_sm_config.cpp
+SS_SystemManager_SRCS += ./src/ss_sm_dynamic_launcher.cpp
+SS_SystemManager_SRCS += ./src/ss_sm_version.cpp
+SS_SystemManager_SRCS += ./src/ss_system_manager.cpp
+SS_SystemManager_SRCS += ./src/ss_system_manager_callbacks.cpp
+SS_SystemManager_SRCS += ./src/ss_system_manager_error_event.cpp
+SS_SystemManager_SRCS += ./src/ss_system_manager_error_event_responses.cpp
+SS_SystemManager_SRCS += ./src/ss_system_manager_error_event_triggers.cpp
+SS_SystemManager_SRCS += ./src/ss_system_memory_monitor.cpp
+
+######### add source path #############
+
+
+######### add include path #############
+CPPFLAGS += -I./
+CPPFLAGS += -I./include
+CPPFLAGS += -I./include/heartbeat
+CPPFLAGS += -I./include/processlauncher
+CPPFLAGS += -I./../../interface_unified/library/include
+
+######### add compile option #############
+CPPFLAGS += -DLINUX
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+
+CPPFLAGS_ProcessLauncher.o = -fno-exceptions
+CPPFLAGS_ProcessLauncher_if.o = -fno-exceptions
+CPPFLAGS_ss_hb_if.o = -fno-exceptions
+CPPFLAGS_ss_hb_thread.o = -fno-exceptions
+CPPFLAGS_systemmanager_application.o = -fno-exceptions
+CPPFLAGS_systemmanager_main.o = -fno-exceptions
+CPPFLAGS_ss_system_memory_monitor.o = -fno-exceptions
+CPPFLAGS_ss_hb_service_protocol.o = -fno-exceptions
+CPPFLAGS_ss_hb_session.o = -fno-exceptions
+CPPFLAGS_ss_sm_dynamic_launcher.o = -fno-exceptions
+CPPFLAGS_ss_sm_version.o = -fno-exceptions
+CPPFLAGS_ss_system_manager.o = -fno-exceptions
+CPPFLAGS_ss_system_manager_error_event.o = -fno-exceptions
+
+######### linked library #############
+#LDLIBS += -Wl,-Bstatic -lxxx
+LDLIBS += -Wl,-Bstatic -lSS_LoggerStoreLogs
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lrt # for mq_xxx
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lssver
+
+LDLIBS += -Wl,-Bdynamic -lresm
+LDLIBS += -Wl,-Bdynamic -lsssmcfg
+LDLIBS += -Wl,-Bdynamic -lDiagCodeAPI
+LDLIBS += -Wl,-Bdynamic -lClock_API
+LDLIBS += -Wl,-Bdynamic -lpower_hal
+
+LDLIBS += -Wl,-Bdynamic -lcommon
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+LDLIBS += -Wl,-Bdynamic -lvp
+LDLIBS += -Wl,-Bdynamic -ltar -lz
+LDLIBS += -Wl,-Bdynamic -lrpc -lev
+
+######### add library path #############
+LDFLAGS += -g -Wl,--gc-sections
+LDFLAGS += -Wl,--warn-unresolved-symbols
+LDFLAGS += -Wl,--no-as-needed
+
+LINK_CXX=Y
+
+install-data: install_data
+
+install_data:
+ cpp -P -include $(SDKTARGETSYSROOT)/usr/agl/include/agl_thread.h ./sm_launch__CWORD84_.xml ./sm_launch.tmp.xml
+ $(SDKTARGETSYSROOT)/usr/agl/share/launch_xml2cfg.sh ./sm_launch.tmp.xml > ./sm_launch.cfg
+ install -d -m 755 $(DESTDIR)/usr/agl/conf/BS/ss/system_manager/rwdata
+ install -m 644 ./sm_launch.cfg $(DESTDIR)/usr/agl/conf/BS/ss/system_manager/rwdata
+ install -d -m 755 $(DESTDIR)/nv/BS/ss/system_manager/rwdata
+ install -d -m 755 $(DESTDIR)/usr/agl/share/BS/ss/system_manager/rodata
+ install -m 644 ./version.txt $(DESTDIR)/usr/agl/share/BS/ss/system_manager/rodata
+ install -m 644 ./PhaseInfo.txt $(DESTDIR)/usr/agl/share/BS/ss/system_manager/rodata
+
+include ../../system_service.mk
diff --git a/systemservice/system_manager/server/PhaseInfo.txt b/systemservice/system_manager/server/PhaseInfo.txt
new file mode 100755
index 0000000..7ed792b
--- /dev/null
+++ b/systemservice/system_manager/server/PhaseInfo.txt
@@ -0,0 +1,2 @@
+Unknown
+20191026
diff --git a/systemservice/system_manager/server/include/crashdetector/ss_crashdetector.h b/systemservice/system_manager/server/include/crashdetector/ss_crashdetector.h
new file mode 100755
index 0000000..ae05af4
--- /dev/null
+++ b/systemservice/system_manager/server/include/crashdetector/ss_crashdetector.h
@@ -0,0 +1,46 @@
+/*
+ * @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 child process exit detection.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_CRASH_DETECTOR_H_ // NOLINT
+#define SS_CRASH_DETECTOR_H_
+
+#include <string>
+
+class CCrashDetector {
+ public:
+ CCrashDetector();
+ virtual ~CCrashDetector();
+ EFrameworkunifiedStatus CrashDetectorInitialize(HANDLE hApp);
+ PCSTR CrashDetectorGetThreadName();
+
+ HANDLE m_hSmQueue;
+
+ private:
+ SI_32 CrashDetectorGetThreadPriority();
+
+ HANDLE m_hApp;
+ pthread_t m_ThreadId;
+ std::string m_ThreadName;
+ SI_32 m_siPriority;
+};
+
+#endif // SS_CRASH_DETECTOR_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/heartbeat/ss_hb_if.h b/systemservice/system_manager/server/include/heartbeat/ss_hb_if.h
new file mode 100755
index 0000000..8d6618f
--- /dev/null
+++ b/systemservice/system_manager/server/include/heartbeat/ss_hb_if.h
@@ -0,0 +1,67 @@
+/*
+ * @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 the application heartbeat system.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef HEARTBEAT_INTERFACE_H_ // NOLINT
+#define HEARTBEAT_INTERFACE_H_
+
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_if_local.h>
+
+/**
+ * Enumeration: message category
+ */
+typedef enum HB_STATUS {
+ HB_STATUS_INVALID
+ , HB_STATUS_REGISTERED
+ , HB_STATUS_GOOD
+ , HB_STATUS_FAILED
+ , HB_STATUS_TIMEOUT
+} EHBStatus;
+
+/*
+ * Structure: report message data
+ */
+typedef struct MODULE_INFO {
+#define SS_SM_HB_MAX_PROC_NAME_SIZE 16
+ EHBStatus ProcHBState;
+ UI_32 HeartBeatRetryCount;
+ // "ProcQueueName" is limited 16 bytes (included terminal-character NULL), so that the size of "THbReportData" will be lower than 4K Bytes.
+ CHAR ProcQueueName[SS_SM_HB_MAX_PROC_NAME_SIZE];
+} TSmModuleInfo;
+
+typedef struct HB_REPORT_DATA {
+ EHBStatus eEntireState; ///< entire state for a request.
+ ///< if all modules are success, it's success, otherwise failed.
+ UI_32 nNumOfModules; ///< number of modules
+ TSmModuleInfo tModuleList[SS_MAX_NUM_MODULES]; ///< module information list, which include module IDs and states
+} THbReportData;
+
+typedef struct HB_AVAIL_CHECK {
+ BOOL isOk;
+ CHAR serviceName[SS_SM_HB_MAX_PROC_NAME_SIZE];
+} THbAvailCheck;
+
+
+EFrameworkunifiedStatus HBThreadStart(HANDLE hThread);
+EFrameworkunifiedStatus HBThreadStop(HANDLE hThread);
+
+#endif // HEARTBEAT_INTERFACE_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/heartbeat/ss_hb_session.h b/systemservice/system_manager/server/include/heartbeat/ss_hb_session.h
new file mode 100755
index 0000000..5414f09
--- /dev/null
+++ b/systemservice/system_manager/server/include/heartbeat/ss_hb_session.h
@@ -0,0 +1,91 @@
+/*
+ * @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 the application heartbeat system.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_HEARTBEAT_SESSION_H_ // NOLINT
+#define SS_HEARTBEAT_SESSION_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_if_local.h>
+#include <map>
+#include <string>
+
+#include "ss_hb_if.h"
+
+// The name of the module that is trying to open a session with Heart Beat
+typedef std::string SubscriberName;
+
+/*
+ *
+ */
+class CHeartBeatSessionHandler {
+ public:
+ CHeartBeatSessionHandler();
+ virtual ~CHeartBeatSessionHandler();
+
+ EFrameworkunifiedStatus HBProcessClientResponse(HANDLE hApp);
+
+ EFrameworkunifiedStatus HBEntrySubscriber(SubscriberName &f_Subscriber); // NOLINT
+ EFrameworkunifiedStatus HBSendRequest(HANDLE hApp, SI_32 f_HeartBeatIntervalRepeat, SI_32 f_ChkIndex);
+ EFrameworkunifiedStatus HBCheckResponses(THbReportData &f_tReportData, UI_32 f_MaxHeartBeatRetryCount, // NOLINT
+ SI_32 f_HeartBeatIntervalRepeat, SI_32 f_ChkIndex);
+
+ EFrameworkunifiedStatus HBDeleteRegisteredClientEntry(HANDLE f_hThread, PSTR pQueueName);
+ EFrameworkunifiedStatus HBAvailableCheck(THbAvailCheck &check); // NOLINT
+
+ VOID HBPrintConnection();
+ VOID HBPrintStack(UI_32 f_MaxHeartBeatRetryCount);
+
+ private:
+ class HbSessionInfo {
+ public:
+ std::string szName;
+ HANDLE hSession;
+ BOOL fRunning;
+ BOOL fHeartBeatRequestSent;
+ BOOL fHeartBeatResponseReceived;
+ UI_8 HeartBeatRetryCount;
+ BOOL fHeartBeatTimedOut;
+ BOOL fisAvailability;
+
+ // Copy constructor
+ HbSessionInfo(const HbSessionInfo &f_SessionInfo) {
+ szName = f_SessionInfo.szName;
+ hSession = f_SessionInfo.hSession;
+ fRunning = f_SessionInfo.fRunning;
+ fHeartBeatRequestSent = f_SessionInfo.fHeartBeatRequestSent;
+ fHeartBeatResponseReceived = f_SessionInfo.fHeartBeatResponseReceived;
+ HeartBeatRetryCount = f_SessionInfo.HeartBeatRetryCount;
+ fHeartBeatTimedOut = f_SessionInfo.fHeartBeatTimedOut;
+ fisAvailability = f_SessionInfo.fisAvailability;
+ }
+
+ explicit HbSessionInfo(SubscriberName f_Subscriber);
+ };
+
+ typedef std::map<SubscriberName, HbSessionInfo> HbSessionMap;
+ typedef HbSessionMap::iterator HbSessionIter;
+
+ HbSessionMap m_mapHbSessions;
+};
+#endif // SS_HEARTBEAT_SESSION_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/heartbeat/ss_hb_thread.h b/systemservice/system_manager/server/include/heartbeat/ss_hb_thread.h
new file mode 100755
index 0000000..7ca8e17
--- /dev/null
+++ b/systemservice/system_manager/server/include/heartbeat/ss_hb_thread.h
@@ -0,0 +1,206 @@
+/*
+ * @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 the application heartbeat system.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef HEARTBEAT_WORKER_H_ // NOLINT
+#define HEARTBEAT_WORKER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_system_timer.h>
+
+#include "ss_hb_session.h"
+#include "ss_sm_config.h"
+
+
+class CHeartBeatThread {
+ public:
+ explicit CHeartBeatThread(HANDLE f_hThread);
+ virtual ~CHeartBeatThread();
+
+ ///////////////////////////
+ /// HBPublishAvailabilityStatus
+ /// At HeartBeat sends NTFY_Availability with availability
+ /// notification to alert client that HeartBeat is available/not available.
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBPublishAvailabilityStatus(HANDLE hThread, BOOL f_AvailabiltyStatus);
+
+ ///////////////////////////
+ /// HBOnStartThread
+ /// Creates and starts the HeartBeat timer
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnStartThread(HANDLE hThread);
+
+
+ ///////////////////////////
+ /// HBOnStopThread
+ /// Stops and deletes the HeartBeat timer
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnStopThread(HANDLE hThread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// HBOnPrintConnections
+ /// Prints all active sessions connected to HeartBeat
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnPrintConnections(HANDLE hThread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// HBOnPrintStack
+ /// Prints all sessions connected to HeartBeat
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnPrintStack(HANDLE hThread);
+
+ ///////////////////////////
+ /// HBOnTimerExpiry
+ /// When APP timer expires, this method sends the HeartBeat request to the client.
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnTimerExpiry(HANDLE hThread);
+
+ ///////////////////////////
+ /// HBOnClientResponse
+ /// When the response from a client is received, this method updates the map
+ /// containing client status to indicate the response.
+ ///
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnClientResponse(HANDLE hThread);
+
+ ///////////////////////////
+ /// HBOnPeriodicStatusRequest
+ /// Reply to Status request from System Manager
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnPeriodicStatusRequest(HANDLE hThread);
+
+
+ ///////////////////////////
+ /// HBOnAvailCheckRequest
+ /// Reply to service's availability condition request from System Manager
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnAvailCheckRequest(HANDLE hThread);
+
+ ///////////////////////////
+ /// HBOnRemoveModule
+ /// Upon receiving delete module notification from sysmgr, this method removes
+ /// a client from the client session map.
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnRemoveModule(HANDLE hApp);
+
+ ///////////////////////////
+ /// HBOnAppendModule
+ /// Upon receiving append module notification from sysmgr, this method append
+ /// a client from the client session map.
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Handle of HeartBeat
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus HBOnAppendModule(HANDLE hApp);
+
+ // Service notification handlers
+ EFrameworkunifiedStatus HBSendRequest(HANDLE hApp);
+ EFrameworkunifiedStatus HBCheckHeartBeatResponses(HANDLE hThread);
+ EFrameworkunifiedStatus HBDeleteRegisteredClientEntry(PSTR pModuleName);
+
+ EFrameworkunifiedStatus HeartBeatTimerInit(HANDLE hThread);
+ EFrameworkunifiedStatus HeartBeatTimersDelete(void);
+
+ private:
+ CHeartBeatSessionHandler m_oSessionHandler;
+ TimerCtrl m_oTimerCtrl;
+ UI_32 m_HBTimerID;
+ HBConfigParameters m_HBConfigParams;
+ SI_32 m_NextChkIndex;
+ HANDLE m_hThread;
+};
+#endif // HEARTBEAT_WORKER_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/processlauncher/ProcessLauncher.h b/systemservice/system_manager/server/include/processlauncher/ProcessLauncher.h
new file mode 100755
index 0000000..409524f
--- /dev/null
+++ b/systemservice/system_manager/server/include/processlauncher/ProcessLauncher.h
@@ -0,0 +1,58 @@
+/*
+ * @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 process launching and termination.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef CPROCESSLAUNCHER_H_ // NOLINT
+#define CPROCESSLAUNCHER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_system_process.h>
+#include <string>
+#include "ss_system_manager.h"
+#include "ss_sm_process_launcher.h"
+
+/*
+ *
+ */
+class CProcessLauncher {
+ public:
+ CProcessLauncher();
+ explicit CProcessLauncher(void *);
+ virtual ~CProcessLauncher();
+
+ EFrameworkunifiedStatus PLOnCmdTerminateModule(HANDLE hThread);
+ EFrameworkunifiedStatus PLOnCmdModuleStatus(HANDLE hThread);
+ EFrameworkunifiedStatus PLOnCmdLaunchModule(HANDLE hThread);
+ EFrameworkunifiedStatus PLOnCmdRelaunchModule(HANDLE hThread);
+ EFrameworkunifiedStatus PLOnCmdHeartbeatStatusReq(HANDLE hThread);
+ EFrameworkunifiedStatus PLOnCmdStop(HANDLE hThread);
+ EFrameworkunifiedStatus PLOnCmdStart(HANDLE hThread);
+ protected:
+ ProcessMap m_mapOfProcesses;
+
+ private:
+ EFrameworkunifiedStatus PLCmdLaunchModule(HANDLE hThread,
+ UI_32 f_protocol_ID,
+ std::string f_protocol_str);
+ EFrameworkunifiedStatus PLLaunchModule(HANDLE hThread, T_ProcessLaunchResp &f_LaunchRespData); // NOLINT
+ EFrameworkunifiedStatus PLTerminateModule(HANDLE hThread, T_ProcessLauncherTerminationResp *f_pTerminateRespData = NULL);
+};
+#endif // CPROCESSLAUNCHER_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/processlauncher/ProcessLauncher_if.h b/systemservice/system_manager/server/include/processlauncher/ProcessLauncher_if.h
new file mode 100755
index 0000000..f8d047a
--- /dev/null
+++ b/systemservice/system_manager/server/include/processlauncher/ProcessLauncher_if.h
@@ -0,0 +1,30 @@
+/*
+ * @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 process launching and termination.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef PROCESSLAUNCHER_IF_H_ // NOLINT
+#define PROCESSLAUNCHER_IF_H_
+
+EFrameworkunifiedStatus ProcessLauncherOnStart(HANDLE hThread);
+EFrameworkunifiedStatus ProcessLauncherOnStop(HANDLE hThread);
+
+#endif // NOLINT
+
diff --git a/systemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher.h b/systemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher.h
new file mode 100755
index 0000000..1ca177c
--- /dev/null
+++ b/systemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher.h
@@ -0,0 +1,111 @@
+/*
+ * @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 process launching and termination.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_PROCESS_LAUNCHER_H_ // NOLINT
+#define SS_SM_PROCESS_LAUNCHER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_system_manager_protocol_local.h>
+
+#include "ss_sm_config.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// System manager launches the modules using the process launcher.
+/// The system manager launches the modules by sending the data about the process to be launched by
+/// the message ePLThrdCmd_LAUNCH_MODULE_REQST.
+/// SM => PL
+///////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ CHAR name[SS_SM_MAX_MODULE_NAME_LENGTH];
+ CHAR path[SS_SM_MAX_MODULE_PATH_LENGTH];
+ CHAR args[SS_SM_MAX_MODULE_ARGS_LENGTH];
+ UI_32 priority;
+ CHAR logging_mask[SS_SM_MAX_MODULE_LOG_MASK_LENGTH];
+ GroupLaunchMapIter groupIterator;
+ ModuleLaunchListIter moduleIterator;
+ int cpu_assign;
+} T_ProcessLauncherLaunchReq;
+
+///////////////////////////////////////////////////////////////////////////////
+/// After successfully launching an module, the process launcher sends the
+/// pid of the launched process along with the process name and arguments
+/// by the message ePLThrdCmd_LAUNCH_MODULE_RESP.
+/// System manager will verify the process name and the arguments and update
+/// the pid in its process table.
+///
+/// This message will be sent for every module that is launched by process launcher.
+/// Launch success returns a number > 0 for ProcessID, which is the PID of the
+/// newly created process.
+/// Launch failure returns -1 for ProcessID.
+/// PL => SM
+///////////////////////////////////////////////////////////////////////////////
+/// The response of the module relaunch message from process launcher to system
+/// manager ePLThrdCmd_RELAUNCH_MODULE_RESP is defined by the below structure
+/// A process ID value of > 0 indicates the success of the operation.
+/// The process name and args are used to ensure correct mapping of requests
+/// and responses.
+/// PL => SM
+///////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ SI_32 pid;
+ CHAR name[SS_SM_MAX_MODULE_NAME_LENGTH];
+ CHAR path[SS_SM_MAX_MODULE_PATH_LENGTH];
+ CHAR args[SS_SM_MAX_MODULE_ARGS_LENGTH];
+ UI_32 priority;
+ GroupLaunchMapIter groupIterator;
+ ModuleLaunchListIter moduleIterator;
+} T_ProcessLaunchResp;
+
+///////////////////////////////////////////////////////////////////////////////
+/// System manager terminates the process when it detects there is something
+/// wrong with the process. The system manager send the message
+/// ePLThrdCmd_TERMINATE_MODULE_REQST to process launcher as required.
+/// The request data is defined as below
+/// SM => PL
+///////////////////////////////////////////////////////////////////////////////
+typedef T_ProcessLauncherLaunchReq T_ProcessLauncherTerminationReq;
+
+///////////////////////////////////////////////////////////////////////////////
+/// The response of the module termination response message from process
+/// launcher to system manager
+/// ePLThrdCmd_TERMINATE_MODULE_RESP is defined by the below structure
+/// A ProcessID value of 0 indicates the success of the operation.
+/// The process name and args are used to ensure correct mapping of requests
+/// and responses.
+/// PL => SM
+///////////////////////////////////////////////////////////////////////////////
+typedef T_ProcessLaunchResp T_ProcessLauncherTerminationResp;
+
+///////////////////////////////////////////////////////////////////////////////
+/// The system manager requests a module relaunch by the message
+/// ePLThrdCmd_RELAUNCH_MODULE_REQST.
+/// The message data is described by the below structure
+/// The old process ID is passed sent in the request and a new process ID is
+/// expected in the response.
+/// The process launcher launches the module and does internal retries for this
+/// kind of request in case of failure.
+/// SM => PL
+///////////////////////////////////////////////////////////////////////////////
+typedef T_ProcessLauncherLaunchReq T_ProcessLauncherRelaunchReq;
+
+#endif // SS_SM_PROCESS_LAUNCHER_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher_protocol.h b/systemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher_protocol.h
new file mode 100755
index 0000000..cd69832
--- /dev/null
+++ b/systemservice/system_manager/server/include/processlauncher/ss_sm_process_launcher_protocol.h
@@ -0,0 +1,62 @@
+/*
+ * @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 process launching and termination.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_PROCESS_LAUNCHER_PROTOCOL_H_ // NOLINT
+#define SS_SM_PROCESS_LAUNCHER_PROTOCOL_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_system_manager_protocol_local.h>
+#include <system_service/ss_system_manager_protocol.h>
+
+typedef enum _ESMPLThreadCommandIds {
+ //// <
+ ePLThrdCmd_LAUNCH_MODULE_REQST = 0x543, ///< SM --> SM.ProcessLauncher
+
+ //// <
+ ePLThrdCmd_LAUNCH_MODULE_RESP, ///< SM.ProcessLauncher --> SM
+
+ //// <
+ ePLThrdCmd_TERMINATE_MODULE_REQST, ///< SM --> SM.ProcessLauncher
+
+ //// <
+ ePLThrdCmd_TERMINATE_MODULE_RESP, ///< SM.ProcessLauncher --> SM
+
+ //// <
+ ePLThrdCmd_RELAUNCH_MODULE_REQST, ///< SM --> SM.ProcessLauncher
+
+ //// <
+ ePLThrdCmd_RELAUNCH_MODULE_RESP, ///< SM.ProcessLauncher --> SM
+
+ //// <
+ ePLThrdCmd_MODULE_STATUS_REQST, ///< SM --> SM.ProcessLauncher
+
+ //// <
+ ePLThrdCmd_THREAD_STATUS_REQST, ///< SM --> SM.ProcessLauncher
+
+ //// <
+ ePLThrdCmd_THREAD_STATUS_RESP, ///< SM.ProcessLauncher --> SM
+
+ ePLThrdCmd_NONE, ///< Not sent. Used for initialization.
+} ESMPLThreadCommandIds;
+
+
+#endif // SS_SM_PROCESS_LAUNCHER_PROTOCOL_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_sm_config.h b/systemservice/system_manager/server/include/ss_sm_config.h
new file mode 100755
index 0000000..19736f6
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_config.h
@@ -0,0 +1,543 @@
+/*
+ * @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 configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_CONFIG_H_ // NOLINT
+#define SS_SM_CONFIG_H_
+
+#include <native_service/ns_config_parser_if.h>
+#include <system_service/ss_system_types.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_if_local.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_string_maps.h>
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+#include "ss_sm_process_launcher_protocol.h"
+
+
+/// All timer values are **position-dependent** in the timer calls ! These
+/// defines are currently all used as Start and Restart Seconds parameters.
+/// \param [in] id
+/// UI_32 - timer id that you want to start
+/// \param [in] ss
+/// UI_32 - Start time in seconds
+/// \param [in] sms
+/// UI_32 - Start time in milliseconds
+/// \param [in] rs
+/// UI_32 - Repeat time in seconds
+/// \param [in] rms
+/// UI_32 - Repeat time in milliseconds
+#define SS_GROUP_LAUNCH_TIMER_CONFIG (3)
+#define SS_HEARTBEAT_MONITOR_TIMER_CONFIG (10)
+#define SS_PROCESSLAUNCHER_MONITOR_TIMER_CONFIG (10)
+#define SS_CLIENT_START_MONITOR_TIMER_CONFIG (3)
+#define SS_CLIENT_STOP_MONITOR_TIMER_CONFIG (1)
+#define SS_NPP_STATUS_CHECK_MONITOR_TIME_SEC (5)
+#define SS_LAUNCH_GROUP_TRIGGER_TIMER_CONFIG (10)
+// size of the internal debug dump buffer
+#define SS_SM_DEBUG_DUMP_MAX_SIZE (12288u)
+// number of _CWORD56_ command history log entries for the debug dump
+#define SS_SM__CWORD56__CMD_HIST_SIZE (10u)
+// number of timer history log entries for the debug dump
+#define SS_SM_TIMER_CMD_HIST_SIZE (10u)
+// number of message history log entries for the debug dump
+#define SS_SM_CMD_HIST_SIZE (20u)
+// number of publishing history log entries for the debug dump
+#define SS_SM_PUB_CMD_HIST_SIZE (5u)
+// number of error history log entries for the debug dump
+#define SS_SM_ERR_HIST_SIZE (5u)
+
+// When occurs repeat to abnormal rebooting, logging cause of error at first time and next time.
+// When it occurs "ILG_RESET", Maximum number of log is 4 so that the log will be stored at the just after the startup.
+// Need reconsideration if maximum number of abnormal logging is less than 4 using SSL.
+#define SS_SM_ERR_LOGGING_LIMIT (8)
+
+// Maximum number of continuous processing of "NaviReset" by errors.
+// It try to recover by NaviDet when it exceeds this limit.
+#define SS_SM_ERR_NAVI_RESET_LIMIT (5)
+
+typedef enum {
+ MODULE_STATE_INVALID = 0 /// Initial state of all modules
+ , MODULE_STATE_SKIPPED /// Non-critical module has crossed max re-launch limit
+ /// or hSession was null when attempted to start
+ , MODULE_STATE_LAUNCHING /// Module launch has been requested
+ , MODULE_STATE_LAUNCHED /// Module has been launched but a session
+ /// connection has NOT been established
+ , MODULE_STATE_LAUNCH_FAILED /// Oops
+ , MODULE_STATE_CONNECTED /// A session connection has been established
+ , MODULE_STATE_START_SENT /// SM has sent START to the module
+ , MODULE_STATE_START_FAILED /// FrameworkunifiedSendMsg(SS_SM_START) failed
+ , MODULE_STATE_STARTED /// Module has replied START Complete to SM
+ , MODULE_STATE_STOP_SENT /// SM has sent STOP to the module
+ , MODULE_STATE_STOP_FAILED /// FrameworkunifiedSendMsg(SS_SM_STOP) failed
+ , MODULE_STATE_STOPPED /// Module has replied STOP Complete to SM
+ , MODULE_STATE_START_PRE_SENT //!< SM has sent Pre-boot start to the module
+ , MODULE_STATE_START_PRE_FAILED //!< FrameworkunifiedSendMsg(SS_SM_PRE_START) failed
+ , MODULE_STATE_STARTED_PRE //!< Module has replied Pre-boot start Complete to SM
+ , MODULE_STATE_STOP_PRE_SENT //!< SM has sent Pre-boot stop to the module
+ , MODULE_STATE_STOP_PRE_FAILED //!< FrameworkunifiedSendMsg(SS_SM_PRE_STOP) failed
+ , MODULE_STATE_STOPPED_PRE //!< Module has replied Pre-boot stopComplete to SM
+ , MODULE_STATE_START_BACKGROUND_SENT //!< SM has sent Background-boot start to the module
+ , MODULE_STATE_START_BACKGROUND_FAILED //!< FrameworkunifiedSendMsg(SS_SM_BACKGROUND_START) failed
+ , MODULE_STATE_STARTED_BACKGROUND //!< Module has replied Background-boot start Complete to SM
+ , MODULE_STATE_STOP_BACKGROUND_SENT //!< SM has sent Background-boot stop to the module
+ , MODULE_STATE_STOP_BACKGROUND_FAILED //!< FrameworkunifiedSendMsg(SS_SM_BACKGROUND_STOP) failed
+ , MODULE_STATE_STOPPED_BACKGROUND //!< Module has replied Background-boot stop Complete to SM
+} SMModuleState;
+//
+// Module State string map type
+typedef std::map<SMModuleState, std::string> SMModuleStateStrMapType;
+
+typedef enum {
+ MODULE_DEBUG_DUMP_STATE_NOT_REQUESTED = 0
+ , MODULE_DEBUG_DUMP_STATE_REQUEST_SENT
+ , MODULE_DEBUG_DUMP_STATE_RESPONSE_RECEIVED
+} SMModuleDebugDumpState;
+
+typedef std::map<SMModuleDebugDumpState, std::string> SMModuleDebugDumpStateStrMapType;
+
+/*
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration>
+ <!-- System Service Launch control elements -->
+ <SystemManager>
+ <Launch>
+ <Group1>
+ <group_name>CoreModules</group_name>
+ <group_id>1</group_id>
+ <Member1>
+ <name>TRUE</name>
+ <path>1</path>
+ <priority>200</priority>
+ <critical>TRUE</critical>
+ <retry_cnt>1</retry_cnt>
+ <arguments></arguments>
+ <logging_mask></logging_msk>
+ <restart>group</restart>
+ <shudown_critical></shudown_critical>
+ <shudown_wait_time></shudown_wait_time>
+ </Member1>
+ <Member2>
+ <name>TRUE</name>
+ <path>1</path>
+ <priority>200</priority>
+ <critical>TRUE</critical>
+ <retry_cnt>1</retry_cnt>
+ <arguments></arguments>
+ <logging_mask></logging_msk>
+ <restart>me</restart>
+ <shudown_critical></shudown_critical>
+ <shudown_wait_time></shudown_wait_time>
+ </Member2>
+ </Group1>
+ </Launch>
+ </SystemManager>
+</Configuration>
+*/
+
+//******************************************************************************
+//* CTimeSpan class *
+//* *
+class CTimeSpan {
+ public:
+ CTimeSpan(): initial(0), final(0), delta(0) {}
+ CTimeSpan(UI_64 f_initial) // NOLINT
+ : initial(f_initial), final(0), delta(0) {}
+ ~CTimeSpan() {}
+ /*
+ * Set Initial time, reset Final and Delta to zero, return time
+ */
+ UI_64 Begin();
+ /*
+ * Set Final time, calculate Delta time, return time
+ */
+ UI_64 End();
+ UI_64 GetInitial();
+ UI_64 GetFinal();
+ UI_64 GetDelta();
+ UI_64 GetTimeMilliseconds();
+
+ private:
+ UI_64 initial;
+ UI_64 final;
+ UI_64 delta;
+}; // End of class CTimeSpan
+//******************************************************************************
+
+
+typedef enum {
+ NotStopped,
+ StoppedByModuleStopComplete,
+ StoppedByModuleStopFail,
+ StoppedByGroupStopTimeout,
+ StoppedByCriticalAppsTimeout,
+ StoppedByModulePreStopComplete,
+ StoppedByModulePreStopFail,
+ StoppedByModuleBackgroundStopComplete,
+ StoppedByModuleBackgroundStopFail
+} EStopReasonType;
+
+typedef enum {
+ NotStarted,
+ StartedByModuleStartComplete,
+ StartedByModuleStartFail,
+ StartedByModulePreStartComplete,
+ StartedByModulePreStartFail,
+ StartedByModuleBackgroundStartComplete,
+ StartedByModuleBackgroundStartFail
+} EStartReasonType;
+
+//******************************************************************************
+//* CTimeEvent class *
+//* *
+template <typename EEventType>
+class CTimeEvent : public CTimeSpan {
+ public:
+ CTimeEvent() {
+ bzero(&m_eventReason, sizeof(m_eventReason));
+ }
+ ~CTimeEvent() {}
+
+ VOID SetReason(EEventType f_eventReason)
+ { m_eventReason = f_eventReason; }
+ private:
+ EEventType m_eventReason;
+}; // End of class CTimeEvent
+//******************************************************************************
+
+typedef enum {
+ NotRelaunched,
+ RelaunchSafe,
+ RelaunchErr
+} ERelaunchStatusType;
+
+
+typedef CTimeEvent<EStartReasonType> CStartReason;
+typedef CTimeEvent<EStopReasonType> CStopReason;
+typedef CHAR TUserNameBuffer[128]; // TODO(yaomingwu): Stuff. Does Posix define a useful
+ // constant representing max length of user id?
+
+class ModuleLaunchParams {
+ public:
+ // Move to private to prevent direct access
+ // SMModuleState module_state;
+ //
+ SS_String name;
+ SS_String path;
+ SS_String arguments;
+ SS_String restart;
+ UI_32 configuration_priority;
+ int cpu_assign;
+ UI_32 previous_priority;
+ UI_32 current_priority;
+ BOOL critical;
+ UI_32 retry_cnt;
+ SS_String logging_msk_str;
+ BOOL is_start_required;
+ BOOL shutdown_critical;
+ UI_32 shutdown_wait_time;
+ UI_32 fast_shutdown_wait_time;
+ SI_32 pid;
+ HANDLE hsession;
+ UI_32 relaunch_count;
+ ERelaunchStatusType relaunch_status;
+ UI_32 group_id;
+ TUserNameBuffer unix_user_name;
+
+ BOOL m_serviceAvailability; // Not set because it does not watch Availability for speeding up start up process.
+
+ CStartReason m_startReason;
+ CStopReason m_stopReason;
+
+ ModuleLaunchParams();
+ ~ModuleLaunchParams();
+ SMModuleState GetModuleState(void);
+ BOOL IsModuleState(SMModuleState f_moduleState);
+ BOOL IsModuleConnected() const;
+ VOID SetModuleState(SMModuleState f_moduleState, BOOL f_bLog = TRUE);
+ std::string ModuleStateStr(void);
+
+ SMModuleDebugDumpState GetModuleDebugDumpState(void);
+ std::string GetModuleDebugDumpStateStr(void);
+ VOID SetModuleDebugDumpState(SMModuleDebugDumpState f_moduleDebugDumpState, BOOL f_bLog = TRUE);
+ EFrameworkunifiedStatus SendMsgAndUpdateState(
+ const UI_32 f_iCmd, const T_SS_SM_START_DataStructType* const f_startData);
+ EFrameworkunifiedStatus SendMsgAndUpdateState(T_SS_SM_STOP_DataStruct const* f_stopData);
+
+ EFrameworkunifiedStatus GetPriority(UI_32& f_Priority); // NOLINT
+ EFrameworkunifiedStatus SetPriority(UI_32 f_Priority);
+
+ BOOL IsAGLUnit(void) const { return is_agl_unit; }
+ BOOL IsAGLResetHistoryDisable(void) const { return disable_agl_resethistory; }
+ BOOL IsNonAGLResetHistoryDisable(void) const { return disable_nonagl_resethistory; }
+ void SetAGLUnit(BOOL f_is_agl_unit) { is_agl_unit = f_is_agl_unit; }
+ void SetAGLResetHistoryDisable(BOOL f_disable_agl_resethistory) {
+ disable_agl_resethistory = f_disable_agl_resethistory;
+ }
+ void SetNonAGLResetHisoryDisable(BOOL f_disable_nonagl_resethistory) {
+ disable_nonagl_resethistory = f_disable_nonagl_resethistory;
+ }
+
+ private:
+ SMModuleState m_moduleState;
+ SMModuleStateStrMapType m_ModuleStateStrMap;
+ SMModuleDebugDumpState m_ModuleDebugDumpState;
+ SMModuleDebugDumpStateStrMapType m_ModuleDebugDumpStateStrMap;
+ BOOL is_agl_unit;
+ BOOL disable_agl_resethistory;
+ BOOL disable_nonagl_resethistory;
+};
+
+typedef std::list<ModuleLaunchParams> ModuleLaunchList;
+typedef ModuleLaunchList::iterator ModuleLaunchListIter;
+
+typedef struct _GroupLaunchInfo { // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ BOOL launch_complete;
+ BOOL start_complete;
+ BOOL stop_complete;
+ SS_String name;
+ UI_32 id;
+ UI_32 grp_launch_wait;
+ UI_32 grp_wait_for_trigger;
+ ModuleLaunchList modules;
+} GroupLaunchInfo;
+
+typedef std::list<GroupLaunchInfo> GroupLaunchList;
+typedef GroupLaunchList::iterator GroupLaunchListIter;
+
+typedef std::map<UI_32, GroupLaunchInfo> GroupLaunchMap;
+typedef GroupLaunchMap::iterator GroupLaunchMapIter;
+
+typedef std::list<GroupLaunchList> GroupList;
+typedef GroupList::iterator GroupListIter;
+
+// Process Binary Name (key) to ModuleLaunchList iterator (ModuleLaunchParams).
+typedef std::map<std::string, ModuleLaunchListIter>ProcessNameMap;
+typedef ProcessNameMap::iterator ProcessNameMapIter;
+
+// Config Parameters specific to Heart Beat Thread
+typedef struct _HBConfigParams {
+ SI_32 MaxHeartBeatRetryCount; /// Retry heart beat check before error report is sent to SM
+ SI_32 ApplicationHeartBeatIntervalInitial; /// Initial Timer interval
+ /// between two heart beat requests & response check
+ SI_32 ApplicationHeartBeatIntervalRepeat; /// Repeat Timer interval between two heart beat requests & response check
+} HBConfigParameters;
+
+typedef struct _CDConfigParams {
+ BOOL CrashDetectorEnabled;
+} CDConfigParameters;
+
+typedef struct _SLMConfigParams { // SLM - System Low Memory
+ SI_32 SLMTimerValue;
+ SI_32 SLMMaxRetryCount;
+ SI_32 SLMThresholdValue;
+ SI_32 SLMSystemmanagerLogIntervalMs;
+} SLMConfigParameters;
+
+typedef struct _UserMModeConfigParams {
+ BOOL IsUserModeNotificationABOOL;
+} UserModeConfigParameters;
+
+typedef struct _ModuleConnectTimeConfigParams {
+ SI_32 ModuleConnectionNumTimesToCheck;
+ SI_32 ModuleConnectionTimeOutSec;
+ SI_32 ModuleStartRespTimeOutSec;
+} ModuleConfigParams;
+
+typedef struct _CriticalAppsMaxShutdownTime {
+ SI_32 CriticalAppsMaxShutdownTimeFastSleep;
+ SI_32 CriticalAppsMaxShutdownTimeNormalReset;
+} CriticalAppsMaxShutdownTime;
+
+typedef struct _ConfigurationData {
+ // Parameters specific to System Manager
+
+ // Parameters specific to Heart Beat Thread
+ HBConfigParameters HBConfig;
+
+ // Parameters specific to Launcher Thread
+
+ // Parameters specific to Crash Detector Thread
+ CDConfigParameters CDConfig;
+
+ // Parameters specific to System Low Memory
+
+ // Parameters specific to Sys Low Memory Thread
+ SLMConfigParameters SLMConfig;
+
+ // Parameters specific to User Mode Notification Data Structure
+ UserModeConfigParameters UMConfig;
+
+ // Parameters specific to Module connection timeout with SM
+ ModuleConfigParams MCConfig;
+
+ // Parameters specific to Critical Apps Max shutdown time
+ CriticalAppsMaxShutdownTime CAMSTConfig;
+} ConfigurationData;
+
+typedef std::vector<UI_32> LaunchOrderedVector;
+typedef LaunchOrderedVector::iterator LaunchOrderedIter;
+
+class SMConfigParams {
+ public:
+ SMConfigParams();
+ virtual ~SMConfigParams();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// LoadSMConfigParameters
+ /// \brief Read System Manager configuration parameters from cfg file or
+ /// use defaults values in case cfg file is not available
+ ///
+ /// \param [in] f_ConfigParams & - Ref to ConfigurationData that get populated.
+ /// \param [in] f_FileName - Configuration file name.
+ ///
+ /// \return BOOL
+ /// BOOL - TRUE or FALSE
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL LoadSMConfigParameters(ConfigurationData& f_ConfigParams, // NOLINT
+ SS_String f_FileName);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetSMConfigInformation
+ /// \brief Read config data from cfg file and populate the configuration data structure
+ ///
+ /// \param [in] f_ConfigParams & - Ref to ConfigurationData that get populated.
+ /// \param [in] f_FileName - Configuration file name.
+ ///
+ /// \return BOOL
+ /// BOOL - TRUE or FALSE
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL GetSMConfigInformation(ConfigurationData& f_ConfigParams, // NOLINT
+ SS_String f_FileName);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintConfigInfo
+ /// \brief Print the configuration data stored in config structure
+ ///
+ /// \param [in] configata
+ /// ConfigurationData & - Ref to structure that get populated.
+ ///
+ /// \return VOID
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID PrintConfigInfo(ConfigurationData const& f_ConfigParams);
+};
+
+class SysMgrConfiguration {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SysMgrConfiguration
+ /// \brief
+ ///
+ /// \return NA
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ SysMgrConfiguration();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~SysMgrConfiguration
+ /// \brief
+ ///
+ /// \return NA
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~SysMgrConfiguration();
+
+// ////////////////////////////////////////////////////////////////////////////////////////////
+// /// LoadParameters
+// /// \brief
+// ///
+// /// \param [in] groups
+// /// GroupLaunchList & - Ref to GroupLaunchList that get populated.
+// ///
+// /// \return BOOL
+// /// BOOL - TRUE or FALSE
+// ////////////////////////////////////////////////////////////////////////////////////////////
+// BOOL LoadParameters(GroupLaunchMap & groups_map);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// LoadParametersCfg
+ /// \brief
+ ///
+ /// \param [in] groups
+ /// GroupLaunchList & - Ref to GroupLaunchList that gets populated.
+ /// ProcessNameMap & - Ref to ProcessNameMap that gets populated.
+ /// LaunchOrderedVector & - Ref to LaunchOrderedVector that gets populated.
+ ///
+ /// \param [in] f_launchOrderName - launch order name.
+ ///
+ /// \return BOOL
+ /// BOOL - TRUE or FALSE
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL LoadParametersCfg(GroupLaunchMap& groups_map, // NOLINT
+ ProcessNameMap& f_processNameMap, // NOLINT
+ LaunchOrderedVector& f_OrderList, // NOLINT
+ SS_String& f_launchOrderName, // NOLINT
+ SS_String& f_launchCfgFn); // NOLINT
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintGroupInfo
+ /// \brief Print method for GroupLaunchInfo only prints the group info not the module info
+ ///
+ /// \param [in] refGrpInfo
+ /// GroupLaunchInfo & - Ref to a GroupLaunchInfo object that will be printed.
+ ///
+ /// \return VOID
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID PrintGroupInfo(GroupLaunchInfo& refGrpInfo); // NOLINT
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintModuleInfo
+ /// \brief Print method for a Module's Params.
+ ///
+ /// \param [in] refMbrInfo
+ /// ModuleLaunchParams & - Ref to ModuleLaunchParams object that will be printed.
+ ///
+ /// \return VOID
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID PrintModuleInfo(ModuleLaunchParams& refMbrInfo); // NOLINT
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintAllInfo
+ /// \brief Print all the information in the GroupLaunchList.
+ ///
+ /// \param [in] refGrpList
+ /// GroupLaunchList & - Ref to GroupLaunchList object that will be printed.
+ ///
+ /// \return VOID
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID PrintAllInfo(GroupLaunchMap& refGrpMap); // NOLINT
+
+ protected:
+ // define all the configuration parameters that will be used to get data
+
+ CNSConfigReader * l_pReaderCfg;
+
+ SysMgrConfiguration(const SysMgrConfiguration&) : l_pReaderCfg(NULL) {}
+ SysMgrConfiguration & operator = (const SysMgrConfiguration &);
+
+ private:
+ BOOL ParseBoolParameter(PCSTR f_value, BOOL f_default = FALSE) const;
+};
+
+#endif // SS_SM_CONFIG_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_sm_default_paths.h b/systemservice/system_manager/server/include/ss_sm_default_paths.h
new file mode 100755
index 0000000..8ffafd9
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_default_paths.h
@@ -0,0 +1,42 @@
+/*
+ * @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 default path names.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef SYSTEM_MANAGER_SERVER_INCLUDE_SS_SM_DEFAULT_PATHS_H_
+#define SYSTEM_MANAGER_SERVER_INCLUDE_SS_SM_DEFAULT_PATHS_H_
+/*
+ * Environment variables
+ */
+const CHAR BaseDirPathEnvVariable[] = "BASE_DIR";
+const CHAR LaunchConfigFileNameEnvVariable[] = "APPS_CONFIG_FILENAME";
+const CHAR SMConfigDataFileNameEnvVariable[] = "SM_CONFIG_DATA_FILENAME";
+const CHAR UsingVMPlayerVariable[] = "USING_VM_PLAYER";
+
+/*
+ * Default paths to be used in case Environment variables are not set
+ */
+const CHAR DefaultBasePath[] = "";
+const CHAR DefaultBinaryPath[] = "/agl/bin/";
+const CHAR DefaultConfigFilesPath[] = "/usr/agl/conf/BS/ss/system_manager/rwdata/";
+const CHAR DefaultLaunchConfigFileName[] = "sm_launch.cfg";
+const CHAR DefaultSMConfigFileName[] = "gpf_ss_sm_config_data.cfg";
+
+#endif // SYSTEM_MANAGER_SERVER_INCLUDE_SS_SM_DEFAULT_PATHS_H_
+
diff --git a/systemservice/system_manager/server/include/ss_sm_dynamic_launch_table.h b/systemservice/system_manager/server/include/ss_sm_dynamic_launch_table.h
new file mode 100755
index 0000000..685b43b
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_dynamic_launch_table.h
@@ -0,0 +1,72 @@
+/*
+ * @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 process launching.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_DYNAMIC_LAUNCH_TABLE_H_ // NOLINT
+#define SS_SM_DYNAMIC_LAUNCH_TABLE_H_
+
+#include "ss_sm_dynamic_launcher.h"
+
+DynamicLaunchInfo g_arrDynamicLaunchTableCfg[] = {
+ // TUNER
+ { SS_SOURCE_FM,
+ (const PCHAR)"FM", (const PCHAR)"Audio", (const PCHAR)"Radio",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", FALSE},
+ { SS_SOURCE_AM,
+ (const PCHAR)"AM", (const PCHAR)"Audio", (const PCHAR)"Radio",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", FALSE},
+ { SS_SOURCE_FM_DAB,
+ (const PCHAR)"FM_DAB", (const PCHAR)"Audio", (const PCHAR)"Radio",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", FALSE},
+ { SS_SOURCE_SDARS,
+ (const PCHAR)"SDARS", (const PCHAR)"Audio", (const PCHAR)"Radio",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", FALSE},
+ // MEDIA
+ { SS_SOURCE_SD_CARD,
+ (const PCHAR)"SDCard", (const PCHAR)"Audio", (const PCHAR)"Multimedia",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE_MSC,
+ (const PCHAR)"MCS", (const PCHAR)"Audio", (const PCHAR)"Multimedia",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE_MTP, (const PCHAR)"MTP",
+ (const PCHAR)"Audio", (const PCHAR)"Multimedia", (const PCHAR)"HMI",
+ (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE__CWORD57_,
+ (const PCHAR)"_CWORD57_", (const PCHAR)"Audio", (const PCHAR)"Multimedia",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE__CWORD73__APP,
+ (const PCHAR)"_CWORD57__APP", (const PCHAR)"Audio",
+ (const PCHAR)"Multimedia", (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE__CWORD73__VIDEO_MODE,
+ (const PCHAR)"_CWORD57__VM", (const PCHAR)"Audio",
+ (const PCHAR)"Multimedia", (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE_USB,
+ (const PCHAR)"USB", (const PCHAR)"Audio", (const PCHAR)"Multimedia",
+ (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE_DATA_CD,
+ (const PCHAR)"DATA_CD", (const PCHAR)"Audio",
+ (const PCHAR)"Multimedia", (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+ { SS_SOURCE_CD,
+ (const PCHAR)"AUDIO_CD", (const PCHAR)"Audio",
+ (const PCHAR)"Multimedia", (const PCHAR)"HMI", (const PCHAR)"AviageTrigger", TRUE},
+};
+
+#endif // SS_SM_DYNAMIC_LAUNCH_TABLE_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_sm_dynamic_launcher.h b/systemservice/system_manager/server/include/ss_sm_dynamic_launcher.h
new file mode 100755
index 0000000..a6efb1f
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_dynamic_launcher.h
@@ -0,0 +1,111 @@
+/*
+ * @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 process launching.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_DYNAMIC_LAUNCHER_H_ // NOLINT
+#define SS_SM_DYNAMIC_LAUNCHER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/interfaceunified_system_types.h>
+#include <vector>
+
+#include "ss_sm_config.h"
+
+using std::vector;
+
+
+typedef struct _tDynamicLaunchParams {
+ SS_SOURCE source;
+ const PCHAR source_name;
+ const PCHAR before_group_name;
+ const PCHAR start_group_name;
+ const PCHAR after_group_name;
+ const PCHAR aviage_trigger_name;
+ BOOL group_trigger;
+} DynamicLaunchInfo;
+
+
+class DynamicLaunchBase {
+ public:
+ DynamicLaunchBase();
+ virtual ~DynamicLaunchBase();
+ UI_32 get_id() const;
+ UI_32 advance_id();
+ UI_32 decrement_id();
+ BOOL is_begin();
+ BOOL is_end();
+ VOID to_begin();
+ VOID to_end();
+ VOID print_info();
+
+ protected:
+ typedef std::vector<UI_32> DynamicOrderedVector;
+ typedef DynamicOrderedVector::iterator DynamicOrderedIter;
+ DynamicOrderedVector m_vOrderedGroup;
+ DynamicOrderedIter m_iterOrderedGroup;
+};
+
+class DynamicModuleStart;
+
+class DynamicLauncher: public DynamicLaunchBase {
+ public:
+ DynamicLauncher();
+ virtual ~DynamicLauncher();
+ BOOL dynamic_launch_enabled() const;
+ VOID configure_dynamic_launch(const SS_SOURCE & source_type, // NOLINT
+ GroupLaunchMap & group_info, LaunchOrderedVector & order_info); // NOLINT
+ VOID copyDynOrderedVector(DynamicModuleStart &);
+
+ private:
+ // Disable class copy constructors
+ explicit DynamicLauncher(const DynamicLauncher& f_source)
+ : m_nLaunchGroupId(f_source.m_nLaunchGroupId)
+ , m_nLaunchBeforeGroupId(f_source.m_nLaunchBeforeGroupId)
+ , m_nLaunchAfterGroupId(f_source.m_nLaunchAfterGroupId)
+ , m_nAviageTriggerId(f_source.m_nAviageTriggerId)
+ , m_bDynamicLaunchEnabled(f_source.m_bDynamicLaunchEnabled)
+ , m_eSourceType(f_source.m_eSourceType) {}
+ DynamicLauncher & operator = (const DynamicLauncher &);
+
+ // helper methods..
+ DynamicLaunchInfo* get_dynamic_source_info(const SS_SOURCE& source_type, // NOLINT
+ BOOL& source_trigger, BOOL &is_aviage_required); // NOLINT
+ UI_32 get_id_using_group_name(PCSTR group_name, GroupLaunchMap& group_info); // NOLINT
+ VOID create_normal_launch_vector(GroupLaunchMap& group_info, LaunchOrderedVector& order_info); // NOLINT
+ BOOL is_inGroupLaunchMap(UI_32& id, GroupLaunchMap& group_info); // NOLINT
+
+ // Data Members
+ UI_32 m_nLaunchGroupId;
+ UI_32 m_nLaunchBeforeGroupId;
+ UI_32 m_nLaunchAfterGroupId;
+ UI_32 m_nAviageTriggerId;
+ BOOL m_bDynamicLaunchEnabled;
+ SS_SOURCE m_eSourceType;
+};
+
+class DynamicModuleStart: public DynamicLaunchBase {
+ public:
+ DynamicModuleStart();
+ virtual ~DynamicModuleStart();
+ VOID setGroupVector(DynamicOrderedVector&);
+};
+
+#endif // SS_SM_DYNAMIC_LAUNCHER_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_sm_launch_configuration.h b/systemservice/system_manager/server/include/ss_sm_launch_configuration.h
new file mode 100755
index 0000000..7296714
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_launch_configuration.h
@@ -0,0 +1,191 @@
+/*
+ * @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 process launching.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_LAUNCH_CONFIGURATION_H_ // NOLINT
+#define SS_SM_LAUNCH_CONFIGURATION_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_client_names.h>
+
+typedef struct _DefaultModuleLaunchParams {
+ const PCHAR name;
+ const PCHAR binary_name;
+ const PCHAR arguments;
+ const PCHAR restart;
+ UI_32 priority;
+ BOOL critical;
+ UI_32 retry_cnt;
+ const PCHAR logging_msk_str;
+ BOOL is_start_required;
+ BOOL shutdown_critical;
+ UI_32 shutdown_wait_time;
+} DefaultModuleLaunchParams;
+
+typedef struct _DefaultGroupLaunchInfo {
+ const PCHAR name;
+ UI_32 id;
+ DefaultModuleLaunchParams *modules;
+} DefaultGroupLaunchInfo;
+
+
+#define prefix
+
+prefix DefaultModuleLaunchParams CoreModulesGroup[] = {
+ // Queue name binary_name arguments
+ {(const PCHAR)SERVICE_NS_SHARED_MEM,
+ (const PCHAR)"NS_SharedMem", (const PCHAR)"", (const PCHAR)"me",
+ 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0},
+ {(const PCHAR)SERVICE_NS_NPP, (const PCHAR)"NS_NPPService",
+ (const PCHAR)"", (const PCHAR)"me", 20, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", FALSE, TRUE, 15},
+ {(const PCHAR)SERVICE_LOGGER, (const PCHAR)SERVICE_LOGGER,
+ (const PCHAR)"", (const PCHAR)"me", 10, FALSE, 3, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0},
+ {(const PCHAR)SERVICE__CWORD69_, (const PCHAR)"_CWORD69_.exe",
+ (const PCHAR)"", (const PCHAR)"me", 10, FALSE, 3, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams ShadowModulesGroup[] = {
+ // Queue name binary_name arguments
+ {(const PCHAR)SERVICE_PS_IPC, (const PCHAR)"PS_IPC",
+ (const PCHAR)"", (const PCHAR)"group", 50, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0},
+ {(const PCHAR)SERVICE_PSM_SHADOW, (const PCHAR)"PS_PSMShadow",
+ (const PCHAR)"", (const PCHAR)"group", 12, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_KEY_HANDLER, (const PCHAR)"PS_KeyHandler",
+ (const PCHAR)"", (const PCHAR)"group", 12, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_IPC_MP_SHADOW, (const PCHAR)"PS_IPC_MP_Shadow",
+ (const PCHAR)"", (const PCHAR)"group", 20, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams SystemModulesGroup[] = {
+ {(const PCHAR)SERVICE_POWER, (const PCHAR)SERVICE_POWER,
+ (const PCHAR)"", (const PCHAR)"me", 12, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SS_DEV_DETECT_SRV, (const PCHAR)SS_DEV_DETECT_SRV,
+ (const PCHAR)"", (const PCHAR)"me", 12, FALSE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SS_PLM_SERVICE, (const PCHAR)SS_PLM_SERVICE,
+ (const PCHAR)"", (const PCHAR)"me", 12, FALSE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams AudioModulesGroup[] = {
+ {(const PCHAR)SERVICE_AS_AUDIO, (const PCHAR)"AS_AudioService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_AS_MODE, (const PCHAR)"AS_ModeService",
+ (const PCHAR)"", (const PCHAR)"me", 10, FALSE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams RadioModulesGroup[] = {
+ {(const PCHAR)SERVICE_TUNER, (const PCHAR)"Radio",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_DAB, (const PCHAR)"Master_Tuner",
+ (const PCHAR)"", (const PCHAR)"me", 10, FALSE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_SDARS, (const PCHAR)"Ext_SDARS_Service",
+ (const PCHAR)"", (const PCHAR)"me", 10, FALSE, 3,
+ (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams MultimediaModulesGroup[] = {
+ {(const PCHAR)SERVICE_MM_ICD, (const PCHAR)"MM_ICDService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_MM_MEDIA, (const PCHAR)"MediaService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams HMIModulesGroup[] = {
+ {(const PCHAR)SERVICE_HMI, (const PCHAR)"GtfStartup",
+ (const PCHAR)"/eb/gtf_5.2.1/models/PastModel004/gtfStartup.cfg", (const PCHAR)"me",
+ 13, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0},
+ {(const PCHAR)SERVICE_HMI__CWORD77_, (const PCHAR)"HMI__CWORD77_",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_HMI__CWORD46_, (const PCHAR)"HMI__CWORD46_Service", (const PCHAR)"",
+ (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams NavigationModulesGroup[] = {
+ {(const PCHAR)SERVICE_NAV_LOC, (const PCHAR)"NAV_LocationService", (const PCHAR)"", (const PCHAR)"me",
+ 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_NAV, (const PCHAR)"NAV_NavigationService", (const PCHAR)"", (const PCHAR)"me",
+ 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0, (const PCHAR)0, (const PCHAR)0,
+ 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams SoftwareUpdateModulesGroup[] = {
+ {(const PCHAR)SERVICE_SOFTWAREUPDATE, (const PCHAR)"SS_SoftwareUpdateService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_PS_SWDL_SHADOW, (const PCHAR)"PS_SoftwareUpdateShadow",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams NetworkingModulesGroup[] = {
+ {(const PCHAR)SERVICE__CWORD51__BT, (const PCHAR)"_CWORD51__BT.exe",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_NW_BT, (const PCHAR)"NW_BluetoothService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_NW_CONNECTION, (const PCHAR)"NW_ConnectionService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_NW_PHONE, (const PCHAR)"NW_PhoneService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_NW_PHONE_BOOK, (const PCHAR)"NW_PhoneBookService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)SERVICE_NW_MESSAGING, (const PCHAR)"NW_MessagingService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultModuleLaunchParams BrowserModulesGroup[] = {
+ {(const PCHAR)SERVICE_BR_BROWSER, (const PCHAR)"BR_BrowserService",
+ (const PCHAR)"", (const PCHAR)"me", 10, TRUE, 3, (const PCHAR)"0x00000000, 0x00000000", TRUE, FALSE, 0},
+ {(const PCHAR)0, (const PCHAR)0,
+ (const PCHAR)0, (const PCHAR)0, 0, FALSE, 0, (const PCHAR)"0x00000000, 0x00000000", FALSE, FALSE, 0}
+};
+
+prefix DefaultGroupLaunchInfo g_arrLaunchTable[] = {
+ {(const PCHAR)"CoreModules", 1, CoreModulesGroup },
+ {(const PCHAR)"ShadowModules", 2, ShadowModulesGroup },
+ {(const PCHAR)"SystemModules", 3, SystemModulesGroup },
+ {(const PCHAR)"Audio", 4, AudioModulesGroup },
+ {(const PCHAR)"Radio", 5, RadioModulesGroup },
+ {(const PCHAR)"Multimedia", 6, MultimediaModulesGroup },
+ {(const PCHAR)"HMI", 7, HMIModulesGroup },
+ {(const PCHAR)"Navigation", 8, NavigationModulesGroup },
+ {(const PCHAR)"SoftwareUpdate", 9, SoftwareUpdateModulesGroup },
+ {(const PCHAR)"Networking", 10, NetworkingModulesGroup },
+ {(const PCHAR)"Browser", 11, BrowserModulesGroup },
+};
+
+#endif // SS_SM_LAUNCH_CONFIGURATION_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_sm_signals.h b/systemservice/system_manager/server/include/ss_sm_signals.h
new file mode 100755
index 0000000..4c52b32
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_signals.h
@@ -0,0 +1,32 @@
+/*
+ * @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 supports process termination.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_SIGNALS_H_ // NOLINT
+#define SS_SM_SIGNALS_H_
+
+#include <signal.h>
+
+#define SS_SM_ABORT_SIGNAL (SIGABRT)
+#define SS_SM_KILL_SIGNAL (SIGKILL)
+#define SS_SM_TERMINATE_SIGNAL (SIGTERM)
+
+#endif // SS_SM_SIGNALS_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_sm_systemmanagerlog.h b/systemservice/system_manager/server/include/ss_sm_systemmanagerlog.h
new file mode 100755
index 0000000..0499751
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_systemmanagerlog.h
@@ -0,0 +1,91 @@
+/*
+ * @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 supports agl application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SS_SM_SYSTEMMANAGERLOG_H__ // NOLINT
+#define __SS_SM_SYSTEMMANAGERLOG_H__
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_FUNC_IPC ZONEMASK(13)
+#define ZONE_APP_LAUNCH ZONEMASK(14)
+#define ZONE_ACTIVE_INDEX ZONEMASK(15)
+#define ZONE_CONFIG_TABLE ZONEMASK(16)
+#define ZONE_FUNC_ARGS ZONEMASK(17)
+#define ZONE_LOG_FILE ZONEMASK(18)
+#define ZONE_MSG ZONEMASK(19)
+#define ZONE_TIMER ZONEMASK(20)
+#define ZONE_LAUNCH_TIME ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_UNUSED ZONEMASK(23)
+#define ZONE_PERIODIC_FUNC ZONEMASK(24)
+#define ZONE_PERIODIC_INFO ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_DYNAMIC_LNCH ZONEMASK(27)
+#define ZONE_STATE ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_SYSLOG ZONE_SYSTEMDATA
+#define ZONE_PERFORM ZONE_PERFORMANCE
+#define ZONE_PROC_LAUNCH_INFO ZONE_FUNC
+
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 "Ipc Function"
+#define ZONE_TEXT_14 "Active Index"
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 "Config Table"
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 "Ipc Info"
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN, ZONE_ERR, ZONE_STATE, ZONE_SYSLOG, ZONE_PERFORM, ZONE_NS_WAR, ZONE_NS_ERR
+#endif // FRAMEWORKUNIFIEDLOGAPPZONES
+
+#endif // __SS_SM_SYSTEMMANAGERLOG_H__ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_sm_version.h b/systemservice/system_manager/server/include/ss_sm_version.h
new file mode 100755
index 0000000..ea0a775
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_sm_version.h
@@ -0,0 +1,39 @@
+/*
+ * @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 module version management.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_VERSION_H_ // NOLINT
+#define SS_SM_VERSION_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include "ss_sm_process_launcher_protocol.h"
+
+class CSMVersion {
+ public:
+ CSMVersion();
+ ~CSMVersion();
+ EFrameworkunifiedStatus get_version(SS_VersionNumberType& f_VersionNumber); // NOLINT
+ EFrameworkunifiedStatus get_build_info(std::string& f_buildInfoStr); // NOLINT
+
+ private:
+};
+#endif // SS_SM_VERSION_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_system_manager.h b/systemservice/system_manager/server/include/ss_system_manager.h
new file mode 100755
index 0000000..12d5bad
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_system_manager.h
@@ -0,0 +1,760 @@
+/*
+ * @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 business logic.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SS_SYSTEM_MANAGER_H__ // NOLINT
+#define __SS_SYSTEM_MANAGER_H__
+
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_error_event_common_local.h>
+#include <system_service/ss_system_timer.h>
+#include <crashdetector/ss_crashdetector.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <heartbeat/ss_hb_if.h>
+#include <other_service/PosixBasedOS001ClockCycleApi.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_system_manager_conf.h>
+#include <system_service/ss_system_manager_protocol_local.h>
+#include <system_service/ss_logger_store_logs.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/frameworkunified_types.h>
+#include <power_hal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <inttypes.h>
+#include <map>
+#include <string>
+#include <vector>
+#include <queue>
+#include <sstream>
+#include <set>
+#include <list>
+#include <utility>
+
+#include "ss_sm_config.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_system_thread_info.h"
+#include "ss_system_memory_monitor.h"
+#include "ss_sm_dynamic_launcher.h"
+
+static_assert((SS_SM_PROG_UPDATE_STATE_NONE == PWR_PROGUPDATE_STATE_NONE),
+ "SS_SM_PROG_UPDATE_STATE_NONE should be equal to "
+ "PWR_PROGUPDATE_STATE_NONE");
+static_assert((SS_SM_PROG_UPDATE_STATE_UPDATED == PWR_PROGUPDATE_STATE_UPDATED),
+ "SS_SM_PROG_UPDATE_STATE_UPDATED should be equal to "
+ "PWR_PROGUPDATE_STATE_UPDATED");
+static_assert((SS_SM_PROG_UPDATE_STATE_MAP_UPDATED ==
+ PWR_PROGUPDATE_STATE_MAP_UPDATED),
+ "SS_SM_PROG_UPDATE_STATE_MAP_UPDATED should be equal to "
+ "PWR_PROGUPDATE_STATE_MAP_UPDATED");
+static_assert((SS_SM_PROG_UPDATE_STATE_MAPDIFF_UPDATED ==
+ PWR_PROGUPDATE_STATE_MAPDIFF_UPDATED),
+ "SS_SM_PROG_UPDATE_STATE_MAPDIFF_UPDATED should be equal to "
+ "PWR_PROGUPDATE_STATE_MAPDIFF_UPDATED");
+
+#define SM_SHUTDOWN_COMPLETE_MONITOR_TIMEOUT 60
+
+typedef enum {
+ eSM_TIMER_GROUP_MONITOR = 0x00
+ , eSM_TIMER_PROCESS_LAUNCH_MONITOR
+ , eSM_TIMER_HEARTBEAT_MONITOR
+ , eSM_TIMER_PROCESSLAUNCHER_MONITOR
+ , eSM_TIMER_CLIENT_START_MONITOR
+ , eSM_TIMER_NPP_STATUS_CHECK_MONITOR
+ , eSM_TIMER__CWORD56__HEARTBEAT_RESPONSE
+ , eSM_TIMER_LAUNCH_GROUP_TRIGGER_PROC_RESP_TIMER
+ , eSM_TIMER_GROUP_LAUNCH_WAIT_TIMER
+ , eSM_TIMER_MODULE_CONNECT_WAIT_TIMER
+ , eSM_TIMER_START_RESP_MONITOR_WAIT_TIMER
+ , eSM_TIMER_SHUTDOWN_COMPLETE_MONITOR
+ , eSM_TIMER_CLIENT_STOP_MONITOR
+ , eSM_TIMERS_END
+} ESMTimerIDs;
+
+typedef enum {
+ eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ
+ , eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN
+ , eSM_ERROR_EVENT_TIMER_BOOT_MICRO_LOG_RSPN
+ , eSM_ERROR_EVENT_TIMER_CORE_FILE_POLL
+ , eSM_ERROR_EVENT_TIMER_END
+} ESMErrorEventTimers;
+
+typedef enum {
+ eErrorEventResetTypeNone = 0,
+ eErrorEventResetTypeHard
+} EErrorEventResetType;
+
+typedef enum _ESMInternalProtocol {
+ SS_SM_SendTriggerToSelf = SS_SM_PROTOCOL_INTERFACE_END ///< System Manager to System Manager
+} ESMInternalProtocol;
+
+typedef enum _SS_SMGroupHirarchy {
+ SS_SM_INVALID_GROUP = 0
+ , SS_SM_INITIAL_GROUP
+ , SS_SM_SECOND_GROUP
+ , SS_SM_THIRD_GROUP
+} SS_SMGroupHirarchy;
+
+typedef enum _SS_SMModuleState {
+ SS_SM_READY_TO_LAUNCH_APP = 0x00
+ , SS_SM_APPS_LAUNCH_IN_PROGRESS
+ , SS_SM_APPS_LAUNCHED_READY_TO_START
+ , SS_SM_APPS_START_IN_PROGRESS
+ , SS_SM_APPS_START_COMPLETE
+ , SS_SM_APPS_STOPPING_AT__CWORD56__REQ
+ , SS_SM_APPS_STOPPING_AT_INTERNAL_REQ
+ , SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ
+ , SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ
+ , SS_SM_APPS_PRE_START_IN_PROGRESS
+ , SS_SM_APPS_PRE_STOP_IN_PROGRESS
+ , SS_SM_APPS_PRE_RUN_COMPLETE
+ , SS_SM_APPS_BACKGROUND_START_IN_PROGRESS
+ , SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS
+ , SS_SM_APPS_BACKGROUND_RUN_COMPLETE
+} SS_SMModuleState;
+
+typedef struct _SMProcessExitInfo {
+ _SMProcessExitInfo() {
+ this->pid = 0;
+ this->exitValue = 0;
+ this->signalNumber = 0;
+ this->binaryFileName[0] = '\0';
+ }
+
+ UI_32 pid;
+ SI_32 exitValue;
+ SI_32 signalNumber;
+ CHAR binaryFileName[MAX_PATH_LENGTH];
+} SMProcessExitInfo;
+
+typedef struct _SMLoggingInfo { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ _SMLoggingInfo() {
+ this->pid = 0;
+ this->exitValue = 0;
+ this->signalNumber = 0;
+ this->binaryFileName[0] = '\0';
+ this->messageStr = "";
+ this->suffixStr = "";
+ this->path = "";
+ this->resetReason = e_SS_SM_CPU_RESET_REASON_INVALID;
+ }
+
+ UI_32 pid;
+ SI_32 exitValue;
+ SI_32 signalNumber;
+ CHAR binaryFileName[MAX_PATH_LENGTH];
+ std::string messageStr;
+ std::string suffixStr;
+ std::string path;
+ ESMCpuResetReason resetReason;
+} SMLoggingInfo;
+
+struct ERROR_EVENT_INFO { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ ERROR_EVENT_INFO() :
+ m_eventEnqueueTimeStamp(""),
+ m_moduleQueueName(""),
+ m_eventType(eErrorEventTypeMaxValue),
+ m_prio(eErrorEventPrioDefault),
+ m_uniqueCycles(ClockCycle()), // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ m_errorEventResetType(eErrorEventResetTypeNone) { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ std::string m_eventEnqueueTimeStamp;
+ std::string m_moduleQueueName;
+ EErrorEventType m_eventType;
+ SMLoggingInfo m_loggingInfo;
+ EErrorEventPrio m_prio;
+ UI_64 m_uniqueCycles;
+ EErrorEventResetType m_errorEventResetType;
+};
+
+struct ERROR_EVENT_COMPARE {
+ bool operator() (const ERROR_EVENT_INFO& lhs,
+ const ERROR_EVENT_INFO& rhs) const {
+ if ((eErrorEventPrioDefault == lhs.m_prio) &&
+ (eErrorEventPrioDefault == rhs.m_prio)) {
+ return (lhs.m_uniqueCycles < rhs.m_uniqueCycles);
+ } else {
+ return (lhs.m_prio > rhs.m_prio);
+ }
+ }
+};
+
+typedef std::set<ERROR_EVENT_INFO, ERROR_EVENT_COMPARE> ERROR_EVENT_QUEUE;
+typedef ERROR_EVENT_QUEUE::iterator ERROR_EVENT_QUEUE_ITER;
+typedef std::pair<ERROR_EVENT_QUEUE_ITER, BOOL> ERROR_EVENT_QUEUE_RET;
+
+typedef EFrameworkunifiedStatus (*HndlrCb)(HANDLE hApp);
+typedef EFrameworkunifiedStatus (*FncCbType2)(HANDLE hApp, UI_32 f_UI_32);
+typedef BOOL (*FncCbType3)(UI_32 f_UI_32);
+
+typedef std::pair<SS_SystemManagerProtocol, Pwr_ServiceSetInterface> SM_POWER_EVENT_INFO;
+typedef std::queue<SM_POWER_EVENT_INFO> SM_POWER_EVENT_QUEUE;
+
+typedef struct {
+ std::string m_cmd;
+ UI_64 m_time;
+ std::string m_sender;
+} Ts_cmdHist;
+
+typedef std::list<std::string> ErrorGroupList;
+typedef ErrorGroupList::iterator ErrorGroupListIter;
+
+typedef std::vector<Ts_cmdHist> cmdHist;
+typedef cmdHist::iterator cmdHistIter;
+
+typedef std::vector<std::string> HBList;
+typedef HBList::iterator HBListIter;
+
+class CVersionNumInfo {
+ public:
+ CVersionNumInfo() : m_VersionNumber(0), m_eSystemmanagerStatus(eFrameworkunifiedStatusErrOther) {}
+ CVersionNumInfo(SS_VersionNumberType f_vn, EFrameworkunifiedStatus f_eStatus)
+ : m_VersionNumber(f_vn), m_eSystemmanagerStatus(f_eStatus) {}
+
+ // System Manager's local data store; write once on initialization,
+ // read as needed at clients' request
+ SS_VersionNumberType m_VersionNumber;
+ EFrameworkunifiedStatus m_eSystemmanagerStatus; // Validity / status of version number
+};
+
+#define SS_SM_RELAUNCH_NO_LIMIT -1
+typedef struct _PreLaunchModuleParams {
+ _PreLaunchModuleParams() {
+ this->LaunchFunc = NULL;
+ this->name = "";
+ this->binaryFileName = "";
+ this->critical = FALSE;
+ this->relaunchLimit = 0;
+ this->pid = -1;
+ this->relaunchCount = 0;
+ }
+
+ int (*LaunchFunc)(); // Launching function
+ std::string name; // Process name
+ std::string binaryFileName; // Binary file name
+ BOOL critical; // Reboot attribute
+ int relaunchLimit; // Maximum number of Relaunch
+ int pid; // pid
+ int relaunchCount; // Count of Relaunching
+} PreLaunchModuleParams;
+
+typedef std::list<PreLaunchModuleParams> PreLaunchModuleList;
+typedef PreLaunchModuleList::iterator PreLaunchModuleListIter;
+
+typedef struct _GroupRelaunchModuleParams {
+ _GroupRelaunchModuleParams() {
+ this->name = "";
+ this->bIsKilled = FALSE;
+ }
+
+ std::string name; // Process name
+ BOOL bIsKilled; // Flag indicates while forced quit process
+} GroupRelaunchModuleParams;
+
+typedef std::list<GroupRelaunchModuleParams> GroupRelaunchModuleList;
+typedef GroupRelaunchModuleList::iterator GroupRelaunchModuleListIter;
+
+
+class CSystemManager {
+ public:
+ static std::string m_bootOpt; // BOOT OPTION
+
+ CSystemManager();
+ virtual ~CSystemManager();
+
+ static CSystemManager & GetInstance();
+ EFrameworkunifiedStatus Initialize(HANDLE hApp);
+ void Initialize_memory(HANDLE hApp, bool* l_isInitFail, EFrameworkunifiedStatus* l_eStatus, BOOL isIllReset);
+ void Initialize_callbacks(HANDLE hApp, bool *l_isInitFail, EFrameworkunifiedStatus *l_eStatus);
+ /// < Process Launcher Thread Callbacks
+ EFrameworkunifiedStatus OnModuleLaunchResponse(HANDLE hApp);
+ EFrameworkunifiedStatus OnTerminateModuleResponse(HANDLE hApp);
+ EFrameworkunifiedStatus OnReLaunchModuleResponse(HANDLE hApp);
+ EFrameworkunifiedStatus PerformModuleLaunchRespProcessing(HANDLE hApp,
+ GroupLaunchMapIter & f_GroupIter, // NOLINT
+ ModuleLaunchListIter & f_ModuleIter, // NOLINT
+ PCSTR p_sPPD_tag);
+ EFrameworkunifiedStatus OnModuleStatusResponse(HANDLE hApp);
+ EFrameworkunifiedStatus OnGroupLaunchTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnLaunchGroup(HANDLE hApp);
+ EFrameworkunifiedStatus OnLaunchGroupSelfTrigger(HANDLE hApp);
+ EFrameworkunifiedStatus OnProcessLaunchTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnHeartBeatMonitorTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnProcessLaunchMonitorTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnHeartBeatThreadHeartbeatResponse(HANDLE hApp);
+ EFrameworkunifiedStatus OnCheckAvailResponse(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnProcessLauncherThreadHeartbeatResponse(HANDLE hApp);
+ EFrameworkunifiedStatus OnClientStartMonitorTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnClientStopMonitorTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnNPPStatusCheckMonitorTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnPowerServiceAvailableNotify(HANDLE hApp);
+ EFrameworkunifiedStatus OnLVI1Notify(HANDLE hApp);
+ EFrameworkunifiedStatus OnLVI2Notify(HANDLE hApp);
+
+ EFrameworkunifiedStatus OnModuleStartCompleteResponse(HANDLE hApp); /// Process start complete from client
+ EFrameworkunifiedStatus OnModuleStopCompleteResponse(HANDLE hApp); /// Process stop Complete from client
+ EFrameworkunifiedStatus OnGetStartExtInfo(HANDLE hApp);
+ EFrameworkunifiedStatus OnGetStopExtInfo(HANDLE hApp);
+ EFrameworkunifiedStatus OnModuleStopCompleteNotification(HANDLE hApp);
+ EFrameworkunifiedStatus ProcessModuleStopCompleteResponse(HANDLE hApp,
+ PCSTR f_moduleName);
+ EFrameworkunifiedStatus ModuleCompleteResponse(HANDLE hApp,
+ ModuleLaunchListIter f_ModuleListIter,
+ SMModuleState f_moduleState,
+ FncCbType3 f_isGroupDoneFnc,
+ FncCbType2 f_groupDoneFnc,
+ PCSTR f_sCompleteTypeText);
+
+ EFrameworkunifiedStatus ProcessGroupOnModuleStopResponse(HANDLE hApp, UI_32 f_groupID);
+
+
+
+ EFrameworkunifiedStatus OnLaunchGroupTriggerProcessResponseTimerExpiry(HANDLE hApp);
+
+ EFrameworkunifiedStatus OnNppStopComplete(HANDLE hApp); /// Process stop Complete from NPPService
+ EFrameworkunifiedStatus OnOpenSession(HANDLE hApp); /// Process open session request
+ EFrameworkunifiedStatus OnCloseSession(HANDLE hApp); /// Process close session acknowledgment
+
+ EFrameworkunifiedStatus CloseApplication(HANDLE hApp);
+ EFrameworkunifiedStatus OnGetAppInfo(HANDLE hApp);
+
+ /// < Heartbeat Thread Callbacks
+ EFrameworkunifiedStatus OnHeartBeatErrorReport(HANDLE hApp);
+
+ EFrameworkunifiedStatus OnCurrentSMStateQuery(HANDLE hApp);
+
+ EFrameworkunifiedStatus OnNPPReadyStatusCallback(HANDLE hApp);
+ EFrameworkunifiedStatus OnNPPReadyEventCallback(HANDLE hApp);
+ EFrameworkunifiedStatus OnWakeupCallback(HANDLE hApp);
+ EFrameworkunifiedStatus OnPowerRequestCallback(HANDLE hApp);
+ EFrameworkunifiedStatus OnBackupMgrAvailCallback(HANDLE hApp);
+ EFrameworkunifiedStatus OnShutdownModulesRequest(HANDLE hApp);
+ EFrameworkunifiedStatus OnSystemModeInfoRequest(HANDLE hApp);
+ EFrameworkunifiedStatus ClearDramBackupInfo(HANDLE hApp);
+ EFrameworkunifiedStatus OnInitCompReportCallback(HANDLE hApp);
+ EFrameworkunifiedStatus SetEnvVariableForVupMode(BOOL bIsVupMode);
+ static int CreateRtUsb();
+ EFrameworkunifiedStatus SecureChipOff();
+ EFrameworkunifiedStatus CallStopCompleteHandler(HANDLE hApp, BOOL bISDetectTimeout = FALSE);
+
+ EFrameworkunifiedStatus On_CWORD56_HeartBeatRequest(HANDLE hApp);
+ EFrameworkunifiedStatus On_CWORD56_HeartBeatResponseIntervalTimerExpiry(HANDLE hApp);
+ EFrameworkunifiedStatus OnGroupLaunchWaitTimeout(HANDLE hApp);
+ EFrameworkunifiedStatus OnModuleConnectWaitTimeout(HANDLE hApp);
+ EFrameworkunifiedStatus OnStartRespMonitorTimeout(HANDLE hApp);
+ EFrameworkunifiedStatus OnShutdownCompleteMonitorTimeout(HANDLE hApp);
+ EFrameworkunifiedStatus PerformCpuReset(HANDLE hApp, ESMCpuResetReason f_eSmCpuResetReason, std::string f_messageStr = ""); // NOLINT
+ EFrameworkunifiedStatus OnCpuResetRequest(HANDLE hApp);
+ EFrameworkunifiedStatus OnSetDataResetModeRequest(HANDLE hApp);
+ EFrameworkunifiedStatus OnSetProgUpdateStateRequest(HANDLE hApp);
+ EFrameworkunifiedStatus OnLaunchGroupTriggerProcessResponse(HANDLE hApp);
+ EFrameworkunifiedStatus OnSetNextWakeupTypeRequest(HANDLE hApp);
+
+ bool GetDramPowerStatusInfo(const HANDLE h_app);
+ bool GetDramStoreStatusInfo(const HANDLE h_app);
+ bool GetSyscomPowerStatusInfo(const HANDLE h_app);
+ //
+ // Start Confirmation, Get _CWORD56_ Version callback functions
+ EFrameworkunifiedStatus OnSetStartupConfirmationDataRequest(HANDLE hApp);
+
+ void SystemManagerDebugDump(HANDLE hApp);
+
+
+ private:
+ CThreadInfo m_hHeartbeatThread; // Handle to Heartbeat Thread
+ CThreadInfo m_hProcLauncherThread; // Handle to Process Launcher Thread
+ UI_32 m_SystemLaunchProgress; // Launch Progress of system
+ TimerCtrl * m_GroupLaunchTimer; // Launch Monitor Timer
+ UI_32 m_aTimerIDs[eSM_TIMERS_END]; // TimerIDs returned by create timer
+ PreLaunchModuleList m_PreLaunchModuleList; // List of modules that shuuld be launched preliminarily.
+ GroupRelaunchModuleList m_GroupRelaunchModuleList; // List of modules that need to relaunch
+ UI_32 m_GroupRelaunchCount; // Count for group relaunch
+ UI_32 m_GroupRelaunchLimit; // Limit for group relaunch
+ GroupLaunchMap m_MapProclaunchGrps; // Map of modules that should be launched.
+ ProcessNameMap m_MapProcNames; // Map of module binary names to queue names.
+ HANDLE m_hPowerServiceSession;
+ UI_32 m_ActiveGroupId; // Modules of Group to whom START/STOP has been sent
+ wakeInfo m_Wake; // WakeUp data from power
+ EPWR_WAKEUP_FACTOR_TYPE m_StartUpReason; // System Manager preserve start up reason
+ ESMDataResetModeInfo m_DataResetMode; // Data Reset Mode
+ SMProgUpdateState m_ProgUpdateState; // ProgUpdate State
+ ESMNextWakeupType m_NextWakeupType; // Next Progupdate State
+ ESMDramBackupStatus m_DramBackupStatus; // Dram Backup Status
+ BOOL m_isIlgReset; // Error Detected by SYS-ucon
+ ESMResetStatus m_ResetStatus; // Reset Status
+ UI_32 m_ResetCount; // Reset Count
+ T_SS_SM_INIT_HOOK_OUT_PARAM m_productCustomPrm; // Product customized parameters
+
+ SS_SMModuleState m_SMCurrentState; // Current state of System Manager
+ UI_32 m_MaxShutdownTime; // Calculate Max shutdown time based on info from xml
+ UI_32 m_NbrDebugDumpRspnRecv; // Total number of debug dump responses received.
+ BOOL m_isRcvModeInfo;
+ SystemModeInfo m_SystemModeInfo; // System Mode Info, SM to read data from persistent file at start
+ SS_String m_BinaryFilesPath; // Store binary files path
+ SS_String m_ConfigFilesPath; // Store config files path
+ ConfigurationData m_SMConfig; // Configuration Data of System Manager and its threads
+ HndlrCb m_pfStopCompleteHandler;
+ CVersionNumInfo m_VersionNumberStruct;
+ SS_String m_BuildInfoStr;
+
+ BOOL m_isRstPending;
+ TSystemManagerCpuResetInfo m_rstPendingInfo;
+
+ SM_POWER_EVENT_QUEUE m_dqDeferMsg;
+ BOOL m_UsingVMPlayer; // Running on a VMPlayer ?
+ UI_32 NVM_VALID_SIGNATURE;
+ StartupConfirmationMsgStrut m_startUpConfirmationMsg;
+ EPWR_USER_MODE_TYPE m_lastUserMode;
+ EPWR_SHUTDOWN_TRIGGER_TYPE m_shutdownTrigger; // Set from Shutdown_Request
+ // msg from _CWORD56_, sent to
+ // all modules as part of
+ // SS_SM_STOP msg.
+ BOOL m_isImmediateReset;
+ BOOL m_isImmResetReq;
+ BOOL m_needReNotifyStartPrm;
+ CHAR *m_pVarCodeStr;
+ GroupLaunchMapIter m_SSLGroupLaunchMapIterator;
+ ModuleLaunchListIter m_ModuleLaunchListIter;
+ BOOL m_bIsNPP_ServicesStarted;
+ BOOL m_bIsBackupAvail;
+ //
+ DynamicLauncher m_oSystemLauncher;
+ DynamicModuleStart m_SystemStarter;
+ //
+ BOOL m_NPPStopSent;
+ ePwrServiceUserModeChangeReasonType m_userModeChangeReason;
+
+ HBList m_HBList;
+
+ cmdHist m__CWORD56_CmdHist;
+ cmdHistIter m__CWORD56_HistIter;
+ cmdHist m_SMCmdHist;
+ cmdHistIter m_SMHistIter;
+ cmdHist m_TimerCmdHist;
+ cmdHistIter m_TimerHistIter;
+ cmdHist m_PubCmdHist;
+ cmdHistIter m_PubHistIter;
+ cmdHist m_ErrHist;
+ cmdHistIter m_ErrHistIter;
+
+ pthread_mutex_t sm_hist_mutex;
+
+ bool m_InitialBoot;
+
+ PsmFactorT m_ResetFactor; // reset(start-up) factor.
+
+ void SetCmdHist(std::string cmd, cmdHist &hist, cmdHistIter &it, std::string sender); // NOLINT
+
+ // ILGRST or ACCOFFON Logging
+ bool StoreDebugLogs(const HANDLE h_app, SS_STORELOGS_OPE_TYPE);
+
+ UI_32 InProgressStateToSendMsg() const;
+ SMModuleState InProgressStateToState() const;
+
+ //************************************************************************
+ // Error Event Logging *
+ //
+ int m_ClProcessSigFd;
+ CSysMemoryMonitor m_SysMemMonitor;
+
+ UI_32 m_FreeMemAvailable;
+ off_t m_coreFileSizeBytes;
+ THbReportData m_HBReport;
+ eSMBootMicroResetReason m_BootMicroResetReason;
+ BOOL m_errorEventQueueLocked;
+ ERROR_EVENT_QUEUE m_errorEventQueue;
+ Timer m_errorEventTimers[eSM_ERROR_EVENT_TIMER_END];
+ BOOL m_isPrevErrEventCompleted;
+ EFrameworkunifiedStatus m_errorEventResult;
+ EArtifactId m_requestedArtifactId;
+ ERROR_EVENT_QUEUE_ITER m_errorEventCurrentIter;
+ // *
+ // End of Error Event Logging *
+ //************************************************************************
+
+
+ ////******************************************************************////
+ //// enum<=>enum maps ////
+ //
+ //
+ // EPWR_POWER_STATE_TYPE <=> BOOL
+ std::map<EPWR_POWER_STATE_TYPE, BOOL> m_PowerType_to_SSBoolEnumMap;
+ std::map<EPWR_POWER_STATE_TYPE, EPWR_USER_MODE_TYPE>
+ m_PowerType_to_SSUserModeEnumMap;
+ std::map<BOOL, EPWR_POWER_STATE_TYPE> m_SSBool_to_PowerTypeEnumMap;
+ //
+ // User Mode
+ std::map<EPWR_USER_MODE_TYPE, BOOL> m_SSUserMode_to_SSBoolEnumMap;
+ std::map<BOOL, EPWR_USER_MODE_TYPE> m_SSBool_to_SSUserModeEnumMap;
+
+ //
+ //// End of enum<=>enum maps ////
+ ////******************************************************************////
+
+ EFrameworkunifiedStatus init_process_launcher(HANDLE hApp);
+ EFrameworkunifiedStatus start_process_launching(HANDLE hApp);
+ EFrameworkunifiedStatus init_Heartbeat(HANDLE hApp);
+ EFrameworkunifiedStatus init_crash_detector(HANDLE hApp);
+ EFrameworkunifiedStatus init_sysmem_monitor(HANDLE hApp);
+ EFrameworkunifiedStatus SendRequestToHeartBeat(HANDLE hAPP, EHBProtocolMessages, VOID *, UI_32);
+ EFrameworkunifiedStatus send_launch_status(HANDLE hApp, UI_32 u32LaunchState);
+
+ EFrameworkunifiedStatus register_all_notification_callbacks(HANDLE hApp);
+ VOID SMStateStartCompleteEntry(HANDLE hApp);
+ VOID SMStateEntry(HANDLE hApp, SS_SMModuleState l_SMState);
+ VOID SMStateExit(HANDLE hApp, SS_SMModuleState l_SMState);
+ VOID SMSetState(HANDLE hApp, SS_SMModuleState l_SMState);
+
+ // Wakeup from Power
+ EFrameworkunifiedStatus BeginStartup(HANDLE hApp);
+ EFrameworkunifiedStatus start_all_modules_of_group(HANDLE hApp, UI_32 f_ui32GroupNumber);
+ EFrameworkunifiedStatus send_power_request_complete_response(HANDLE hApp,
+ std::string pStr);
+ BOOL have_all_services_start_completed(const SMModuleState f_moduleState);
+
+ // Power Off from Power
+ EFrameworkunifiedStatus PublishPowerOnOffNotification(HANDLE hApp);
+
+ // Shutdown from Power
+ EFrameworkunifiedStatus stop_all_modules_of_group(HANDLE hApp);
+ UI_32 calculate_max_shutdown_time();
+ BOOL is_service_shutdown_ready(ModuleLaunchListIter &modIte); // NOLINT
+ BOOL have_critical_services_stopped();
+ VOID check_all_groups_have_stopped(HANDLE hApp);
+ EFrameworkunifiedStatus perform_force_reset(HANDLE hApp);
+ EFrameworkunifiedStatus send_shutdown_complete_response(HANDLE hApp);
+ EFrameworkunifiedStatus SendShutdownResponseMessage(HANDLE hApp);
+
+ PsmFactorT GetResetFactor(PCSTR f_module_name, BOOL f_user_reset);
+ PsmFactorT GetResetFactor(const ModuleLaunchListIter f_module_iter, BOOL f_user_reset);
+
+ EFrameworkunifiedStatus ValidateUserModeMessage(HANDLE hApp, EPWR_USER_MODE_TYPE &l_eUserModeState); // NOLINT
+
+ VOID SetStartGroup();
+
+ VOID ReadPathFromEnvironmentVariables();
+ SS_String ReadConfigDataFileNameFromEnvironmentVariable();
+ SS_String ReadLaunchConfigFileNameFromEnvironmentVariable();
+
+
+ VOID ReadUsingVMPlayerEnvironmentVariable();
+
+ VOID InitiateAllGroupsShutdown(HANDLE hApp);
+ VOID SendDeferMsg(HANDLE hApp);
+ EFrameworkunifiedStatus GetVersionNumber(SS_VersionNumberType &f_VersionNumber); // NOLINT
+ EFrameworkunifiedStatus GetBuildInfo(std::string &f_BuildInfoStr); // NOLINT
+ EFrameworkunifiedStatus RegisterCallbacksForRequester(HANDLE hApp, PCSTR pRequester);
+ EFrameworkunifiedStatus SetSystemModeInfoStruct();
+
+ EFrameworkunifiedStatus PerformLaunchProcedure(HANDLE hApp
+ , ModuleLaunchListIter f_ModuleIterator
+ , SS_String & f_stopCompName); // NOLINT
+
+ EFrameworkunifiedStatus PerformTerminateProcedure(HANDLE hApp
+ , ModuleLaunchListIter f_ModuleIterator
+ , SS_String & f_availabilityName
+ , SS_String & f_stopCompName); // NOLINT
+
+ EFrameworkunifiedStatus SendRequestToLauncher(HANDLE hApp
+ , ModuleLaunchListIter f_ModuleIterator
+ , ESMPLThreadCommandIds f_CommandId
+ , SS_String f_CommandIdStr);
+
+ EFrameworkunifiedStatus FindNameOfTerminatedProcess(SI_32 pid, SS_String &f_ModuleName); // NOLINT
+
+ EFrameworkunifiedStatus GetBinaryNameOfProcess(SS_String f_ModuleQueueName,
+ SS_String &f_ModuleBinaryName); // NOLINT
+
+ EFrameworkunifiedStatus RemoveModuleEntryFromHB(HANDLE hApp, const CHAR *f_ModuleName);
+
+ EFrameworkunifiedStatus PublishUserModeNotification(HANDLE hApp);
+ EFrameworkunifiedStatus PerformPowerOnOffUserModePublication(
+ HANDLE hApp,
+ const char * p_NotificationStr);
+ EFrameworkunifiedStatus SendSystemModeInfoResponse(
+ HANDLE hApp,
+ EPWR_STARTUP_STAGE_TYPE f_startupStage);
+
+ VOID SYSTEMMANAGERLOG_StartupConfirmationMsg(EPWR_SC_MSG_STRUCT & f_scMsg); // NOLINT
+ VOID LogGroupModulesState(UI_32 f_groupId, std::string pStr);
+ VOID LogAllGroupModulesState(std::string pStr);
+
+ EFrameworkunifiedStatus ProcessGroupAsStarted(HANDLE hApp
+ , GroupLaunchMapIter f_GroupIterator);
+ EFrameworkunifiedStatus ProcessGroupAsStarted(HANDLE hApp
+ , UI_32 f_groupId);
+ EFrameworkunifiedStatus GetModuleIterator(PCSTR f_moduleName, ModuleLaunchListIter & f_moduleIter); // NOLINT
+ BOOL IsGroupStarted(UI_32 f_groupId);
+ BOOL IsGroupStopped(UI_32 f_groupId);
+ EFrameworkunifiedStatus ResetModulesStateToConnected(HANDLE hApp);
+
+ EFrameworkunifiedStatus GetTimeStamp(std::string& TimeStamp); // NOLINT
+ std::string GetErrorEventInString(UI_32 &ErrorEventType); // NOLINT
+ EFrameworkunifiedStatus GetLastSourceInfo(SS_SOURCE &source_type); // NOLINT
+ //
+ // Return True when Module is in correct / appropriate state wrt SM state
+ // return false otherwise
+ BOOL GetModuleCondition(ModuleLaunchListIter & f_ModuleIter); // NOLINT
+
+ VOID LogESystemmanagerStatusEnums();
+ VOID LogProtocolIDs();
+
+ VOID SystemmanagerLogString(TFrameworkunifiedZone f_zone,
+ PCSTR f_func,
+ std::string &f_text); // NOLINT
+
+ inline BOOL is_current_state(SS_SMModuleState SMState) {
+ return (m_SMCurrentState == SMState);
+ }
+
+ //**************************************************************************
+ // Get results from TestClient *
+ // *
+ EFrameworkunifiedStatus add_state_information_to_response(CHAR *f_MessageResponse) const;
+ EFrameworkunifiedStatus construct_get_result_response(CHAR *f_MessageResponse); // *
+ EFrameworkunifiedStatus open_session_with_sm_test_client(HANDLE hApp, // *
+ PCSTR pRequester); // *
+ // *
+ // End of 'Get results from TestClient' *
+ //**************************************************************************
+
+ //************************************************************************
+ // Error Event Logging *
+ // *
+ EFrameworkunifiedStatus ErrorEventInit(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnHeartBeatErrorDetected(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnProcessTermDetected(HANDLE f_hApp);
+ BOOL isPreLaunchedProcess(int f_pid);
+ EFrameworkunifiedStatus OnPreLaunchedProcessTermDetected(HANDLE f_hApp,
+ SMProcessExitInfo &f_procExitInfo, // NOLINT
+ BOOL f_bIsExited);
+ EFrameworkunifiedStatus OnProcessCrashDetected(HANDLE f_hApp,
+ SMProcessExitInfo &f_procExitInfo); // NOLINT
+ EFrameworkunifiedStatus OnProcessExitDetected(HANDLE f_hApp,
+ SMProcessExitInfo &f_procExitInfo); // NOLINT
+
+ EFrameworkunifiedStatus OnUserInvokedLoggingRequest(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnEelExportRequest(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnSystemmanagerEmmcLogsRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnSystemmanagerClearLogsRequest(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnDiagLoggingRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnCANLoggingRequest(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnPropagateSystemError(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnCaptureAllLogsRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnCaptureScreenShotRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnCaptureSystemmanagerLogsRequest(HANDLE f_hApp);
+
+
+ EFrameworkunifiedStatus OnBootMicroResetNotification(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnObtainBootMicroLog(HANDLE f_hApp);
+ EFrameworkunifiedStatus RequestBootMicroLog(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnBootMicroLogResponse(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnErrorEventBootMicroLogResponseTimeout(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnLowSystemMemory(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainSystemmanagerSystemDataCsv(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainShowMemTxt(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnErrorEventCoreFilePollTimeout(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnObtainDebugDumpLog(HANDLE f_hApp);
+ EFrameworkunifiedStatus SendDebugDumpRequestToAllModules(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnDebugDumpResponseReceived(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnDebugDumpCompleteTimeout(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus ErrorEventEnqueue(HANDLE f_hApp,
+ EErrorEventType f_eventType,
+ std::string &f_moduleQueueName, // NOLINT
+ EErrorEventResetType f_resetType = eErrorEventResetTypeNone,
+ const SMLoggingInfo &f_loggingInfo = SMLoggingInfo());
+
+ EFrameworkunifiedStatus PerformResetAfterLogging(HANDLE f_hApp,
+ ESMCpuResetReason f_eCpuResetReason,
+ std::string f_messageStr = "");
+
+ EFrameworkunifiedStatus ErrorEventProcessNext(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnLoggingStartRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnErrorEventLoggerStartRequestTimeout(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnErrorEventArtifactRequest(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus SendLogArtifactResponseToLogger(HANDLE f_hApp,
+ EArtifactId f_artifactId,
+ std::string f_artifactFilePathAndName);
+
+ EFrameworkunifiedStatus OnErrorEventLoggingComplete(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus ActOnModuleFailure(HANDLE f_hApp,
+ SS_String f_moduleName,
+ BOOL &f_refResetRequired); // NOLINT
+ std::string ErrorEventCreateHmiDisplayString(void);
+
+ // *
+ // End of Error Event Logging *
+ //************************************************************************
+
+ UI_32 m_SystemManagerPriority;
+};
+#define REC_HIST(pStrCmd, hist, it, pStrSender) \
+ SetCmdHist(pStrCmd, hist, it, pStrSender);
+
+#define REC_HIST_IF_SUCCESSFUL(pStr, hist, it, sender, l_eStatus) \
+ if (eFrameworkunifiedStatusOK == l_eStatus) { \
+ REC_HIST(pStr, hist, it, sender) \
+ }
+
+#define LOG_ERROR_REC_HIST(l_eStatus, pStr) { \
+ LOG_ERROR(pStr); \
+ REC_HIST(pStr, m_ErrHist, m_ErrHistIter, GetStr(l_eStatus).c_str()); \
+ }
+#define LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, pStr) \
+ if (eFrameworkunifiedStatusOK != l_eStatus) { \
+ LOG_ERROR(pStr); \
+ REC_HIST(pStr, m_ErrHist, m_ErrHistIter, GetStr(l_eStatus).c_str()); \
+ } else { \
+ LOG_SUCCESS(pStr); \
+ } // End of #define LOG_STATUS(l_eStatus,pStr)
+
+#define LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, pStr) \
+ if (eFrameworkunifiedStatusOK != l_eStatus) { \
+ LOG_ERROR(pStr); \
+ REC_HIST(pStr, m_ErrHist, m_ErrHistIter, GetStr(l_eStatus).c_str()); \
+ } // End of #define LOG_STATUS_IF_ERRORED(l_eStatus,pStr)
+
+#endif // __SS_SYSTEM_MANAGER_H__ // NOLINT
diff --git a/systemservice/system_manager/server/include/ss_system_manager_callbacks.h b/systemservice/system_manager/server/include/ss_system_manager_callbacks.h
new file mode 100755
index 0000000..e9d5938
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_system_manager_callbacks.h
@@ -0,0 +1,29 @@
+/*
+ * @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 business logic.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SYSTEM_MANAGER_CALLBACKS_H_ // NOLINT
+#define SS_SYSTEM_MANAGER_CALLBACKS_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+#endif // SS_SYSTEM_MANAGER_CALLBACK_H_ // NOLINT
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 100755
index 0000000..50cf857
--- /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 <native_service/frameworkunified_types.h>
+#include <system_service/resm.h>
+#include <system_service/ss_system_timer.h>
+#include <iostream>
+#include <string>
+#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
diff --git a/systemservice/system_manager/server/include/ss_system_thread_info.h b/systemservice/system_manager/server/include/ss_system_thread_info.h
new file mode 100755
index 0000000..f21ad5a
--- /dev/null
+++ b/systemservice/system_manager/server/include/ss_system_thread_info.h
@@ -0,0 +1,45 @@
+/*
+ * @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 thread management.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SYSTEM_THREAD_INFO_H_ // NOLINT
+#define SS_SYSTEM_THREAD_INFO_H_
+
+#include <native_service/frameworkunified_types.h>
+
+typedef enum {
+ eSM_ThreadNotExist
+ , eSM_ThreadCreated
+ , eSMThreadIsFine
+ , eSMWaitForHeartbeat
+ , eSM_ThreadError
+} ESMThreadInfo;
+
+class CThreadInfo {
+ public:
+ CThreadInfo() : m_ThreadHdl(INVALID_HANDLE), m_ThreadState(eSM_ThreadNotExist) {}
+ CThreadInfo(HANDLE hdl, ESMThreadInfo State) : m_ThreadHdl(hdl), m_ThreadState(State) {}
+ public:
+ HANDLE m_ThreadHdl;
+ ESMThreadInfo m_ThreadState;
+};
+
+#endif // SS_SYSTEM_THREAD_INFO_H_ // NOLINT
diff --git a/systemservice/system_manager/server/include/system_launcher_cfg_format.h b/systemservice/system_manager/server/include/system_launcher_cfg_format.h
new file mode 100755
index 0000000..b30b21f
--- /dev/null
+++ b/systemservice/system_manager/server/include/system_launcher_cfg_format.h
@@ -0,0 +1,66 @@
+
+/*
+ * @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 process launching.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SS_SM_LAUNCH_CONFIG_H_ // NOLINT
+#define SS_SM_LAUNCH_CONFIG_H_
+
+#include <native_service/frameworkunified_types.h>
+
+typedef struct _tLaunchParams {
+ const PCHAR group_name;
+ UI_32 group_id;
+ UI_32 group_launch_wait;
+ const PCHAR name;
+ const PCHAR binary_name;
+ UI_32 priority;
+ BOOL critical;
+ UI_32 retry_cnt;
+ const PCHAR arguments;
+ const PCHAR logging_msk_str;
+ const PCHAR restart;
+ BOOL is_start_required;
+ BOOL shutdown_critical;
+ UI_32 shutdown_wait_time;
+ UI_32 fast_shutdown_wait_time;
+
+ public:
+ BOOL IsAGLUnit(void) const { return is_agl_unit; }
+ BOOL IsAGLResetHistoryDisable(void) const { return disable_agl_resethistory; }
+ BOOL IsNonAGLResetHistoryDisable(void) const { return disable_nonagl_resethistory; }
+ void SetAGLUnit(BOOL f_is_agl_unit) { is_agl_unit = f_is_agl_unit; }
+ void SetAGLResetHistoryDisable(BOOL f_disable_agl_resethistory) {
+ disable_agl_resethistory = f_disable_agl_resethistory;
+ }
+ void SetNonAGLResetHisoryDisable(BOOL f_disable_nonagl_resethistory) {
+ disable_nonagl_resethistory = f_disable_nonagl_resethistory;
+ }
+
+ private:
+ BOOL is_agl_unit;
+ BOOL disable_agl_resethistory;
+ BOOL disable_nonagl_resethistory;
+} LaunchInfo;
+
+LaunchInfo g_arrLaunchTableCfg[] = {
+};
+#endif // SS_SM_LAUNCH_CONFIG_H_ // NOLINT
diff --git a/systemservice/system_manager/server/sm_launch__CWORD84_.xml b/systemservice/system_manager/server/sm_launch__CWORD84_.xml
new file mode 100755
index 0000000..1392bbb
--- /dev/null
+++ b/systemservice/system_manager/server/sm_launch__CWORD84_.xml
@@ -0,0 +1,116 @@
+<!-- group_id=1 -->
+<group name="CoreModules" wait_time="0" trigger="False" >
+ <launch
+ name=MN_NS_NPPSERVICE path="/usr/agl/bin/NS_NPPService" priority=PR_NS_NPPSERVICE_S
+ critical="True" retry_cnt="0" arguments="-a SS_SysManager -r output=0x2"
+ restart="NULL" is_start_required="False"
+ shutdown_critical="True" shutdown_wait_time="20" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+ <launch
+ name=MN_NS_BACKUPMGR path="/usr/agl/bin/NS_BackupMgr" priority=PR_NS_BACKUPMGR_S
+ critical="True" retry_cnt="0" arguments="-l console"
+ restart="NULL" is_start_required="True"
+ shutdown_critical="True" shutdown_wait_time="15" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+</group>
+<!-- group_id=2 -->
+<group name="SS_Logger" wait_time="0" trigger="False" >
+ <launch
+ name=MN_SS_LOGGERSRV path="/usr/agl/bin/SS_LoggerService" priority=PR_SS_LOGGERSRV_S
+ critical="True" retry_cnt="0" arguments="-l console -p thrd=pdg.LogQueReader:30,thrd=pdg.TransmitQueReader:30,thrd=pdg.DumpQueReader:11,thrd=pdg.PerformanceQueReader:11,thrd=pdg.LogQueWriter:30,thrd=pdg.TransmitQueWriter:30,thrd=pdg.EvntLogQue:8,thrd=pdg.UdpQueWriter:10"
+ restart="NULL" is_start_required="True"
+ shutdown_critical="True" shutdown_wait_time="10" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+</group>
+<!-- group_id=3 -->
+<group name="ShadowModules" wait_time="0" trigger="False" >
+ <!--
+ In order to excute the termination process promptly, the shutdown_wait_time of GROUP4~ sha be a;; set tp 0,
+ and FrameworkunifiedOnStop shall be issued to the servies of GROUP~ at almost the same time upon termination.
+ Setting shutdown_wait_time in the COMMUNICATION of GROUP3 makes GROUP3 wait for GROUP4~ to terminate service (wait for FrameworkunifiedOnStop responses) all at once.
+ The reason for batch wait by GROUP3 is to save the LOG of tge ternubatuib processing at the time of ACC-OFF of services
+ because the LOG save processing is performed by the GROUP2 termination processing of SS_LoggerService.
+ -->
+ <launch
+ name=MN_COMMUNICATION path="/usr/agl/bin/communication" priority=PR_COMMUNICATION_S
+ critical="True" retry_cnt="0" arguments="-l console"
+ restart="NULL" is_start_required="True"
+ shutdown_critical="False" shutdown_wait_time="20" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+</group>
+
+<!-- group_id=4 -->
+<group name="VehicleModules" wait_time="0" trigger="False" >
+ <launch
+ name=MN_POSITIONING path="/usr/agl/bin/Positioning" priority=PR_POSITIONING_S
+ critical="True" retry_cnt="0" arguments="NULL"
+ restart="NULL" is_start_required="True"
+ shutdown_critical="False" shutdown_wait_time="0" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+</group>
+
+<!-- group_id=5 -->
+<group name="SystemModules" wait_time="0" trigger="False" >
+ <launch
+ name=MN_SS_POWERSERVICE path="/usr/agl/bin/SS_PowerService" priority=PR_SS_POWERSERVICE_S
+ critical="True" retry_cnt="0" arguments="-l console"
+ restart="NULL" is_start_required="True"
+ shutdown_critical="False" shutdown_wait_time="0" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+ <launch
+ name=MN_SS_TASKMANAGER path="/usr/agl/bin/tskmgr" priority=PR_SS_TASKMANAGER_S
+ critical="True" retry_cnt="0" arguments="-l console"
+ restart="NULL" is_start_required="True"
+ shutdown_critical="True" shutdown_wait_time="0" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+ <launch
+ name=MN_SS_RESOURCEMGR path="/usr/agl/bin/resm" priority=PR_SS_RESOURCEMGR_S
+ critical="True" retry_cnt="0" arguments="-l console"
+ restart="NULL" is_start_required="True"
+ shutdown_critical="False" shutdown_wait_time="0" fast_shutdown_wait_time="1000"
+ user_name=""
+ />
+</group>
+<!-- group_id=6 -->
+<!-- group_id=7 -->
+<!-- group_id=8 -->
+<!-- group_id=9 -->
+<!-- group_id=10 -->
+<!-- group_id=11 -->
+<!-- group_id=12 -->
+<!-- group_id=13 -->
+<!-- group_id=14 -->
+<!-- group_id=15 -->
+<!-- group_id=16 -->
+<!-- group_id=17 -->
+<!-- group_id=18 -->
+<!-- group_id=19 -->
+<!-- group_id=20 -->
+<!-- group_id=21 -->
+<!-- group_id=22 -->
+<!-- group_id=23 -->
+<!-- group_id=24 -->
+<!-- group_id=25 -->
+<!-- group_id=26 -->
+<!-- group_id=28 -->
+<!-- group_id=29 -->
+<!-- group_id=30 -->
+<!-- group_id=31 -->
+<!-- group_id=32 -->
+<!-- group_id=33 -->
+<!-- group_id=34 -->
+<!-- group_id=35 -->
+<!-- group_id=36 -->
+<!-- group_id=37 -->
+<!-- group_id=38 -->
+<!-- group_id=39 -->
+<!-- group_id=40 -->
+<!-- group_id=41 -->
+<!-- group_id=42 -->
diff --git a/systemservice/system_manager/server/src/heartbeat/ss_hb_if.cpp b/systemservice/system_manager/server/src/heartbeat/ss_hb_if.cpp
new file mode 100755
index 0000000..a3c2777
--- /dev/null
+++ b/systemservice/system_manager/server/src/heartbeat/ss_hb_if.cpp
@@ -0,0 +1,201 @@
+/*
+ * @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 the application heartbeat system.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <ss_hb_thread.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_heartbeat_notifications.h>
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_templates.h>
+#include <new>
+#include "ss_sm_systemmanagerlog.h"
+
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus HBThreadCallback(HANDLE hThread) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusNullPointer;
+ C * pObj = static_cast<C *>(FrameworkunifiedGetThreadSpecificData(hThread));
+ if (pObj) { // LCOV_EXCL_BR_LINE 4:pObj must not be NULL
+ eStatus = (pObj->*M)(hThread);
+ }
+ return eStatus;
+}
+
+static VOID DeletePObj(CHeartBeatThread * pObj) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ delete pObj;
+}
+// LCOV_EXCL_STOP
+
+static VOID DeleteHBTimer(CHeartBeatThread * pObj) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = pObj->HeartBeatTimersDelete();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "pObj->HeartBeatTimersDelete()");
+}
+// LCOV_EXCL_STOP
+
+#define DetachParentCbThreadProtocols(hThread, handler) \
+{ \
+ EFrameworkunifiedStatus l_eStatus = DetachParentCallbacksFromInterfaceunifiedDispatcher( \
+ hThread, \
+ handler, \
+ static_cast<UI_32>(_countof(handler))); \
+ LOG_STATUS_IF_ERRORED(l_eStatus, "DetachParentCallbacksFromInterfaceunifiedDispatcher()") \
+}
+
+#define DetachCbProtocols(hThread, f_pStr, f_protocolHandlers, hSession) \
+{ \
+ EFrameworkunifiedStatus l_eStatus = \
+ DetachCallbacksFromInterfaceunifiedDispatcher( \
+ hThread, \
+ f_pStr, \
+ f_protocolHandlers, \
+ static_cast<UI_32>(_countof(f_protocolHandlers)), \
+ hSession); \
+ LOG_STATUS_IF_ERRORED(l_eStatus, "DetachCallbacksFromInterfaceunifiedDispatcher()") \
+}
+
+/*****************************************************************************/
+/**
+ @ingroup: SS_SystemManager
+ @brief: HBThreadStart: function would be called at the time of starting of the thread
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+ */
+/*****************************************************************************/
+EFrameworkunifiedStatus HBThreadStart(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ FrameworkunifiedProtocolCallbackHandler HBThreadCommonHandlers[] = {
+ // Command ID, Call back functions
+ { SS_HEARTBEAT_RESPONSE, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnClientResponse> },
+ { SS_HEARTBEAT_PRINT_CONNECTIONS, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnPrintConnections> },
+ { SS_HEARTBEAT_PRINT_STACK, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnPrintStack> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ FrameworkunifiedProtocolCallbackHandler HBThreadProtocolHandlers[] = {
+ // Command ID, Call back functions
+ { SS_HEARTBEAT_START, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnStartThread> },
+ { SS_HEARTBEAT_STOP, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnStopThread> },
+ { SS_HEARTBEAT_DELETE_MODULE_ENTRY, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnRemoveModule> },
+ { SS_HEARTBEAT_APPEND_MODULE_ENTRY, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnAppendModule> },
+ { SS_HEARTBEAT_PERIODIC_STATUS_REQ, HBThreadCallback<CHeartBeatThread,
+ &CHeartBeatThread::HBOnPeriodicStatusRequest> },
+ { SS_HEARTBEAT_AVAIL_CHECK_REQ, HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnAvailCheckRequest> }
+ }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ CHeartBeatThread * pObj = new (std::nothrow) CHeartBeatThread(hThread); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (NULL == pObj) { // LCOV_EXCL_BR_LINE 5: Standard lib
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 5: Standard lib
+ LOG_ERROR("new(std::nothrow) CHeartBeatThread(hThread)"); // LCOV_EXCL_LINE 5: Standard lib
+ // LCOV_EXCL_BR_START 6:always return eFrameworkunifiedStatusOK
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->HeartBeatTimerInit(hThread))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("pObj->HeartBeatTimerInit(hThread)"); // LCOV_EXCL_LINE 6:always return eFrameworkunifiedStatusOK
+ DeletePObj(pObj); // LCOV_EXCL_LINE 6:always return eFrameworkunifiedStatusOK
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachParentCallbacksToDispatcher(hThread,
+ HBThreadProtocolHandlers, static_cast<UI_32>(_countof(HBThreadProtocolHandlers))))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachParentCallbacksToDispatcher(HBThreadProtocolHandlers)");
+ DeleteHBTimer(pObj);
+ DeletePObj(pObj);
+ // LCOV_EXCL_STOP
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachParentCallbacksToDispatcher(hThread,
+ HBThreadCommonHandlers, static_cast<UI_32>(_countof(HBThreadCommonHandlers))))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachParentCallbacksToDispatcher(HBThreadCommonHandlers)");
+ DetachParentCbThreadProtocols(hThread, HBThreadProtocolHandlers);
+ DeleteHBTimer(pObj);
+ DeletePObj(pObj);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hThread, FRAMEWORKUNIFIED_ANY_SOURCE, HBThreadCommonHandlers, static_cast<UI_32>(_countof(HBThreadCommonHandlers)), NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher("
+ "FRAMEWORKUNIFIED_ANY_SOURCE, HBThreadCommonHandlers)");
+ DetachParentCbThreadProtocols(hThread, HBThreadCommonHandlers);
+ DetachParentCbThreadProtocols(hThread, HBThreadProtocolHandlers);
+ DeleteHBTimer(pObj);
+ DeletePObj(pObj);
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = FrameworkunifiedSetThreadSpecificData(hThread, pObj); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSetThreadSpecificData(hThread, pObj)");
+ DetachCbProtocols(hThread, FRAMEWORKUNIFIED_ANY_SOURCE, HBThreadCommonHandlers,
+ NULL);
+ DetachParentCbThreadProtocols(hThread, HBThreadCommonHandlers);
+ DetachParentCbThreadProtocols(hThread, HBThreadProtocolHandlers);
+ DeleteHBTimer(pObj);
+ DeletePObj(pObj);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Successful");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************/
+/**
+ @ingroup: SS_SystemManager
+ @brief: HBThreadStop: function would be called at the time of stopping of the thread
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+ */
+/*****************************************************************************/
+EFrameworkunifiedStatus HBThreadStop(HANDLE hThread) { // LCOV_EXCL_START 14: Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus;
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "+");
+
+ CHeartBeatThread * pObj = static_cast<CHeartBeatThread *>(FrameworkunifiedGetThreadSpecificData(hThread));
+ if (NULL == pObj) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetThreadSpecificData(hThread)");
+ } else {
+ // delete timers
+ CALL_AND_LOG_STATUS_IF_ERRORED(pObj->HeartBeatTimersDelete());
+ CALL_AND_LOG_STATUS_IF_ERRORED(pObj->HBPublishAvailabilityStatus(hThread, FALSE));
+ DeletePObj(pObj);
+ }
+
+ FrameworkunifiedSetThreadSpecificData(hThread, NULL);
+ CALL_AND_LOG_STATUS_IF_ERRORED(FrameworkunifiedDetachServiceFromDispatcher(hThread, FrameworkunifiedGetAppName(hThread)));
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_eStatus;
+}// LCOV_EXCL_STOP
diff --git a/systemservice/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp b/systemservice/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp
new file mode 100755
index 0000000..5fb4e00
--- /dev/null
+++ b/systemservice/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp
@@ -0,0 +1,184 @@
+/*
+ * @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 the application heartbeat system.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_if_local.h>
+#include <stdlib.h>
+#include <string.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+
+#include "ss_hb_thread.h"
+#include "ss_sm_systemmanagerlog.h"
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnTimerExpiry
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnTimerExpiry(HANDLE f_hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ // check heart beat replies received from clients.
+ l_eStatus = HBCheckHeartBeatResponses(f_hThread);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "HBCheckHeartBeatResponses()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ // send heart beat requests to clients
+ l_eStatus = HBSendRequest(f_hThread);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "HBSendRequest()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnClientResponse
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus OK or Fail
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnClientResponse(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ l_eStatus = m_oSessionHandler.HBProcessClientResponse(f_hThread);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBProcessClientResponse(f_hThread)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnPeriodicStatusRequest
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus OK or Fail
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnPeriodicStatusRequest(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendParent(f_hThread, SS_HEARTBEAT_PERIODIC_RESP, 0, NULL))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendParent(SS_HEARTBEAT_PERIODIC_RESP)"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "Successful");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnPeriodicStatusRequest
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus OK or Fail
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnAvailCheckRequest(HANDLE f_hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ THbAvailCheck check;
+ l_eStatus = m_oSessionHandler.HBAvailableCheck(check);
+ SS_ASERT(l_eStatus == eFrameworkunifiedStatusOK); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendParent(f_hThread, SS_HEARTBEAT_AVAIL_CHECK_RESP, sizeof(check), &check))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendParent(SS_HEARTBEAT_AVAIL_CHECK_RESP)"); // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnRemoveModule
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus OK or Fail
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnRemoveModule(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ TSMRequestMessage tReqMsgData;
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg <TSMRequestMessage> (f_hThread, tReqMsgData))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " %s is required to be Deleted from HeartBeat Monitor List", tReqMsgData.pstModuleName);
+
+ // delete module entry from map
+ l_eStatus = m_oSessionHandler.HBDeleteRegisteredClientEntry(f_hThread, tReqMsgData.pstModuleName);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBDeleteRegisteredProcessEntry()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnAppendModule
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus OK or Fail
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnAppendModule(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ TSMRequestMessage tReqMsgData;
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < TSMRequestMessage > (f_hThread, tReqMsgData))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " %s is required to be Appended from HeartBeat Monitor List", tReqMsgData.pstModuleName);
+
+ // append module entry from map
+ SubscriberName l_Subscriber = tReqMsgData.pstModuleName;
+ l_eStatus = m_oSessionHandler.HBEntrySubscriber(l_Subscriber); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBEntrySubscriber()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// EOF
diff --git a/systemservice/system_manager/server/src/heartbeat/ss_hb_session.cpp b/systemservice/system_manager/server/src/heartbeat/ss_hb_session.cpp
new file mode 100755
index 0000000..8178e46
--- /dev/null
+++ b/systemservice/system_manager/server/src/heartbeat/ss_hb_session.cpp
@@ -0,0 +1,415 @@
+/*
+ * @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 the application heartbeat system.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_sm_thread_names.h>
+#include <system_service/ss_templates.h>
+#include <iostream>
+#include <iomanip>
+#include <utility>
+#include <list>
+#include <string>
+
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_hb_thread.h"
+#include "ss_hb_session.h"
+#include "ss_system_manager.h"
+
+using namespace std; // NOLINT
+
+CHeartBeatSessionHandler::CHeartBeatSessionHandler() {
+}
+
+CHeartBeatSessionHandler::~CHeartBeatSessionHandler() { // LCOV_EXCL_START 14: Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HbSessionInfo
+ @note: HbSessionInfo constructor
+ @param
+ @return
+ *****************************************************************************/
+CHeartBeatSessionHandler::HbSessionInfo::HbSessionInfo(SubscriberName f_Subscriber) {
+ fRunning = FALSE;
+ fHeartBeatRequestSent = FALSE;
+ fHeartBeatResponseReceived = FALSE;
+ HeartBeatRetryCount = 0;
+ fHeartBeatTimedOut = FALSE;
+ hSession = NULL;
+ szName = f_Subscriber;
+ fisAvailability = FALSE;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBEntrySubscriber
+ @note:
+ @param
+ @return
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatSessionHandler::HBEntrySubscriber(SubscriberName &f_Subscriber) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // check if the subscriber is already in map
+ HbSessionIter l_SessionInfoIterator = m_mapHbSessions.find(f_Subscriber);
+
+ // the l_SessionInfoIterator is set to the end then the subscriber is not in the map
+ if (m_mapHbSessions.end() == l_SessionInfoIterator) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Entry Subscriber : %s", f_Subscriber.c_str());
+ HbSessionInfo l_NewHBClientSessionInfo(f_Subscriber.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ pair<HbSessionIter, bool> ret;
+ // insert new subscriber entry into the session map
+ ret = m_mapHbSessions.insert(std::make_pair(f_Subscriber, l_NewHBClientSessionInfo));
+ if (!ret.second) { // LCOV_EXCL_BR_LINE 6:l_NewHBClientSessionInfo must not be NULL.
+ // LCOV_EXCL_START 6:l_NewHBClientSessionInfo must not be NULL.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Subscriber '%s' is already in the map", f_Subscriber.c_str());
+ }
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: ProcessHBClientResponse
+ @note: Process the response received from client, update relevant structure data
+ @param HANDLE
+ @return EFrameworkunifiedStatus
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatSessionHandler::HBProcessClientResponse(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "+");
+ BOOL l_availability = FALSE;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<BOOL>(f_hThread, l_availability))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ // find the subscriber...
+ HbSessionIter l_SessionInfoIterator = m_mapHbSessions.find(FrameworkunifiedGetMsgSrc(f_hThread));
+
+ // the l_SessionInfoIterator is set to the end then the subscriber is not in the map
+ if (m_mapHbSessions.end() != l_SessionInfoIterator) {
+ l_SessionInfoIterator->second.HeartBeatRetryCount = 0;
+ l_SessionInfoIterator->second.fHeartBeatResponseReceived = TRUE;
+ l_SessionInfoIterator->second.fHeartBeatRequestSent = FALSE;
+ l_SessionInfoIterator->second.fisAvailability = l_availability;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__,
+ "HeartBeat received from module: %s ", l_SessionInfoIterator->first.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__,
+ "Ignoring Heart Beat Response, Client: %s not found in the map!", FrameworkunifiedGetMsgSrc(f_hThread));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBPrintConnection
+ @note: .Print registered client information
+ @param VOID
+ @return VOID
+ *****************************************************************************/
+VOID CHeartBeatSessionHandler::HBPrintConnection() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // find the subscriber...
+ HbSessionIter l_SessionInfoIterator = m_mapHbSessions.begin();
+ for (; l_SessionInfoIterator != m_mapHbSessions.end(); l_SessionInfoIterator++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG_DUMP, __FUNCTION__,
+ "HeartBeat Service is Connected to: %s via a Session: Running: %s ",
+ l_SessionInfoIterator->second.szName.data(),
+ (l_SessionInfoIterator->second.fRunning ? "YES" : "NO"));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBPrintStack
+ @note: .Print registered client information
+ @param VOID
+ @return VOID
+ *****************************************************************************/
+VOID CHeartBeatSessionHandler::HBPrintStack(UI_32 f_MaxHeartBeatRetryCount) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // find the subscriber...
+ HbSessionIter l_SessionInfoIterator = m_mapHbSessions.begin();
+ for (; l_SessionInfoIterator != m_mapHbSessions.end(); l_SessionInfoIterator++) {
+ if (FALSE == l_SessionInfoIterator->second.fHeartBeatResponseReceived) {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG_DUMP, __FUNCTION__,
+ "HeartBeat Service is Connected to: %s via a Session: Running: %s ",
+ l_SessionInfoIterator->second.szName.data(),
+ (l_SessionInfoIterator->second.fRunning ? "YES" : "NO"));
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG_DUMP, __FUNCTION__,
+ "Retry count (%d) within limit (%d), HeartBeatTimedout = %s",
+ l_SessionInfoIterator->second.HeartBeatRetryCount,
+ f_MaxHeartBeatRetryCount,
+ (l_SessionInfoIterator->second.fHeartBeatTimedOut == TRUE ?
+ "TRUE" : "FALSE"));
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBCheckResponses
+ @note: Check if all clients have replied to heartbeat query and generate report
+ @param THbReportData Report structure to be filled
+ @param UI_32 Heartbeat max retry count
+ @return eFrameworkunifiedStatusFail if one or more modules have timed out, eFrameworkunifiedStatusOK otherwise.
+ *****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatSessionHandler::HBCheckResponses(
+ THbReportData &f_tReportData, UI_32 f_MaxHeartBeatRetryCount,
+ SI_32 f_HeartBeatIntervalRepeat, SI_32 f_ChkIndex) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+
+ HbSessionIter l_SessionInfoIterator = m_mapHbSessions.begin();
+ memset(&f_tReportData, 0, sizeof(THbReportData));
+
+ int index = 0;
+
+ while (l_SessionInfoIterator != m_mapHbSessions.end()) {
+ if (f_ChkIndex == (index % f_HeartBeatIntervalRepeat)) {
+ // check if report queue is full
+ // LCOV_EXCL_BR_START 6: f_tReportData.nNumOfModules can't more than SS_MAX_NUM_MODULES
+ if (SS_MAX_NUM_MODULES <= f_tReportData.nNumOfModules) {
+ // LCOV_EXCL_BR_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SS_MAX_NUM_MODULES '%d' <= f_tReportData.nNumOfModules '%d'. See ss_system_manager_if.h.",
+ SS_MAX_NUM_MODULES, f_tReportData.nNumOfModules);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+
+ strncpy(f_tReportData.tModuleList[f_tReportData.nNumOfModules].ProcQueueName,
+ l_SessionInfoIterator->first.c_str(),
+ sizeof(f_tReportData.tModuleList[f_tReportData.nNumOfModules].ProcQueueName) - 1);
+ f_tReportData.tModuleList[f_tReportData.nNumOfModules].HeartBeatRetryCount =
+ l_SessionInfoIterator->second.HeartBeatRetryCount;
+ f_tReportData.tModuleList[f_tReportData.nNumOfModules].ProcHBState = HB_STATUS_GOOD;
+
+ if (TRUE == l_SessionInfoIterator->second.fHeartBeatResponseReceived) {
+ l_SessionInfoIterator->second.fHeartBeatResponseReceived = FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__,
+ "[%s] Heart Beat Response Received !",
+ l_SessionInfoIterator->second.szName.c_str());
+ } else if (TRUE == l_SessionInfoIterator->second.fHeartBeatTimedOut) {
+ f_tReportData.tModuleList[f_tReportData.nNumOfModules].ProcHBState = HB_STATUS_TIMEOUT;
+ } else if ((TRUE == l_SessionInfoIterator->second.fHeartBeatRequestSent)
+ && (FALSE == l_SessionInfoIterator->second.fHeartBeatTimedOut)) {
+ l_SessionInfoIterator->second.HeartBeatRetryCount++;
+
+ if (l_SessionInfoIterator->second.HeartBeatRetryCount > f_MaxHeartBeatRetryCount) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ l_SessionInfoIterator->second.fHeartBeatTimedOut = TRUE;
+ l_SessionInfoIterator->second.HeartBeatRetryCount = 0;
+
+ f_tReportData.tModuleList[f_tReportData.nNumOfModules].ProcHBState = HB_STATUS_TIMEOUT;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Heart Beat Retry count of [%s] has crossed max limit (%d)."
+ "Disabling sending HeartBeat query to it",
+ l_SessionInfoIterator->second.szName.c_str(),
+ f_MaxHeartBeatRetryCount);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: [%s] has missed a Heart Beat. Retry count (%d) is within max retry limit (%d)",
+ l_SessionInfoIterator->second.szName.c_str(),
+ l_SessionInfoIterator->second.HeartBeatRetryCount,
+ f_MaxHeartBeatRetryCount);
+ }
+ }
+ }
+
+ f_tReportData.nNumOfModules++;
+ ++l_SessionInfoIterator;
+ index++;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBSendRequest
+ @note: .Sent heart beat query to the registered clients
+ @param void
+ @return EFrameworkunifiedStatus
+******************************************************************************/
+EFrameworkunifiedStatus CHeartBeatSessionHandler::HBSendRequest(HANDLE f_hThread,
+ SI_32 f_HeartBeatIntervalRepeat, SI_32 f_ChkIndex) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+
+ // Get session iterator
+ HbSessionIter l_SessionInfoIterator = m_mapHbSessions.begin();
+
+ if (l_SessionInfoIterator == m_mapHbSessions.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "No Client has opened session with HeartBeat");
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+
+ int index = 0;
+
+ while (l_SessionInfoIterator != m_mapHbSessions.end()) {
+ if (f_ChkIndex == (index % f_HeartBeatIntervalRepeat)) {
+ if (l_SessionInfoIterator->second.hSession == NULL) { // LCOV_EXCL_BR_LINE 200:hSession must not be NULL
+ l_SessionInfoIterator->second.hSession = FrameworkunifiedMcOpenSender(f_hThread, l_SessionInfoIterator->first.c_str());
+ if (NULL == l_SessionInfoIterator->second.hSession) { // LCOV_EXCL_BR_LINE 200:hSession must not be NULL
+ // LCOV_EXCL_START 200: hSession must not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedMcOpenSender(%s) returned NULL",
+ l_SessionInfoIterator->first.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ l_SessionInfoIterator->second.fRunning = TRUE;
+ }
+ }
+
+ if ((NULL != l_SessionInfoIterator->second.hSession)
+ && (FALSE == l_SessionInfoIterator->second.fHeartBeatTimedOut)) {
+ if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedSendMsg(l_SessionInfoIterator->second.hSession, SS_HEARTBEAT_REQUEST, 0, NULL))) { // LCOV_EXCL_BR_LINE 5:NSFW's error // NOLINT(whitespace/line_length)
+ /// TODO review if we are required to return failure if sending message to one process failed.
+ l_SessionInfoIterator->second.fHeartBeatResponseReceived = FALSE;
+ l_SessionInfoIterator->second.fHeartBeatRequestSent = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__,
+ "HeartBeat Request sent to : %s", l_SessionInfoIterator->first.c_str());
+ } else {
+ // LCOV_EXCL_START 5:NSFW's error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedSendMsg(%s, SS_HEARTBEAT_REQUEST) errored: %d/'%s'",
+ l_SessionInfoIterator->first.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__,
+ " HeartBeat Request was not sent to '%s', timeout is '%s'",
+ l_SessionInfoIterator->first.c_str(),
+ (l_SessionInfoIterator->second.fHeartBeatTimedOut == TRUE ? "TRUE" : "FALSE"));
+ }
+ }
+ ++l_SessionInfoIterator;
+ index++;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBDeleteRegisteredClientEntry
+ @note: .
+ @param
+ @return EFrameworkunifiedStatus
+******************************************************************************/
+EFrameworkunifiedStatus CHeartBeatSessionHandler::HBDeleteRegisteredClientEntry(HANDLE f_hThread, PSTR pQueueName) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ SubscriberName tQueuename(pQueueName);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Looking for %s.", tQueuename.c_str());
+
+ HbSessionIter l_SessionInfoIterator = m_mapHbSessions.find(tQueuename);
+
+ if (m_mapHbSessions.end() != l_SessionInfoIterator) {
+ // Close the session handle
+ if (NULL != l_SessionInfoIterator->second.hSession) { // LCOV_EXCL_BR_LINE 200:hSession must not be NULL when tQueuename exists. // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedMcClose(l_SessionInfoIterator->second.hSession))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedMcClose()"); // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ l_SessionInfoIterator->second.hSession = NULL;
+ }
+ m_mapHbSessions.erase(tQueuename);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting '%s' Successful ", tQueuename.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "%s not found in Heart beat client list", tQueuename.c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBAvailableCheck
+ @note: .
+ @param
+ @return EFrameworkunifiedStatus
+******************************************************************************/
+EFrameworkunifiedStatus CHeartBeatSessionHandler::HBAvailableCheck(THbAvailCheck &check) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL isOk = TRUE;
+
+ std::list<std::string> ngList;
+ for (HbSessionIter ite = m_mapHbSessions.begin(); ite != m_mapHbSessions.end(); ite++) {
+ if (ite->second.fisAvailability == FALSE) {
+ ngList.push_back(ite->first);
+ // Notify Last Service as Representative
+ snprintf(check.serviceName, SS_SM_HB_MAX_PROC_NAME_SIZE, "%s", ite->first.c_str());
+ isOk = FALSE;
+ }
+ }
+
+ if (isOk == FALSE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "********* AVAILABILITY CHECK ERROR **********");
+ fprintf(stderr, "HBOnAvailCheckRequest/********* AVAILABILITY CHECK ERROR **********\n"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "********* AVAILABILITY CHECK OK **********");
+ fprintf(stderr, "HBOnAvailCheckRequest/********* AVAILABILITY CHECK OK **********\n"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ for (std::list<std::string>::iterator ite = ngList.begin(); ite != ngList.end(); ite++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " %s", ite->c_str());
+ fprintf(stderr, " %s\n", ite->c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ check.isOk = isOk;
+
+ return l_eStatus;
+}
diff --git a/systemservice/system_manager/server/src/heartbeat/ss_hb_thread.cpp b/systemservice/system_manager/server/src/heartbeat/ss_hb_thread.cpp
new file mode 100755
index 0000000..19d124a
--- /dev/null
+++ b/systemservice/system_manager/server/src/heartbeat/ss_hb_thread.cpp
@@ -0,0 +1,355 @@
+/*
+ * @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 the application heartbeat system.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <system_service/ss_heartbeat_notifications.h>
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+
+#include "ss_hb_thread.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_system_manager.h"
+
+/// Total Timers used by Heart Beat Thread
+/// This value is used for creating timers
+#define HBMaxTimers 1
+#define HBTimerInterval 1
+
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus HBThreadCallback(HANDLE hThread) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ C * pObj = static_cast<C *>(FrameworkunifiedGetThreadSpecificData(hThread));
+ if (pObj) { // LCOV_EXCL_BR_LINE 4:pObj must not be NULL
+ eStatus = (pObj->*M)(hThread);
+ }
+ return eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: CHeartBeatThread
+ @note: Constructor
+*****************************************************************************/
+CHeartBeatThread::CHeartBeatThread(HANDLE f_hThread) :
+ m_oTimerCtrl(HBMaxTimers)
+ , m_HBTimerID(0)
+ , m_NextChkIndex(0)
+ , m_hThread(f_hThread) { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::memset(&m_HBConfigParams, 0, sizeof(m_HBConfigParams));
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: ~CHeartBeatThread
+ @note: Destructor
+*****************************************************************************/
+CHeartBeatThread::~CHeartBeatThread() { // LCOV_EXCL_START 14: Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBPublishAvailabilityStatus
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @param BOOL - The Availability Status to be published
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBPublishAvailabilityStatus(HANDLE hThread, BOOL f_bAvailabiltyStatus) {// LCOV_EXCL_START 14: Resident process, not called by NSFW
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Send availability notification to users
+ l_eStatus = FrameworkunifiedPublishServiceAvailability(hThread, f_bAvailabiltyStatus);
+ char l_cBuf[100] = { 0 };
+ snprintf(l_cBuf,
+ sizeof(l_cBuf),
+ "FrameworkunifiedPublishServiceAvailability(%s)",
+ GetStr(f_bAvailabiltyStatus).c_str());
+ LOG_STATUS(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}// LCOV_EXCL_STOP
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnStartThread
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnStartThread(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ UI_32 l_DataLen = FrameworkunifiedGetMsgLength(hThread); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if ((sizeof(UI_32) + (SS_MAX_NUM_MODULES * SS_SM_HB_MAX_PROC_NAME_SIZE) + sizeof(m_HBConfigParams)) < l_DataLen) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: message buffer sizes invalid:received %d", l_DataLen);
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ CHAR l_Data[l_DataLen]; // NOLINT
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hThread, (PVOID) & l_Data, static_cast<UI_32>(sizeof(l_Data)), eSMRRelease))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedGetMsgDataOfSize() errored: 0x%x", l_eStatus);
+ return l_eStatus;
+ }
+
+ CHAR* p_Data = &l_Data[0];
+ UI_32 list_num;
+ memcpy(&m_HBConfigParams, p_Data, sizeof(m_HBConfigParams));
+ p_Data = p_Data + sizeof(m_HBConfigParams);
+ memcpy(&list_num, p_Data, sizeof(list_num));
+ p_Data = p_Data + sizeof((list_num));
+
+ for (UI_32 i = 0; i < list_num; i++) {
+ SubscriberName l_Subscriber = p_Data; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK != m_oSessionHandler.HBEntrySubscriber(l_Subscriber)) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: HBEntrySubscriber");
+ }
+ p_Data = p_Data + SS_SM_HB_MAX_PROC_NAME_SIZE;
+ }
+
+ if (0 == m_HBConfigParams.ApplicationHeartBeatIntervalInitial) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Heart beat disabled via configuration file interval "
+ "parameter set to 0.");
+ } else if (0 != m_HBTimerID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Heart Beat Timer ID '%d' already created, ignoring "
+ "repeated Heart Beat Start command.", m_HBTimerID);
+ } else {
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK !=
+ (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hThread, NTFY_HeartBeatAvailability))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedRegisterServiceAvailabilityNotification(" NTFY_HeartBeatAvailability ")");
+ // LCOV_EXCL_STOP
+ }
+ else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Service availability %s Registered SOURCE : %s",
+ NTFY_HeartBeatAvailability,
+ FrameworkunifiedGetAppName(hThread));
+
+ // Publish Heart Beat Availability
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK != (l_eStatus = HBPublishAvailabilityStatus(hThread, TRUE))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("HBPublishAvailabilityStatus(TRUE)");
+ // LCOV_EXCL_STOP
+ }
+ }
+ // Create Heart Beat app monitor
+ m_HBTimerID = m_oTimerCtrl.CreateTimer(HBThreadCallback<CHeartBeatThread, &CHeartBeatThread::HBOnTimerExpiry>); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (0 == m_HBTimerID) { // LCOV_EXCL_BR_LINE 8: m_HBTimerID can't be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Heart Beat Timer ID creation failed.");
+ // return eFrameworkunifiedStatusFail;
+ } else {
+ // Start Heart Beat app monitor
+ m_oTimerCtrl.StartTimer(m_HBTimerID,
+ m_HBConfigParams.ApplicationHeartBeatIntervalInitial,
+ 0,
+ HBTimerInterval,
+ 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Initial Heart Beat Timer created for %d seconds interval",
+ m_HBConfigParams.ApplicationHeartBeatIntervalInitial);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Repetitive Heart Beat Timer created for %d seconds interval",
+ m_HBConfigParams.ApplicationHeartBeatIntervalRepeat);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnStopThread
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnStopThread(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (0 != m_HBTimerID) {
+ // Stop HeartBeat timer
+ m_oTimerCtrl.StopTimer(m_HBTimerID);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Timer '%d' stopped", m_HBTimerID);
+ }
+ else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: 'm_HBTimerID' is '0'; unable to stop timer");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HeartBeatTimerInit
+ @note:
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HeartBeatTimerInit(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_oTimerCtrl.Initialize(hThread);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HeartBeatTimersDelete
+ @note:
+ @param void
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HeartBeatTimersDelete() {// LCOV_EXCL_START 14: Resident process, not called by NSFW
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (0 == m_HBTimerID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: 'm_HBTimerID' is '0'; unable to delete timer");
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ // Delete Heart Beat timer
+ UI_32 l_TimerID = m_oTimerCtrl.DeleteTimer(m_HBTimerID);
+ if (0 == l_TimerID) {
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ LOG_ERROR("m_oTimerCtrl.DeleteTimer(m_HBTimerID)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Successful");
+ }
+ m_HBTimerID = 0;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}// LCOV_EXCL_STOP
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBCheckHeartBeatResponses
+ @note: This function checks heartbeat responses and generates a summary
+ report for System Manager if one or more modules have failed to
+ reply within the configured maximum number of heartbeat retries.
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBCheckHeartBeatResponses(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+ THbReportData f_tReportData;
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = m_oSessionHandler.HBCheckResponses(f_tReportData,
+ m_HBConfigParams.MaxHeartBeatRetryCount,
+ m_HBConfigParams.ApplicationHeartBeatIntervalRepeat,
+ m_NextChkIndex);
+ if (l_eStatus == eFrameworkunifiedStatusFail) { // Send a heartbeat report ONLY if a heartbeat failure is detected.
+ // send report to system manager
+ l_eStatus = FrameworkunifiedSendParent(hThread,
+ SS_HEARTBEAT_ERROR_DETECTED,
+ sizeof(f_tReportData),
+ &f_tReportData);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSendParent(SS_HEARTBEAT_ERROR_DETECTED)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG0(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBSendRequest
+ @note: .
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBSendRequest(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+
+ CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ m_oSessionHandler.HBSendRequest(hThread, m_HBConfigParams.ApplicationHeartBeatIntervalRepeat, m_NextChkIndex)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ m_NextChkIndex++;
+ if (m_HBConfigParams.ApplicationHeartBeatIntervalRepeat <= m_NextChkIndex) {
+ m_NextChkIndex = 0;
+ }
+
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnPrintConnections
+ @note: .Prints all active sessions connected to HeartBeat
+ @param HANDLE hThread
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnPrintConnections(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_oSessionHandler.HBPrintConnection();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/*****************************************************************************
+ @ingroup: SS_SystemManager
+ @brief: HBOnPrintStack
+ @note: . Prints all sessions connected to HeartBeat
+ @param HANDLE - Handle to message queue of HeartBeat Service.
+ @return EFrameworkunifiedStatus
+*****************************************************************************/
+EFrameworkunifiedStatus CHeartBeatThread::HBOnPrintStack(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_oSessionHandler.HBPrintStack(m_HBConfigParams.MaxHeartBeatRetryCount);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/systemservice/system_manager/server/src/processlauncher/ProcessLauncher.cpp b/systemservice/system_manager/server/src/processlauncher/ProcessLauncher.cpp
new file mode 100755
index 0000000..6b709fe
--- /dev/null
+++ b/systemservice/system_manager/server/src/processlauncher/ProcessLauncher.cpp
@@ -0,0 +1,317 @@
+/*
+ * @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 process launching and termination.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_string_maps.h>
+#include <native_service/ns_plogger_if.h>
+#include <string>
+
+#include "ProcessLauncher.h"
+#include "ss_sm_process_launcher_protocol.h"
+#include "ss_sm_process_launcher.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_sm_signals.h"
+
+CProcessLauncher::CProcessLauncher() { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+CProcessLauncher::CProcessLauncher(void *) {
+}
+
+CProcessLauncher::~CProcessLauncher() { // LCOV_EXCL_START 14: resident process end
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ m_mapOfProcesses.clear();
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CProcessLauncher::PLTerminateModule(
+ HANDLE hThread,
+ T_ProcessLauncherTerminationResp *f_pTerminateRespData) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ T_ProcessLauncherTerminationReq l_ModuleTerminateReq;
+
+ // LCOV_EXCL_BR_START 4:NSFW error case
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg < T_ProcessLauncherTerminationReq > (hThread, l_ModuleTerminateReq, eSMRRetain))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4:NSFW error case
+ } else {
+ // get pointer to the process object launched earlier
+ Process * l_pProcessPtr = m_mapOfProcesses[l_ModuleTerminateReq.path]; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ // Confirm that the process pointer for the module exists in the map
+ if (NULL != l_pProcessPtr) { // LCOV_EXCL_BR_LINE 200: l_pProcessPtr must not be null
+ // check if process still exists
+ if (l_pProcessPtr->DoesProcessExist()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Terminating %s, PID: %d.", l_ModuleTerminateReq.path, l_pProcessPtr->GetProcessId());
+ // kill unresponsive process
+ l_pProcessPtr->KillProcess(SS_SM_ABORT_SIGNAL);
+
+ if (NULL != f_pTerminateRespData) { // LCOV_EXCL_BR_LINE 200: f_pTerminateRespData must not be null
+ std::strcpy(f_pTerminateRespData->name, // NOLINT
+ l_ModuleTerminateReq.name);
+ std::strcpy(f_pTerminateRespData->path, // NOLINT
+ l_ModuleTerminateReq.path);
+ std::strcpy(f_pTerminateRespData->args, // NOLINT
+ l_ModuleTerminateReq.args);
+ f_pTerminateRespData->moduleIterator =
+ l_ModuleTerminateReq.moduleIterator;
+ f_pTerminateRespData->groupIterator =
+ l_ModuleTerminateReq.groupIterator;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info: %s has already terminated.", l_ModuleTerminateReq.path);
+
+ l_eStatus = eFrameworkunifiedStatusServNotFound;
+ }
+ // remove process entry
+ m_mapOfProcesses.erase(l_ModuleTerminateReq.path);
+ // delete process object
+ delete l_pProcessPtr; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ } else { // LCOV_EXCL_BR_LINE 200: l_pProcessPtr will not be null
+ // LCOV_EXCL_START 200: l_pProcessPtr will not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s not in m_mapOfProcesses", l_ModuleTerminateReq.path);
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLOnCmdTerminateModule(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ T_ProcessLauncherTerminationResp l_TerminateRespData;
+ if (eFrameworkunifiedStatusOK == (l_eStatus = PLTerminateModule(hThread, &l_TerminateRespData))) {
+ // reply to System Manager about successful module termination
+ l_eStatus = FrameworkunifiedSendParent(hThread,
+ ePLThrdCmd_TERMINATE_MODULE_RESP,
+ sizeof(l_TerminateRespData),
+ &l_TerminateRespData);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendParent(ePLThrdCmd_TERMINATE_MODULE_RESP"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else if (eFrameworkunifiedStatusServNotFound == l_eStatus) { // Already terminated
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Module already terminated.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: PLTerminateModule(%s) errored: %d/'%s'",
+ l_TerminateRespData.name, l_eStatus, GetStr(l_eStatus).c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLOnCmdModuleStatus(HANDLE hThread) {
+ return eFrameworkunifiedStatusOK;
+}
+
+VOID buildArgList(StringList& arg_list, PSTR args) { // NOLINT
+ arg_list.clear();
+ char * pch = NULL;
+ pch = std::strtok(args, " ");
+ while (pch != NULL) {
+ arg_list.push_back(pch);
+ pch = std::strtok(NULL, " ");
+ }
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLLaunchModule(HANDLE hThread, T_ProcessLaunchResp &f_LaunchRespData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ Process *l_pProcessPtr = NULL;
+ T_ProcessLauncherLaunchReq l_ModuleLaunchReq;
+
+ // LCOV_EXCL_BR_START 4:NSFW error case
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg < T_ProcessLauncherLaunchReq > (hThread, l_ModuleLaunchReq))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4:NSFW error case
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Sending to Launcher name: %s, path: %s, args: %s, lmsk: %s, "
+ "prio: %d ", l_ModuleLaunchReq.name,
+ l_ModuleLaunchReq.path, l_ModuleLaunchReq.args,
+ l_ModuleLaunchReq.logging_mask, l_ModuleLaunchReq.priority);
+
+ StringList args;
+ buildArgList(args, l_ModuleLaunchReq.args); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ int log_mask_str_len = static_cast<int>(std::strlen(l_ModuleLaunchReq.logging_mask));
+ if (log_mask_str_len > 0) {
+ // Create mask argument to be passed to application.
+ // The argument must be of the form "-m 0x00000000,0x00000000,...", assuming n 32-bit mask values.
+ // The storage size of the argument must include one byte for the NULL termination character.
+ args.push_back("-m");
+ args.push_back(l_ModuleLaunchReq.logging_mask);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s args: logging_mask: %s",
+ l_ModuleLaunchReq.path, l_ModuleLaunchReq.logging_mask);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PROC_LAUNCH_INFO, __FUNCTION__,
+ " '%s' has no logging_mask specified. Using compile time defaults.",
+ l_ModuleLaunchReq.path);
+ }
+
+ std::strcpy(f_LaunchRespData.name, l_ModuleLaunchReq.name); // NOLINT Module queue name
+ std::strcpy(f_LaunchRespData.path, l_ModuleLaunchReq.path); // NOLINT Module path and file name
+ std::strcpy(f_LaunchRespData.args, l_ModuleLaunchReq.args); // NOLINT
+ f_LaunchRespData.moduleIterator = l_ModuleLaunchReq.moduleIterator;
+ f_LaunchRespData.groupIterator = l_ModuleLaunchReq.groupIterator;
+
+ // Process exists? If not, re-launch the process and create a new map entry.
+ l_pProcessPtr = m_mapOfProcesses[l_ModuleLaunchReq.path]; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (NULL == l_pProcessPtr) { // LCOV_EXCL_BR_LINE 200: l_pProcessPtr must not be null
+ FRAMEWORKUNIFIEDLOG(ZONE_PROC_LAUNCH_INFO, __FUNCTION__,
+ " '%s' is not in the module map. Creating new process.",
+ l_ModuleLaunchReq.name);
+
+ SS_String sPathAndFileName = l_ModuleLaunchReq.path; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_pProcessPtr = new (std::nothrow) Process(l_ModuleLaunchReq.cpu_assign); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (NULL == l_pProcessPtr) { // LCOV_EXCL_BR_LINE 11::new operation failed
+ // LCOV_EXCL_START 11::new operation failed
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Process() returned NULL");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusThreadNotExist;
+ // LCOV_EXCL_STOP 11::new operation failed
+ }
+
+ const char* uname =
+ ('\0' == f_LaunchRespData.moduleIterator->unix_user_name[0]) ?
+ NULL : &f_LaunchRespData.moduleIterator->unix_user_name[0]; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_pProcessPtr->CreateProcess(sPathAndFileName, "", l_ModuleLaunchReq.priority, args, uname); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PROC_LAUNCH_INFO, __FUNCTION__,
+ " Process Name: %s Process File: %s Pid: %d Is Alive: %s\n",
+ l_pProcessPtr->GetProcessName().data(),
+ l_pProcessPtr->GetExecutableFileName(),
+ l_pProcessPtr->GetProcessId(),
+ (l_pProcessPtr->DoesProcessExist() == FALSE) ? "No" : "Yes");
+
+ // Add the process in the map
+ m_mapOfProcesses[l_ModuleLaunchReq.path] = l_pProcessPtr; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ // launch response
+ f_LaunchRespData.pid = l_pProcessPtr->GetProcessId();
+ f_LaunchRespData.priority = l_pProcessPtr->GetPriority(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ // LCOV_EXCL_START 200: l_pProcessPtr must not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_PROC_LAUNCH_INFO, __FUNCTION__,
+ " %s already in Process Map", l_ModuleLaunchReq.name);
+ // the module is already in the list. Send the response to system manager with PID 0x7FFFFFFF
+ f_LaunchRespData.pid = 0x7FFFFFFF;
+ f_LaunchRespData.priority = l_ModuleLaunchReq.priority;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLOnCmdLaunchModule(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = PLCmdLaunchModule(hThread, ePLThrdCmd_LAUNCH_MODULE_RESP, "ePLThrdCmd_LAUNCH_MODULE_RESP"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_STATUS_IF_ERRORED(l_eStatus, " PLCmdLaunchModule(ePLThrdCmd_LAUNCH_MODULE_RESP)"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLOnCmdRelaunchModule(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Terminate unresponsive module
+ CALL_AND_LOG_STATUS(PLTerminateModule(hThread)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ l_eStatus = PLCmdLaunchModule(hThread, ePLThrdCmd_RELAUNCH_MODULE_RESP, "ePLThrdCmd_RELAUNCH_MODULE_RESP"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_STATUS_IF_ERRORED(l_eStatus, "PLCmdLaunchModule(ePLThrdCmd_RELAUNCH_MODULE_RESP)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLCmdLaunchModule(HANDLE hThread, UI_32 f_protocol_ID, std::string f_protocol_str) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ T_ProcessLaunchResp l_LaunchRespData;
+ l_LaunchRespData.pid = 0;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = PLLaunchModule(hThread, l_LaunchRespData))) { // LCOV_EXCL_BR_LINE 4:NSFW error case
+ // LCOV_EXCL_START 4:NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: PLLaunchModule(%s, %s) errored: %d/'%s'",
+ l_LaunchRespData.name, f_protocol_str.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP 4:NSFW error case
+ } else {
+ l_eStatus = FrameworkunifiedSendParent(hThread, f_protocol_ID,
+ sizeof(T_ProcessLaunchResp), &l_LaunchRespData);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4:NSFW error case
+ // LCOV_EXCL_START 4:NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedSendParent( %s, %s ) errored: %d/'%s'",
+ l_LaunchRespData.name, f_protocol_str.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP 4:NSFW
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLOnCmdStop(HANDLE hThread) { // LCOV_EXCL_START 14: resident process end
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CProcessLauncher::PLOnCmdStart(HANDLE hThread) {
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus CProcessLauncher::PLOnCmdHeartbeatStatusReq(HANDLE hThread) {
+ FrameworkunifiedSendParent(hThread, ePLThrdCmd_THREAD_STATUS_RESP, 0, NULL);
+ return eFrameworkunifiedStatusOK;
+}
+
diff --git a/systemservice/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp b/systemservice/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp
new file mode 100755
index 0000000..3d9b2e9
--- /dev/null
+++ b/systemservice/system_manager/server/src/processlauncher/ProcessLauncher_if.cpp
@@ -0,0 +1,126 @@
+/*
+ * @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 process launching and termination.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_framework_if.h>
+
+#include "ProcessLauncher.h"
+#include "ss_sm_process_launcher_protocol.h"
+#include "ss_sm_systemmanagerlog.h"
+
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus ProcessLauncherCallback(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ C * pObj = static_cast<C *>(FrameworkunifiedGetThreadSpecificData(hThread));
+
+ if (pObj) { // LCOV_EXCL_BR_LINE 5:pObj must not be NULL
+ l_eStatus = (pObj->*M)(hThread);
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus ProcessLauncherOnStart(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ CProcessLauncher * pObj = new (std::nothrow) CProcessLauncher(NULL); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (pObj) { // LCOV_EXCL_BR_LINE 5:new error
+ // LCOV_EXCL_BR_START 200:l_eStatus always return eFrameworkunifiedStatusOK
+ if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->PLOnCmdStart(hThread))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 200:l_eStatus always return eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: pObj->PLOnCmdStart(hThread) errored: %d/'%s'",
+ l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ FrameworkunifiedSetThreadSpecificData(hThread, pObj);
+
+ FrameworkunifiedProtocolCallbackHandler aParentHandlers[] = { {
+ ePLThrdCmd_LAUNCH_MODULE_REQST, ProcessLauncherCallback<
+ CProcessLauncher,
+ &CProcessLauncher::PLOnCmdLaunchModule> }, {
+ ePLThrdCmd_TERMINATE_MODULE_REQST, ProcessLauncherCallback<
+ CProcessLauncher,
+ &CProcessLauncher::PLOnCmdTerminateModule> }, {
+ ePLThrdCmd_RELAUNCH_MODULE_REQST, ProcessLauncherCallback<
+ CProcessLauncher,
+ &CProcessLauncher::PLOnCmdRelaunchModule> }, {
+ ePLThrdCmd_MODULE_STATUS_REQST, ProcessLauncherCallback<
+ CProcessLauncher,
+ &CProcessLauncher::PLOnCmdModuleStatus> }, {
+ ePLThrdCmd_THREAD_STATUS_REQST, ProcessLauncherCallback<
+ CProcessLauncher,
+ &CProcessLauncher::PLOnCmdHeartbeatStatusReq> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ // LCOV_EXCL_BR_START 4:NSFW error case
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedAttachParentCallbacksToDispatcher(hThread, aParentHandlers,
+ static_cast<UI_32>(_countof(aParentHandlers))))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4:NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedAttachParentCallbacksToDispatcher() errored: %d/'%s'",
+ l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ // Add other Attaches here!!!
+ }
+ }
+ } else { // LCOV_EXCL_BR_LINE 5::new operation failed
+ // LCOV_EXCL_START 5:new error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: new CProcessLauncher( NULL ) returned NULL");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+// LCOV_EXCL_START 200:Thread which registered in init_process_launcher() is never stoppped.
+EFrameworkunifiedStatus ProcessLauncherOnStop(HANDLE hThread) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ CProcessLauncher * pObj = static_cast<CProcessLauncher *>(FrameworkunifiedGetThreadSpecificData(hThread));
+
+ if (pObj) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->PLOnCmdStop(hThread))) {
+ LOG_ERROR("PLOnCmdStop()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ delete pObj;
+ pObj = NULL;
+ }
+
+ FrameworkunifiedSetThreadSpecificData(hThread, NULL);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDetachServiceFromDispatcher(hThread, FrameworkunifiedGetAppName(hThread)))) {
+ LOG_ERROR("FrameworkunifiedDetachServiceFromDispatcher()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
diff --git a/systemservice/system_manager/server/src/ss_sm_config.cpp b/systemservice/system_manager/server/src/ss_sm_config.cpp
new file mode 100755
index 0000000..2a8d11e
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_sm_config.cpp
@@ -0,0 +1,1528 @@
+/*
+ * @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 configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <boost/algorithm/string.hpp>
+
+
+#include <other_service/PosixBasedOS001ClockCycleApi.h>
+#include <other_service/ultoa.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_templates.h>
+#include <native_service/ns_config_parser_if.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <cctype>
+#include <string>
+#include <iomanip>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <vector>
+#include <utility>
+
+#include "ss_sm_config.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_sm_launch_configuration.h"
+#include "system_launcher_cfg_format.h"
+#include "ss_sm_default_paths.h"
+
+using namespace std; // NOLINT
+
+// Constants for Heart Beat configuration data
+const UI_32 HBApplicationHeartBeatIntervalInitial = 40u; // Units of seconds. 0 = HB Disabled.
+const UI_32 HBApplicationHeartBeatIntervalRepeat = 5u; // Units of seconds. 0 = HB Disabled.
+const UI_32 HBMaxHeartBeatRetryCount = 3u;
+
+// Constants for Crash Detector configuration data
+const BOOL CDEnabled = TRUE;
+
+// Constants for system low memory configuration data
+
+const UI_32 SLMTimerValue = 5000; // msec
+const UI_32 SLMThresholdValue = (1024 * 512); // bytes
+const UI_32 SLMRetryCount = 6;
+const UI_32 SLMSystemmanagerLogIntervalMs = 30000;
+
+// Constants for Module connect time and Stat Resp Time
+
+const UI_32 ModuleConnectionNumTimesToCheck = 5;
+const UI_32 ModuleConnectionTimeOutSec = 5; // sec
+const UI_32 ModuleStartRespTimeOutSec = 120; // sec
+
+// Constants for Critical Apps Max wait timeout
+
+const UI_32 CriticalAppsMaxShutdownTimeFastSleepSec = 2; // sec
+const UI_32 CriticalAppsMaxShutdownTimeNormalResetSec = 15; // sec
+
+// Constants for User Mode data structure type
+const BOOL isBoolean = TRUE;
+
+const CHAR SMConfigDataHeader[] = "SystemManager";
+const CHAR HBConfigDataHeader[] = "HeartBeat";
+const CHAR CDConfigDataHeader[] = "CrashDetector";
+const CHAR SLMConfigDataHeader[] = "SysLowMemory";
+const CHAR UserModeConfigDataHeader[] = "UserMode";
+
+struct CfgLaunchParams {
+ CfgLaunchParams() :
+ group_id(0),
+ group_launch_wait(0),
+ group_wait_for_trigger(0),
+ priority(0),
+ critical(0),
+ retry_cnt(0),
+ is_start_required(0),
+ shutdown_critical(0),
+ shutdown_wait_time(0),
+ fast_shutdown_wait_time(0),
+ cpu_assign(0x0),
+ is_agl_unit(TRUE),
+ disable_agl_resethistory(FALSE),
+ disable_nonagl_resethistory(FALSE) {
+ std::memset(&group_name[0], 0, sizeof(group_name));
+ std::memset(&name[0], 0, sizeof(name));
+ std::memset(&binary_name[0], 0, sizeof(binary_name));
+ std::memset(&arguments[0], 0, sizeof(arguments));
+ std::memset(&logging_msk_str[0], 0, sizeof(logging_msk_str));
+ std::memset(&restart[0], 0, sizeof(restart));
+ std::memset(&unix_user_name[0], 0, sizeof(unix_user_name));
+ std::memset(&env_value_condition[0], 0, sizeof(env_value_condition));
+ }
+
+ CHAR group_name[100];
+ UI_32 group_id;
+ UI_32 group_launch_wait;
+ BOOL group_wait_for_trigger;
+ CHAR name[100];
+ CHAR binary_name[MAX_PATH_LENGTH];
+ UI_32 priority;
+ BOOL critical;
+ UI_32 retry_cnt;
+ CHAR arguments[512];
+ CHAR logging_msk_str[50];
+ CHAR restart[32];
+ BOOL is_start_required;
+ BOOL shutdown_critical;
+ UI_32 shutdown_wait_time;
+ UI_32 fast_shutdown_wait_time;
+ TUserNameBuffer unix_user_name; // TODO(username): Stuff.: Does Posix define a useful
+ // constant representing max length of user id?
+ CHAR env_value_condition[256];
+ int cpu_assign;
+
+ public:
+ BOOL IsAGLUnit(void) const { return is_agl_unit; }
+ BOOL IsAGLResetHistoryDisable(void) const { return disable_agl_resethistory; }
+ BOOL IsNonAGLResetHistoryDisable(void) const { return disable_nonagl_resethistory; }
+ void SetAGLUnit(BOOL f_is_agl_unit) { is_agl_unit = f_is_agl_unit; }
+ void SetAGLResetHistoryDisable(BOOL f_disable_agl_resethistory) {
+ disable_agl_resethistory = f_disable_agl_resethistory;
+ }
+ void SetNonAGLResetHisoryDisable(BOOL f_disable_nonagl_resethistory) {
+ disable_nonagl_resethistory = f_disable_nonagl_resethistory;
+ }
+
+ private:
+ BOOL is_agl_unit;
+ BOOL disable_agl_resethistory;
+ BOOL disable_nonagl_resethistory;
+};
+
+namespace ss_sm_cfg {
+class cfg_args {
+ public:
+ enum { // typedef enum _tokens
+ group_name,
+ group_id,
+ group_launch_wait,
+ group_wait_for_trigger,
+ name,
+ binary_name,
+ priority,
+ critical,
+ retry_cnt,
+ arguments,
+ logging_msk,
+ restart,
+ is_start_required,
+ shutdown_critical,
+ shutdown_wait_time,
+ fast_shutdown_wait_time,
+ unix_user_name,
+ is_agl_unit,
+ disable_agl_resethistory,
+ disable_nonagl_resethistory,
+ env_value_condition,
+ cpu_assign,
+ END
+ };
+};
+}; // namespace ss_sm_cfg
+
+static void set_grp_member_info(const LaunchInfo& launch_info, ModuleLaunchList& module_lst); // NOLINT
+static void load_parameters_order_cfg(
+ GroupLaunchMap& groups_map, LaunchOrderedVector& f_OrderList, SS_String& f_launchOrderName, SS_String& f_launchCfgFn); // NOLINT
+
+/*******************************************************************************
+ * CTimeSpan class *
+ * *
+ * Set Initial time, reset Final and Delta to zero, return time *
+ * */
+UI_64 CTimeSpan::Begin() {
+ initial = GetTimeMilliseconds();
+ final = 0;
+ delta = 0;
+ return initial;
+} // End of UI_64 CTimeSpan::Begin()
+
+/*
+ * Set Final time, calculate Delta time, return time
+ */
+UI_64 CTimeSpan::End() {
+ final = GetTimeMilliseconds();
+ delta = (final > initial) ? (final - initial) : 0; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ return final;
+} // End of UI_64 CTimeSpan::End()
+
+UI_64 CTimeSpan::GetInitial(void) {
+ return initial;
+}
+
+UI_64 CTimeSpan::GetFinal() {
+ return final;
+}
+
+UI_64 CTimeSpan::GetDelta() {
+ return delta;
+}
+
+UI_64 CTimeSpan::GetTimeMilliseconds() {
+ UI_64 l_totalmsec = 0;
+ struct timespec timeSpec;
+
+ if (0 != clock_gettime(CLOCK_MONOTONIC, &timeSpec)) {
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ l_totalmsec = (timeSpec.tv_sec * 1000ULL)
+ + (timeSpec.tv_nsec / 1000000);
+ }
+
+ return l_totalmsec;
+}
+
+/* *
+ * End of CTimeSpan class *
+ ******************************************************************************/
+
+ModuleLaunchParams::ModuleLaunchParams():
+ name("")
+ , path("")
+ , arguments("")
+ , restart("")
+ , configuration_priority(0)
+ , cpu_assign(0x0)
+ , previous_priority(0)
+ , current_priority(0)
+ , critical(FALSE)
+ , retry_cnt(0)
+ , logging_msk_str("")
+ , is_start_required(FALSE)
+ , shutdown_critical(FALSE)
+ , shutdown_wait_time(0)
+ , fast_shutdown_wait_time(0)
+ , pid(0)
+ , hsession(NULL)
+ , relaunch_count(0)
+ , relaunch_status(NotRelaunched)
+ , group_id(0xFFFF)
+ , m_serviceAvailability(FALSE)
+ , m_startReason()
+ , m_stopReason()
+ , m_ModuleDebugDumpState(MODULE_DEBUG_DUMP_STATE_NOT_REQUESTED)
+ , is_agl_unit(TRUE)
+ , disable_agl_resethistory(FALSE)
+ , disable_nonagl_resethistory(FALSE) { // LCOV_EXCL_BR_START 11:Gcov constraints (because exception-handling routes are automatically generated)
+ SetModuleState(MODULE_STATE_INVALID, FALSE);
+ //
+ // Module State strings
+ m_ModuleStateStrMap[MODULE_STATE_INVALID] = "INVALID";
+ m_ModuleStateStrMap[MODULE_STATE_SKIPPED] = "SKIPPED";
+ m_ModuleStateStrMap[MODULE_STATE_LAUNCHING] = "LAUNCHING";
+ m_ModuleStateStrMap[MODULE_STATE_LAUNCHED] = "LAUNCHED";
+ m_ModuleStateStrMap[MODULE_STATE_LAUNCH_FAILED] = "LAUNCH_FAIL";
+ m_ModuleStateStrMap[MODULE_STATE_CONNECTED] = "CONNECTED";
+ m_ModuleStateStrMap[MODULE_STATE_START_SENT] = "START_SENT";
+ m_ModuleStateStrMap[MODULE_STATE_START_FAILED] = "START_FAIL";
+ m_ModuleStateStrMap[MODULE_STATE_STARTED] = "STARTED";
+ m_ModuleStateStrMap[MODULE_STATE_STOP_FAILED] = "STOP_FAIL";
+ m_ModuleStateStrMap[MODULE_STATE_STOP_SENT] = "STOP_SENT";
+ m_ModuleStateStrMap[MODULE_STATE_STOPPED] = "STOPPED";
+ m_ModuleStateStrMap[MODULE_STATE_START_PRE_SENT] = "PRE_START_SENT";
+ m_ModuleStateStrMap[MODULE_STATE_START_PRE_FAILED] = "PRE_START_FAIL";
+ m_ModuleStateStrMap[MODULE_STATE_STARTED_PRE] = "PRE_STARTED";
+ m_ModuleStateStrMap[MODULE_STATE_STOP_PRE_SENT] = "PRE_STOP_SENT";
+ m_ModuleStateStrMap[MODULE_STATE_STOP_PRE_FAILED] = "PRE_STOP_FAIL";
+ m_ModuleStateStrMap[MODULE_STATE_STOPPED_PRE] = "PRE_STOPPED";
+ m_ModuleStateStrMap[MODULE_STATE_START_BACKGROUND_SENT] = "BACKGROUND_START_SENT";
+ m_ModuleStateStrMap[MODULE_STATE_START_BACKGROUND_FAILED] = "BACKGROUND_START_FAIL";
+ m_ModuleStateStrMap[MODULE_STATE_STARTED_BACKGROUND] = "BACKGROUND_STARTED";
+ m_ModuleStateStrMap[MODULE_STATE_STOP_BACKGROUND_SENT] = "BACKGROUND_STOP_SENT";
+ m_ModuleStateStrMap[MODULE_STATE_STOP_BACKGROUND_FAILED] = "BACKGROUND_STOP_FAIL";
+ m_ModuleStateStrMap[MODULE_STATE_STOPPED_BACKGROUND] = "BACKGROUND_STOPPED";
+ // LCOV_EXCL_BR_STOP
+
+ m_startReason.SetReason(NotStarted);
+ m_stopReason.SetReason(NotStopped);
+
+ MAP_ENTRY(m_ModuleDebugDumpStateStrMap, MODULE_DEBUG_DUMP_STATE_NOT_REQUESTED); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ MAP_ENTRY(m_ModuleDebugDumpStateStrMap, MODULE_DEBUG_DUMP_STATE_REQUEST_SENT); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ MAP_ENTRY(m_ModuleDebugDumpStateStrMap, MODULE_DEBUG_DUMP_STATE_RESPONSE_RECEIVED); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ std::memset(&unix_user_name[0], 0, sizeof(unix_user_name));
+} // End of ModuleLaunchParams::ModuleLaunchParams() :
+
+ModuleLaunchParams::~ModuleLaunchParams() {
+} // End of ModuleLaunchParams::~ModuleLaunchParams() :
+
+SMModuleState ModuleLaunchParams::GetModuleState(void) {
+ return m_moduleState;
+} // End of SMModuleState ModuleLaunchParams::GetModuleState(void)
+
+BOOL ModuleLaunchParams::IsModuleState(SMModuleState f_moduleState) {
+ return m_moduleState == f_moduleState;
+} // End of BOOL ModuleLaunchParams::IsModuleState(SMModuleState f_moduleState )
+
+// IsModuleConnected
+// Determine if a module is in a state capable of receiving messages from System Manager.
+BOOL ModuleLaunchParams::IsModuleConnected() const {
+ BOOL l_isModuleConnected = FALSE;
+
+ switch (m_moduleState) {
+ case MODULE_STATE_CONNECTED:
+ case MODULE_STATE_START_SENT:
+ case MODULE_STATE_START_FAILED:
+ case MODULE_STATE_STARTED:
+ case MODULE_STATE_STOP_SENT:
+ case MODULE_STATE_STOP_FAILED:
+ case MODULE_STATE_STOPPED:
+ case MODULE_STATE_START_PRE_SENT:
+ case MODULE_STATE_START_PRE_FAILED:
+ case MODULE_STATE_STARTED_PRE:
+ case MODULE_STATE_STOP_PRE_SENT:
+ case MODULE_STATE_STOP_PRE_FAILED:
+ case MODULE_STATE_STOPPED_PRE:
+ case MODULE_STATE_START_BACKGROUND_SENT:
+ case MODULE_STATE_START_BACKGROUND_FAILED:
+ case MODULE_STATE_STARTED_BACKGROUND:
+ case MODULE_STATE_STOP_BACKGROUND_SENT:
+ case MODULE_STATE_STOP_BACKGROUND_FAILED:
+ case MODULE_STATE_STOPPED_BACKGROUND:
+ l_isModuleConnected = TRUE;
+ break;
+
+ default:
+ l_isModuleConnected = FALSE;
+ break;
+ }
+
+ return (l_isModuleConnected);
+} // End of BOOL ModuleLaunchParams::IsModuleConnected(void)
+
+VOID ModuleLaunchParams::SetModuleState(SMModuleState f_moduleState, BOOL f_bLog) {
+ m_moduleState = f_moduleState;
+
+ switch (m_moduleState) { // Because the module status cannot be changed from the external API
+ case MODULE_STATE_INVALID:
+ case MODULE_STATE_SKIPPED:
+ case MODULE_STATE_LAUNCH_FAILED:
+ case MODULE_STATE_LAUNCHING:
+ case MODULE_STATE_LAUNCHED:
+ case MODULE_STATE_CONNECTED:
+ break;
+ case MODULE_STATE_START_SENT:
+ m_startReason.Begin();
+ break;
+ case MODULE_STATE_START_FAILED:
+ m_startReason.End();
+ m_startReason.SetReason(StartedByModuleStartFail);
+ break;
+ case MODULE_STATE_STARTED:
+ m_startReason.End();
+ m_startReason.SetReason(StartedByModuleStartComplete);
+ break;
+
+ case MODULE_STATE_STOP_SENT:
+ m_stopReason.Begin();
+ break;
+
+ case MODULE_STATE_STOP_FAILED:
+ m_stopReason.End();
+ m_stopReason.SetReason(StoppedByModuleStopFail);
+ break;
+ case MODULE_STATE_STOPPED:
+ m_stopReason.End();
+ m_stopReason.SetReason(StoppedByModuleStopComplete);
+ break;
+
+ case MODULE_STATE_START_PRE_SENT:
+ m_startReason.Begin();
+ break;
+ case MODULE_STATE_START_PRE_FAILED:
+ m_startReason.End();
+ m_startReason.SetReason(StartedByModulePreStartFail);
+ break;
+ case MODULE_STATE_STARTED_PRE:
+ m_startReason.End();
+ m_startReason.SetReason(StartedByModulePreStartComplete);
+ break;
+ case MODULE_STATE_STOP_PRE_SENT:
+ m_stopReason.Begin();
+ break;
+ case MODULE_STATE_STOP_PRE_FAILED:
+ m_stopReason.End();
+ m_stopReason.SetReason(StoppedByModulePreStopFail);
+ break;
+ case MODULE_STATE_STOPPED_PRE:
+ m_stopReason.End();
+ m_stopReason.SetReason(StoppedByModulePreStopComplete);
+ break;
+
+ case MODULE_STATE_START_BACKGROUND_SENT:
+ m_startReason.Begin();
+ break;
+ case MODULE_STATE_START_BACKGROUND_FAILED:
+ m_startReason.End();
+ m_startReason.SetReason(StartedByModuleBackgroundStartFail);
+ break;
+ case MODULE_STATE_STARTED_BACKGROUND:
+ m_startReason.End();
+ m_startReason.SetReason(StartedByModuleBackgroundStartComplete);
+ break;
+ case MODULE_STATE_STOP_BACKGROUND_SENT:
+ m_stopReason.Begin();
+ break;
+ case MODULE_STATE_STOP_BACKGROUND_FAILED:
+ m_stopReason.End();
+ m_stopReason.SetReason(StoppedByModuleBackgroundStopFail);
+ break;
+ case MODULE_STATE_STOPPED_BACKGROUND:
+ m_stopReason.End();
+ m_stopReason.SetReason(StoppedByModuleBackgroundStopComplete);
+ break;
+
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ }
+
+ if (f_bLog) {
+ char buf[255];
+ char *p = buf;
+ strcpy(p, m_ModuleStateStrMap[m_moduleState].c_str()); // NOLINT
+ p += m_ModuleStateStrMap[m_moduleState].size();
+ strcpy(p, ":"); // NOLINT
+ p += sizeof(":") - 1;
+ strcpy(p, name.c_str()); // NOLINT
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, buf);
+ }
+} // End of VOID ModuleLaunchParams::SetModuleState(SMModuleState f_moduleState )
+
+std::string ModuleLaunchParams::ModuleStateStr(void) {
+ return m_ModuleStateStrMap[m_moduleState];
+} // End of std::string ModuleLaunchParams::ModuleStateStr(SMModuleState f_moduleState )
+
+SMModuleDebugDumpState ModuleLaunchParams::GetModuleDebugDumpState(void) { // LCOV_EXCL_START 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_ModuleDebugDumpState;
+} // End of SMModuleDebugDumpState ModuleLaunchParams::GetModuleDebugDumpState(void)
+// LCOV_EXCL_STOP
+
+std::string ModuleLaunchParams::GetModuleDebugDumpStateStr(void) {
+ return m_ModuleDebugDumpStateStrMap[m_ModuleDebugDumpState];
+} // End of std::string ModuleLaunchParams::GetModuleDebugDumpStateStr()
+
+VOID ModuleLaunchParams::SetModuleDebugDumpState(
+ SMModuleDebugDumpState f_moduleDebugDumpState, BOOL f_bLog) {
+ m_ModuleDebugDumpState = f_moduleDebugDumpState;
+
+ if (f_bLog) { // LCOV_EXCL_BR_LINE 200:f_bLog must be TRUE
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s set for %s",
+ GetModuleDebugDumpStateStr().c_str(), name.c_str());
+ }
+} // End of VOID ModuleLaunchParams::SetModuleDebugDumpState(SMModuleDebugDumpState f_moduleDebugDumpState )
+
+EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(
+ const UI_32 f_iCmd, const T_SS_SM_START_DataStructType* const f_startData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ char l_cBuf[500] = " Error: char l_cBuf[] not built";
+ T_SS_SM_START_DataStructType l_startData;
+ SMModuleState l_SendSuccess = MODULE_STATE_START_SENT;
+ SMModuleState l_SendFailed = MODULE_STATE_START_FAILED;
+
+ memcpy(&l_startData, f_startData, sizeof(T_SS_SM_START_DataStructType));
+
+ switch (relaunch_status) { // LCOV_EXCL_BR_LINE 6: Because all conditions cannot be satisfied from the external API
+ case NotRelaunched:
+ // Setting startup information at the first startup
+ break;
+ case RelaunchSafe: // LCOV_EXCL_START 6: Because all conditions cannot be satisfied from the external API
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_startData.resetStatus = e_SS_SM_RESET_STATUS_NONE;
+ break;
+ case RelaunchErr:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_startData.resetStatus = e_SS_SM_RESET_STATUS_NG;
+ break;
+ default:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0);
+ break;
+ // LCOV_EXCL_STOP
+ }
+
+ switch (f_iCmd) {
+ case SS_SM_PRE_START:
+ l_SendSuccess = MODULE_STATE_START_PRE_SENT;
+ l_SendFailed = MODULE_STATE_START_PRE_FAILED;
+ break;
+ case SS_SM_PRE_STOP:
+ l_SendSuccess = MODULE_STATE_STOP_PRE_SENT;
+ l_SendFailed = MODULE_STATE_STOP_PRE_FAILED;
+ break;
+ case SS_SM_BACKGROUND_START:
+ l_SendSuccess = MODULE_STATE_START_BACKGROUND_SENT;
+ l_SendFailed = MODULE_STATE_START_BACKGROUND_FAILED;
+ break;
+ case SS_SM_BACKGROUND_STOP:
+ l_SendSuccess = MODULE_STATE_STOP_BACKGROUND_SENT;
+ l_SendFailed = MODULE_STATE_STOP_BACKGROUND_FAILED;
+ break;
+ case SS_SM_START:
+ default:
+ l_SendSuccess = MODULE_STATE_START_SENT;
+ l_SendFailed = MODULE_STATE_START_FAILED;
+ break;
+ }
+
+ const EFrameworkunifiedStatus l_eStatus = FrameworkunifiedSendMsg(hsession, f_iCmd,
+ sizeof(T_SS_SM_START_DataStructType),
+ static_cast<PCVOID>(&l_startData));
+
+ // LCOV_EXCL_START 6: As no TRUE is returned
+ if (IS_ZONE_SET(ZONE_ERR) || IS_ZONE_SET(ZONE_INFO)) {
+
+ snprintf(l_cBuf, sizeof(l_cBuf), "FrameworkunifiedSendMsg(%s, system_manager protocol message, %d/%s)",
+ name.c_str(), l_startData.startupReason,
+ GetStr(l_startData.startupReason).c_str());
+ }
+ // LCOV_EXCL_STOP 6:As no TRUE is returned
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4:NSFW's error
+ // LCOV_EXCL_START 4:NSFW's error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR(l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ SetModuleState(l_SendFailed);
+ // LCOV_EXCL_STOP
+ } else {
+ LOG_SUCCESS(l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ SetModuleState(l_SendSuccess);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// End of EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(T_SS_SM_START_DataStructType const * f_startData)
+
+EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(
+ T_SS_SM_STOP_DataStructType const* f_stopData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ char l_cBuf[500] = " Error: char l_cBuf[] not built";
+ EFrameworkunifiedStatus l_eStatus = FrameworkunifiedSendMsg(hsession, SS_SM_STOP,
+ sizeof(T_SS_SM_STOP_DataStructType),
+ static_cast<PCVOID>(f_stopData));
+
+ if (IS_ZONE_SET(ZONE_ERR) || IS_ZONE_SET(ZONE_INFO)) { // LCOV_EXCL_BR_LINE 200:alwasy true
+ snprintf(l_cBuf, sizeof(l_cBuf), "FrameworkunifiedSendMsg(%s, SS_SM_STOP, %d/%s, "
+ "Last User Mode: %s)", name.c_str(),
+ f_stopData->shutdownTrigger,
+ GetStr(f_stopData->shutdownTrigger).c_str(),
+ GetStr(f_stopData->lastUserMode).c_str());
+ }
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4:NSFW's error
+ // LCOV_EXCL_START 4:NSFW's error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR(l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ SetModuleState(MODULE_STATE_STOP_FAILED);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s successful", l_cBuf);
+ SetModuleState(MODULE_STATE_STOP_SENT);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// End of EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(T_SS_SM_STOP_DataStructType const * f_stopData)
+
+EFrameworkunifiedStatus ModuleLaunchParams::GetPriority(UI_32& f_Priority) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ struct sched_param cur_sch_params;
+ errno = 0;
+ f_Priority = 0xDEAD;
+
+ if (0 == pid) { // LCOV_EXCL_BR_LINE 200: pid can not be 0
+ // LCOV_EXCL_START 200: pid can not be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("0 == pid"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else if (-1 >= sched_getparam(pid, &cur_sch_params)) { // LCOV_EXCL_BR_LINE 5: system function failed
+ // LCOV_EXCL_START 5: system function failed
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFault;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: 'sched_getparam( pid %d, &cur_sch_params )' returned -1, "
+ "strerr() is '%s'", pid, strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ f_Priority = cur_sch_params.sched_priority;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus ModuleLaunchParams::GetPriority (UI_32 & f_Priority )
+
+EFrameworkunifiedStatus ModuleLaunchParams::SetPriority(UI_32 f_Priority) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ errno = 0;
+
+ if (99 < f_Priority) { // LCOV_EXCL_BR_LINE 200: priority can not greater than 99
+ // LCOV_EXCL_START 200: priority can not greater than 99
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Invalid 'f_Priority' %d/0x%X",
+ f_Priority, f_Priority);
+ // LCOV_EXCL_STOP
+ } else if (0 == pid) { // LCOV_EXCL_BR_LINE 200: pid can not be 0
+ // LCOV_EXCL_START 200: pid can not be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("0 == pid"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ int rc;
+ struct sched_param l_schedParam = { };
+ l_schedParam.sched_priority = f_Priority;
+
+ if (f_Priority == 0) { // LCOV_EXCL_BR_LINE 200: f_Priority can not be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ rc = sched_setscheduler(pid, SCHED_OTHER, &l_schedParam); // LCOV_EXCL_LINE 200: f_Priority can not be 0
+ } else {
+ rc = sched_setscheduler(pid, SCHED_FIFO, &l_schedParam);
+ }
+ SS_ASERT_ERRNO(0 == rc); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ if (rc == 0) {
+ previous_priority = current_priority;
+ current_priority = f_Priority;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " setprio( %s, pid %d, 'previous_priority' %d -> %d ) successful",
+ name.c_str(), pid, previous_priority, f_Priority);
+ } else if (rc == -1) { // LCOV_EXCL_BR_LINE 5: system function failed
+ // LCOV_EXCL_START 5: system function failed
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFault;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " setprio( %s, pid %d, 'current_priority' %d -> %d ) returned '-1', strerr() is '%s'",
+ name.c_str(), pid, current_priority, f_Priority,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else { // LCOV_EXCL_BR_LINE 5: can not be other value
+ // LCOV_EXCL_START 5: can not be other value
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFault;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " setprio( %s, pid %d, 'current_priority' %d -> %d ) returned '%d'; "
+ "'rc' is neither original priority nor '-1': 'errno' is '%d', strerr() is '%s'",
+ name.c_str(), pid, current_priority, f_Priority, rc,
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus ModuleLaunchParams::SetPriority( UI_32 f_Priority )
+
+SysMgrConfiguration::SysMgrConfiguration():
+l_pReaderCfg(NULL) {
+}
+
+SysMgrConfiguration::~SysMgrConfiguration() {
+}
+
+static BOOL is_satisfy_env_launch_cond(CHAR *env_cond) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL l_isSatisfy = FALSE;
+ BOOL l_isReverse = FALSE;
+ CHAR *l_pString = NULL;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "env_cond [%s]", env_cond);
+
+ if (NULL != (l_pString = strstr(env_cond, "!="))) {
+ l_isReverse = TRUE;
+ } else if (NULL == (l_pString = strstr(env_cond, "=="))) {
+ SS_ASERT(0);
+ }
+
+ if (NULL != l_pString) {
+ CHAR *l_pEnv = env_cond;
+ CHAR *l_pValue = l_pString + 2;
+ *l_pString = '\0';
+
+ CHAR *l_pEnvVariable = NULL;
+
+ if (NULL != (l_pEnvVariable = std::getenv(l_pEnv))) {
+ l_isSatisfy = (0 == strcmp(l_pValue, l_pEnvVariable)) ? TRUE : FALSE;
+ if (l_isReverse) {
+ l_isSatisfy = !l_isSatisfy;
+ }
+ }
+ }
+
+ return l_isSatisfy;
+}
+
+static void set_grp_member_info(const LaunchInfo& launch_info, ModuleLaunchList& module_lst) { // NOLINT
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // Note: the
+ ModuleLaunchParams grp_member_info;
+ grp_member_info.name = launch_info.name;
+ grp_member_info.path = launch_info.binary_name;
+ grp_member_info.arguments = launch_info.arguments;
+ grp_member_info.restart = launch_info.restart;
+ grp_member_info.configuration_priority = launch_info.priority;
+ grp_member_info.retry_cnt = launch_info.retry_cnt;
+ grp_member_info.logging_msk_str = launch_info.logging_msk_str;
+ grp_member_info.critical = launch_info.critical;
+ grp_member_info.shutdown_critical = launch_info.shutdown_critical;
+ grp_member_info.shutdown_wait_time = launch_info.shutdown_wait_time;
+ grp_member_info.group_id = launch_info.group_id;
+ grp_member_info.is_start_required = launch_info.is_start_required;
+ grp_member_info.fast_shutdown_wait_time = launch_info.fast_shutdown_wait_time;
+ grp_member_info.SetAGLUnit(launch_info.IsAGLUnit());
+ grp_member_info.SetAGLResetHistoryDisable(launch_info.IsAGLResetHistoryDisable());
+ grp_member_info.SetNonAGLResetHisoryDisable(launch_info.IsNonAGLResetHistoryDisable());
+
+ module_lst.push_back(grp_member_info);
+}
+// LCOV_EXCL_STOP
+
+static ModuleLaunchListIter set_cfg_grp_member_info(
+ const CfgLaunchParams& launch_info, ModuleLaunchList& module_lst) { // NOLINT
+ ModuleLaunchParams grp_member_info;
+ ModuleLaunchListIter moduleLaunchListIter;
+
+ grp_member_info.name = launch_info.name;
+ grp_member_info.path = launch_info.binary_name;
+ grp_member_info.arguments = ( // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::strcmp(launch_info.arguments, "NULL") == 0 ? "" : launch_info.arguments);
+ grp_member_info.restart = ( // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::strcmp(launch_info.restart, "NULL") == 0 ? "" : launch_info.restart);
+ grp_member_info.configuration_priority = launch_info.priority;
+ grp_member_info.cpu_assign = launch_info.cpu_assign;
+ grp_member_info.retry_cnt = launch_info.retry_cnt;
+ grp_member_info.logging_msk_str = ( // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::strcmp(launch_info.logging_msk_str, "NULL") == 0 ? "" : launch_info.logging_msk_str);
+
+ grp_member_info.critical = launch_info.critical;
+ grp_member_info.shutdown_critical = launch_info.shutdown_critical;
+ grp_member_info.shutdown_wait_time = launch_info.shutdown_wait_time;
+ grp_member_info.group_id = launch_info.group_id;
+ grp_member_info.is_start_required = launch_info.is_start_required;
+ grp_member_info.fast_shutdown_wait_time = launch_info.fast_shutdown_wait_time;
+ grp_member_info.SetAGLUnit(launch_info.IsAGLUnit());
+ grp_member_info.SetAGLResetHistoryDisable(launch_info.IsAGLResetHistoryDisable());
+ grp_member_info.SetNonAGLResetHisoryDisable(launch_info.IsNonAGLResetHistoryDisable());
+
+ strncpy(&grp_member_info.unix_user_name[0], &launch_info.unix_user_name[0],
+ sizeof(TUserNameBuffer));
+
+ moduleLaunchListIter = module_lst.insert(module_lst.end(), grp_member_info);
+ return (moduleLaunchListIter);
+}
+
+static void load_parameters_order_cfg(GroupLaunchMap& groups_map, // NOLINT
+ LaunchOrderedVector& f_OrderList, SS_String& f_launchOrderName, // NOLINT
+ SS_String& f_launchCfgFn) { // NOLINT
+ SS_String l_OrderCfgFn = f_launchCfgFn;
+ string::size_type pos = l_OrderCfgFn.find(".cfg");
+
+ if (pos == string::npos) { // LCOV_EXCL_BR_LINE 5:C error
+ // LCOV_EXCL_START 5:C error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "invalid file name:%s",
+ f_launchCfgFn.c_str());
+ return;
+ // LCOV_EXCL_STOP
+ }
+
+ l_OrderCfgFn.replace(pos, strlen(".order.cfg"), ".order.cfg");
+ CNSConfigReader *l_pReaderOrderCfg = new CNSConfigReader(l_OrderCfgFn);
+
+ if (l_pReaderOrderCfg != NULL) { // LCOV_EXCL_BR_LINE 5:new error
+ CHAR key[128];
+ std::sprintf(key, "%s.order", f_launchOrderName.c_str()); // NOLINT
+ SS_String value = l_pReaderOrderCfg->GetString(key);
+ std::vector<std::string> strList;
+ if (value.empty()) { // LCOV_EXCL_BR_LINE 200:cannot be empty
+ goto ERROR;
+ }
+// LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ boost::split(strList, value, boost::is_any_of("|"));
+ for (UI_32 i = 0; i < strList.size(); i++) {
+ char* endptr = NULL;
+ f_OrderList.push_back(
+ static_cast<UI_32>(strtoul(strList[i].c_str(), &endptr, 10)));
+ if (*endptr != '\0') {
+ // Discard boot order if invalid string is detected
+ f_OrderList.clear();
+ goto ERROR;
+ }
+ }
+ std::sprintf(key, "%s.owlist", f_launchOrderName.c_str()); // NOLINT
+ SS_String ow_list_value = l_pReaderOrderCfg->GetString(key);
+ std::vector<std::string> owList;
+
+ if (!ow_list_value.empty()) {
+ boost::split(owList, ow_list_value, boost::is_any_of("|"));
+ for (UI_32 i = 0; i < owList.size(); i++) {
+ std::sprintf(key, "%s.%s", f_launchOrderName.c_str(), // NOLINT
+ owList[i].c_str());
+ SS_String grop_ow_time = l_pReaderOrderCfg->GetString(key);
+ if (owList[i].compare(0, 4, "oww_") == 0) {
+ char* endptr = NULL;
+ SS_String group_name = owList[i].substr(strlen("oww_"));
+ UI_32 group_launch_wait = static_cast<UI_32>(strtoul(
+ grop_ow_time.c_str(), &endptr, 10));
+ if (*endptr != '\0') {
+ continue;
+ }
+ GroupLaunchMapIter grp_iter = groups_map.begin();
+ while (grp_iter != groups_map.end()) {
+ if (group_name == grp_iter->second.name) {
+ grp_iter->second.grp_launch_wait = group_launch_wait;
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
+ "grp_launch_wait %s=%d", group_name.c_str(),
+ group_launch_wait);
+ break;
+ }
+ grp_iter++;
+ }
+ }
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "ConfigReader(%s) is NULL",
+ l_OrderCfgFn.c_str());
+ }
+// LCOV_EXCL_STOP
+ ERROR: if (l_pReaderOrderCfg != NULL) { // LCOV_EXCL_BR_LINE 200:cannot be null
+ delete l_pReaderOrderCfg; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ return;
+}
+
+// Given a string, splits it up on the seperator character
+// SubStringIterator( "a|b|| c |", '|' )
+// -> On each subsequent invocation of next() would return "a", "b", "", " c ", ""
+class SubStringIterator {
+ typedef std::string::const_iterator SCIter;
+
+ public:
+ SubStringIterator(const std::string& s, char c) :
+ m_position(s.begin()), m_end(s.end()), m_seperator(c), m_done(false) {
+ }
+
+ std::string next() {
+ SCIter begin = m_position;
+ while (m_position != m_end &&
+ *m_position != m_seperator) {
+ ++m_position;
+ }
+
+ const std::string ret(begin, m_position);
+ if (m_position == m_end) {
+ m_done = true;
+ } else {
+ ++m_position;
+ }
+
+ return ret;
+ }
+ bool done() const {
+ return m_done;
+ }
+
+ private:
+ SCIter m_position;
+ const SCIter m_end;
+ const char m_seperator;
+ bool m_done;
+};
+
+template<class Iter>
+static
+Iter skipPrecedingWS(Iter begin, Iter end) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return std::find_if(begin, end,
+ std::not1(std::ptr_fun((int (*)(int))std::isspace)));
+}
+
+// remove only preceding and trailing whitespace, but leave intermediate whitespace characters alone
+std::string strip(const std::string& str) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::string::const_iterator skipTo = skipPrecedingWS(str.begin(), str.end());
+ if (skipTo == str.end()) { // if string consists of ONLY whitespace
+ return std::string("");
+ } else {
+ return std::string(skipTo, skipPrecedingWS(str.rbegin(), str.rend()).base());
+ }
+}
+// LCOV_EXCL_STOP
+
+BOOL SysMgrConfiguration::LoadParametersCfg(GroupLaunchMap& groups_map,
+ ProcessNameMap& f_processNameMap, LaunchOrderedVector& f_OrderList,
+ SS_String& f_launchOrderName, SS_String& f_launchCfgFn) {
+ BOOL rtn_code = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_pReaderCfg = new (std::nothrow) CNSConfigReader(f_launchCfgFn); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (NULL != l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5:new error
+ UI_32 launch_idx = 1;
+ CHAR key[128];
+ std::sprintf(key, "ModulesLaunchConfig.Launch%d", launch_idx); // NOLINT
+ SS_String value = l_pReaderCfg->GetString(key);
+
+ if (value.empty()) { // LCOV_EXCL_BR_LINE 200:cannot be empty
+// LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: l_pReaderCfg->GetString(%s) returned empty-string; "
+ "is launch configuration file mis-configured ?",
+ key);
+ rtn_code = FALSE;
+// LCOV_EXCL_STOP
+ } else {
+ const char* nfsenv = getenv("AGL_NFS");
+ bool isNfs = (nfsenv && strcmp(nfsenv, "y") == 0) ? true : false; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ std::list<std::string> capFiles;
+ if (isNfs) {
+// LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ const std::string capPath("/usr/debug/share/target/cap.lst");
+ std::ifstream fin(capPath.c_str());
+ std::string line;
+ while (fin && std::getline(fin, line)) {
+ std::list<std::string> strList;
+ boost::split(strList, line, boost::is_any_of("|"));
+ if (!strList.empty()) {
+ if (strList.front()[0] == '/') { // Only character strings beginning with '/' are considered PATH
+ capFiles.push_back(strList.front().c_str());
+ }
+ }
+ }
+ }
+// LCOV_EXCL_STOP
+ while (!value.empty()) {
+ CHAR critical[10] = { };
+ CHAR is_start_required[10] = { };
+ CHAR shutdown_critical[10] = { };
+ CHAR group_wait_for_trigger[10] = { };
+ CHAR is_agl_unit[10] = { };
+ CHAR disable_agl_resethistory[10] = { };
+ CHAR disable_nonagl_resethistory[10] = { };
+ CfgLaunchParams cfg_data;
+
+ int at = static_cast<int>(ss_sm_cfg::cfg_args::group_name);
+
+ SubStringIterator iter(value, '|');
+ while (!iter.done() && ss_sm_cfg::cfg_args::END != at) {
+ const std::string data_ = iter.next();
+ if (!data_.empty()) {
+ const char* data = data_.c_str();
+ switch (at) {
+ case ss_sm_cfg::cfg_args::group_name:
+ snprintf(cfg_data.group_name,
+ sizeof(cfg_data.group_name), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::group_id:
+ cfg_data.group_id = static_cast<UI_32>(strtoul(data, NULL, 10));
+ break;
+ case ss_sm_cfg::cfg_args::group_launch_wait:
+ cfg_data.group_launch_wait =
+ static_cast<UI_32>(strtoul(data, NULL, 10));
+ break;
+ case ss_sm_cfg::cfg_args::group_wait_for_trigger:
+ snprintf(group_wait_for_trigger,
+ sizeof(group_wait_for_trigger), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::name:
+ snprintf(cfg_data.name, sizeof(cfg_data.name), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::binary_name:
+ snprintf(cfg_data.binary_name,
+ sizeof(cfg_data.binary_name), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::priority:
+ cfg_data.priority = static_cast<UI_32>(strtoul(data, NULL, 10));
+ break;
+ case ss_sm_cfg::cfg_args::critical:
+ snprintf(critical, sizeof(critical), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::retry_cnt:
+ cfg_data.retry_cnt = static_cast<UI_32>(strtoul(data, NULL, 10));
+ break;
+ case ss_sm_cfg::cfg_args::arguments:
+ strncpy(cfg_data.arguments, data,
+ sizeof(cfg_data.arguments) - 1);
+ break;
+ case ss_sm_cfg::cfg_args::logging_msk:
+ snprintf(cfg_data.logging_msk_str,
+ sizeof(cfg_data.logging_msk_str), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::restart:
+ snprintf(cfg_data.restart, sizeof(cfg_data.restart), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::is_start_required:
+ snprintf(is_start_required,
+ sizeof(is_start_required), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::shutdown_critical:
+ snprintf(shutdown_critical,
+ sizeof(shutdown_critical), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::shutdown_wait_time:
+ cfg_data.shutdown_wait_time =
+ static_cast<UI_32>(strtoul(data, NULL, 10));
+ break;
+ case ss_sm_cfg::cfg_args::fast_shutdown_wait_time:
+ cfg_data.fast_shutdown_wait_time =
+ static_cast<UI_32>(strtoul(data, NULL, 10));
+ break;
+ case ss_sm_cfg::cfg_args::unix_user_name:
+ strncpy(&cfg_data.unix_user_name[0],
+ strip(data_).c_str(),
+ sizeof(cfg_data.unix_user_name) - 1);
+ break;
+ case ss_sm_cfg::cfg_args::is_agl_unit:
+ strncpy(is_agl_unit, data, sizeof(is_agl_unit));
+ break;
+ case ss_sm_cfg::cfg_args::disable_agl_resethistory:
+ strncpy(disable_agl_resethistory, data, sizeof(disable_agl_resethistory));
+ break;
+ case ss_sm_cfg::cfg_args::disable_nonagl_resethistory:
+ strncpy(disable_nonagl_resethistory, data, sizeof(disable_nonagl_resethistory));
+ break;
+ case ss_sm_cfg::cfg_args::env_value_condition: // LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ snprintf(cfg_data.env_value_condition,
+ sizeof(cfg_data.env_value_condition), "%s", data);
+ break;
+ case ss_sm_cfg::cfg_args::cpu_assign:
+ cfg_data.cpu_assign =
+ static_cast<int>(strtoul(data, NULL, 16));
+ break;
+ default:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: unknown ss_sm_cfg::cfg_args::xxx/'at' "
+ "enum value '%d'", at);
+ break;
+ // LCOV_EXCL_STOP
+ }
+ }
+ ++at;
+ }
+ ////////////////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_BR_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
+ if (0 != std::strlen(cfg_data.env_value_condition)
+ && FALSE
+ == is_satisfy_env_launch_cond(
+// LCOV_EXCL_BR_STOP
+ cfg_data.env_value_condition)) { // LCOV_EXCL_LINE 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "exclude %s from wakeup service", cfg_data.name);
+ } else {
+ if (isNfs) { // LCOV_EXCL_BR_LINE 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
+ // Since the NFS environment is used by copying the executable file containing the CAP to /tmp, it is read out.
+// LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::string binPath(cfg_data.binary_name);
+ for (std::list<std::string>::iterator ite =
+ capFiles.begin(); ite != capFiles.end(); ite++) {
+ if (binPath == *ite) {
+ std::list<std::string> nodes;
+ boost::split(nodes, binPath, boost::is_any_of("/"));
+ std::string newPath("/tmp/");
+ newPath += nodes.back();
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "EXCHG %s", newPath.c_str());
+ snprintf(cfg_data.binary_name,
+ sizeof(cfg_data.binary_name), "%s", newPath.c_str());
+ break;
+ }
+ }
+ }
+// LCOV_EXCL_STOP
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "is_start_required: %s", is_start_required);
+ cfg_data.is_start_required = (std::strcmp("True",
+ is_start_required) == 0);
+
+ if (std::strcmp("True", group_wait_for_trigger) == 0) {
+ cfg_data.group_wait_for_trigger = TRUE;
+ } else {
+ cfg_data.group_wait_for_trigger = FALSE;
+ }
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "critical: %s", critical);
+ cfg_data.critical = (std::strcmp("True", critical) == 0);
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown_critical: %s", shutdown_critical);
+ cfg_data.shutdown_critical = (std::strcmp("True",
+ shutdown_critical) == 0);
+
+ cfg_data.SetAGLUnit(ParseBoolParameter(is_agl_unit, TRUE));
+ cfg_data.SetAGLResetHistoryDisable(ParseBoolParameter(disable_agl_resethistory));
+ cfg_data.SetNonAGLResetHisoryDisable(ParseBoolParameter(disable_nonagl_resethistory));
+
+ GroupLaunchInfo grp_info;
+ grp_info.start_complete = FALSE;
+ grp_info.stop_complete = FALSE;
+ grp_info.launch_complete = FALSE;
+ grp_info.name = cfg_data.group_name;
+ grp_info.id = cfg_data.group_id;
+ grp_info.grp_launch_wait = cfg_data.group_launch_wait;
+ grp_info.grp_wait_for_trigger =
+ cfg_data.group_wait_for_trigger;
+ ModuleLaunchListIter l_moduleLaunchListIter;
+
+ GroupLaunchMapIter grp_iter = groups_map.find(grp_info.id);
+ if (grp_iter != groups_map.end()) {
+ l_moduleLaunchListIter = set_cfg_grp_member_info(
+ cfg_data, grp_iter->second.modules);
+ } else {
+ l_moduleLaunchListIter = set_cfg_grp_member_info(
+ cfg_data, grp_info.modules);
+
+ // add this grp info object to the list of grps
+ groups_map.insert(make_pair(grp_info.id, grp_info));
+ }
+
+ std::string l_binaryNameStr = cfg_data.binary_name;
+ size_t l_binaryNamePos = l_binaryNameStr.find_last_of("/");
+ if (std::string::npos != l_binaryNamePos) {
+ l_binaryNameStr = l_binaryNameStr.substr(l_binaryNamePos + 1);
+ f_processNameMap.insert(
+ make_pair(l_binaryNameStr, l_moduleLaunchListIter));
+ }
+ }
+
+ std::sprintf(key, "ModulesLaunchConfig.Launch%d", ++launch_idx); // NOLINT
+ value = l_pReaderCfg->GetString(key);
+ } // end while
+ }
+ } else { // LCOV_EXCL_START 6: Because new doesn't pass the failure case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // defaults use from the header file ... this is much faster then reading from an xml file.
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: \"new CNSConfigReader(%s)\" returned NULL; using "
+ "constants.", f_launchCfgFn.c_str());
+ UI_32 num_of_items = static_cast<UI_32>(_countof(g_arrLaunchTableCfg));
+ for (UI_32 arr_idx = 0; arr_idx < num_of_items; arr_idx++) {
+ GroupLaunchInfo grp_info;
+ grp_info.launch_complete = FALSE;
+ grp_info.name = g_arrLaunchTableCfg[arr_idx].group_name;
+ grp_info.id = g_arrLaunchTableCfg[arr_idx].group_id;
+ grp_info.grp_launch_wait =
+ g_arrLaunchTableCfg[arr_idx].group_launch_wait;
+
+ GroupLaunchMapIter grp_iter = groups_map.find(grp_info.id);
+
+ if (grp_iter != groups_map.end()) {
+ set_grp_member_info(g_arrLaunchTableCfg[arr_idx],
+ grp_iter->second.modules);
+ } else {
+ set_grp_member_info(g_arrLaunchTableCfg[arr_idx],
+ grp_info.modules);
+ // add this grp info object to the list of grps
+ groups_map.insert(make_pair(grp_info.id, grp_info));
+ }
+ }
+ }
+ // LCOV_EXCL_STOP
+ if (rtn_code == TRUE) {
+ load_parameters_order_cfg(groups_map, f_OrderList, f_launchOrderName, f_launchCfgFn);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return rtn_code;
+}
+
+VOID SysMgrConfiguration::PrintGroupInfo(GroupLaunchInfo& refGrpInfo) {
+ std::stringstream l_logMsg;
+
+ l_logMsg << endl << "Group: " << refGrpInfo.name.data() << endl
+ << " id: " << refGrpInfo.id << endl << " wait-time: "
+ << refGrpInfo.grp_launch_wait << endl << " launch complete: "
+ << (refGrpInfo.launch_complete == TRUE ? "YES" : "NO"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ std::string l_logStr = l_logMsg.str();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", l_logStr.c_str());
+}
+
+VOID SysMgrConfiguration::PrintModuleInfo(ModuleLaunchParams& refMbrInfo) {
+ std::stringstream l_logMsg;
+
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_logMsg << endl << "Module: " << refMbrInfo.name.data() << endl
+ << " path: " << refMbrInfo.path.data() << endl << " args: "
+ << refMbrInfo.arguments.data() << endl << " restart: "
+ << refMbrInfo.restart.data() << endl
+ << " configuration_priority: "
+ << refMbrInfo.configuration_priority << endl
+ << " cpu_assign: "
+ << refMbrInfo.cpu_assign << endl
+ << " current_priority: " << refMbrInfo.current_priority << endl
+ << " previous_priority: " << refMbrInfo.previous_priority << endl
+ << " critical: " << (refMbrInfo.critical == TRUE ? "YES" : "NO")
+ << endl
+ << " retry count: " << refMbrInfo.retry_cnt << endl
+ << " logging mask: " << refMbrInfo.logging_msk_str << endl
+ << " is_start_required: "
+ << (refMbrInfo.is_start_required == TRUE ? "YES" : "NO")
+ << endl
+ << " shutdown_critical: "
+ << (refMbrInfo.shutdown_critical == TRUE ? "YES" : "NO") << endl
+ << " shutdown_wait_time: " << refMbrInfo.shutdown_wait_time
+ << endl << " fast_shutdown_wait_time: "
+ << refMbrInfo.fast_shutdown_wait_time << endl << " is_agl_unit: "
+ << refMbrInfo.IsAGLUnit() << endl << " disable_agl_resethistory: "
+ << refMbrInfo.IsAGLResetHistoryDisable() << endl << " disable_nonagl_resethistory: "
+ << refMbrInfo.IsNonAGLResetHistoryDisable() << endl << " state: "
+ << refMbrInfo.ModuleStateStr() << endl << " group ID: "
+ << refMbrInfo.group_id << endl << " debug dump state: "
+ << refMbrInfo.GetModuleDebugDumpStateStr();
+ // LCOV_EXCL_BR_STOP
+ std::string l_logStr = l_logMsg.str();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", l_logStr.c_str());
+}
+
+VOID SysMgrConfiguration::PrintAllInfo(GroupLaunchMap& refGrpMap) {
+ // get first client from the map...
+ GroupLaunchMapIter grp_iter = refGrpMap.begin();
+
+ for (; grp_iter != refGrpMap.end(); grp_iter++) {
+ PrintGroupInfo(grp_iter->second);
+ ModuleLaunchListIter mbr_iter = grp_iter->second.modules.begin();
+ for (; mbr_iter != grp_iter->second.modules.end(); mbr_iter++) {
+ PrintModuleInfo(*mbr_iter);
+ }
+ }
+}
+
+BOOL SysMgrConfiguration::ParseBoolParameter(PCSTR f_value, BOOL f_default) const {
+ if (FALSE == f_default) {
+ const char TRUE_VALUE[] = "True";
+ if (0 == strcmp(TRUE_VALUE, f_value)) {
+ return TRUE;
+ }
+ } else {
+ const char FALSE_VALUE[] = "False";
+ if (0 == strcmp(FALSE_VALUE, f_value)) {
+ return FALSE;
+ }
+ }
+ return f_default;
+}
+
+/*
+ * SM Configuration data constructor
+ */
+SMConfigParams::SMConfigParams() {
+}
+
+/*
+ * SM Configuration data destructor
+ */
+SMConfigParams::~SMConfigParams() {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// PrintConfigInfo
+/// \brief Print the configuration data stored in config structure
+///
+/// \param [in] configata
+/// ConfigurationData & - Ref to structure that get populated.
+///
+/// \return VOID
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID SMConfigParams::PrintConfigInfo(ConfigurationData const & f_ConfigParams) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "AppHeartBeatInterval_Initial Info: %d",
+ f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalInitial);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "AppHeartBeatInterval_Repeat Info: %d",
+ f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalRepeat);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "HBMaxHeartBeatRetryCount Info: %d",
+ f_ConfigParams.HBConfig.MaxHeartBeatRetryCount);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CDEnabled: %d",
+ f_ConfigParams.CDConfig.CrashDetectorEnabled);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMTimerValue: %d",
+ f_ConfigParams.SLMConfig.SLMTimerValue);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMMaxRetryCount: %d",
+ f_ConfigParams.SLMConfig.SLMMaxRetryCount);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMThresholdValue: %d",
+ f_ConfigParams.SLMConfig.SLMThresholdValue);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMSystemmanagerLogIntervalMs: %d",
+ f_ConfigParams.SLMConfig.SLMSystemmanagerLogIntervalMs);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "UserModeStructIsBoolean: %s",
+ GetStr(f_ConfigParams.UMConfig.IsUserModeNotificationABOOL).c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "ModuleConnectionNumTimesToCheck: %d",
+ f_ConfigParams.MCConfig.ModuleConnectionNumTimesToCheck);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "ModuleConnectionTimeOutSec: %d",
+ f_ConfigParams.MCConfig.ModuleConnectionTimeOutSec);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "ModuleStartRespTimeOutSec: %d",
+ f_ConfigParams.MCConfig.ModuleStartRespTimeOutSec);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CriticalAppsMaxShutdownTimeFastSleep: %d",
+ f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeFastSleep);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "CriticalAppsMaxShutdownTimeNormalReset: %d",
+ f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeNormalReset);
+ return;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetSMConfigInformation
+/// \brief Read config data from cfg file and populate the configuration data structure
+///
+/// \param [in] f_ConfigParams & - Ref to ConfigurationData that get populated.
+/// \param [in] f_FileName - Configuration file name.
+///
+/// \return BOOL
+/// BOOL - TRUE or FALSE
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL SMConfigParams::GetSMConfigInformation(ConfigurationData& f_ConfigParams, SS_String f_FileName) {
+ EFrameworkunifiedStatus l_eStatus;
+ BOOL l_rtnCode = FALSE; // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ CNSConfigReader *l_pReaderCfg = new (std::nothrow) CNSConfigReader(); // LCOV_EXCL_BR_LINE 10: As new does not fail
+// LCOV_EXCL_BR_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ if (NULL == l_pReaderCfg) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. new CNSConfigReader() returned NULL pointer.");
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(f_FileName))) {
+ // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->Open(%s) returned NULL pointer.",
+ f_FileName.c_str());
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "Heartbeat.MaxHeartBeatRetryCount",
+ f_ConfigParams.HBConfig.MaxHeartBeatRetryCount))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('Heartbeat.MaxHeartBeatRetryCount')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "Heartbeat.AppHeartBeatIntervalInitial",
+ f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalInitial))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('Heartbeat.AppHeartBeatIntervalInitial')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "Heartbeat.AppHeartBeatIntervalRepeat",
+ f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalRepeat))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('Heartbeat.AppHeartBeatIntervalRepeat')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetBool("CrashDetector.Enabled",
+ f_ConfigParams.CDConfig.CrashDetectorEnabled))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetBool('CrashDetector.Enabled')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt("SysLowMemory.TimerValue",
+ f_ConfigParams.SLMConfig.SLMTimerValue))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('SysLowMemory.TimerValue')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "SysLowMemory.MaxRetryCount",
+ f_ConfigParams.SLMConfig.SLMMaxRetryCount))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('SysLowMemory.MaxRetryCount')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "SysLowMemory.ThresholdValue",
+ f_ConfigParams.SLMConfig.SLMThresholdValue))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('SysLowMemory.ThresholdValue')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "SysLowMemory.InterfaceunifiedLogIntervalMs",
+ f_ConfigParams.SLMConfig.SLMSystemmanagerLogIntervalMs))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('SysLowMemory.InterfaceunifiedLogIntervalMs')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetBool(
+ "UserModeNotification.IsBoolean",
+ f_ConfigParams.UMConfig.IsUserModeNotificationABOOL))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetBool('UserModeNotification.IsBoolean')");
+ f_ConfigParams.UMConfig.IsUserModeNotificationABOOL = TRUE;
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "Module.ModuleConnectionNumTimesToCheck",
+ f_ConfigParams.MCConfig.ModuleConnectionNumTimesToCheck))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('Module.ModuleConnectionNumTimesToCheck')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "Module.ModuleConnectionTimeOutSec",
+ f_ConfigParams.MCConfig.ModuleConnectionTimeOutSec))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('Module.ModuleConnectionTimeOutSec')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "Module.ModuleStartRespTimeOutSec",
+ f_ConfigParams.MCConfig.ModuleStartRespTimeOutSec))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('Module.ModuleStartRespTimeOutSec')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "CriticalApps.CriticalAppsMaxShutdownTimeFastSleep",
+ f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeFastSleep))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('CriticalApps.CriticalAppsMaxShutdownTimeFastSleep')");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt(
+ "CriticalApps.CriticalAppsMaxShutdownTimeNormalReset",
+ f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeNormalReset))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ "l_pReaderCfg->GetInt('CriticalApps.CriticalAppsMaxShutdownTimeNormalReset')");
+ } else {
+ l_rtnCode = TRUE;
+ }
+
+ delete l_pReaderCfg; // LCOV_EXCL_BR_LINE 10: As the delete does not fail
+ }
+// LCOV_EXCL_BR_STOP
+
+ return (l_rtnCode);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// LoadSMConfigParameters
+/// \brief Read System Manager configuration parameters from cfg file or
+/// use defaults values in case cfg file is not available
+///
+/// \param [in] f_ConfigParams & - Ref to ConfigurationData that get populated.
+/// \param [in] f_FileName - Configuration file name.
+///
+/// \return BOOL
+/// BOOL - TRUE or FALSE
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL SMConfigParams::LoadSMConfigParameters(ConfigurationData& f_ConfigParams, SS_String f_FileName) {
+ BOOL rtn_code = TRUE;
+
+ rtn_code = GetSMConfigInformation(f_ConfigParams, f_FileName);
+
+ // cfg config file not found, use constants
+ if (FALSE == rtn_code) {
+ // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: cfg config file not open, using constants");
+
+ // Heart Beat constants
+ f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalInitial =
+ HBApplicationHeartBeatIntervalInitial;
+ f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalRepeat =
+ HBApplicationHeartBeatIntervalRepeat;
+ f_ConfigParams.HBConfig.MaxHeartBeatRetryCount = HBMaxHeartBeatRetryCount;
+
+ // Crash Detector constants
+ f_ConfigParams.CDConfig.CrashDetectorEnabled = CDEnabled;
+
+ // System Low Memory
+ f_ConfigParams.SLMConfig.SLMTimerValue = SLMTimerValue;
+ f_ConfigParams.SLMConfig.SLMMaxRetryCount = SLMRetryCount;
+ f_ConfigParams.SLMConfig.SLMThresholdValue = SLMThresholdValue;
+ f_ConfigParams.SLMConfig.SLMSystemmanagerLogIntervalMs = SLMSystemmanagerLogIntervalMs;
+
+ // Module connect and start resp
+ f_ConfigParams.MCConfig.ModuleConnectionNumTimesToCheck =
+ ModuleConnectionNumTimesToCheck;
+ f_ConfigParams.MCConfig.ModuleConnectionTimeOutSec =
+ ModuleConnectionTimeOutSec;
+ f_ConfigParams.MCConfig.ModuleStartRespTimeOutSec = ModuleStartRespTimeOutSec;
+
+ // Critical Apps shutdown time
+ f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeFastSleep =
+ CriticalAppsMaxShutdownTimeFastSleepSec;
+ f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeNormalReset =
+ CriticalAppsMaxShutdownTimeNormalResetSec;
+
+ // USer Mode Data Structure Type
+ f_ConfigParams.UMConfig.IsUserModeNotificationABOOL = TRUE;
+ // LCOV_EXCL_STOP
+ }
+ PrintConfigInfo(f_ConfigParams);
+
+ return rtn_code;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/system_manager/server/src/ss_sm_dynamic_launcher.cpp b/systemservice/system_manager/server/src/ss_sm_dynamic_launcher.cpp
new file mode 100755
index 0000000..6144fa4
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_sm_dynamic_launcher.cpp
@@ -0,0 +1,221 @@
+/*
+ * @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 process launching.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <string>
+#include <sstream>
+#include <iomanip>
+
+#include "ss_sm_dynamic_launch_table.h"
+#include "ss_sm_systemmanagerlog.h"
+
+DynamicLaunchBase::DynamicLaunchBase():
+m_vOrderedGroup(),
+m_iterOrderedGroup() {
+}
+
+
+DynamicLaunchBase::~DynamicLaunchBase() {
+}
+
+UI_32 DynamicLaunchBase::get_id() const {
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " DLB: Active Group ID is %d", *m_iterOrderedGroup);
+ return *m_iterOrderedGroup;
+}
+
+UI_32 DynamicLaunchBase::advance_id() {
+ if (!is_end()) {
+ m_iterOrderedGroup++;
+ }
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " DLB: Active Group ID is %d", *m_iterOrderedGroup);
+ return *m_iterOrderedGroup;
+}
+
+UI_32 DynamicLaunchBase::decrement_id() {
+ if (!is_begin()) { // LCOV_EXCL_BR_LINE 5: stdlib error case.
+ m_iterOrderedGroup--;
+ }
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " DLB: Active Group ID is %d", *m_iterOrderedGroup);
+ return *m_iterOrderedGroup;
+}
+
+BOOL DynamicLaunchBase::is_begin() {
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " DLB: Active Group ID is %d", *m_iterOrderedGroup);
+ return (m_iterOrderedGroup == m_vOrderedGroup.begin());
+}
+
+BOOL DynamicLaunchBase::is_end() {
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " DLB: Active Group ID is %d", *m_iterOrderedGroup);
+ DynamicOrderedIter l_it = m_iterOrderedGroup;
+ l_it++;
+ return (l_it == m_vOrderedGroup.end());
+}
+
+VOID DynamicLaunchBase::to_begin() {
+ m_iterOrderedGroup = m_vOrderedGroup.begin();
+ return;
+}
+
+VOID DynamicLaunchBase::to_end() {
+ m_iterOrderedGroup = m_vOrderedGroup.end();
+ m_iterOrderedGroup--;
+ return;
+}
+
+VOID DynamicLaunchBase::print_info() {
+ UI_32 idx = 1;
+ std::stringstream l_logMsg;
+ DynamicOrderedIter l_dyn_iter = m_vOrderedGroup.begin();
+ for (; l_dyn_iter != m_vOrderedGroup.end(); l_dyn_iter++) {
+ l_logMsg << std::endl << "Index: " << std::setw(2) << idx
+ << " Group Id: " << std::setw(2) << *l_dyn_iter;
+
+ idx++;
+ }
+
+ std::string l_logStr = l_logMsg.str();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", l_logStr.c_str());
+}
+
+DynamicLauncher::DynamicLauncher() :DynamicLaunchBase(),
+m_nLaunchGroupId(0),
+m_nLaunchBeforeGroupId(0),
+m_nLaunchAfterGroupId(0),
+m_nAviageTriggerId(0),
+m_bDynamicLaunchEnabled(FALSE), // by default until set by some one will this be disabled.
+m_eSourceType(SS_SOURCE_NA) { // invalid
+}
+
+DynamicLauncher::~DynamicLauncher() {
+}
+
+BOOL DynamicLauncher::dynamic_launch_enabled() const { // LCOV_EXCL_START 8: Dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_bDynamicLaunchEnabled;
+}
+// LCOV_EXCL_STOP
+
+VOID DynamicLauncher::configure_dynamic_launch(const SS_SOURCE& source_type,
+ GroupLaunchMap& group_info, LaunchOrderedVector& order_info) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_eSourceType = source_type;
+ // "Dynamic Launch" is not used due to high dependency on a service table
+ create_normal_launch_vector(group_info, order_info);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+BOOL DynamicLauncher::is_inGroupLaunchMap(UI_32& id,
+ GroupLaunchMap& group_info) { // LCOV_EXCL_START 8: Dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL Ret = FALSE;
+ GroupLaunchMapIter l_grp_iter = group_info.find(id);
+ if (l_grp_iter != group_info.end()) {
+ Ret = TRUE;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return Ret;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: Dead code
+DynamicLaunchInfo* DynamicLauncher::get_dynamic_source_info(
+ const SS_SOURCE& source_type, BOOL& source_trigger,
+ BOOL& is_aviage_required) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ UI_32 num_of_items = static_cast<UI_32>(_countof(g_arrDynamicLaunchTableCfg));
+ DynamicLaunchInfo * point_to_this = NULL;
+ for (UI_32 arr_idx = 0; arr_idx < num_of_items; arr_idx++) {
+ if (g_arrDynamicLaunchTableCfg[arr_idx].source == source_type) {
+ source_trigger = g_arrDynamicLaunchTableCfg[arr_idx].group_trigger;
+ point_to_this = &g_arrDynamicLaunchTableCfg[arr_idx];
+ if ((SS_SOURCE_FM == source_type) || (SS_SOURCE_AM == source_type)
+ || (SS_SOURCE_FM_DAB == source_type)
+ || (SS_SOURCE_SDARS == source_type)) {
+ is_aviage_required = FALSE;
+ }
+ break;
+ }
+ }
+
+ return point_to_this;
+}
+// LCOV_EXCL_STOP
+
+UI_32 DynamicLauncher::get_id_using_group_name(PCSTR group_name,
+ GroupLaunchMap& group_info) { // LCOV_EXCL_START 8: Dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ GroupLaunchMapIter l_grp_iter = group_info.begin();
+ UI_32 rtn_grp_id = 0;
+ for (; l_grp_iter != group_info.end(); l_grp_iter++) {
+ if (0 == strcmp(group_name, l_grp_iter->second.name.c_str())) {
+ rtn_grp_id = l_grp_iter->second.id;
+ break;
+ }
+ }
+
+ return rtn_grp_id;
+}
+// LCOV_EXCL_STOP
+
+VOID DynamicLauncher::create_normal_launch_vector(GroupLaunchMap& group_info,
+ LaunchOrderedVector& order_info) {
+ m_vOrderedGroup.clear();
+
+ if (order_info.size() != 0) { // LCOV_EXCL_BR_LINE 6: To initialize conditions for launching SystemManager
+ // LCOV_EXCL_START 6: To initialize conditions for launching SystemManager
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LaunchOrderedIter l_ord_iter = order_info.begin();
+ while (l_ord_iter != order_info.end()) {
+ if (is_inGroupLaunchMap(*l_ord_iter, group_info) == TRUE) {
+ m_vOrderedGroup.push_back(*l_ord_iter);
+ }
+ l_ord_iter++;
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ GroupLaunchMapIter l_grp_iter = group_info.begin();
+ while (l_grp_iter != group_info.end()) {
+ m_vOrderedGroup.push_back(l_grp_iter->second.id);
+ l_grp_iter++;
+ }
+ }
+ m_iterOrderedGroup = m_vOrderedGroup.begin();
+ m_bDynamicLaunchEnabled = TRUE;
+ print_info();
+}
+
+VOID DynamicLauncher::copyDynOrderedVector(DynamicModuleStart& Start) {
+ Start.setGroupVector(this->m_vOrderedGroup);
+}
+
+// DynamicModuleStart
+
+DynamicModuleStart::DynamicModuleStart() :DynamicLaunchBase() {
+}
+
+DynamicModuleStart::~DynamicModuleStart() {
+}
+
+VOID DynamicModuleStart::setGroupVector(DynamicOrderedVector& Vector) {
+ m_vOrderedGroup.assign(Vector.begin(), Vector.end());
+ m_iterOrderedGroup = m_vOrderedGroup.begin();
+} // LCOV_EXCL_BR_LINE 10: Final line
diff --git a/systemservice/system_manager/server/src/ss_sm_version.cpp b/systemservice/system_manager/server/src/ss_sm_version.cpp
new file mode 100755
index 0000000..9df970f
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_sm_version.cpp
@@ -0,0 +1,79 @@
+/*
+ * @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 module version management.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <system_service/ss_package.h>
+#include <system_service/ss_ver.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_system_manager_protocol_local.h>
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <fstream>
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_sm_version.h"
+
+using namespace std; // NOLINT
+
+CSMVersion::CSMVersion() {
+}
+
+CSMVersion::~CSMVersion() {
+}
+
+EFrameworkunifiedStatus CSMVersion::get_version(SS_VersionNumberType& f_VersionNumber) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CSSVer ver;
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_VersionNumber = 0;
+
+ SSVER_PkgInfo info;
+ l_eStatus = ver.getPkgInfo(SS_PKG_MAIN_EMMC, &info);
+ if (l_eStatus == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 6: To initialize conditions for launching SystemManager
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_VersionNumber = strtoull(info.version, NULL, 10); // LCOV_EXCL_LINE 6: To initialize conditions for launching SystemManager
+ } else {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSMVersion::get_version(SS_VersionNumberType &f_VersionNumber)
+
+EFrameworkunifiedStatus CSMVersion::get_build_info(std::string& f_buildInfoStr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string build_info_str;
+ CSSVer ver;
+ SSVER_PkgInfo info;
+ l_eStatus = ver.getPkgInfo(SS_PKG_MAIN_PRODUCT_SI, &info);
+ if (l_eStatus == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 6: To initialize conditions for launching SystemManager
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ build_info_str += info.version; // LCOV_EXCL_LINE 6: To initialize conditions for launching SystemManager
+ } else {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ f_buildInfoStr = build_info_str;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // LCOV_EXCL_BR_LINE 10: Final line End of EFrameworkunifiedStatus CSMVersion::get_build_info(SS_String &f_buildInfoStr)
+// EOF /SS_SystemManager/src/ss_sm_version.cpp
diff --git a/systemservice/system_manager/server/src/ss_system_manager.cpp b/systemservice/system_manager/server/src/ss_system_manager.cpp
new file mode 100755
index 0000000..8e26f23
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_system_manager.cpp
@@ -0,0 +1,3655 @@
+/*
+ * @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 business logic.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/cl_lock.h>
+#include <native_service/cl_process.h>
+#include <native_service/cl_monitor.h>
+
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/frameworkunified_thread_priority.h>
+
+#include <native_service/ns_np_service_nor_persistence.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_plogger_if.h>
+#include <native_service/ns_np_service_if.h>
+#include <native_service/ns_backup.h>
+
+#include <heartbeat/ss_hb_if.h>
+
+#include <processlauncher/ProcessLauncher_if.h>
+#include <processlauncher/ss_sm_process_launcher.h>
+#include <processlauncher/ss_sm_process_launcher_protocol.h>
+
+#include <system_service/ss_system_manager_conf.h>
+#include <stub/ss_diag.h>
+
+#include <system_service/ss_client_names.h>
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_power_service_if.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_sm_thread_names.h>
+#include <system_service/ss_sm_thread_names_local.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <system_service/ss_system_manager_notifications_local.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_sm_client_if_local.h>
+#include <system_service/ss_test_clients.h>
+#include <stub/Clock_API.h>
+#include <power_hal.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/procfs.h>
+#include <sys/timeb.h>
+#include <sys/wait.h>
+#include <inttypes.h>
+#include <libgen.h>
+#include <spawn.h>
+#include <pthread.h>
+#include <linux/oom.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sched.h>
+#include <other_service/itoa.h>
+#include <iomanip>
+#include <fstream>
+#include <string>
+#include <map>
+#include <vector>
+#include "ss_sm_signals.h"
+#include "ss_sm_default_paths.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_sm_version.h"
+#include "ss_system_manager.h"
+using namespace std; // NOLINT
+
+static CSystemManager g_oSystemManger;
+
+#define SS_SM_TEMP_FILE_FOR_STORE_LOGS "/nv/BS/ss/system_manager/rwdata/sm_tempStoreLogs"
+#define TR_USB_PATH "/usr/agl/bin/realtimeUsbLog"
+
+// \brief: public structure that is used for logging by NSLogger.
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
+ FRAMEWORKUNIFIEDLOGOPTIONS,
+ {
+ ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ ZONE_TEXT_31
+ },
+ FRAMEWORKUNIFIEDLOGZONES
+};
+
+std::string NumberToString(int Number) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::ostringstream ss;
+ ss << Number;
+ return ss.str();
+}
+// LCOV_EXCL_STOP
+
+/* Check if "Mount Point" exsists as Directory */
+/*****************************************************************************/
+/**
+ @ingroup: CSystemManager
+ @brief: No Argument Constructor.
+ @note: .
+ @param void
+ @return void
+ */
+/*****************************************************************************/
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus SysMgrCallback(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ C * pObj = static_cast<C *>(&g_oSystemManger);
+ if (pObj) {
+ l_eStatus = (pObj->*M)(hApp);
+ }
+ return l_eStatus;
+}
+
+//**************************************************************************
+// System Manager State String Map *
+// *
+void Init_SS_SMModuleState_StrMap(std::map<SS_SMModuleState, SS_String> & m_strMap) { // NOLINT
+ MAP_ENTRY(m_strMap, SS_SM_READY_TO_LAUNCH_APP);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_LAUNCH_IN_PROGRESS);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_LAUNCHED_READY_TO_START);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_START_IN_PROGRESS);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_START_COMPLETE);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_STOPPING_AT__CWORD56__REQ);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_STOPPING_AT_INTERNAL_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ);
+ MAP_ENTRY(m_strMap, SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_PRE_START_IN_PROGRESS);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_PRE_STOP_IN_PROGRESS);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_PRE_RUN_COMPLETE);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_BACKGROUND_START_IN_PROGRESS);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS);
+ MAP_ENTRY(m_strMap, SS_SM_APPS_BACKGROUND_RUN_COMPLETE);
+} // End of void Init_SS_SMModuleState_StrMap(std::map<SS_SMModuleState,
+
+class EnumStringMap<SS_SMModuleState, Init_SS_SMModuleState_StrMap>
+ m_oSS_SMModuleStateStrMap;
+SS_String GetStr(SS_SMModuleState f_enum) {
+ return m_oSS_SMModuleStateStrMap.GetStr(f_enum); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+} // End of SS_String :GetStr(SS_SMModuleState f_enum)
+// *
+// End of System Manager State String Map *
+//**************************************************************************
+
+std::string CSystemManager::m_bootOpt; // NOLINT
+
+/*****************************************************************************/
+/**
+ @ingroup: CSystemManager
+ @brief: No Argument Constructor.
+ @note: .
+ @param void
+ @return void
+ */
+/*****************************************************************************/
+CSystemManager & CSystemManager::GetInstance() {
+ return g_oSystemManger;
+}
+
+/*****************************************************************************/
+/**
+ @ingroup: CSystemManager
+ @brief: No Argument Constructor.
+ @note: .
+ @param void
+ @return void
+ */
+/*****************************************************************************/
+CSystemManager::CSystemManager() :
+ m_hHeartbeatThread(INVALID_HANDLE, eSM_ThreadNotExist),
+ m_hProcLauncherThread(INVALID_HANDLE, eSM_ThreadNotExist),
+ m_SystemLaunchProgress(SS_SM_INITIAL_GROUP),
+ m_GroupLaunchTimer(NULL),
+ m_GroupRelaunchCount(0),
+ m_GroupRelaunchLimit(0),
+ m_hPowerServiceSession(NULL),
+ m_ActiveGroupId(SS_SM_INITIAL_GROUP),
+ m_StartUpReason(epswfINVALID),
+ m_DataResetMode(e_SS_SM_DATA_RESET_MODE_NONE),
+ m_ProgUpdateState(SS_SM_PROG_UPDATE_STATE_NONE),
+ m_NextWakeupType(e_SS_SM_NEXT_WAKEUP_TYPE_NONE),
+ m_DramBackupStatus(e_SS_SM_DRAM_BACKUP_NG),
+ m_isIlgReset(FALSE),
+ m_ResetStatus(e_SS_SM_RESET_STATUS_NONE),
+ m_ResetCount(0),
+ m_SMCurrentState(SS_SM_READY_TO_LAUNCH_APP),
+
+ m_MaxShutdownTime(0),
+ m_NbrDebugDumpRspnRecv(0),
+ m_isRcvModeInfo(FALSE),
+ m_BinaryFilesPath(""),
+ m_ConfigFilesPath(""),
+ m_pfStopCompleteHandler(
+ SysMgrCallback<CSystemManager, &CSystemManager::send_shutdown_complete_response>),
+ m_VersionNumberStruct(0, eFrameworkunifiedStatusErrOther),
+ m_BuildInfoStr(""),
+ m_isRstPending(FALSE),
+ m_rstPendingInfo(),
+ m_UsingVMPlayer(FALSE),
+ NVM_VALID_SIGNATURE(0xBA5EBA11),
+ m_lastUserMode(epsumON),
+ m_shutdownTrigger(epssdmsdtINVALID),
+ m_isImmediateReset(FALSE),
+ m_isImmResetReq(FALSE),
+ m_needReNotifyStartPrm(FALSE),
+ m_pVarCodeStr(NULL),
+ m_SSLGroupLaunchMapIterator(NULL),
+ m_ModuleLaunchListIter(NULL),
+ m_bIsNPP_ServicesStarted(FALSE),
+ m_bIsBackupAvail(FALSE),
+ m_oSystemLauncher(),
+ m_SystemStarter(),
+ m_NPPStopSent(FALSE),
+ m_userModeChangeReason(epsumcrNOT_AVAILABLE),
+ m__CWORD56_CmdHist(SS_SM__CWORD56__CMD_HIST_SIZE),
+ m_SMCmdHist(SS_SM_CMD_HIST_SIZE),
+ m_TimerCmdHist(SS_SM_TIMER_CMD_HIST_SIZE),
+ m_PubCmdHist(SS_SM_PUB_CMD_HIST_SIZE),
+ m_ErrHist(SS_SM_ERR_HIST_SIZE),
+ m_ClProcessSigFd(-1),
+ m_SysMemMonitor(),
+ m_FreeMemAvailable(0),
+ m_coreFileSizeBytes(0),
+ m_BootMicroResetReason(SS_SM_BOOT_MICRO_RESET_REASON_SELF_RESET),
+ m_errorEventQueueLocked(FALSE),
+ m_isPrevErrEventCompleted(TRUE),
+ m_errorEventResult(eFrameworkunifiedStatusOK),
+ m_requestedArtifactId(eArtifactIdInterfaceunifiedDebugLog) { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ m_InitialBoot = true;
+
+ m_ResetFactor = PSM_FACTOR_NONE;
+
+ m_Wake.powerupType = epswsPWRON;
+ m_Wake.up.level = epswlFULLRUN;
+
+ m_SystemModeInfo.lastUserMode = m_lastUserMode;
+ m_SystemModeInfo.limpHomeCutoff = epslhcINVALID;
+ m_SystemModeInfo.productionMode = epspmINVALID;
+ m_SystemModeInfo.transportMode = epstmINVALID;
+ m_SystemModeInfo.systemMode = epssinfINVALID;
+ m_SystemModeInfo.startupStage = epssusfINVALID;
+
+ bzero(&m_SMConfig, sizeof(m_SMConfig));
+ bzero(&m_startUpConfirmationMsg, sizeof(m_startUpConfirmationMsg));
+ bzero(&m_HBReport, sizeof(m_HBReport));
+
+ m__CWORD56_HistIter = m__CWORD56_CmdHist.begin();
+ m_TimerHistIter = m_TimerCmdHist.begin();
+ m_SMHistIter = m_SMCmdHist.begin();
+ m_PubHistIter = m_PubCmdHist.begin();
+ m_ErrHistIter = m_ErrHist.begin();
+
+ ////******************************************************************////
+ //// Initialization of enum<=>enum and enum=>string maps ////
+ //// ////
+
+ //
+ // **** Initialization of powerupType enum maps ****
+ // Map of System Services powerupType to BOOL enum values
+ m_PowerType_to_SSBoolEnumMap[epswsPWRON] = TRUE;
+ m_PowerType_to_SSBoolEnumMap[epswsPWROFF] = FALSE;
+ //
+ // Map of System Services powerupType to System Services User Mode enum values
+ m_PowerType_to_SSUserModeEnumMap[epswsPWRON] = epsumON;
+ m_PowerType_to_SSUserModeEnumMap[epswsPWROFF] = epsumOFF;
+ //
+ // Map of BOOL to System Services powerupType enum values
+ m_SSBool_to_PowerTypeEnumMap[TRUE] = epswsPWRON;
+ m_SSBool_to_PowerTypeEnumMap[FALSE] = epswsPWROFF;
+ //
+ // **** Initialization of User Mode ( aka Last User Mode ) maps ****
+ // Map of BOOL to System Services User Mode enum values
+ m_SSBool_to_SSUserModeEnumMap[FALSE] = epsumOFF;
+ m_SSBool_to_SSUserModeEnumMap[TRUE] = epsumON;
+ //
+ // Map of BOOL to System Services User Mode enum values
+ m_SSUserMode_to_SSBoolEnumMap[epsumOFF] = FALSE;
+ m_SSUserMode_to_SSBoolEnumMap[epsumON] = TRUE;
+
+ // LCOV_EXCL_BR_STOP
+ //// ////
+ //// End of Initialization of enum<=>enum and enum=>string maps ////
+ ////******************************************************************////
+
+ m_startUpConfirmationMsg.wakeupType = epsstINVALID;
+ m_startUpConfirmationMsg.coldStartRequest = epsscrtINVALID;
+ m_startUpConfirmationMsg.HWVersion = UINT32_MAX;
+ m_startUpConfirmationMsg.matchedHardwareType = UINT32_MAX;
+ m_startUpConfirmationMsg.softwareType = UINT32_MAX;
+ m_startUpConfirmationMsg.imageType = UINT32_MAX;
+ m_startUpConfirmationMsg.majorVersion = UINT32_MAX;
+ m_startUpConfirmationMsg.minorVersion = UINT32_MAX;
+
+ m_SystemManagerPriority = PR_SS_SYSMANAGER;
+}
+
+/*****************************************************************************/
+/**
+ @ingroup: CSystemManager
+ @brief: Destructor
+ @note: .
+ @param void
+ @return void
+ */
+/*****************************************************************************/
+CSystemManager::~CSystemManager() { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (NULL != m_pVarCodeStr) {
+ delete[] m_pVarCodeStr; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+}
+
+/*****************************************************************************/
+/**
+ @ingroup: CSystemManager
+ @brief: Initialize_memory Memory initialization processing
+ @note: .
+ @param
+ @return void
+ */
+/*****************************************************************************/
+void CSystemManager::Initialize_memory(HANDLE hApp, bool* l_isInitFail, EFrameworkunifiedStatus* l_eStatus_work, BOOL isIllReset) {
+ int ret;
+ EFrameworkunifiedStatus l_eStatus;
+
+ /// Start Process for Realtime USB Logging
+ {
+ PreLaunchModuleParams l_rtuparam;
+ l_rtuparam.LaunchFunc = CreateRtUsb;
+ l_rtuparam.relaunchLimit = 1;
+ l_rtuparam.name = "realtimeUsbLog";
+ l_rtuparam.binaryFileName = TR_USB_PATH;
+/* l_rtuparam.pid = CreateRtUsb();
+ if (l_rtuparam.pid == 1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: CreateRtUsb()");
+ } */
+ m_PreLaunchModuleList.push_back(l_rtuparam);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ int fd = open("/dev/urandom", O_RDONLY); // LCOV_EXCL_BR_LINE 5: standard lib error
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 5: standard lib error
+ } else {
+ char buf[4];
+ ret = static_cast<int>(read(fd, buf, 4)); // LCOV_EXCL_BR_LINE 5: standard lib error
+ if (-1 == ret) { // LCOV_EXCL_BR_LINE 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 5: standard lib error
+ } else if (4 != ret) { // LCOV_EXCL_BR_LINE 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_LINE 5: standard lib error
+ } else {
+ fprintf(stderr, "WakeupID:%X%X%X%X\n", buf[0], buf[1], buf[2], buf[3]);
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "WakeupID:%X%X%X%X", buf[0], buf[1], buf[2], buf[3]);
+ }
+ close(fd);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "bootOpt:%s", m_bootOpt.c_str());
+
+ *l_eStatus_work = FrameworkunifiedAttachCallbackToDispatcherWithFd(hApp, m_ClProcessSigFd, // LCOV_EXCL_BR_LINE 4: nsfw error
+ SysMgrCallback<CSystemManager, &CSystemManager::OnProcessTermDetected>);
+
+ if (eFrameworkunifiedStatusOK != *l_eStatus_work) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachCallbackToDispatcherWithFd()");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+ pthread_mutex_init(&sm_hist_mutex, NULL);
+
+ ReadPathFromEnvironmentVariables();
+ ReadUsingVMPlayerEnvironmentVariable();
+
+ // FIXME : Dump information from power_hal by using
+
+ if (eFrameworkunifiedStatusOK != (*l_eStatus_work = SetSystemModeInfoStruct())) {
+ LOG_ERROR("SetSystemModeInfoStruct()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ *l_isInitFail = true;
+ }
+
+ // Select configuration file for wakeup services
+ BOOL bIsVupMode = (m_SystemModeInfo.systemMode == epssinfPROGRAMMING) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ T_SS_SM_INIT_HOOK_IN_PARAM inPrm;
+
+ std::memset(&inPrm, 0, sizeof(inPrm));
+ inPrm.bIsVupMode = bIsVupMode;
+
+ if (eFrameworkunifiedStatusOK != (*l_eStatus_work = ss_sm_initHook(hApp, &inPrm, &m_productCustomPrm))) {
+ SS_ASERT_LOG(0, "ERROR: ss_sm_initHook()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ *l_isInitFail = true;
+ }
+
+ SetEnvVariableForVupMode(bIsVupMode);
+
+ // Get the Version Number
+ // GetVersionNumber() will report any errors
+ m_VersionNumberStruct.m_eSystemmanagerStatus = GetVersionNumber(m_VersionNumberStruct.m_VersionNumber);
+
+ *l_eStatus_work = GetBuildInfo(m_BuildInfoStr);
+ l_eStatus = *l_eStatus_work;
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "GetBuildInfo()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ INTERFACEUNIFIEDLOG_WHEN_COMPILED; // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s priority is %d", SERVICE_SYSMANAGER, m_SystemManagerPriority);
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " %s was compiled at %s @ %s", __FILE__, __DATE__, __TIME__);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " Host Processor Software Version is '0x%016llX'",
+ m_VersionNumberStruct.m_VersionNumber);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " Host Processor Build Version is '%s'", m_BuildInfoStr.c_str());
+
+ LogESystemmanagerStatusEnums();
+ LogProtocolIDs();
+}
+
+/*****************************************************************************/
+/**
+ @ingroup: CSystemManager
+ @brief: Initialize_callbacks Callback enrollment process
+ @note: .
+ @param
+ @return void
+ */
+/*****************************************************************************/
+void CSystemManager::Initialize_callbacks(HANDLE hApp, bool *l_isInitFail, EFrameworkunifiedStatus *l_eStatus_work) {
+ EFrameworkunifiedStatus l_eStatus;
+
+ m_GroupLaunchTimer = new (std::nothrow) TimerCtrl(eSM_TIMERS_END); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (NULL == m_GroupLaunchTimer) { // LCOV_EXCL_BR_LINE 5: Because new doesn't pass the failure case
+ // LCOV_EXCL_START 5: Because new doesn't pass the failure case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ *l_eStatus_work = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("new(std::nothrow)TimerCtrl(eSM_TIMERS_END)");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ m_GroupLaunchTimer->Initialize(hApp);
+ m_aTimerIDs[eSM_TIMER_GROUP_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnGroupLaunchTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER_PROCESS_LAUNCH_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnProcessLaunchTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER_HEARTBEAT_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnHeartBeatMonitorTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER_PROCESSLAUNCHER_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
+ &CSystemManager::OnProcessLaunchMonitorTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
+ &CSystemManager::OnClientStartMonitorTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER_NPP_STATUS_CHECK_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
+ &CSystemManager::OnNPPStatusCheckMonitorTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER__CWORD56__HEARTBEAT_RESPONSE] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
+ &CSystemManager::On_CWORD56_HeartBeatResponseIntervalTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER_LAUNCH_GROUP_TRIGGER_PROC_RESP_TIMER] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
+ &CSystemManager::OnLaunchGroupTriggerProcessResponseTimerExpiry>);
+ m_aTimerIDs[eSM_TIMER_GROUP_LAUNCH_WAIT_TIMER] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnGroupLaunchWaitTimeout>);
+ m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnModuleConnectWaitTimeout>);
+ m_aTimerIDs[eSM_TIMER_START_RESP_MONITOR_WAIT_TIMER] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnStartRespMonitorTimeout>);
+ m_aTimerIDs[eSM_TIMER_SHUTDOWN_COMPLETE_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
+ &CSystemManager::OnShutdownCompleteMonitorTimeout>);
+ m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR] =
+ m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnClientStopMonitorTimerExpiry>);
+
+ FrameworkunifiedProtocolCallbackHandler l_cbArrayAnySource[] = {
+ // Command ID, Call back functions
+ { SS_SM_PROTOCOL_OPEN_SESSION_REQ, SysMgrCallback<CSystemManager, &CSystemManager::OnOpenSession> },
+ { SS_SM_CPU_RESET_REQ, SysMgrCallback<CSystemManager, &CSystemManager::OnCpuResetRequest> }
+ };
+
+ FrameworkunifiedProtocolCallbackHandler l_cbArrayGroupLaunchService[] = {
+ // Command ID, Call back functions
+ { SS_SM_GROUP_LAUNCH_TRIGGER, SysMgrCallback<CSystemManager, &CSystemManager::OnLaunchGroupTriggerProcessResponse> }
+ };
+
+ FrameworkunifiedProtocolCallbackHandler l_cbArrayNPPService[] = {
+ // Command ID, Call back functions
+ { NPS_NPP_READY_EVENT, SysMgrCallback<CSystemManager, &CSystemManager::OnNPPReadyEventCallback> },
+ { NPS_GET_READYSTATUS_ACK, SysMgrCallback<CSystemManager, &CSystemManager::OnNPPReadyStatusCallback> },
+ { NPS_NPP_STOP_ACK, SysMgrCallback<CSystemManager, &CSystemManager::OnNppStopComplete> }
+ };
+
+ FrameworkunifiedProtocolCallbackHandler l_cbArrayPowerService[] = {
+ // Command ID, Call back functions
+ { SS_SM_POWER_REQUEST_MSG, SysMgrCallback<CSystemManager, &CSystemManager::OnPowerRequestCallback> },
+ { SS_SM_WAKEUP_MODULES, SysMgrCallback<CSystemManager, &CSystemManager::OnWakeupCallback> },
+ { SS_SM_SYSTEM_MODE_INFO_REQ, SysMgrCallback<CSystemManager, &CSystemManager::OnSystemModeInfoRequest> },
+ { SS_SM_INITCOMP_REP, SysMgrCallback<CSystemManager, &CSystemManager::OnInitCompReportCallback> },
+ { SS_SM_SHUTDOWN_MODULES, SysMgrCallback<CSystemManager, &CSystemManager::OnShutdownModulesRequest> },
+ { SS_SM_FWD_STARTUP_CONFIRMATION_MSG_REQ,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnSetStartupConfirmationDataRequest> }
+ };
+
+ FrameworkunifiedProtocolCallbackHandler l_cbArraySystemManager[] = {
+ // Command ID, Call back functions
+ { SS_SM_SendTriggerToSelf, SysMgrCallback<CSystemManager, &CSystemManager::OnLaunchGroupSelfTrigger> },
+ { SS_SM_DEBUG_DUMP_RSPN, SysMgrCallback<CSystemManager, &CSystemManager::OnDebugDumpResponseReceived> }
+ };
+ // LCOV_EXCL_BR_STOP
+
+#define ATTACH_CBS_TO_DISPATCHER(L_ARRAY, CALLING_SERVICE_NAME) \
+ *l_eStatus_work = l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, \
+ CALLING_SERVICE_NAME, \
+ L_ARRAY, \
+ static_cast<UI_32>_countof(L_ARRAY)); \
+ if (eFrameworkunifiedStatusOK != l_eStatus) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, \
+ " Error: FrameworkunifiedAttachCallbacksToDispatcher(%s) errored: %d/'%s'", \
+ #L_ARRAY, \
+ l_eStatus, \
+ GetStr(l_eStatus).c_str()); \
+ *l_isInitFail = true; \
+ }
+// End of #define ATTACH_CBS_TO_DISPATCHER( CALLING_SERVICE_NAME, L_ARRAY )
+
+ // LCOV_EXCL_BR_START 15: marco defined above
+ // Note: This macro will exit this function if the embedded fnc errors.
+ ATTACH_CBS_TO_DISPATCHER(l_cbArrayAnySource, FRAMEWORKUNIFIED_ANY_SOURCE);
+
+ // Note: This macro will exit this function if the embedded fnc errors.
+ ATTACH_CBS_TO_DISPATCHER(l_cbArrayGroupLaunchService, SS_GROUP_LAUNCH_TRIGGER);
+
+ // Note: This macro will exit this function if the embedded fnc errors.
+ ATTACH_CBS_TO_DISPATCHER(l_cbArrayNPPService, FRAMEWORKUNIFIED_NS_NPSERVICE);
+
+ // Note: This macro will exit this function if the embedded fnc errors.
+ ATTACH_CBS_TO_DISPATCHER(l_cbArrayPowerService, SERVICE_POWER);
+
+ // Note: This macro will exit this function if the embedded fnc errors.
+ ATTACH_CBS_TO_DISPATCHER(l_cbArraySystemManager, SERVICE_SYSMANAGER);
+ // LCOV_EXCL_BR_STOP
+
+ {
+ char pathBuf[128];
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ snprintf(pathBuf, sizeof(pathBuf), "/proc/%d/oom_score_adj", getpid());
+ std::ofstream fo(pathBuf);
+ fo << OOM_SCORE_ADJ_MIN << endl;
+ fo.close();
+ // LCOV_EXCL_BR_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "set OOM_SCORE_ADJ_MIN(SS_SysManager/%d)", getpid());
+ }
+
+#undef ATTACH_CBS_TO_DISPATCHER
+
+ // LCOV_EXCL_BR_START 4: nsfw error
+ *l_eStatus_work = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_BackupMgr_Availability,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnBackupMgrAvailCallback>);
+ // LCOV_EXCL_BR_STOP
+ if (eFrameworkunifiedStatusOK != *l_eStatus_work) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSubscribeNotificationWithCallback()");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK != (*l_eStatus_work = ErrorEventInit(hApp))) { // LCOV_EXCL_BR_LINE 6: function do not return error
+ // LCOV_EXCL_START 6: function do not return error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ErrorEventInit()");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+#ifndef SS_SM_SKIP_HEARTBEAT_INIT
+ // LCOV_EXCL_BR_START 6: function do not return error, expect nsfw error
+ if (eFrameworkunifiedStatusOK != (*l_eStatus_work = init_Heartbeat(hApp))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: function do not return error, expect nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("init_HeartBeat()");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+#else
+#warning Test code - NOT calling init_Heartbeat(hApp)
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: NOT calling init_Heartbeat(hApp)");
+#endif
+#undef SS_SM_SKIP_HEARTBEAT_INIT
+
+ // LCOV_EXCL_BR_START 6: function do not return error, expect nsfw error
+ if (eFrameworkunifiedStatusOK != (*l_eStatus_work = init_process_launcher(hApp))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: function do not return error, expect nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("init_process_launcher()");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+ // LCOV_EXCL_BR_START 6: function do not return error, expect init error
+ if (eFrameworkunifiedStatusOK != (*l_eStatus_work = start_process_launching(hApp))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: function do not return error, expect init error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("start_process_launching()");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+ // LCOV_EXCL_BR_START 6: function do not return error, expect nsfw error
+ if (eFrameworkunifiedStatusOK != (*l_eStatus_work = init_sysmem_monitor(hApp))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: function do not return error, expect nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("init_sysmem_monitor()");
+ *l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+ /// Internal thread monitoring start
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ m_GroupLaunchTimer->StartTimer(m_aTimerIDs[eSM_TIMER_HEARTBEAT_MONITOR],
+ SS_HEARTBEAT_MONITOR_TIMER_CONFIG, 0,
+ SS_HEARTBEAT_MONITOR_TIMER_CONFIG, 0);
+
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_PROCESSLAUNCHER_MONITOR],
+ SS_PROCESSLAUNCHER_MONITOR_TIMER_CONFIG, 0,
+ SS_PROCESSLAUNCHER_MONITOR_TIMER_CONFIG, 0);
+
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_NPP_STATUS_CHECK_MONITOR],
+ SS_NPP_STATUS_CHECK_MONITOR_TIME_SEC, 0,
+ SS_NPP_STATUS_CHECK_MONITOR_TIME_SEC, 0);
+ // LCOV_EXCL_BR_STOP
+}
+
+
+/*****************************************************************************/
+/**
+ @ingroup: CSystemManager
+ @brief: Initialization
+ @note: .
+ @param HANDLE hApp
+ @return void
+ */
+/*****************************************************************************/
+EFrameworkunifiedStatus CSystemManager::Initialize(HANDLE hApp) {
+ bool l_isInitFail = false;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int ret;
+ PsmFactorT l_startup_factor;
+
+ // Need to call Lock System Initialize API once in the system
+ ret = CL_LockSystemInit();
+ if (ret != 0) {
+ fprintf(stderr, "SS_SysManager/%s/Error: CL_LockSystemInit() errored: %d\n", __FUNCTION__, ret);
+ }
+
+ ret = CL_LockProcessInit();
+ if (ret != 0) {
+ fprintf(stderr, "SS_SysManager/%s/Error: CL_LockProcessInit() errored: %d\n", __FUNCTION__, ret);
+ l_isInitFail = true;
+ }
+
+ ret = PsmGetStartupFactor(hApp, &l_startup_factor);
+ if (ret == 0) {
+ if ((static_cast<UI_32>(l_startup_factor) & PSM_RESET_HISTORY) == PSM_RESET_HISTORY) {
+ DGCODE_RET_API l_ret = DGCODE_RET_ERROR;
+ uint64_t l_SystemResetRobCode = 0;
+ DGCODE_ROB_SSR_INFO l_info;
+ if (l_startup_factor == PSM_FACTOR_AGL_WITH_HISTORY) {
+ l_SystemResetRobCode = 0x2219; // AGL cause
+ } else if (l_startup_factor == PSM_FACTOR_TIER1_WITH_HISTORY) {
+ l_SystemResetRobCode = 0x221A; // Tier1 cause
+ } else if (l_startup_factor == PSM_FACTOR_USER_WITH_HISTORY) {
+ l_SystemResetRobCode = 0x8027; // USER cause
+ } else {
+ // No processing
+ }
+
+ if (l_SystemResetRobCode != 0) {
+ memset(&l_info, 0x00, sizeof(DGCODE_ROB_SSR_INFO));
+
+ l_ret = Diag_PutRoBInfo(hApp, l_SystemResetRobCode, &l_info);
+ if (l_ret == DGCODE_RET_ERROR) {
+ LOG_ERROR("Diag_PutRoBInfo()");
+ }
+ }
+ }
+ } else {
+ (void)fprintf(stderr, "SS_SysManager/%s/ERROR:start-up factor not get\n", __FUNCTION__);
+ }
+
+ m_isIlgReset = (false == GetSyscomPowerStatusInfo(hApp)) ? TRUE : FALSE;
+ if (m_isIlgReset || ("elog" == m_bootOpt)) {
+ fprintf(stderr, "SS_SysManager/%s/Error: ILGRST LOG SAVE\n", __func__);
+ StoreDebugLogs(hApp, SS_STORELOGS_ILLEGAL);
+ } else {
+ StoreDebugLogs(hApp, SS_STORELOGS_ACCOFFON);
+ }
+
+ if (m_isIlgReset == TRUE) {
+ // overwrite AGL_ILLRESET_FLAG.
+ uint32_t tmp = static_cast<uint32_t>(m_isIlgReset);
+ if (PowerHalSetResetInfo(AGL_ILLRESET_FLAG, tmp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not set AGL_ILLRESET_FLAG to power_hal");
+ }
+ } else {
+ // keep last value of AGL_ILLRESET_FLAG.
+ }
+
+ FRAMEWORKUNIFIED_SET_ZONES();
+ NsLogSetLogMethod(LPRINT | LMSGQ);
+ // FRAMEWORKUNIFIEDLOG can not be used until this line
+
+ m_ClProcessSigFd = CL_ProcessInit(); // LCOV_EXCL_BR_LINE 4: nsfw error
+ if (m_ClProcessSigFd == -1) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: CL_ProcessInit()");
+ l_isInitFail = true;
+ // LCOV_EXCL_STOP
+ }
+
+ ret = CL_MonitorInit(CL_MONITOR_INIT_SYSTEM);
+ if(ret != 0) {
+ fprintf(stderr, "SS_SysManager/%s/Error: CL_MonitorInit() errored: %d\n", __FUNCTION__, ret);
+ l_isInitFail = true;
+ }
+
+ // Threads MUST NOT be started until this line
+// ===== Initialization No.1
+ Initialize_memory(hApp, &l_isInitFail, &l_eStatus, m_isIlgReset);
+
+// ===== Initialization No.2
+ Initialize_callbacks(hApp, &l_isInitFail, &l_eStatus);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::SetEnvVariableForVupMode(BOOL bIsVupMode) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ const CHAR SmVupModeEnvVariable[] = "SM_VUP_MODE";
+ const CHAR *l_pValue = bIsVupMode ? "y" : "n"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (0 != setenv(SmVupModeEnvVariable, l_pValue, 1)) { // LCOV_EXCL_BR_LINE 5: standard lib error
+ // LCOV_EXCL_START 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT_ERRNO(0);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ return l_eStatus;
+}
+
+int CSystemManager::CreateRtUsb(void) {// LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ int pid = -1;
+ int ret;
+
+ ret = mkdir("/var/run", 0775);
+ if ((ret < 0) && (errno != EEXIST)) {
+ return -1;
+ }
+ pid = fork();
+ switch (pid) {
+ case 0: /* child process */
+ {
+ struct sched_param param;
+ int policy;
+ const char *exec;
+ exec = const_cast<char *>(TR_USB_PATH);
+ param.sched_priority = 0;
+ policy = SCHED_OTHER;
+ if (sched_setscheduler(getpid(), policy, &param) < 0) {
+ SS_ASERT(0);
+ _exit(-1);
+ }
+ if (setpriority(PRIO_PROCESS, getpid(), 0) < 0) {
+ SS_ASERT(0);
+ _exit(-1);
+ }
+ // exec
+ if (execlp(exec, exec, NULL) < 0) {
+ SS_ASERT(0);
+ _exit(-1);
+ }
+ _exit(0);
+ }
+ break;
+
+ case -1: /* error */
+ SS_ASERT(0);
+ goto ERROR;
+
+ default: /* parent process */
+ break;
+ }
+
+ERROR:
+ return pid;
+}// LCOV_EXCL_STOP
+
+bool CSystemManager::StoreDebugLogs(const HANDLE h_app,
+ SS_STORELOGS_OPE_TYPE type) {
+ bool isMountRamd = false;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int pid;
+
+ if (!GetDramPowerStatusInfo(h_app)) {
+ goto ERROR;
+ } else if (access(SS_SM_TEMP_FILE_FOR_STORE_LOGS, F_OK) == 0) {
+ fprintf(stderr, "SS_SysManager/%s/Error: Skip StoreDebugLogs\n", __FUNCTION__);
+ goto ERROR;
+ }
+
+ isMountRamd = true;
+
+ if (type == SS_STORELOGS_ILLEGAL) {
+ UI_32 l_ErrLogCount = 0;
+ if (PowerHalGetResetInfo(AGL_ERRLOG_COUNTER, &l_ErrLogCount)) {
+ fprintf(stderr, "SS_SysManager/%s/Error: "
+ "Could not read AGL_ERRLOG_COUNTER from power_hal\n", __FUNCTION__);
+ goto ERROR;
+ }
+
+ if (l_ErrLogCount >= SS_SM_ERR_LOGGING_LIMIT) {
+ fprintf(stderr, "SS_SysManager/%s/Error: "
+ "Skip StoreDebugLogs by continuous error l_ErrLogCount=%lu\n",
+ __FUNCTION__, l_ErrLogCount);
+ goto ERROR;
+ }
+
+ l_ErrLogCount++;
+ if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, l_ErrLogCount)) {
+ // Just logging, don't go to ERROR.
+ fprintf(stderr, "SS_SysManager/%s/Error: "
+ "Could not write AGL_ERRLOG_COUNTER to power_hal\n", __FUNCTION__);
+ }
+ } else if (type == SS_STORELOGS_ACCOFFON) {
+ if (0 != unlink(SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG)) {
+ fprintf(stderr, "SS_SysManager/%s/Error: ACCOFFON LOG SAVE\n", __FUNCTION__);
+ } else {
+ goto ERROR;
+ }
+ }
+
+ pid = fork();
+ if (pid == 0) {
+ int fd = open(SS_SM_TEMP_FILE_FOR_STORE_LOGS,
+ O_CREAT | O_TRUNC | O_RDWR, 00664);
+ if (-1 == fd) { // LCOV_EXCL_BR_LINE 5:fd must not be -1
+ fprintf(stderr, "SS_SysManager/%s/Error: Failed open %s errno: %d\n",
+ __FUNCTION__, SS_SM_TEMP_FILE_FOR_STORE_LOGS, errno);
+ } else {
+ fsync(fd);
+ close(fd);
+ }
+ FRAMEWORKUNIFIED_SET_ZONES(); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ NsLogSetLogMethod(LPRINT | LMSGQ);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = SS_LoggerStoreLogs(type))) { // LCOV_EXCL_BR_LINE 200: always return OK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ fprintf(stderr, "SS_SysManager/%s/Error: SS_LoggerStoreDebugLogs() errored: %d\n", __FUNCTION__, l_eStatus); // LCOV_EXCL_LINE 200: always return OK // NOLINT(whitespace/line_length)
+ }
+ // Close accessing the RAMD by FRAMEWORKUNIFIEDLOG for RAMD initialization
+ NsForceClose();
+
+ if (0 != unlink(SS_SM_TEMP_FILE_FOR_STORE_LOGS)) {
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ exit(0);
+ } else if (pid == -1) { // LCOV_EXCL_BR_LINE 5:fork error case
+ // LCOV_EXCL_START 5:fork error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ fprintf(stderr, "SS_SysManager/%s/Error: ASSERT %d\n", __FUNCTION__, __LINE__);
+ // LCOV_EXCL_STOP
+ } else {
+ if (-1 == waitpid(pid, NULL, 0)) { // LCOV_EXCL_BR_LINE 5:waitpid error case
+ // LCOV_EXCL_START 5:waitpid error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ fprintf(stderr, "SS_SysManager/%s/Error: ASSERT %d\n", __FUNCTION__, __LINE__);
+ // LCOV_EXCL_STOP
+ }
+ }
+ ERROR:
+ return isMountRamd;
+}
+
+#define SS_SM_SCAC_DEVICE_NODE "/dev/scac_driver"
+#define SS_SM_SCAC_CMD_SHUTDOWN 0x3000
+
+EFrameworkunifiedStatus CSystemManager::SecureChipOff() {
+ static bool isOffDone = false;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int32_t fd;
+ int32_t res;
+
+ if (!isOffDone) {
+ fd = open(SS_SM_SCAC_DEVICE_NODE, O_RDWR);
+ if (fd < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "open(%s) ERR", SS_SM_SCAC_DEVICE_NODE);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ res = ioctl(fd, SS_SM_SCAC_CMD_SHUTDOWN);
+ if (res < 0) { // LCOV_EXCL_BR_LINE 5: standard lib error
+ // LCOV_EXCL_START 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "ioctl(SS_SM_SCAC_CMD_SHUTDOWN) ERR");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ close(fd);
+ }
+
+ isOffDone = true;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Skip Chip Off");
+ }
+
+ return l_eStatus;
+}
+
+UI_32 CSystemManager::InProgressStateToSendMsg() const {
+ UI_32 l_iCmd = SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX;
+ switch (m_SMCurrentState) {
+ case SS_SM_APPS_PRE_START_IN_PROGRESS:
+ l_iCmd = SS_SM_PRE_START;
+ break;
+ case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
+ l_iCmd = SS_SM_PRE_STOP;
+ break;
+ case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
+ l_iCmd = SS_SM_BACKGROUND_START;
+ break;
+ case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
+ l_iCmd = SS_SM_BACKGROUND_STOP;
+ break;
+ case SS_SM_APPS_START_IN_PROGRESS:
+ l_iCmd = SS_SM_START;
+ break;
+ default:
+ break;
+ }
+ return l_iCmd;
+}
+
+SMModuleState CSystemManager::InProgressStateToState() const {
+ SMModuleState l_state = MODULE_STATE_INVALID;
+ switch (m_SMCurrentState) {
+ case SS_SM_APPS_PRE_START_IN_PROGRESS:
+ l_state = MODULE_STATE_STARTED_PRE;
+ break;
+ case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
+ l_state = MODULE_STATE_STOPPED_PRE;
+ break;
+ case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
+ l_state = MODULE_STATE_STARTED_BACKGROUND;
+ break;
+ case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
+ l_state = MODULE_STATE_STOPPED_BACKGROUND;
+ break;
+ case SS_SM_APPS_START_IN_PROGRESS:
+ l_state = MODULE_STATE_STARTED;
+ break;
+ default:
+ break;
+ }
+ return l_state;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SetSystemModeInfoStruct
+/// Read ( or initialize ) NVM and set the SystemModeInfo structure
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::SetSystemModeInfoStruct() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (m_UsingVMPlayer) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " 'm_UsingVMPlayer' is True,"
+ " using default SystemModeInfo values");
+ m_SystemModeInfo.limpHomeCutoff = epslhcDISABLED;
+ m_SystemModeInfo.productionMode = epspmDISABLED;
+ m_SystemModeInfo.transportMode = epstmDISABLED;
+ m_SystemModeInfo.systemMode = epssinfNORMAL;
+ m_DataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
+ m_ResetCount = 0;
+ m_ProgUpdateState = SS_SM_PROG_UPDATE_STATE_NONE;
+ // Don't change the m_SystemModeInfo.startupStage.
+ // It is set dynamically as System Manager initializes the _CWORD102_.
+ } else {
+ uint32_t tmp = 0;
+ if (PowerHalGetResetInfo(AGL_RESET_COUNTER, &m_ResetCount)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not read AGLRESET_COUNTER from power_hal, assume to 0");
+ m_ResetCount = 0;
+ }
+
+ if (PowerHalGetResetInfo(AGL_PROGUPDATE_STATE, &m_ProgUpdateState)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not read AGL_PROGUPDATE_STATE from power_hal, "
+ "assume to SS_SM_PROG_UPDATE_STATE_NONE");
+ m_ProgUpdateState = SS_SM_PROG_UPDATE_STATE_NONE;
+ }
+
+ if (PowerHalGetResetInfo(AGL_DATARESET_STATE, &tmp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not read AGL_DATARESET_STATE from power_hal, "
+ "assume to e_SS_SM_DATA_REESET_MODE_NONE");
+ m_DataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
+ } else {
+ m_DataResetMode = static_cast<ESMDataResetModeInfo>(tmp);
+ }
+ m_SystemModeInfo.systemMode = epssinfNORMAL;
+ } // End else ! m_UsingVMPlayer
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::SetSystemModeInfoStruct()
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ClearDramBackupInfo
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::ClearDramBackupInfo(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int ret;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "PsmClrRamJudgeFlgPower()");
+ ret = PsmClrRamJudgeFlgPower(hApp);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 11: Excluded due to gcov constraints (others)
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup CloseApplication
+/// Process request to close Application
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::CloseApplication(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) {
+ LOG_ERROR("FrameworkunifiedPublishServiceAvailability(hApp,FALSE)");
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus =
+ FrameworkunifiedUnRegisterServiceAvailabilityNotification(hApp))) {
+ LOG_ERROR("FrameworkunifiedUnRegisterServiceAvailabilityNotification(hApp)");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Successful");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::CloseApplication(HANDLE hApp)
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SMStateStartCompleteEntry
+/// entry for SM module state(SS_SM_APPS_START_COMPLETE)
+///
+/// \param
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+VOID CSystemManager::SMStateStartCompleteEntry(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "All %d groups have been sent system_manager protocol message, sending Start Complete to _CWORD56_",
+ m_SystemStarter.get_id());
+ CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ send_power_request_complete_response(hApp, "Startup")); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ CALL_AND_LOG_STATUS(PublishPowerOnOffNotification(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ if (m_InitialBoot == true) {
+ m_InitialBoot = false;
+
+ const ESMServiceWakeupStatus l_svcWupStatus = e_SS_SM_SVC_WAKEUP_STATUS_COMPLETE;
+
+ CALL_AND_LOG_STATUS( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FrameworkunifiedNPPublishNotification(hApp, NTFY_SSServiceWakeupStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ &l_svcWupStatus, sizeof(ESMServiceWakeupStatus))); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ // If all modules are restarted, a passive warning will be issued
+ // indicating that Heartbeat is already running.
+
+ UI_32 l_list_num = static_cast<UI_32>(m_HBList.size());
+ if (SS_MAX_NUM_MODULES < l_list_num) {
+ l_list_num = SS_MAX_NUM_MODULES;
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warn: SS_MAX_NUM_MODULES '%d' < m_HBList.size '%d'",
+ SS_MAX_NUM_MODULES, l_list_num);
+ }
+
+ CHAR send_data[sizeof(l_list_num)
+ + (l_list_num * SS_SM_HB_MAX_PROC_NAME_SIZE)
+ + sizeof(m_SMConfig.HBConfig)];
+ CHAR* p_prm = &send_data[0];
+
+ memcpy(p_prm, reinterpret_cast<char *>(&m_SMConfig.HBConfig), sizeof(m_SMConfig.HBConfig));
+ p_prm = p_prm + sizeof(m_SMConfig.HBConfig);
+ memcpy(p_prm, reinterpret_cast<char *>(&l_list_num), sizeof(l_list_num));
+ p_prm = p_prm + sizeof(l_list_num);
+
+ for (UI_32 i = 0; i < l_list_num; i++) {
+ snprintf(p_prm, SS_SM_HB_MAX_PROC_NAME_SIZE, "%s", m_HBList[i].c_str());
+ p_prm = p_prm + SS_SM_HB_MAX_PROC_NAME_SIZE;
+ }
+ l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_START, &send_data, static_cast<UI_32>(sizeof(send_data))); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToHeartBeat()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ m_DataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
+ {
+ uint32_t tmp = static_cast<uint32_t>(m_DataResetMode);
+ if (PowerHalSetResetInfo(AGL_DATARESET_STATE, tmp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not set AGL_DATARESET_STATE to power_hal");
+ }
+ }
+
+ m_ProgUpdateState = SS_SM_PROG_UPDATE_STATE_NONE;
+ if (PowerHalSetResetInfo(AGL_PROGUPDATE_STATE, m_ProgUpdateState)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not set AGL_PROGUPDATE_STATE to power_hal");
+ }
+
+ m_isIlgReset = FALSE;
+ {
+ uint32_t tmp = static_cast<uint32_t>(m_isIlgReset);
+ if (PowerHalSetResetInfo(AGL_ILLRESET_FLAG, tmp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not set AGL_ILLRESET_FLAG to power_hal");
+ }
+ }
+
+ if (access(SS_SM_TEMP_FILE_FOR_STORE_LOGS, F_OK) == 0) {
+ SS_ASERT_ERRNO(0 == unlink(SS_SM_TEMP_FILE_FOR_STORE_LOGS)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+
+ for (vector<std::string>::iterator protectedSvc =
+ m_productCustomPrm.protectedSvcs.begin();
+ protectedSvc != m_productCustomPrm.protectedSvcs.end();
+ protectedSvc++) {
+ ModuleLaunchListIter l_ModuleListIter;
+ l_eStatus = GetModuleIterator(protectedSvc->c_str(), l_ModuleListIter);
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if ((l_ModuleListIter->IsModuleState(MODULE_STATE_STARTED))
+ || (l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHED)
+ && !l_ModuleListIter->is_start_required)) {
+ char pathBuf[128];
+
+ snprintf(pathBuf, 128, "/proc/%d/oom_score_adj", l_ModuleListIter->pid); // NOLINT
+ std::ofstream fo(pathBuf); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ fo << OOM_SCORE_ADJ_MIN << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ fo.close(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "set OOM_SCORE_ADJ_MIN(%s/%d)",
+ l_ModuleListIter->name.c_str(), l_ModuleListIter->pid);
+ } else {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+
+ for (vector<std::string>::iterator groupRelaunchSvc =
+ m_productCustomPrm.groupRelaunchSvcs.begin();
+ groupRelaunchSvc != m_productCustomPrm.groupRelaunchSvcs.end();
+ groupRelaunchSvc++) {
+ ModuleLaunchListIter l_ModuleListIter;
+ l_eStatus = GetModuleIterator(groupRelaunchSvc->c_str(), l_ModuleListIter);
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if ((l_ModuleListIter->IsModuleState(MODULE_STATE_STARTED))
+ || (l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHED)
+ && !l_ModuleListIter->is_start_required)) {
+ GroupRelaunchModuleParams l_param; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_param.name = l_ModuleListIter->name.c_str();
+ m_GroupRelaunchModuleList.push_back(l_param);
+
+ if (l_ModuleListIter->retry_cnt > m_GroupRelaunchLimit) {
+ m_GroupRelaunchLimit = l_ModuleListIter->retry_cnt;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "GroupRelaunchSvcs:%s(%d)",
+ l_ModuleListIter->name.c_str(), l_ModuleListIter->pid);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s is not Launched", groupRelaunchSvc->c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s is not exist", groupRelaunchSvc->c_str());
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "GroupRelaunchLimit:%d", m_GroupRelaunchLimit);
+
+ SendDeferMsg(hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+} // End of VOID CSystemManager::SMStateStartCompleteEntry()
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SMStateEntry
+/// entry for SM module state
+///
+/// \param
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+VOID CSystemManager::SMStateEntry(HANDLE hApp, SS_SMModuleState l_SMState) {
+ switch (l_SMState) {
+ case SS_SM_APPS_START_COMPLETE:
+ case SS_SM_APPS_PRE_RUN_COMPLETE:
+ case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
+ SMStateStartCompleteEntry(hApp);
+ break;
+ default:
+ break;
+ }
+} // End of VOID CSystemManager::SMStateEntry(SS_SMModuleState l_SMState)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SMStateExit
+/// exit for SM module state
+///
+/// \param
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+VOID CSystemManager::SMStateExit(HANDLE hApp, SS_SMModuleState l_SMState) {
+ switch (l_SMState) {
+ case SS_SM_APPS_START_COMPLETE:
+ break;
+ default:
+ break;
+ }
+} // End of VOID CSystemManager::SMStateExit(SS_SMModuleState l_SMState)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SMSetState
+/// set module state
+///
+/// \param
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+VOID CSystemManager::SMSetState(HANDLE hApp, SS_SMModuleState l_SMNewState) {
+ // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s -> %s",
+ GetStr(m_SMCurrentState).c_str(), GetStr(l_SMNewState).c_str());
+
+ if (l_SMNewState != m_SMCurrentState) {
+ SMStateExit(hApp, m_SMCurrentState);
+
+ m_SMCurrentState = l_SMNewState;
+
+ SMStateEntry(hApp, m_SMCurrentState);
+ }
+ // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup register_all_notification_callbacks
+/// register all notifications and callbacks with NP_NPS
+/// this function gets called when NP_NPS reply launch complete
+///
+/// \param
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::register_all_notification_callbacks(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FrameworkunifiedNotificationsList userModeNotificationsBOOL[] = { {
+ NTFY_SSSystemMgrPowerOnOff, sizeof(BOOL), eFrameworkunifiedStateVar }, {
+ NTFY_SSSystemMgrUserMode, sizeof(BOOL), eFrameworkunifiedStateVar } };
+
+ FrameworkunifiedNotificationsList userModeNotificationsStruct[] = { {
+ NTFY_SSSystemMgrPowerOnOff,
+ sizeof(T_SS_SM_UserModeOnOffNotification_Struct), eFrameworkunifiedStateVar }, {
+ NTFY_SSSystemMgrUserMode,
+ sizeof(T_SS_SM_UserModeOnOffNotification_Struct), eFrameworkunifiedStateVar } };
+
+ FrameworkunifiedNotificationsList sm_notifications[] = {
+ { NTFY_SSSystemMgrStartUpType, sizeof(EPWR_SC_WAKEUP_TYPE), eFrameworkunifiedStateVar },
+ { NTFY_SSSystemMgrDataReset, sizeof(ESMDataResetType), eFrameworkunifiedStateVar },
+ { NTFY_SSSystemMgrShutdownStarted, 0, eFrameworkunifiedStateVar },
+ { NTFY_SSServiceWakeupStatus, sizeof(ESMServiceWakeupStatus), eFrameworkunifiedStateVar },
+ { NTFY_SSNeedAplRestart, 0, eFrameworkunifiedStateVar } };
+
+ if (m_SMConfig.UMConfig.IsUserModeNotificationABOOL) {
+ l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp, userModeNotificationsBOOL,
+ static_cast<UI_32>(_countof(userModeNotificationsBOOL)));
+ } else {
+ l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp,
+ userModeNotificationsStruct,
+ static_cast<UI_32>(_countof(userModeNotificationsStruct)));
+ }
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("FrameworkunifiedNPRegisterNotifications(userModeNotifications)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp, sm_notifications, static_cast<UI_32>(_countof(sm_notifications))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedNPRegisterNotifications(sm_notifications)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hApp, NTFY_SSSystemMgrAvailability))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedRegisterServiceAvailabilityNotification(" // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ NTFY_SSSystemMgrAvailability ")"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedPublishServiceAvailability('NTFY_SSSystemMgrAvailability ', TRUE)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ LOG_SUCCESS("FrameworkunifiedPublishServiceAvailability('NTFY_SSSystemMgrAvailability ', TRUE)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ REC_HIST_IF_SUCCESSFUL(NTFY_SSSystemMgrAvailability, m_PubCmdHist, // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ m_PubHistIter, "", l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::init_Heartbeat(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FrameworkunifiedProtocolCallbackHandler hb_protocol_callbacks[] = { {
+ SS_HEARTBEAT_PERIODIC_RESP, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnHeartBeatThreadHeartbeatResponse> }, {
+ SS_HEARTBEAT_ERROR_DETECTED, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnHeartBeatErrorDetected> }, {
+ SS_HEARTBEAT_AVAIL_CHECK_RESP, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnCheckAvailResponse> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ // Subscribe to Notifications (All required notifications)
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, SS_SMHeartbeat, hb_protocol_callbacks, static_cast<UI_32>(_countof(hb_protocol_callbacks))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher(hb_notification_handlers)");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (m_hHeartbeatThread.m_ThreadHdl = FrameworkunifiedCreateChildThreadWithPriority(hApp, SS_SMHeartbeat, HBThreadStart, HBThreadStop, PR_SMHEARTBEAT))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusThreadNotExist;
+ m_hHeartbeatThread.m_ThreadState = eSM_ThreadNotExist;
+ LOG_ERROR("FrameworkunifiedCreateChildThreadWithPriority(hApp, SS_SMHeartbeat)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp, m_hHeartbeatThread.m_ThreadHdl, 0, NULL))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ m_hHeartbeatThread.m_ThreadState = eSM_ThreadNotExist;
+ LOG_ERROR("FrameworkunifiedStartChildThread(SS_SMHeartbeat)");
+ // LCOV_EXCL_STOP
+ } else {
+ m_hHeartbeatThread.m_ThreadState = eSMThreadIsFine;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::init_sysmem_monitor(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FrameworkunifiedProtocolCallbackHandler sysmem_protocol_callbacks[] = { {
+ eSysMemThrdCmd_SYS_LOW_MEMORY, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnLowSystemMemory> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_BR_START 4: For setting the initialization conditions at SystemManager startup
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hApp,
+ m_SysMemMonitor.GetThreadName().c_str(), sysmem_protocol_callbacks,
+ static_cast<UI_32>(_countof(sysmem_protocol_callbacks))))) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher()"); // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
+ } else {
+ m_SysMemMonitor.SetSLMConfigData(m_SMConfig.SLMConfig); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_eStatus = m_SysMemMonitor.Initialize(hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_ERROR_REC_HIST_IF_ERRORED // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ (l_eStatus, "m_SysMemMonitor.Initialize(hApp);"); // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnGroupLaunchTimerExpiry(HANDLE hThread) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ UI_32 l_launchID = m_oSystemLauncher.get_id();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " Received from group %d", l_launchID);
+ REC_HIST_IF_SUCCESSFUL("SM_TIMER_GROUP_MONITOR", m_TimerCmdHist,
+ m_TimerHistIter, "TIMER", l_eStatus);
+
+ LogGroupModulesState(l_launchID,
+ " Group launch timer expired, processing next group.");
+
+ if (NULL == hThread) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ LOG_ERROR("NULL == hThread");
+ } else {
+ // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Timer expired for group id,%d",m_oSystemLauncher.get_id());
+ if (!m_oSystemLauncher.is_end()) {
+ l_launchID = m_oSystemLauncher.advance_id();
+ if (eFrameworkunifiedStatusOK != (l_eStatus = OnLaunchGroup(hThread))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: OnLaunchGroup(%d) errored: %d/'%s'", l_launchID,
+ l_eStatus, GetStr(l_eStatus).c_str());
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnGroupLaunchTimerExpiry( HANDLE hThread )
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::FindNameOfTerminatedProcess(SI_32 f_pid, SS_String &f_ModuleName) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
+ if (l_GroupIterator == m_MapProclaunchGrps.end()) { // LCOV_EXCL_BR_LINE 200: Group Map cannot be empty
+ // LCOV_EXCL_START 200: Group Map cannot be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : Group Map empty"); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ BOOL l_bModuleFound = FALSE;
+ for (; (FALSE == l_bModuleFound)
+ && (l_GroupIterator != m_MapProclaunchGrps.end());
+ l_GroupIterator++) {
+ ModuleLaunchListIter l_ModuleListIterator =
+ l_GroupIterator->second.modules.begin();
+ for (; (FALSE == l_bModuleFound)
+ && (l_ModuleListIterator
+ != l_GroupIterator->second.modules.end());
+ l_ModuleListIterator++) {
+ if (l_ModuleListIterator->pid == f_pid) {
+ l_bModuleFound = TRUE;
+ f_ModuleName = l_ModuleListIterator->name;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::GetBinaryNameOfProcess(SS_String f_ModuleQueueName,
+ SS_String &f_ModuleBinaryName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ ModuleLaunchListIter l_moduleIter;
+
+ f_ModuleBinaryName = "";
+ l_eStatus = GetModuleIterator(f_ModuleQueueName.c_str(), l_moduleIter);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("GetModuleIterator()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ size_t l_pos = l_moduleIter->path.find_last_of("\\/");
+ if (std::string::npos == l_pos) { // LCOV_EXCL_BR_LINE 5: stdlib error case.
+ // LCOV_EXCL_START 5: stdlib error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unable to parse binary name from path %s.",
+ l_moduleIter->path.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ f_ModuleBinaryName = l_moduleIter->path.substr(l_pos + 1);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::init_process_launcher(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ UI_32 TODO = 0;
+
+ FrameworkunifiedProtocolCallbackHandler process_launcher_protocol_callbacks[] = {
+ // Command ID, Call back functions
+ { ePLThrdCmd_LAUNCH_MODULE_RESP, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnModuleLaunchResponse> },
+ { ePLThrdCmd_TERMINATE_MODULE_RESP, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnTerminateModuleResponse> },
+ { ePLThrdCmd_RELAUNCH_MODULE_RESP, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnReLaunchModuleResponse> },
+ { ePLThrdCmd_THREAD_STATUS_RESP, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnProcessLauncherThreadHeartbeatResponse> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ // setup call backs for my children
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, SS_SMLauncher, process_launcher_protocol_callbacks, static_cast<UI_32>(_countof(process_launcher_protocol_callbacks))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher()"); // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
+ //////// Create Writer Child Threads handles the writing of data
+ } else if (NULL == (m_hProcLauncherThread.m_ThreadHdl = FrameworkunifiedCreateChildThreadWithPriority(hApp, SS_SMLauncher, ProcessLauncherOnStart, ProcessLauncherOnStop, PR_SMPROCLAUNCH))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ m_hProcLauncherThread.m_ThreadState = eSM_ThreadNotExist;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedCreateChildThreadWithPriority(%s) errored: %d/'%s'",
+ SS_SMLauncher, l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp, m_hProcLauncherThread.m_ThreadHdl, sizeof(UI_32), &TODO))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ m_hProcLauncherThread.m_ThreadState = // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
+ eSM_ThreadNotExist; // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
+ LOG_ERROR("FrameworkunifiedStartChildThread()"); // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
+ } else {
+ m_hProcLauncherThread.m_ThreadState = eSMThreadIsFine;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::OnGroupLaunchWaitTimeout(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ SetCmdHist("SM_TIMER_GROUP_LAUNCH_WAIT_TIMER", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ CALL_AND_LOG_STATUS(OnLaunchGroup(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnModuleLaunchResponse(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ GroupLaunchMapIter l_GroupIter;
+ ModuleLaunchListIter l_ModuleIter;
+ UI_32 l_launchID = m_oSystemLauncher.get_id();
+
+ l_eStatus = PerformModuleLaunchRespProcessing(hApp, l_GroupIter, l_ModuleIter, "ML");
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("PerformModuleLaunchRespProcessing()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else if (l_GroupIter->second.id == l_launchID) {
+ BOOL IsGroupLaunchComplete = TRUE;
+ // Search the group for any module that has not completed launching.
+ for (l_ModuleIter = l_GroupIter->second.modules.begin();
+ IsGroupLaunchComplete && (l_ModuleIter != l_GroupIter->second.modules.end());
+ l_ModuleIter++) {
+ IsGroupLaunchComplete = !l_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHING);
+ }
+
+ if (IsGroupLaunchComplete) {
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_GROUP_MONITOR]);
+ l_GroupIter->second.launch_complete = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Group%d LaunchComp", l_GroupIter->second.id);
+
+ if (!m_oSystemLauncher.is_end()) {
+ l_launchID = m_oSystemLauncher.advance_id();
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Next group:%d", l_launchID);
+ if (FALSE == l_GroupIter->second.grp_wait_for_trigger) {
+ UI_32 l_Sec = (l_GroupIter->second.grp_launch_wait) / (1000 * 1000);
+ UI_32 l_mSec = 0;
+ if (l_Sec > 0) {
+ l_mSec = ((l_GroupIter->second.grp_launch_wait) % (1000 * 1000)) / 1000;
+ } else {
+ l_mSec = (l_GroupIter->second.grp_launch_wait) / 1000;
+ }
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_GROUP_LAUNCH_WAIT_TIMER], l_Sec, l_mSec, 0, 0);
+ } else {
+ // Start the timer for group trigger... added for optimization
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_LAUNCH_GROUP_TRIGGER_PROC_RESP_TIMER],
+ SS_LAUNCH_GROUP_TRIGGER_TIMER_CONFIG, 0, 0, 0);
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Group %d/%s LaunchIncomp", l_launchID,
+ l_GroupIter->second.name.c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " '%s' ( Group %d/%s ) Launch Response received late - "
+ "group id is now %d", l_ModuleIter->name.c_str(),
+ l_GroupIter->second.id, l_GroupIter->second.name.c_str()
+ , l_launchID);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::OnReLaunchModuleResponse(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ GroupLaunchMapIter l_GroupIter;
+ ModuleLaunchListIter l_ModuleIter;
+
+ l_eStatus = PerformModuleLaunchRespProcessing(hApp, l_GroupIter, l_ModuleIter, "RL");
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "PerformModuleLaunchRespProcessing()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnReLaunchModuleResponse( HANDLE hApp )
+
+
+EFrameworkunifiedStatus CSystemManager::PerformModuleLaunchRespProcessing(HANDLE hApp,
+ GroupLaunchMapIter & f_GroupIter, ModuleLaunchListIter & f_ModuleIter,
+ PCSTR p_sPPD_tag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ T_ProcessLaunchResp l_LaunchRespData;
+
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < T_ProcessLaunchResp > (hApp, l_LaunchRespData))) { // LCOV_EXCL_BR_LINE 4: nsfw error // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: nsfw error
+ } else {
+ BOOL b_DidModuleLaunch = FALSE;
+ f_GroupIter = l_LaunchRespData.groupIterator;
+ f_ModuleIter = l_LaunchRespData.moduleIterator;
+ SS_String l_ModulePath = l_LaunchRespData.path;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "%s(%d)", l_LaunchRespData.name, l_LaunchRespData.pid);
+
+ if (l_LaunchRespData.pid == -1) {
+ f_ModuleIter->pid = -1;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Process launch failed: %s, %s",
+ f_ModuleIter->name.c_str(), l_ModulePath.c_str());
+
+ /// TODO
+ /// If PID is -1, launch had failed. Add logic to do necessary action.
+
+ f_ModuleIter->SetModuleState(MODULE_STATE_LAUNCH_FAILED);
+ } else if (l_LaunchRespData.pid == 0x7FFFFFFF) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning: '%s', '%s' already launched",
+ f_ModuleIter->name.c_str(), l_ModulePath.c_str());
+
+ b_DidModuleLaunch = TRUE;
+ } else {
+ f_ModuleIter->pid = l_LaunchRespData.pid;
+ b_DidModuleLaunch = TRUE;
+ }
+
+ if (b_DidModuleLaunch) {
+ //
+ // Module state could already be MODULE_STATE_CONNECTED if
+ // module process ran before process launcher thread completed;
+ // don't overwrite/reset the MODULE_STATE_CONNECTED state.
+ if (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHING)) {
+ f_ModuleIter->SetModuleState(MODULE_STATE_LAUNCHED);
+ }
+
+ l_eStatus = f_ModuleIter->GetPriority(f_ModuleIter->current_priority);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning: f_ModuleIter->GetPriority( "
+ "f_ModuleIter->current_priority ) returned %d/'%s'. "
+ "Setting 'current_priority' = 'configuration_priority' %d.",
+ l_eStatus, GetStr(l_eStatus).c_str(),
+ f_ModuleIter->configuration_priority);
+ f_ModuleIter->current_priority = f_ModuleIter->configuration_priority;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::PerformModuleLaunchRespProcessing(
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnTerminateModuleResponse
+///
+/// \param HANDLE hApp
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnTerminateModuleResponse(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ T_ProcessLauncherTerminationResp l_TerminateRespData;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < T_ProcessLauncherTerminationResp
+ > (hApp, l_TerminateRespData))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ ModuleLaunchListIter l_ModuleIter = l_TerminateRespData.moduleIterator;
+
+ SS_String l_ModulePath = m_BinaryFilesPath + l_ModuleIter->path;
+
+ if ((0 == strcmp(l_ModulePath.c_str(), l_TerminateRespData.path))
+ && (0 == strcmp(l_ModuleIter->arguments.c_str(),
+ l_TerminateRespData.args))) {
+ l_ModuleIter->pid = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s Termination successful",
+ l_ModuleIter->name.c_str());
+ } else {
+ if (0 != strcmp(l_ModulePath.c_str(), l_TerminateRespData.path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: ModuleIter->path != l_TerminateRespData.path"
+ " \" '%s' != '%s' \"", l_ModuleIter->path.c_str(),
+ l_TerminateRespData.path);
+ }
+ if (0 != strcmp(l_ModuleIter->arguments.c_str(),
+ l_TerminateRespData.args)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: ModuleIter->arguments != "
+ "l_TerminateRespData.args, \" '%s' != '%s' \"",
+ l_ModuleIter->arguments.c_str(), l_TerminateRespData.args);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnTerminateModuleResponse( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////
+/// \ingroup ReadPathAndFileNameEnvironmentVariables
+///
+/// \param
+///
+/// \return VOID
+///////////////////////////////////////////////////////////////////////////////
+VOID CSystemManager::ReadPathFromEnvironmentVariables() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ CHAR *l_pEnvVariable = NULL;
+
+ // read Path from environment variable
+ if (NULL == (l_pEnvVariable = std::getenv(BaseDirPathEnvVariable))) {
+ // Environment variable not set, set it to default path
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Using Default path for Binary Files : %s", DefaultBasePath);
+ m_BinaryFilesPath = DefaultBasePath;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Using Default path for Config Files : %s%s",
+ DefaultBasePath, DefaultConfigFilesPath);
+ m_ConfigFilesPath = DefaultBasePath;
+ } else {
+ // set path of binary files
+ m_BinaryFilesPath = l_pEnvVariable;
+
+ // set path of configuration files
+ m_ConfigFilesPath = l_pEnvVariable;
+ }
+ // set path of configuration files
+ m_ConfigFilesPath += DefaultConfigFilesPath;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// \ingroup GetConfigDataFileNameFromEnvironmentVariable
+///
+/// \param
+///
+/// \return SS_String
+///////////////////////////////////////////////////////////////////////////////
+SS_String CSystemManager::ReadLaunchConfigFileNameFromEnvironmentVariable() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CHAR *l_pEnvVariable = NULL;
+ SS_String l_FileName;
+
+ // read Launch Config File Name from environment variable
+ // LCOV_EXCL_BR_START 5: standard lib error
+ if (NULL == (l_pEnvVariable = std::getenv(LaunchConfigFileNameEnvVariable))) {
+ // LCOV_EXCL_BR_STOP
+ // Environment variable not set, set it to default file name
+ // LCOV_EXCL_START 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Using Default Launch Configuration file : %s",
+ DefaultLaunchConfigFileName);
+ l_FileName = DefaultLaunchConfigFileName;
+ // LCOV_EXCL_STOP
+ } else {
+ l_FileName = l_pEnvVariable;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Using Launch Configuration file: %s", l_FileName.c_str());
+
+ SS_String retStr = m_ConfigFilesPath + l_FileName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (access(retStr.c_str(), F_OK) != 0) { // LCOV_EXCL_BR_LINE 5: standard lib error
+ // LCOV_EXCL_START 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "no found %s", retStr.c_str());
+ SS_ASERT(0);
+ // LCOV_EXCL_STOP
+ }
+ return retStr;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// \ingroup GetConfigDataFileNameFromEnvironmentVariable
+///
+/// \param
+///
+/// \return SS_String
+///////////////////////////////////////////////////////////////////////////////
+SS_String CSystemManager::ReadConfigDataFileNameFromEnvironmentVariable() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CHAR *l_pEnvVariable = NULL;
+ SS_String l_FileName = "";
+
+ // read SM Config Data File Name from environment variable
+ // LCOV_EXCL_BR_START 5: standard lib error
+ if (NULL == (l_pEnvVariable = std::getenv(SMConfigDataFileNameEnvVariable))) {
+ // LCOV_EXCL_BR_STOP 5: standard lib error
+ // LCOV_EXCL_START 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // Environment variable not set, set it to default file name
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Using Default Configuration Data file : %s", DefaultSMConfigFileName);
+ l_FileName = DefaultSMConfigFileName;
+ // LCOV_EXCL_STOP
+ } else {
+ l_FileName = l_pEnvVariable;
+ }
+
+ SS_String retStr = m_ConfigFilesPath + l_FileName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (access(retStr.c_str(), F_OK) != 0) { // LCOV_EXCL_BR_LINE 5: standard lib error
+ // LCOV_EXCL_START 5: standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "no found %s", retStr.c_str());
+ SS_ASERT(0);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return retStr;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// \ingroup ReadUsingVMPlayerEnvironmentVariable
+///
+/// \param
+///
+/// \return VOID
+///////////////////////////////////////////////////////////////////////////////
+VOID CSystemManager::ReadUsingVMPlayerEnvironmentVariable() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CHAR *l_pEnvVariable = std::getenv(UsingVMPlayerVariable);
+ m_UsingVMPlayer = (NULL != l_pEnvVariable);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %sunning on a VMPlayer",
+ m_UsingVMPlayer ? "R" : "Not r");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return;
+} // End of VOID CSystemManager::ReadUsingVMPlayerEnvironmentVariable()
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::start_process_launching(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_bIsGoodRc;
+ SS_String l_SMConfigFile(ReadConfigDataFileNameFromEnvironmentVariable());
+ SMConfigParams SMConfigData;
+ SS_String l_LaunchConfigFile(ReadLaunchConfigFileNameFromEnvironmentVariable()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ SysMgrConfiguration l_launchConfig;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Reading %s Configuration Data from %s",
+ SERVICE_SYSMANAGER, l_SMConfigFile.c_str());
+
+ l_bIsGoodRc = SMConfigData.LoadSMConfigParameters(m_SMConfig, l_SMConfigFile);
+
+ if (!l_bIsGoodRc) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SMConfigData.LoadSMConfigParameters(m_SMConfig, "
+ " %s) returned FALSE", l_SMConfigFile.c_str());
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ // LCOV_EXCL_STOP
+ } else {
+ SMSetState(hApp, SS_SM_APPS_LAUNCH_IN_PROGRESS); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Reading Launch Configuration Data from %s",
+ l_LaunchConfigFile.c_str());
+
+ SS_String l_launchOrderName = "DEFAULT"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LaunchOrderedVector l_OrderList;
+
+ l_bIsGoodRc = l_launchConfig.LoadParametersCfg(m_MapProclaunchGrps,
+ m_MapProcNames, l_OrderList, l_launchOrderName, l_LaunchConfigFile);
+
+ if (l_OrderList.size() != 0) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "wakeup order:%s",
+ l_launchOrderName.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "wakeup order:DEFAULT");
+ }
+
+ if (!l_bIsGoodRc) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: l_launchConfig.LoadParametersCfg( "
+ "m_MapProclaunchGrps, m_MapProcNames, %s ) returned FALSE",
+ l_LaunchConfigFile.c_str());
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ // LCOV_EXCL_STOP
+ } else {
+ m_SystemLaunchProgress = SS_SM_INITIAL_GROUP;
+ // l_launchConfig.PrintAllInfo( m_MapProclaunchGrps );
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " System Launch Started");
+ // Don't use DynamicLaunch because its dependency on the services table is complex
+ SS_SOURCE source_type = SS_SOURCE_FM;
+
+ m_oSystemLauncher.configure_dynamic_launch(source_type, m_MapProclaunchGrps, l_OrderList);
+ m_oSystemLauncher.copyDynOrderedVector(m_SystemStarter);
+ // m_SystemStarter.print_info();
+
+ // start the timer upon successful launching of first process
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Starting Module Connection Timeout timer with %d sec period",
+ m_SMConfig.MCConfig.ModuleConnectionTimeOutSec);
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER],
+ m_SMConfig.MCConfig.ModuleConnectionTimeOutSec, 0,
+ m_SMConfig.MCConfig.ModuleConnectionTimeOutSec, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ CALL_AND_LOG_STATUS(OnLaunchGroup(hApp)); // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+
+EFrameworkunifiedStatus CSystemManager::GetLastSourceInfo(SS_SOURCE &source_type) { // LCOV_EXCL_START 8: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ CHAR LastSource[64 + 1] = { '\0' };
+ l_eStatus = NPSynchronousReadPersistentData(SERVICE_AS_MODE,
+ NTFY_SSLastSourceType, LastSource, static_cast<UI_32>(sizeof(LastSource) - 1));
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("NPSynchronousReadPersistentData("
+ SERVICE_AS_MODE "," NTFY_SSLastSourceType);
+ } else {
+ std::string tempstr(LastSource);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " String got from persistence %s", LastSource);
+ UI_32 pos = static_cast<UI_32>(tempstr.find("_"));
+ std::string tempstr2 = tempstr.substr(0, pos);
+ UI_64 value = strtoull(tempstr2.c_str(), 0, 10);
+ source_type = static_cast<SS_SOURCE>((UI_32)(value >> 32) & 0x0000FFFF);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::OnLaunchGroupTriggerProcessResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
+ UI_32 l_groupID;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+ SetCmdHist("SS_SM_GROUP_LAUNCH_TRIGGER", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
+ // stop group launch trigger process response timer
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_LAUNCH_GROUP_TRIGGER_PROC_RESP_TIMER]);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < UI_32 > (hApp, l_groupID))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ SS_SOURCE source_type = SS_SOURCE_NA;
+ l_eStatus = GetLastSourceInfo(source_type);
+
+ if ((SS_SOURCE_AM == source_type) || (SS_SOURCE_FM == source_type)
+ || (SS_SOURCE_FM_DAB == source_type) || (SS_SOURCE_SDARS == source_type)) {
+ if (l_groupID == m_oSystemLauncher.get_id()) {
+ CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Received Group ID %d != Sys Mgr Group ID %d", l_groupID,
+ m_oSystemLauncher.get_id());
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else { // media is last source
+ CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::OnLaunchGroupTriggerProcessResponseTimerExpiry(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
+ REC_HIST_IF_SUCCESSFUL("SM_TIMER_LAUNCH_GROUP_TRIGGER", m_TimerCmdHist,
+ m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
+ CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnLaunchGroupSelfTrigger(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ REC_HIST_IF_SUCCESSFUL("SS_SM_SendTriggerToSelf", m_SMCmdHist, m_SMHistIter,
+ FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
+
+ CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+///
+/// \param
+///
+/// \return
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnLaunchGroup(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ GroupLaunchMapIter l_GroupIter;
+ UI_32 l_launch_ID = m_oSystemLauncher.get_id();
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Launching group %d", l_launch_ID );
+
+ l_GroupIter = m_MapProclaunchGrps.find(l_launch_ID);
+
+ if (l_GroupIter->second.launch_complete == FALSE) { // LCOV_EXCL_BR_LINE 6: Because it is not called for a condition that results in "TRUE"
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__
+ // , " m_bIsNPP_ServicesStarted ? %s, group.id: %d, Launch_Group: %d"
+ // , m_bIsNPP_ServicesStarted ? "Yes" : "No"
+ // , l_GroupIter->second.id
+ // , m_SystemLaunchProgress );
+
+ if ((m_bIsNPP_ServicesStarted && m_bIsBackupAvail) || (l_GroupIter->second.id <= 2)) { // LCOV_EXCL_BR_LINE 6: Because it is not called for the condition that results in "FALSE" // NOLINT(whitespace/line_length)
+ ModuleLaunchListIter l_ModuleListIterator = l_GroupIter->second.modules.begin();
+ if (l_ModuleListIterator != l_GroupIter->second.modules.end()) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ // FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "GRPLCH,(start),%d,%s",
+ // l_GroupIter->second.id,l_GroupIter->second.name.c_str());
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Launching Group%d/%s",
+ l_GroupIter->second.id, l_GroupIter->second.name.c_str());
+ SS_String l_ModulePath;
+ for (; l_ModuleListIterator != l_GroupIter->second.modules.end(); l_ModuleListIterator++) {
+ if (l_ModuleListIterator->IsModuleState(MODULE_STATE_INVALID)) {
+ char l_cFormat[] = "SendRequestToLauncher(%s, "
+ "ePLThrdCmd_LAUNCH_MODULE_REQST)";
+ char l_cBuf[sizeof(l_cFormat) + MAX_NAME_SIZE_APP];
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat,
+ l_ModuleListIterator->name.c_str());
+
+ l_eStatus = SendRequestToLauncher(hApp, l_ModuleListIterator, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ ePLThrdCmd_LAUNCH_MODULE_REQST, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ "ePLThrdCmd_LAUNCH_MODULE_REQST"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_ModuleListIterator->SetModuleState(
+ MODULE_STATE_LAUNCH_FAILED);
+ SetCmdHist(l_cBuf, m_ErrHist, m_ErrHistIter,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ l_ModuleListIterator->SetModuleState(MODULE_STATE_LAUNCHING);
+ }
+ } else {
+ l_ModulePath = (m_BinaryFilesPath + l_ModuleListIterator->path); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Not launching %s: module state is %s",
+ l_ModulePath.c_str(),
+ l_ModuleListIterator->ModuleStateStr().c_str());
+ }
+ }
+
+ // LCOV_EXCL_BR_START 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ if (FALSE ==
+ l_GroupIter->second.grp_wait_for_trigger) {
+ // LCOV_EXCL_BR_STOP
+ m_GroupLaunchTimer->StartTimer(m_aTimerIDs[eSM_TIMER_GROUP_MONITOR],
+ SS_GROUP_LAUNCH_TIMER_CONFIG, 0, 0, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+
+ if (m_oSystemLauncher.is_end()) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "System Launch Completed");
+
+ if (epssusSYSTEM_SERVICES_STARTED == m_SystemModeInfo.startupStage) {
+ // If startupStage == SYSTEM_SERVICES_STARTED, a notification is requested because there are SVCs required for notification to the _CWORD56_.
+ l_eStatus = SendSystemModeInfoResponse(hApp, epssusALL_SERVICES_LAUNCHED);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "UpdateStartupStageState_SendSystemModeInfoResponse" // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "( epssusALL_SERVICES_LAUNCHED )"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ m_SystemModeInfo.startupStage = epssusALL_SERVICES_LAUNCHED;
+
+ if (is_current_state(SS_SM_APPS_LAUNCH_IN_PROGRESS)) {
+ SMSetState(hApp, SS_SM_APPS_LAUNCHED_READY_TO_START);
+ }
+ // SysMgrConfiguration config;
+ // config.PrintAllInfo( m_MapProclaunchGrps );
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnLaunchGroup(HANDLE hApp)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnProcessLaunchTimerExpiry
+///
+/// \param HANDLE hApp
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnProcessLaunchTimerExpiry(HANDLE hApp) { // LCOV_EXCL_START 8: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // ToDo 2013_05_17 Jay When used ? Dead code ? Don't see a StartTimer call.
+ REC_HIST_IF_SUCCESSFUL("SM_TIMER_PROCESS_LAUNCH_MONITOR", m_TimerCmdHist,
+ m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_PROCESS_LAUNCH_MONITOR]);
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnHeartBeatMonitorTimerExpiry
+///
+/// \param HANDLE hApp
+///
+/// \return EFrameworkunifiedStatus
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnHeartBeatMonitorTimerExpiry(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, " Received from %s", FrameworkunifiedGetMsgSrc(hApp));
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ REC_HIST_IF_SUCCESSFUL("SM_TIMER_HEARTBEAT_MONITOR", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ // LCOV_EXCL_BR_START 4: nsfw error
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hHeartbeatThread.m_ThreadHdl,
+ SS_HEARTBEAT_PERIODIC_STATUS_REQ, 0, NULL))) {
+ // LCOV_EXCL_BR_STOP 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild(m_hHeartbeatThread.m_ThreadHdl, " // LCOV_EXCL_LINE 4: nsfw error
+ "SS_HEARTBEAT_PERIODIC_STATUS_REQ)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ m_hHeartbeatThread.m_ThreadState = eSMWaitForHeartbeat;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SystemManagerDebugDump
+/// implement post mortem function
+///
+/// \param
+///
+/// \return void
+///////////////////////////////////////////////////////////////////////////////
+
+VOID CSystemManager::SystemManagerDebugDump(HANDLE hApp) {
+ std::stringstream l_debugDumpBuf;
+ cmdHistIter i;
+
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_debugDumpBuf << FrameworkunifiedGetAppName(hApp) << "/" << endl
+ << " <SYSTEM MANAGER DUMP DATA> " << endl << endl << " ***internals*** " << endl
+ << endl << " SM state: "
+ << GetStr(m_SMCurrentState).c_str() << endl << " SM startup reason: "
+ << GetStr(m_StartUpReason).c_str() << endl << " SM shutdown reason: "
+ << GetStr(m_shutdownTrigger).c_str() << endl << " LUM: "
+ << GetStr(m_lastUserMode).c_str() << endl << " TPM: "
+ << GetStr(m_SystemModeInfo.transportMode).c_str() << endl << " LPH: "
+ << GetStr(m_SystemModeInfo.limpHomeCutoff).c_str() << endl << " PMode: "
+ << GetStr(m_SystemModeInfo.productionMode).c_str() << endl << " ActiveGroup: "
+ << m_ActiveGroupId << endl << " m_MaxShutdownTime: " << m_MaxShutdownTime
+ << endl << " NPP: " << (m_bIsNPP_ServicesStarted ? "Started" : "notStarted")
+ << endl
+ << endl << " ***Error history***" << endl;
+ // LCOV_EXCL_BR_STOP
+
+ for (i = m_ErrHist.begin(); i != m_ErrHist.end(); ++i) {
+ l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ << "ms EC:" << i->m_sender.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ l_debugDumpBuf << endl << " ***_CWORD56_ command history***" << endl;
+
+ for (i = m__CWORD56_CmdHist.begin(); i != m__CWORD56_CmdHist.end(); ++i) {
+ l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ l_debugDumpBuf << endl << " ***Timer history***" << endl;
+
+ for (i = m_TimerCmdHist.begin(); i != m_TimerCmdHist.end(); ++i) {
+ l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ l_debugDumpBuf << endl << " ***SM message history***" << endl;
+
+ for (i = m_SMCmdHist.begin(); i != m_SMCmdHist.end(); ++i) {
+ l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms " // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ << i->m_sender.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ l_debugDumpBuf << endl << " ***Publishshing history***" << endl;
+
+ for (i = m_PubCmdHist.begin(); i != m_PubCmdHist.end(); ++i) {
+ l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms " // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ << i->m_sender.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ l_debugDumpBuf << endl << " ***SM start table***" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_debugDumpBuf << endl
+ << " index | name | start required? | isOKFlag | Module state | start sent "
+ "| start resposne received |start delta | stop sent | reply received | stop delta | PID"
+ << endl;
+ // LCOV_EXCL_BR_STOP
+
+ for (UI_32 k = 1u; (k <= m_MapProclaunchGrps.size()); k++) {
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(k);
+
+ if (l_GroupIterator != m_MapProclaunchGrps.end()) {
+ ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
+
+ for (int i = 1u; l_ModuleListIterator != l_GroupIterator->second.modules.end();
+ l_ModuleListIterator++, i++) {
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::string sIsOKFlag = GetModuleCondition(l_ModuleListIterator) ? " " : // 'blank' means OK
+ "X"; // 'X' means state mismatch
+
+ l_debugDumpBuf << " " << std::setw(2) << std::right << i << " | "
+ << std::setw(24) << std::left << l_ModuleListIterator->name.c_str()
+ << " | " << std::setw(5) << std::left
+ << (l_ModuleListIterator->is_start_required ? "TRUE" : "FALSE")
+
+ << " | " << sIsOKFlag.c_str() << " | " << std::setw(24) << std::left
+ << l_ModuleListIterator->ModuleStateStr().c_str() << " | "
+ << l_ModuleListIterator->m_startReason.GetInitial() << " | "
+ << l_ModuleListIterator->m_startReason.GetFinal() << " | "
+ << std::setw(3) << std::right
+ << static_cast<SI_16>(l_ModuleListIterator->m_startReason.GetDelta())
+ << "ms" << " | " << l_ModuleListIterator->m_stopReason.GetInitial()
+ << " | " << l_ModuleListIterator->m_stopReason.GetFinal() << " | "
+ << std::setw(3)
+ << static_cast<SI_16>(l_ModuleListIterator->m_stopReason.GetDelta())
+ << "ms" << " | " << l_ModuleListIterator->pid << endl;
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+ }
+
+ l_debugDumpBuf << endl << " ***Heartbeat information***" << endl;
+
+ l_debugDumpBuf << endl << " Entire State:" << m_HBReport.eEntireState << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_debugDumpBuf << endl << " Number of Modules:" << m_HBReport.nNumOfModules << endl;
+
+ for (UI_32 j = 0; j < m_HBReport.nNumOfModules; j++) { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (0 != m_HBReport.tModuleList[j].HeartBeatRetryCount) {
+ l_debugDumpBuf << endl << " " << m_HBReport.tModuleList[j].ProcQueueName << ","
+ << m_HBReport.tModuleList[j].ProcHBState << ", "
+ << m_HBReport.tModuleList[j].HeartBeatRetryCount << endl;
+ }
+ // LCOV_EXCL_STOP
+ }
+
+ std::string l_debugDumpStr = l_debugDumpBuf.str();
+
+ SendDebugDumpResponseToSystemManager(l_debugDumpStr); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnProcessLaunchMonitorTimerExpiry
+/// This sends request to launcher thread to confirm that it
+/// is still responsive.
+///
+/// \param [in] hApp
+/// HANDLE - Handle of the Client Application
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnProcessLaunchMonitorTimerExpiry(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from %s", FrameworkunifiedGetMsgSrc(hApp));
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ REC_HIST_IF_SUCCESSFUL("TIMER_PROCESSLAUNCHER_MONITOR", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ // LCOV_EXCL_BR_START 4: nsfw error
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hProcLauncherThread.m_ThreadHdl,
+ ePLThrdCmd_THREAD_STATUS_REQST, 0, NULL))) {
+ // LCOV_EXCL_BR_STOP 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild(m_hProcLauncherThread.m_ThreadHdl," // LCOV_EXCL_LINE 4: nsfw error
+ "ePLThrdCmd_THREAD_STATUS_REQST)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ m_hProcLauncherThread.m_ThreadState = eSMWaitForHeartbeat;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendRequestToLauncher
+/// This function is used for sending request to launcher thread from
+/// System Manager.
+///
+/// \param HANDLE hApp
+/// ModuleLaunchListIter f_ModuleListIterator => iterator node from map for the module
+/// ESMPLThreadCommandIds f_CommandId => command id to send
+/// SS_String f_ModulePath => Path of the Module
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::PerformLaunchProcedure(HANDLE hApp,
+ ModuleLaunchListIter f_ModuleIterator, SS_String & f_stopCompName) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ SS_String s_ModuleStatus2;
+
+ // Register for Stop Complete notification
+ if (!f_ModuleIterator->shutdown_critical) {
+ s_ModuleStatus2 = "is not shutdown_critical";
+ // LCOV_EXCL_BR_START 6: For setting the initialization conditions at SystemManager startup
+
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus =
+ FrameworkunifiedSubscribeNotificationWithCallback(
+ hApp,
+ f_stopCompName.c_str(),
+ SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStopCompleteNotification>))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedSubscribeNotificationWithCallback(hApp, %s) errored: %d/'%s'",
+ f_stopCompName.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
+
+ s_ModuleStatus2 = "is shutdown_critical but errored";
+ // LCOV_EXCL_STOP
+ } else {
+ s_ModuleStatus2 = f_stopCompName + " is now registered"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", s_ModuleStatus2.c_str());
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup PerformTerminateProcedure
+/// Perform Procedure for Service Terminate.
+///
+/// \param HANDLE hApp
+/// ModuleLaunchListIter f_ModuleListIterator => iterator node from map for the module
+/// SS_String & f_availabilityName => Availability Name
+/// SS_String & f_stopCompName => Stop Complete Notification Name
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::PerformTerminateProcedure(HANDLE hApp,
+ ModuleLaunchListIter f_ModuleIterator, SS_String & f_availabilityName,
+ SS_String & f_stopCompName) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // close session
+ f_ModuleIterator->SetModuleState(MODULE_STATE_INVALID);
+ f_ModuleIterator->pid = 0;
+ if (NULL != f_ModuleIterator->hsession) { // LCOV_EXCL_BR_LINE 200:hsession must not be NULL.
+ l_eStatus = FrameworkunifiedMcClose(f_ModuleIterator->hsession); // LCOV_EXCL_BR_LINE 4: nsfw error
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: FrameworkunifiedMcClose(%s) errored: %d/'%s'",
+ f_ModuleIterator->name.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ }
+ f_ModuleIterator->hsession = NULL;
+ }
+
+ // Availability
+ if (f_ModuleIterator->is_start_required) {
+ // Initialize Availability
+ HANDLE pPublishMq = McOpenSender(FRAMEWORKUNIFIED_NS_NPSERVICE); // LCOV_EXCL_BR_LINE 4: nsfw error
+ if (NULL == pPublishMq) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_LINE 4: nsfw error
+ } else {
+ ServiceAvailability tServiceAvailability;
+
+ snprintf(tServiceAvailability.cServiceName, MAX_NAME_SIZE_APP, "%s",
+ f_ModuleIterator->name.c_str());
+ tServiceAvailability.eServiceAvailability = eFrameworkunifiedServiceNotAvailable;
+
+ l_eStatus = NPPublishNotification(pPublishMq, f_ModuleIterator->name.c_str(), // LCOV_EXCL_BR_LINE 4: nsfw error
+ f_availabilityName.c_str(), &tServiceAvailability, // LCOV_EXCL_BR_LINE 4: nsfw error
+ sizeof(tServiceAvailability)); // LCOV_EXCL_BR_LINE 4: nsfw error
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: NPPublishNotification(%s)",
+ f_availabilityName.c_str());
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = McClose(pPublishMq); // LCOV_EXCL_BR_LINE 4: nsfw error
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+
+ if (f_ModuleIterator->shutdown_critical) {
+ // Unregister Stop Complete notification
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithCallback(hApp, f_stopCompName.c_str()))) { // LCOV_EXCL_BR_LINE 4: nsfw error // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedUnsubscribeNotificationWithCallback(hApp, %s) errored: %d/'%s'",
+ f_stopCompName.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ SS_String s_ModuleStatus2 = f_stopCompName + " is now unregistered ";
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", s_ModuleStatus2.c_str());
+ }
+ }
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendRequestToLauncher
+/// This function is used for sending request to launcher thread from
+/// System Manager.
+///
+/// \param HANDLE hApp
+/// ModuleLaunchListIter f_ModuleListIterator => iterator node from map for the module
+/// ESMPLThreadCommandIds f_CommandId => command id to send
+/// SS_String f_ModulePath => Path of the Module
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::SendRequestToLauncher(HANDLE hApp,
+ ModuleLaunchListIter f_ModuleIterator, ESMPLThreadCommandIds f_CommandId,
+ SS_String f_CommandIdStr) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SS_String l_ModulePath = m_BinaryFilesPath + f_ModuleIterator->path;
+
+ T_ProcessLauncherLaunchReq l_ModuleLaunchReq = { };
+ strcpy(l_ModuleLaunchReq.name, f_ModuleIterator->name.c_str()); // NOLINT
+ strcpy(l_ModuleLaunchReq.path, l_ModulePath.c_str()); // NOLINT
+ strncpy(l_ModuleLaunchReq.args, f_ModuleIterator->arguments.c_str(), // NOLINT
+ sizeof(l_ModuleLaunchReq.args) - 1);
+ strcpy(l_ModuleLaunchReq.logging_mask, // NOLINT
+ f_ModuleIterator->logging_msk_str.c_str());
+ l_ModuleLaunchReq.priority = f_ModuleIterator->configuration_priority;
+ l_ModuleLaunchReq.cpu_assign = f_ModuleIterator->cpu_assign;
+ l_ModuleLaunchReq.groupIterator = m_MapProclaunchGrps.find(
+ f_ModuleIterator->group_id);
+ l_ModuleLaunchReq.moduleIterator = f_ModuleIterator;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Queue:%s, path:%s, args:%s, lmsk:%s, prio:%d, cmd:%s", l_ModuleLaunchReq.name,
+ l_ModuleLaunchReq.path, l_ModuleLaunchReq.args, l_ModuleLaunchReq.logging_mask,
+ l_ModuleLaunchReq.priority, f_CommandIdStr.c_str());
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hProcLauncherThread.m_ThreadHdl, f_CommandId, sizeof(l_ModuleLaunchReq), reinterpret_cast<void *>(&l_ModuleLaunchReq)))) { // LCOV_EXCL_BR_LINE 4: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 4: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedSendChild( %s, %s ) errored: %d/'%s'", l_ModulePath.c_str(),
+ f_CommandIdStr.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ SS_String l_availabilityName = f_ModuleIterator->name + "/Availability"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ SS_String l_stopCompName = f_ModuleIterator->name + "/StopComp"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ // Perform command-specific processing
+ switch (f_CommandId) { // LCOV_EXCL_BR_LINE 6: Because the case is fixed on the call from the SystemManager::Initialize
+ // LCOV_EXCL_START 6: Because the case is fixed on the call from the SystemManager::Initialize
+ case ePLThrdCmd_RELAUNCH_MODULE_REQST:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = PerformTerminateProcedure(hApp, f_ModuleIterator,
+ l_availabilityName, l_stopCompName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ SS_ASERT(0);
+ }
+
+ l_eStatus = PerformLaunchProcedure(hApp, f_ModuleIterator, l_stopCompName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ SS_ASERT(0);
+ }
+ break;
+ // LCOV_EXCL_STOP
+
+ case ePLThrdCmd_LAUNCH_MODULE_REQST:
+ l_eStatus = PerformLaunchProcedure(hApp, f_ModuleIterator, l_stopCompName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_LINE 6: For setting the initialization conditions at SystemManager startup
+ }
+ break;
+
+ case ePLThrdCmd_TERMINATE_MODULE_REQST:
+ l_eStatus = PerformTerminateProcedure(hApp, f_ModuleIterator,
+ l_availabilityName, l_stopCompName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ break;
+
+ // LCOV_EXCL_START 6: Because the case is fixed on the call from the SystemManager::Initialize
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ case ePLThrdCmd_LAUNCH_MODULE_RESP:
+ case ePLThrdCmd_MODULE_STATUS_REQST:
+ case ePLThrdCmd_RELAUNCH_MODULE_RESP:
+ case ePLThrdCmd_TERMINATE_MODULE_RESP:
+ case ePLThrdCmd_THREAD_STATUS_REQST:
+ case ePLThrdCmd_THREAD_STATUS_RESP:
+ case ePLThrdCmd_NONE:
+ break;
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::SendRequestToLauncher(
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup RemoveModuleEntryFromHB
+/// This function is called to send module information to heart beat thread
+/// which is to be removed from its list of services to be monitored.
+///
+/// \param HANDLE hApp,
+/// const CHAR *f_ModuleName => Module Name
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::RemoveModuleEntryFromHB(HANDLE hApp, const CHAR *f_ModuleName) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ HBListIter l_HBIter = std::find(m_HBList.begin(), m_HBList.end(), f_ModuleName);
+ if (l_HBIter != m_HBList.end()) {
+ m_HBList.erase(l_HBIter);
+ }
+
+ TSMRequestMessage l_ModuleDetails;
+ strncpy(l_ModuleDetails.pstModuleName, f_ModuleName,
+ sizeof(l_ModuleDetails.pstModuleName) - 1);
+ l_ModuleDetails.pstModuleName[sizeof(l_ModuleDetails.pstModuleName) - 1] = '\0';
+ l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_DELETE_MODULE_ENTRY,
+ &l_ModuleDetails, sizeof(TSMRequestMessage));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnHeartBeatThreadHeartbeatResponse
+/// This function gets called when heart beat thread replies the
+/// heart beat query sent by the System Manager.
+/// \param [in] hApp
+/// HANDLE - Handle of the Client Application
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnHeartBeatThreadHeartbeatResponse(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "HeartBeat HeartBeat Received");
+ m_hHeartbeatThread.m_ThreadState = eSMThreadIsFine;
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnCheckAvailResponse
+/// This function gets service's availability status from HBThread
+/// \param [in] hApp
+/// HANDLE - Handle of the Client Application
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnCheckAvailResponse(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ THbAvailCheck result;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < THbAvailCheck > (hApp, result))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_tempaltes.h // NOLINT(whitespace/line_length)
+ } else if (result.isOk == FALSE) {
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnProcessLauncherThreadHeartbeatResponse
+/// This function gets called when launcher thread replies the
+/// heart beat query sent by the System Manager.
+/// \param [in] hApp
+/// HANDLE - Handle of the Client Application
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnProcessLauncherThreadHeartbeatResponse(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "ProcessLaunch HeartBeat Received");
+ m_hProcLauncherThread.m_ThreadState = eSMThreadIsFine;
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup RegisterCallbacksForRequester
+/// Register callbacks for External Protocol commands
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::RegisterCallbacksForRequester(HANDLE hApp, PCSTR f_pRequester) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Attach Session Protocol messages.
+ FrameworkunifiedProtocolCallbackHandler l_sm_protocol_handlers[] = {
+ // Command ID, Call back functions
+ { SS_SM_START_COMPL_RSPN,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
+ { SS_SM_STOP_COMPL_RSPN,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStopCompleteResponse> },
+ { SS_SM_PRE_START_COMPL_RSPN,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
+ { SS_SM_PRE_STOP_COMPL_RSPN,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
+ { SS_SM_BACKGROUND_START_COMPL_RSPN,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
+ { SS_SM_BACKGROUND_STOP_COMPL_RSPN,
+ SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
+ { SS_SM_GET_START_EXT_INFO, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnGetStartExtInfo> },
+ { SS_SM_GET_STOP_EXT_INFO, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnGetStopExtInfo> },
+ { SS_SM_CRNT_STATE_QUERY, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnCurrentSMStateQuery> },
+ { SS_SM_DATA_RESET_MODE_SET_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnSetDataResetModeRequest> },
+ { SS_SM_PROG_UPDATE_STATE_SET_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnSetProgUpdateStateRequest> },
+
+ { SS_SM__CWORD56__HEARTBEAT_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::On_CWORD56_HeartBeatRequest> },
+ { SS_SM_NEXT_WAKEUP_TYPE_SET_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnSetNextWakeupTypeRequest> },
+ // Error Event Logging
+ { SS_SM_ERROR_EVENT_LOGGING_START_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnLoggingStartRequest> },
+ { SS_SM_ERROR_EVENT_ARTIFACT_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnErrorEventArtifactRequest> },
+ { SS_SM_ERROR_EVENT_LOGGING_COMPLETE, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnErrorEventLoggingComplete> },
+ { SS_SM_DEBUG_DUMP_RSPN, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnDebugDumpResponseReceived> },
+ { SS_SM_PROPAGATE_SYSTEM_ERROR, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnPropagateSystemError> },
+ { SS_SM_BOOT_MICRO_RESET_NTF, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnBootMicroResetNotification> },
+ { SS_SM_BOOT_MICRO_LOG_RSP, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnBootMicroLogResponse> },
+ { SS_SM_USER_INVOKED_LOG_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnUserInvokedLoggingRequest> },
+ { SS_SM_ERROR_EVENT_EEL_EXPORT_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnEelExportRequest> },
+ { SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnSystemmanagerEmmcLogsRequest> },
+ { SS_SM_ERROR_EVENT_CLR_LOGS_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnSystemmanagerClearLogsRequest> },
+ { SS_SM_ERROR_EVENT_DIAG_LOG_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnDiagLoggingRequest> },
+ { SS_SM_ERROR_EVENT_CAN_LOG_REQ, SysMgrCallback<CSystemManager,
+ &CSystemManager::OnCANLoggingRequest> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, f_pRequester,
+ l_sm_protocol_handlers, static_cast<UI_32>(_countof(l_sm_protocol_handlers))); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedAttachCallbacksToDispatcher(%s) errored: %d/'%s'", f_pRequester,
+ l_eStatus, GetStr(l_eStatus).c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::RegisterCallbacksForRequester( HANDLE hApp, PCSTR f_pRequester)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup open_session_with_sm_test_client
+/// Process request to open session with sm test client
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::open_session_with_sm_test_client(HANDLE hApp, PCSTR pRequester) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ UI_32 const l_ui32DefaultSessionID = 0;
+ OpenSessionAck tOpenAck = { };
+
+/*
+ * Here pRequester is SMTesteClient with whom session is opened and its handle is stored in m_hPowerServiceSession handle.
+ * This case comes only while testing SystemManager through SMTestClient (PowerService should not be running).
+ */
+ // Validate session handle
+ if (NULL == m_hPowerServiceSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Session Handle NULL, calling FrameworkunifiedMcOpenSender for %s", pRequester);
+
+ m_hPowerServiceSession = FrameworkunifiedMcOpenSender(hApp, pRequester);
+ //
+ // Set the Session Handle for Framework so FrameworkunifiedSendResponse won't error due to a null
+ // session handle.
+ //
+ // LCOV_EXCL_BR_START 4:NSFW's error
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSetSessionHandle(hApp,
+ pRequester, // [in] PCSTR - Name of the associated service name
+ m_hPowerServiceSession))) { // [in] HANDLE - Session handle
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4:NSFW's error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedSetSessionHandle(%s) errored: %d/'%s'", pRequester,
+ l_eStatus, GetStr(l_eStatus).c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (m_hPowerServiceSession == NULL) { // LCOV_EXCL_BR_LINE 200:m_hPowerServiceSession must not be NULL
+ // LCOV_EXCL_START 200:m_hPowerServiceSession must not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Invalid Session Handle to service (%s) ", pRequester);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Session opened with %s", pRequester);
+
+ // Copy session name to data structure
+ strncpy(tOpenAck.cSessionName, FrameworkunifiedGetAppName(hApp),
+ sizeof(tOpenAck.cSessionName) - 1);
+ tOpenAck.eStatus = eFrameworkunifiedStatusOK;
+ tOpenAck.sessionId = l_ui32DefaultSessionID;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "About to send Open Session ACK");
+ // send OpenSession ACK
+ // LCOV_EXCL_BR_START 4:NSFW's error
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession,
+ PROTOCOL_OPEN_SESSION_ACK, sizeof(OpenSessionAck),
+ (PVOID) & tOpenAck))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4:NSFW's error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendMsg(PROTOCOL_OPEN_SESSION_ACK)");
+
+ // Close the message queue handle
+ if (NULL != m_hPowerServiceSession) {
+ CALL_AND_LOG_STATUS_IF_ERRORED(FrameworkunifiedMcClose(m_hPowerServiceSession));
+ m_hPowerServiceSession = NULL;
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ CALL_AND_LOG_STATUS_IF_ERRORED(RegisterCallbacksForRequester(hApp, pRequester));
+ }
+ } // end of else block of if(l_ModuleListIterator->hsession == NULL)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnOpenSession
+/// Process request to open session
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnOpenSession(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 const l_ui32DefaultSessionID = 0;
+ UI_32 const l_ui32DefaultSessionType = 0;
+ OpenSessionAck tOpenAck = { };
+ PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "%s", pRequester);
+
+ ModuleLaunchListIter l_ModuleListIter;
+
+ REC_HIST_IF_SUCCESSFUL("PROTOCOL_OPEN_SESSION_REQ", m_SMCmdHist, m_SMHistIter, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ FrameworkunifiedGetMsgSrc(hApp), l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ l_eStatus = GetModuleIterator(pRequester, l_ModuleListIter);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ // Special handling for open session request from SMTestClient.
+ if ((0 == strcmp(TC_SysManager, pRequester))) {
+ open_session_with_sm_test_client(hApp, pRequester);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s not found in Group Launch Map",
+ pRequester);
+ }
+ } else {
+ /**********************************************************************/
+ if (0 != l_ModuleListIter->pid) {
+ UI_32 l_ClientPriority;
+ l_eStatus = l_ModuleListIter->GetPriority(l_ClientPriority);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("l_ModuleListIter->GetPriority( l_ClientPriority )"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else if (l_ClientPriority != l_ModuleListIter->configuration_priority) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Changing %s's priority from %d to %d",
+ pRequester, l_ClientPriority,
+ l_ModuleListIter->configuration_priority);
+ CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_ModuleListIter->SetPriority( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_ModuleListIter->configuration_priority)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+ /**********************************************************************/
+
+ // ToDo Jay 2013 Jan 09 REPLACE WITH CORRECT SERVICE / SESSION HANDLE
+ // LOGIC
+ // validate session handle
+ if (NULL == l_ModuleListIter->hsession) {
+ // LCOV_EXCL_BR_START 4: nsfw error
+ if (NULL == (l_ModuleListIter->hsession = FrameworkunifiedMcOpenSender(hApp, pRequester))) {
+ // LCOV_EXCL_BR_STOP 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedMcOpenSender(App %s, %s) returned NULL",
+ FrameworkunifiedGetAppName(hApp), pRequester);
+ return eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ /*
+ * Currently System Manager does not support multiple sessions from same client.
+ * When a client gets restarted after Crash or after missing HeartBeat, System Manager
+ * would receive OpenSession request from that client even when System Manager already
+ * has a open session with that client.
+ */
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Repeated Session Opening Request from %s", pRequester);
+ }
+ if (eFrameworkunifiedStatusOK != (l_eStatus = RegisterCallbacksForRequester(hApp, pRequester))) {
+ // Close the message queue handle
+ if (NULL != l_ModuleListIter->hsession) { // LCOV_EXCL_BR_LINE 6: Due to NULL checking
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedMcClose(l_ModuleListIter->hsession))) {
+ LOG_ERROR("FrameworkunifiedMcClose()"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ l_ModuleListIter->hsession = NULL;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+
+ // Copy session name to data structure
+ strncpy(tOpenAck.cSessionName, FrameworkunifiedGetAppName(hApp), sizeof(tOpenAck.cSessionName) - 1);
+ tOpenAck.eStatus = eFrameworkunifiedStatusOK;
+ tOpenAck.sessionId = l_ui32DefaultSessionID;
+ tOpenAck.sessionType = l_ui32DefaultSessionType;
+
+ // send OpenSession ACK
+ // LCOV_EXCL_BR_START 4: nsfw error
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_ModuleListIter->hsession,
+ SS_SM_PROTOCOL_OPEN_SESSION_ACK, sizeof(OpenSessionAck),
+ (PVOID) & tOpenAck))) { // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedSendMsg( %s, SS_SM_PROTOCOL_OPEN_SESSION_ACK)"
+ " errored: %d/'%s'", l_ModuleListIter->name.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+
+ if (NULL != l_ModuleListIter->hsession) {
+ // Close the message queue handle
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedMcClose(l_ModuleListIter->hsession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedMcClose(%s) errored: %d/'%s'",
+ l_ModuleListIter->name.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ }
+ l_ModuleListIter->hsession = NULL;
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ // Store PowerService session handle in class so it can be accessed faster
+ // to use opened session while replying to PowerService.
+ if ((0 == strcmp(SERVICE_POWER, pRequester))) {
+ m_hPowerServiceSession = l_ModuleListIter->hsession;
+ }
+
+ l_ModuleListIter->SetModuleState(MODULE_STATE_CONNECTED);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " SM State: %s, %s.is_start_required: %s",
+ GetStr(m_SMCurrentState).c_str(), l_ModuleListIter->name.c_str(),
+ GetStr(l_ModuleListIter->is_start_required).c_str());
+
+ if (l_ModuleListIter->is_start_required
+ && ((SS_SM_APPS_START_IN_PROGRESS == m_SMCurrentState)
+ || (SS_SM_APPS_START_COMPLETE == m_SMCurrentState))) {
+ T_SS_SM_START_DataStructType f_startupData(m_StartUpReason,
+ m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType], m_DataResetMode,
+ m_startUpConfirmationMsg.securityStatus,
+ m_startUpConfirmationMsg.wakeupType, m_DramBackupStatus,
+ m_ResetStatus, m_ResetCount);
+ const UI_32 l_iCmd = InProgressStateToSendMsg();
+ if (l_iCmd != SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX) {
+ CALL_AND_LOG_STATUS_IF_ERRORED(l_ModuleListIter->SendMsgAndUpdateState(l_iCmd, &f_startupData)); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ std::string l_Subscriber;
+ l_Subscriber = FrameworkunifiedGetMsgSrc(hApp);
+
+ // check if the heart beat subscriber is already in list
+ HBListIter l_HBIter = std::find(m_HBList.begin(), m_HBList.end(), l_Subscriber);
+ if (l_HBIter == m_HBList.end()) {
+ m_HBList.push_back(l_Subscriber);
+ }
+ if (m_SMCurrentState == SS_SM_APPS_START_COMPLETE) {
+ TSMRequestMessage l_ModuleDetails;
+ snprintf(l_ModuleDetails.pstModuleName, sizeof(l_ModuleDetails.pstModuleName),
+ "%s", l_Subscriber.c_str());
+ l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_APPEND_MODULE_ENTRY,
+ &l_ModuleDetails, sizeof(TSMRequestMessage));
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToHeartBeat()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// ConstructGetResultResponse
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::add_state_information_to_response(CHAR *f_MessageResponse) const {
+ const CHAR ReadyToLaunchAppDescription[] = "_READY_TO_LAUNCH:";
+ const CHAR StartInProgressDescription[] = "_START_IN_PROGRESS:";
+ const CHAR LaunchInProgressDescription[] = "_LAUNCH_IN_PROGRESS:";
+ const CHAR LaunchedReadyToStartDescription[] = "_READY_TO_START:";
+ const CHAR StopInProgressDescription[] = "_STOP_IN_PROGRESS:";
+ const CHAR StartCompleteDescription[] = "_START_COMPLETED:";
+ const CHAR WaitingForCriticalAppsToStopDescription[] = "_WAITING_FOR_CRITICAL_APPS_TO_STOP:";
+ const CHAR PreStartInProgressDescription[] = "_PRE_START_IN_PROGRESS:";
+ const CHAR PreStopInProgressDescription[] = "_PRE_STOP_IN_PROGRESS:";
+ const CHAR PreRunCompleteDescription[] = "_PRE_RUN_COMPLETE:";
+ const CHAR BackgroundStartInProgressDescription[] = "_BACKGROUND_START_IN_PROGRESS:";
+ const CHAR BackgroundStopInProgressDescription[] = "_BACKGROUND_STOP_IN_PROGRESS:";
+ const CHAR BackgroundRunCompleteDescription[] = "_BACKGROUND_RUN_COMPLETE:";
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CHAR l_Buffer[5];
+ UI_32 l_Index = 0;
+
+ std::map<SS_SMModuleState, std::string> StateMap; // State Map
+ StateMap[SS_SM_READY_TO_LAUNCH_APP] = ReadyToLaunchAppDescription;
+ StateMap[SS_SM_APPS_LAUNCH_IN_PROGRESS] = LaunchInProgressDescription;
+ StateMap[SS_SM_APPS_LAUNCHED_READY_TO_START] = LaunchedReadyToStartDescription;
+ StateMap[SS_SM_APPS_START_IN_PROGRESS] = StartInProgressDescription;
+ StateMap[SS_SM_APPS_START_COMPLETE] = StartCompleteDescription;
+ StateMap[SS_SM_APPS_STOPPING_AT__CWORD56__REQ] = StopInProgressDescription;
+ StateMap[SS_SM_APPS_STOPPING_AT_INTERNAL_REQ] = StopInProgressDescription;
+ StateMap[SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ] =
+ WaitingForCriticalAppsToStopDescription;
+ StateMap[SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ] =
+ WaitingForCriticalAppsToStopDescription;
+ StateMap[SS_SM_APPS_PRE_START_IN_PROGRESS] = PreStartInProgressDescription;
+ StateMap[SS_SM_APPS_PRE_STOP_IN_PROGRESS] = PreStopInProgressDescription;
+ StateMap[SS_SM_APPS_PRE_RUN_COMPLETE] = PreRunCompleteDescription;
+ StateMap[SS_SM_APPS_BACKGROUND_START_IN_PROGRESS] = BackgroundStartInProgressDescription;
+ StateMap[SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS] = BackgroundStopInProgressDescription;
+ StateMap[SS_SM_APPS_BACKGROUND_RUN_COMPLETE] = BackgroundRunCompleteDescription;
+
+ itoa(m_SMCurrentState, l_Buffer, 16);
+ while (l_Buffer[l_Index]) {
+ l_Buffer[l_Index] = toupper(l_Buffer[l_Index]);
+ l_Index++;
+ }
+
+ if (SS_SM_MAX_RESP_MSG_SIZE > (strlen(f_MessageResponse) + sizeof(l_Buffer)
+ + StateMap[m_SMCurrentState].length() + 1)) {
+ strncat(f_MessageResponse, l_Buffer, sizeof(l_Buffer));
+ strncat(f_MessageResponse, StateMap[m_SMCurrentState].c_str(),
+ StateMap[m_SMCurrentState].length());
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// ConstructGetResultResponse
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::construct_get_result_response(CHAR *f_MessageResponse) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ const EFrameworkunifiedStatus eStatus = add_state_information_to_response(f_MessageResponse);
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Response Constructed");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// REC_HIST_IF_SUCCESSFUL / SetCmdHist
+///
+///
+//////////////////////////////////////////////////////////////////////
+void CSystemManager::SetCmdHist(std::string cmd, cmdHist &hist, cmdHistIter &it, std::string sender) {
+ UI_64 l_time = 0XDEAD;
+ CTimeSpan* timerClass = new (std::nothrow) CTimeSpan(); // LCOV_EXCL_BR_LINE 5: Because new cannot fail
+ if (NULL == timerClass) { // LCOV_EXCL_BR_LINE 5: Because new cannot fail
+ // LCOV_EXCL_START 5: Because new cannot fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " 'new (std::nothrow) CTimeSpan()' returned NULL, "
+ "'it->m_time' being set to 0xDEAD");
+ // LCOV_EXCL_STOP
+ } else {
+ l_time = timerClass->GetTimeMilliseconds();
+ }
+
+ pthread_mutex_lock(&sm_hist_mutex);
+
+ it->m_time = l_time;
+ it->m_cmd = cmd;
+ it->m_sender = sender;
+ it++;
+
+ if (it != hist.end()) { // LCOV_EXCL_BR_LINE 5: std: because it is a member of a vector and it is difficult to create a failing condition
+ it = hist.begin();
+ }
+
+ pthread_mutex_unlock(&sm_hist_mutex);
+
+ delete timerClass; // LCOV_EXCL_BR_LINE 5: Because the delete cannot fail
+}
+
+///////////////////////////////////////////////////////////////////////
+/// OnCurrentPowerStateQuery
+///
+///
+//////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnCurrentSMStateQuery(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Received from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ SS_SMCurrentState l_CurrentState;
+
+ REC_HIST_IF_SUCCESSFUL("SS_SM_CRNT_STATE_QUERY", m_SMCmdHist, m_SMHistIter,
+ FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < SS_SMCurrentState > (hApp, l_CurrentState))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ } else {
+ construct_get_result_response(l_CurrentState.respMsgString);
+
+ ModuleLaunchListIter l_ModuleListIter;
+ PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
+ if (eFrameworkunifiedStatusOK != (l_eStatus = GetModuleIterator(l_moduleName, l_ModuleListIter))) { // LCOV_EXCL_BR_LINE 200: can not be other value // NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 200: can not be other value
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Module %s not found in Group Launch Map", l_moduleName);
+ // LCOV_EXCL_STOP
+ } else if (l_ModuleListIter->hsession != NULL) { // LCOV_EXCL_BR_LINE 200: can not be NULL // NOLINT (whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(l_ModuleListIter->hsession, // LCOV_EXCL_BR_LINE 4: nsfw error
+ SS_SM_CRNT_STATE_QUERY_RSPN, sizeof(SS_SMCurrentState),
+ (PVOID) & l_CurrentState))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendMsg(SS_SM_CRNT_STATE_QUERY_RSPN)"); // LCOV_EXCL_LINE 4: nsfw error
+ }
+ } else {
+ // LCOV_EXCL_START 200: can not be NUL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " NULL == hsession; %s not connected yet",
+ l_ModuleListIter->name.c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::GetVersionNumber(SS_VersionNumberType & f_VersionNumber) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ CSMVersion cVersion;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = cVersion.get_version(f_VersionNumber))) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ LOG_ERROR("cVersion.get_version()"); // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::GetVersionNumber( SS_VersionNumberType
+
+EFrameworkunifiedStatus CSystemManager::GetBuildInfo(std::string &f_BuildInfoStr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ CSMVersion cVersion;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = cVersion.get_build_info(f_BuildInfoStr))) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ LOG_ERROR("cVersion.get_build_info()"); // LCOV_EXCL_BR_LINE 6:For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::GetBuildInfo(std::string)
+
+bool CSystemManager::GetDramPowerStatusInfo(const HANDLE h_app) {
+ PsmDramStsT l_dram_sts = PSM_DRAM_STS_NORMAL;
+ bool ret = false;
+
+ // Checking dram power status.
+ if (PsmGetDramPowerSupplyAbnormalityCheckResultPower(h_app, &l_dram_sts))
+ return ret;
+
+ if (l_dram_sts == PSM_DRAM_STS_NORMAL)
+ ret = true;
+
+ return ret;
+}
+
+bool CSystemManager::GetDramStoreStatusInfo(const HANDLE h_app) {
+ PsmSysupDramT l_dram1 = PSM_SYSUP_DRAM_NORMAL;
+ PsmSysupDramT l_dram2 = PSM_SYSUP_DRAM_NORMAL;
+ PsmSysupDramT l_dram3 = PSM_SYSUP_DRAM_NORMAL;
+ PsmStartStatusT l_sts = PSM_START_STATUS_FACTRESET;
+
+ bool ret = false;
+
+ // Checking factory shipment status
+ if (PsmGetStartStatusPower(h_app, &l_sts))
+ return ret;
+
+ if (l_sts == PSM_START_STATUS_FACTRESET) {
+ ret = true;
+ goto finish;
+ }
+
+ // Checking dram power
+ if (!GetDramPowerStatusInfo(h_app))
+ goto finish;
+
+ // Checking dram status.
+ if (PsmGetDramBackupStatusPower(h_app, &l_dram1, &l_dram2, &l_dram3))
+ goto finish;
+
+ // l_dram2 and l_dram3 would be ignored.
+ if (l_dram1 == PSM_SYSUP_DRAM_NORMAL)
+ ret = true;
+
+ if (l_dram2 == PSM_SYSUP_DRAM_SFTERRSR)
+ ret = true;
+
+finish:
+ return ret;
+}
+
+bool CSystemManager::GetSyscomPowerStatusInfo(const HANDLE h_app) {
+ PsmComStsT l_syscom_sts = PSM_COM_STS_NORMAL;
+ bool ret = false;
+
+ if (PsmGetSyscomStatusPower(h_app, &l_syscom_sts))
+ return ret;
+
+ if (l_syscom_sts == PSM_COM_STS_NORMAL)
+ ret = true;
+
+ return ret;
+}
+
+EFrameworkunifiedStatus CSystemManager::OnSetStartupConfirmationDataRequest(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+ EFrameworkunifiedStatus l_eStatus;
+ Pwr_ServiceSetInterface tServiceSetIf;
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4:NSFW's error
+ // LCOV_EXCL_START 4:NSFW's error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ m_startUpConfirmationMsg = tServiceSetIf.data.startupConfirmationMsg;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s Startup Confirmation data:", FrameworkunifiedGetMsgSrc(hApp));
+ SYSTEMMANAGERLOG_StartupConfirmationMsg(m_startUpConfirmationMsg); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ DGCODE_RET_API l_ret = DGCODE_RET_ERROR;
+
+ l_ret = Diag_StartupAllStatusOfDTC();
+ if (l_ret == DGCODE_RET_ERROR) {
+ LOG_ERROR("Diag_StartupAllStatusOfDTC()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ if ((e_SS_SM_NEXT_WAKEUP_TYPE_COLD == m_NextWakeupType) && (epsstCOLDSTART != m_startUpConfirmationMsg.wakeupType)) { // LCOV_EXCL_BR_LINE 6: Because the above formula cannot be set to true // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "WakeupType Change to Cold by Svc Request");
+ m_startUpConfirmationMsg.wakeupType = epsstCOLDSTART;
+ // LCOV_EXCL_STOP
+ }
+
+ m_ResetStatus = ((m_isIlgReset == TRUE) ?
+ e_SS_SM_RESET_STATUS_NG :
+ ((m_isImmediateReset == TRUE) ?
+ e_SS_SM_RESET_STATUS_IMMEDIATE : e_SS_SM_RESET_STATUS_NONE));
+ if (e_SS_SM_RESET_STATUS_NG == m_ResetStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "ResetStatus NG illRst:%s lastErr:Not Support",
+ m_isIlgReset ? "TRUE" : "FALSE");
+ m_ResetCount++;
+ if (PowerHalSetResetInfo(AGL_RESET_COUNTER, m_ResetCount)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not back up m_ResetCount(%lu) to power_hal", m_ResetCount);
+ }
+ }
+
+ m_DramBackupStatus =
+ ((epsstWARMSTART != m_startUpConfirmationMsg.wakeupType)
+ || (e_SS_SM_DATA_RESET_MODE_FACTORY == m_DataResetMode)
+ || (GetDramStoreStatusInfo(hApp) == false)) ?
+ e_SS_SM_DRAM_BACKUP_NG : e_SS_SM_DRAM_BACKUP_OK;
+
+ if (e_SS_SM_DRAM_BACKUP_NG == m_DramBackupStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "DramBackup NG wakeupType:%s dataResetMode:%s",
+ (epsstWARMSTART == m_startUpConfirmationMsg.wakeupType) ?
+ "WARM" : "COLD",
+ (e_SS_SM_DATA_RESET_MODE_FACTORY == m_DataResetMode) ?
+ "FACTORY" : "NotFactory");
+ }
+
+ if (m_needReNotifyStartPrm) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be satisfied from the external API
+ // LCOV_EXCL_BR_START 6: Because both sides are not FALSE
+ if (e_SS_SM_DRAM_BACKUP_NG == m_DramBackupStatus) {
+ // LCOV_EXCL_BR_STOP
+ m_DramBackupStatus = e_SS_SM_DRAM_BACKUP_NG;
+ }
+ }
+
+ if (m_needReNotifyStartPrm) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be satisfied from the external API
+ if (e_SS_SM_RESET_STATUS_NG == m_ResetStatus) {
+ // do nothing, keep m_ResetStatus.
+ } else if (e_SS_SM_RESET_STATUS_IMMEDIATE == m_ResetStatus) {
+ // do nothing, keep m_ResetStatus.
+ } else {
+ m_ResetStatus = e_SS_SM_RESET_STATUS_NONE;
+ }
+
+ if (epsstWARMSTART != m_startUpConfirmationMsg.wakeupType) { // LCOV_EXCL_BR_LINE 6: Because the above condition cannot be satisfied // NOLINT(whitespace/line_length)
+ m_startUpConfirmationMsg.wakeupType = epsstCOLDSTART;
+ }
+ }
+
+ CALL_AND_LOG_STATUS(ClearDramBackupInfo(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "\n"
+ "start prm\n"
+ "dramBackupStatus = %s\n"
+ "wakeupType = %s\n"
+ "dataResetMode = %s\n"
+ "resetStatus = %s\n"
+ "resetCount = %d\n"
+ "progUpdateState = %d",
+ (m_DramBackupStatus == e_SS_SM_DRAM_BACKUP_OK) ? "OK" : "NG",
+ (m_startUpConfirmationMsg.wakeupType == epsstWARMSTART) ? "WARM" : "COLD",
+ (m_DataResetMode == e_SS_SM_DATA_RESET_MODE_FACTORY) ? "FACT" :
+ (m_DataResetMode == e_SS_SM_DATA_RESET_MODE_USER) ? "USER" :
+ (m_DataResetMode == e_SS_SM_DATA_RESET_MODE_PROGUPDATE) ? "PROG" : "NONE",
+ (m_ResetStatus == e_SS_SM_RESET_STATUS_IMMEDIATE) ? "IMM" :
+ (m_ResetStatus == e_SS_SM_RESET_STATUS_NONE) ? "NONE" : "NG", m_ResetCount,
+ m_ProgUpdateState);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPPublishNotification(hApp, NTFY_SSSystemMgrStartUpType, &m_startUpConfirmationMsg.wakeupType, sizeof(EPWR_SC_WAKEUP_TYPE)))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedNPPublishNotification(%s, %s) errored: %d/'%s'",
+ NTFY_SSSystemMgrStartUpType,
+ GetStr(m_startUpConfirmationMsg.wakeupType).c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " FrameworkunifiedNPPublishNotification(%s, %s) successful",
+ NTFY_SSSystemMgrStartUpType,
+ GetStr(m_startUpConfirmationMsg.wakeupType).c_str());
+
+ // LCOV_EXCL_BR_START 200: As there are no cases other than eFrameworkunifiedStatusOK
+ REC_HIST_IF_SUCCESSFUL("SM/StartUpType",
+ m_PubCmdHist, m_PubHistIter, "", l_eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+
+ EFrameworkunifiedStatus l_responseStatus = l_eStatus;
+
+ ModuleLaunchListIter l_ModuleListIter;
+ PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
+ if (eFrameworkunifiedStatusOK != (l_eStatus = GetModuleIterator(l_moduleName, l_ModuleListIter))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Module %s not found in Group Launch Map", l_moduleName);
+ } else if (l_ModuleListIter->hsession != NULL) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(l_ModuleListIter->hsession, // LCOV_EXCL_BR_LINE 4:NSFW's error
+ SS_SM_FWD_START_CONFIRMATION_MSG_RESP, sizeof(EFrameworkunifiedStatus),
+ (PVOID) & l_responseStatus))) {
+ // LCOV_EXCL_START 4:NSFW's error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendMsg(SS_SM_FWD_START_CONFIRMATION_MSG_RESP)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " NULL == hsession; %s not connected yet", l_ModuleListIter->name.c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnSetStartupConfirmationDataRequest( HANDLE hApp )
+
+EFrameworkunifiedStatus CSystemManager::GetTimeStamp(std::string& TimeStamp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ CHAR format[256] = { '\0' };
+ CHAR l_format[256] = { '\0' };
+ struct timeb timebuf;
+ uint32_t time;
+ uint8_t status;
+ struct tm theTime;
+ ftime(&timebuf);
+ Clock_getSystemTimeY2K38(&time, &status);
+ CLOCK_RETURN clock_ret = Clock_CnvSecToDateY2K38(&time, &theTime);
+
+ if (CLOCK_OK != clock_ret) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ sprintf(l_format, "GMT Time,%04d-%02d-%02d %02d:%02d:%02d.%hu\n", // NOLINT
+ theTime.tm_year + 1900, theTime.tm_mon + 1, theTime.tm_mday,
+ theTime.tm_hour, theTime.tm_min, theTime.tm_sec, timebuf.millitm);
+
+ struct timespec timeSpec;
+
+ if (0 != clock_gettime(CLOCK_MONOTONIC, &timeSpec)) {
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ time_t timeInSecs = timeSpec.tv_sec;
+ sprintf(format, "Elaps Time,%ld:%02ld:%02ld\n", (timeInSecs / 3600), // NOLINT
+ ((timeInSecs % 3600) / 60), (timeInSecs % 60));
+ }
+
+ TimeStamp.clear();
+ TimeStamp.assign(format);
+ TimeStamp.append(l_format);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+VOID CSystemManager::SYSTEMMANAGERLOG_StartupConfirmationMsg(EPWR_SC_MSG_STRUCT & f_scMsg) {
+ std::stringstream l_enumStr;
+ l_enumStr << endl;
+ l_enumStr << " HostProcSoftVer:" << hex << std::setw(16) << std::setfill('0')
+ << m_VersionNumberStruct.m_VersionNumber << endl;
+ l_enumStr << " _CWORD56_ Boot Mode:" << GetStr(f_scMsg._CWORD56_BootMode) << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_enumStr << " wakeupType :" << GetStr(f_scMsg.wakeupType); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s", l_enumStr.str().c_str());
+} // End of VOID CSystemManager::SYSTEMMANAGERLOG_StartupConfirmationMsg( EPWR_SC_MSG_STRUCT & f_scMsg )
+
+VOID CSystemManager::LogESystemmanagerStatusEnums() {
+ #define INITIAL_INDEX eFrameworkunifiedStatusEmptyMediaList
+ #define FINAL_INDEX eFrameworkunifiedStatusErrNoEINTR
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::stringstream l_enumStr;
+ for (int i = INITIAL_INDEX; i <= FINAL_INDEX; i++) {
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_enumStr << "\n" << "0x" << std::setfill('0') << std::setw(8) << hex << i
+ << "/" << std::setfill(' ') << std::setw(2) << dec << i << ": "
+ << GetStr(static_cast<EFrameworkunifiedStatus>(i));
+ // LCOV_EXCL_BR_STOP
+ }
+
+ std::string l_logMsg = l_enumStr.str();
+ SystemmanagerLogString(ZONE_INFO, __FUNCTION__, l_logMsg); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+#undef INITIAL_INDEX
+#undef FINAL_INDEX
+} // End of VOID CSystemManager::LogESystemmanagerStatusEnums()
+
+VOID CSystemManager::LogProtocolIDs() {
+#define INITIAL_INDEX SS_SYSTEM_MANAGER_PROTOCOL_BEGINNING_INDEX
+#define FINAL_INDEX SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::stringstream l_enumStr;
+ for (int i = INITIAL_INDEX; i <= FINAL_INDEX; i++) {
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_enumStr << "\n" << "0x" << std::setfill('0') << std::setw(8) << hex << i
+ << "/" << std::setfill(' ') << std::setw(2) << dec << i << ": "
+ << GetStr(static_cast<SS_SystemManagerProtocol>(i));
+ // LCOV_EXCL_BR_STOP
+ }
+
+ std::string l_logMsg = l_enumStr.str();
+ SystemmanagerLogString(ZONE_INFO, __FUNCTION__, l_logMsg); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+#undef INITIAL_INDEX
+#undef FINAL_INDEX
+} // End of VOID CSystemManager::LogProtocolIDs()
+
+VOID CSystemManager::SystemmanagerLogString(TFrameworkunifiedZone f_zone, PCSTR f_func, std::string &f_text) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ UI_32 l_offset = 0;
+ UI_32 l_msgLenMax = MAX_QUEUE_MSG_SIZE - 512; // Leave space for the appending of
+ // the NSLog date/time/service/line string.
+
+ if (f_text.at(f_text.length() - 1) == '\n') { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_text.erase(f_text.length() - 1); // LCOV_EXCL_LINE 6: For setting the initialization conditions at SystemManager startup
+ }
+
+ while (l_offset < f_text.size()) {
+ UI_32 l_charsRem = static_cast<UI_32>(f_text.size() - l_offset);
+ UI_32 l_msgLen = (l_charsRem > l_msgLenMax) ? // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ l_msgLenMax : l_charsRem; // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
+ std::string l_msgStr = f_text.substr(l_offset, l_msgLen);
+ size_t l_newLinePos = l_msgStr.find_last_of("\n", l_msgLen);
+ if ((l_newLinePos != std::string::npos) && (l_charsRem > l_msgLenMax)) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_msgStr = f_text.substr(l_offset, l_newLinePos);
+ l_offset += static_cast<UI_32>(l_newLinePos);
+ // LCOV_EXCL_STOP
+ } else {
+ l_offset += l_msgLen;
+ }
+
+ FRAMEWORKUNIFIEDLOG(f_zone, f_func, l_msgStr.c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+} // LCOV_EXCL_BR_LINE 10: Final line
+
+// End of /SS_SystemManager/src/ss_system_manager.cpp
diff --git a/systemservice/system_manager/server/src/ss_system_manager_callbacks.cpp b/systemservice/system_manager/server/src/ss_system_manager_callbacks.cpp
new file mode 100755
index 0000000..2e597ce
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_system_manager_callbacks.cpp
@@ -0,0 +1,3411 @@
+/*
+ * @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 business logic.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_if_local.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <sys/wait.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <system_service/ss_system_manager_notifications_local.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_power_service_if.h>
+#include <processlauncher/ProcessLauncher.h>
+#include <processlauncher/ss_sm_process_launcher_protocol.h>
+#include <processlauncher/ss_sm_process_launcher.h>
+#include <heartbeat/ss_hb_thread.h>
+
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service_protocol.h>
+
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_backup.h>
+
+#include <stub/ss_diag.h>
+
+#include <system_service/ss_error_message.h>
+#include <system_service/ss_test_clients.h>
+#include <system_service/ss_templates.h>
+#include <native_service/ns_plogger_if.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <iomanip>
+#include <vector>
+#include <algorithm>
+#include <string>
+
+#include "ss_system_manager_callbacks.h"
+#include "ss_system_manager.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_sm_config.h"
+
+using namespace std; // NOLINT
+
+extern SS_String GetStr(SS_SMModuleState f_enum);
+
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus SysMgrCallback(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
+ if (pObj) { // LCOV_EXCL_BR_LINE 5 : new error
+ l_eStatus = (pObj->*M)(hApp);
+ }
+ return l_eStatus;
+}
+
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE, UI_32)>
+EFrameworkunifiedStatus SysMgrCbType2(HANDLE hApp, UI_32 f_UI_32) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
+ if (pObj) { // LCOV_EXCL_BR_LINE 5 : new error
+ l_eStatus = (pObj->*M)(hApp, f_UI_32);
+ }
+ return l_eStatus;
+}
+
+template<typename C, BOOL (C::*M)(UI_32)>
+BOOL SysMgrCbType3(UI_32 f_UI_32) {
+ BOOL l_bValue = FALSE;
+ C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
+ if (pObj) { // LCOV_EXCL_BR_LINE 5 : new error
+ l_bValue = (pObj->*M)(f_UI_32);
+ }
+ return l_bValue;
+}
+
+enum {
+ POWERON = TRUE,
+ POWEROFF = FALSE
+};
+
+VOID CSystemManager::LogGroupModulesState(UI_32 f_groupId, std::string pStr) {
+ if (IS_ZONE_SET(ZONE_INFO)) { // LCOV_EXCL_BR_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(f_groupId);
+ if (l_GroupIterator == m_MapProclaunchGrps.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Group %d not found; 'm_MapProclaunchGrps' is empty",
+ f_groupId);
+ } else {
+ std::string sIsOKFlag;
+ TEXT(__FUNCTION__, " Group %d/%s, %ld modules: %s, %s", f_groupId,
+ l_GroupIterator->second.name.c_str(),
+ l_GroupIterator->second.modules.size(), pStr.c_str(),
+ GetStr(m_SMCurrentState).c_str());
+
+ ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
+ for (int i = 1;
+ l_ModuleListIterator != l_GroupIterator->second.modules.end();
+ l_ModuleListIterator++, i++) {
+ sIsOKFlag = GetModuleCondition(l_ModuleListIterator) ? " " : // 'blank' means OK
+ "X"; // 'X' means state mismatch
+
+ TEXT(__FUNCTION__,
+ " %2d: %-24s Start Req'd: %-5s %s %-24s %3dms, %3dms, %d",
+ i, l_ModuleListIterator->name.c_str(),
+ l_ModuleListIterator->is_start_required ?
+ "TRUE" : "FALSE", sIsOKFlag.c_str(),
+ l_ModuleListIterator->ModuleStateStr().c_str(),
+ static_cast<SI_16>(l_ModuleListIterator->m_startReason.GetDelta()),
+ static_cast<SI_16>(l_ModuleListIterator->m_stopReason.GetDelta()),
+ l_ModuleListIterator->pid);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ // LCOV_EXCL_STOP
+ }
+} // End of VOID CSystemManager::LogGroupModulesState( UI_32 f_groupId, std::string pStr)
+
+VOID CSystemManager::LogAllGroupModulesState(std::string pStr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ std::string l_sIsOKFlag;
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
+
+ std::stringstream l_comStream;
+
+ l_comStream << pStr << "," << GetStr(m_SMCurrentState);
+
+ std::string l_comStr = l_comStream.str();
+ SystemmanagerLogString(ZONE_STATE, __FUNCTION__, l_comStr);
+
+ while (l_GroupIterator != m_MapProclaunchGrps.end()) {
+ std::stringstream l_tblStream;
+ l_tblStream << "G" << l_GroupIterator->second.id << "/" << l_GroupIterator->second.name;
+
+ ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
+
+ for (int i = 1;
+ l_ModuleListIterator != l_GroupIterator->second.modules.end();
+ l_ModuleListIterator++, i++) {
+ // Since NPPService exceptionally transitions to STARTED when StartReq'd = N, it is not checked
+ l_sIsOKFlag =
+ GetModuleCondition(l_ModuleListIterator)
+ | (FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIterator->name) ?
+ " " : // 'blank' means OK
+ "X"; // 'X' means state mismatch
+
+ std::string l_isStartReqd = l_ModuleListIterator->is_start_required ? "T" : "F";
+
+ l_tblStream << endl << " " << std::setw(2) << std::right << i << ":"
+ << l_ModuleListIterator->pid << " "
+ << l_ModuleListIterator->name << " " << "StartReq:"
+ << l_isStartReqd << " " << l_sIsOKFlag
+ << l_ModuleListIterator->ModuleStateStr();
+
+ if (l_ModuleListIterator->is_start_required && (FRAMEWORKUNIFIED_NS_NPSERVICE != l_ModuleListIterator->name)) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
+ l_tblStream << " "
+ << static_cast<SI_32>(l_ModuleListIterator->m_startReason.GetDelta())
+ << "ms "
+ << static_cast<SI_32>(l_ModuleListIterator->m_stopReason.GetDelta())
+ << "ms";
+ }
+ }
+
+ l_GroupIterator++;
+
+ // Outputs each GROUP so that buffers do not overflow.
+ std::string l_logMsgStr = l_tblStream.str();
+ SystemmanagerLogString(ZONE_STATE, __FUNCTION__, l_logMsgStr);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+} // End of VOID CSystemManager::LogAllGroupModulesState(std::string pStr)
+
+BOOL CSystemManager::GetModuleCondition(ModuleLaunchListIter & f_ModuleIter) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bIsModuleStateGood = TRUE;
+
+ switch (m_SMCurrentState) { // LCOV_EXCL_BR_LINE 6: As no values are passed into the default case
+ case SS_SM_READY_TO_LAUNCH_APP:
+ l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_INVALID);
+ break;
+
+ case SS_SM_APPS_LAUNCH_IN_PROGRESS:
+ l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHING)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED);
+ break;
+
+ case SS_SM_APPS_LAUNCHED_READY_TO_START:
+ l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED);
+ break;
+
+ case SS_SM_APPS_START_IN_PROGRESS:
+ l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
+ || (f_ModuleIter->is_start_required
+ && (f_ModuleIter->IsModuleState(MODULE_STATE_START_SENT)
+ || f_ModuleIter->IsModuleState(
+ MODULE_STATE_STARTED)))
+ || (!f_ModuleIter->is_start_required
+ && (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED)
+ || f_ModuleIter->IsModuleState(
+ MODULE_STATE_CONNECTED)));
+ break;
+
+ case SS_SM_APPS_START_COMPLETE:
+ l_bIsModuleStateGood =
+ ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
+ || ((f_ModuleIter->is_start_required == TRUE)
+ && (f_ModuleIter->IsModuleState(MODULE_STATE_STARTED) == TRUE))
+ || ((f_ModuleIter->is_start_required == FALSE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
+ break;
+
+ case SS_SM_APPS_PRE_START_IN_PROGRESS:
+ l_bIsModuleStateGood =
+ ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
+ || ((f_ModuleIter->is_start_required == TRUE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_START_PRE_SENT) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_PRE) == TRUE)))
+ || ((f_ModuleIter->is_start_required == FALSE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
+ break;
+
+ case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
+ l_bIsModuleStateGood =
+ ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
+ || ((f_ModuleIter->is_start_required == TRUE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_STOP_PRE_SENT) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_PRE) == TRUE)))
+ || ((f_ModuleIter->is_start_required == FALSE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
+ break;
+
+ case SS_SM_APPS_PRE_RUN_COMPLETE:
+ l_bIsModuleStateGood =
+ ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
+ || ((f_ModuleIter->is_start_required == TRUE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_PRE) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_PRE) == TRUE)))
+ || ((f_ModuleIter->is_start_required == FALSE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
+ break;
+
+ case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
+ l_bIsModuleStateGood =
+ ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
+ || ((f_ModuleIter->is_start_required == TRUE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_START_BACKGROUND_SENT) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_BACKGROUND) == TRUE)))
+ || ((f_ModuleIter->is_start_required == FALSE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
+ break;
+
+ case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
+ l_bIsModuleStateGood =
+ ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
+ || ((f_ModuleIter->is_start_required == TRUE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_STOP_BACKGROUND_SENT) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_BACKGROUND) == TRUE)))
+ || ((f_ModuleIter->is_start_required == FALSE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
+ break;
+ case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
+ l_bIsModuleStateGood =
+ ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
+ || ((f_ModuleIter->is_start_required == TRUE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_BACKGROUND) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_BACKGROUND) == TRUE)))
+ || ((f_ModuleIter->is_start_required == FALSE)
+ && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
+ || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
+ break;
+
+ case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
+ case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
+ l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
+ || (f_ModuleIter->is_start_required
+ && (f_ModuleIter->IsModuleState(MODULE_STATE_STOP_SENT)
+ || f_ModuleIter->IsModuleState(
+ MODULE_STATE_STOPPED)))
+ || (!f_ModuleIter->is_start_required
+ && (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED)
+ || f_ModuleIter->IsModuleState(
+ MODULE_STATE_CONNECTED)));
+ break;
+
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
+ l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
+ || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
+ || (f_ModuleIter->is_start_required
+ && f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED))
+ || (!f_ModuleIter->is_start_required
+ && (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED)
+ || f_ModuleIter->IsModuleState(
+ MODULE_STATE_CONNECTED)));
+ break;
+
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bIsModuleStateGood;
+} // End of BOOL CSystemManager::GetModuleCondition( ModuleLaunchListIter & f_ModuleIter )
+
+/*****************************************************************************
+ @ingroup: CSystemManager
+ @brief: Post Termination handler
+ @note: .
+ @param void
+ @return void
+*****************************************************************************/
+EFrameworkunifiedStatus CSystemManager::SendRequestToHeartBeat(HANDLE hApp,
+ EHBProtocolMessages tRequest, VOID *tReqMessageData,
+ UI_32 u32SizeofMessage) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL bValid = FALSE;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ switch (tRequest) {
+ case SS_HEARTBEAT_START:
+ bValid = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_START");
+ break;
+
+ case SS_HEARTBEAT_STOP:
+ bValid = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_STOP");
+ tReqMessageData = NULL;
+ break;
+
+ case SS_HEARTBEAT_DELETE_MODULE_ENTRY:
+ bValid = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_DELETE_MODULE_ENTRY");
+ break;
+
+ case SS_HEARTBEAT_APPEND_MODULE_ENTRY:
+ bValid = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_APPEND_MODULE_ENTRY");
+ break;
+
+ default:
+ bValid = FALSE;
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error : Ignored Invalid message id 0x%X", tRequest);
+ break;
+ }
+
+ if (TRUE == bValid) { // LCOV_EXCL_BR_LINE 200:tRequest cannot be default, so bValid cannot be false
+ if (INVALID_HANDLE != m_hHeartbeatThread.m_ThreadHdl) { // LCOV_EXCL_BR_LINE 200:m_ThreadHdl cannot be null
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hHeartbeatThread.m_ThreadHdl, tRequest, u32SizeofMessage, tReqMessageData))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: m_ThreadHdl cannot be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error : Invalid Heartbeat Thread Handle, cannot send message");
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnModuleConnectWaitTimeout
+/// SM maintains timer (40 sec) to check if all modules opened session with him whoever requires Start.
+/// This timer is common to all modules. After timeout it checks the status of every module in group map.
+/// If a module requires start and does not connect, SM will initiate error event logging followed by Soft Reset
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnModuleConnectWaitTimeout(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ static SI_32 l_NumTimesChecked = 0;
+ {
+ char l_cFormat[] = " Received from (Timer expiration %d)";
+ char l_cBuf[sizeof(l_cFormat) + 1];
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_NumTimesChecked + 1);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, l_cBuf);
+ }
+
+ std::string l_ProcName;
+
+ SetCmdHist("SM_TIMER_MODULE_CONNECT_WAIT_TIMER", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ BOOL l_bModuleConnMissed = false;
+
+ GroupLaunchMap::reverse_iterator l_grp_riter = m_MapProclaunchGrps.rbegin();
+
+ ModuleLaunchList::reverse_iterator l_mod_riter;
+
+ if (l_grp_riter == m_MapProclaunchGrps.rend()) { // LCOV_EXCL_BR_LINE 200: group cannot be empty
+ // LCOV_EXCL_START 200: group cannot be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Group Map is Empty"); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ // LCOV_EXCL_STOP
+ } else {
+ // scan the group map in reverse order
+ for (; l_grp_riter != m_MapProclaunchGrps.rend(); l_grp_riter++) {
+ l_mod_riter = l_grp_riter->second.modules.rbegin();
+ for (; l_mod_riter != l_grp_riter->second.modules.rend();
+ l_mod_riter++) {
+ SMModuleState l_ModuleState = l_mod_riter->GetModuleState();
+ // if the module is still in MODULE_STATE_LAUNCHED state at
+ // this point though it requires start something is wrong with
+ // the module. SM initiates error event logging followed by
+ // soft rest
+ if (l_mod_riter->is_start_required
+ && ((l_ModuleState == MODULE_STATE_INVALID)
+ || (l_ModuleState == MODULE_STATE_SKIPPED)
+ || (l_ModuleState == MODULE_STATE_LAUNCHING)
+ || (l_ModuleState == MODULE_STATE_LAUNCHED)
+ || (l_ModuleState == MODULE_STATE_LAUNCH_FAILED))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Module %s/%s is not connected",
+ l_mod_riter->name.c_str(),
+ l_mod_riter->ModuleStateStr().c_str());
+ l_bModuleConnMissed = true;
+ l_ProcName.assign(l_mod_riter->name);
+
+ if (l_ModuleState == MODULE_STATE_LAUNCHED) {
+ CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_mod_riter->SetPriority( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ m_SystemManagerPriority - 1)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+ }
+ }
+
+ PreLaunchModuleListIter l_itr;
+ for (l_itr = m_PreLaunchModuleList.begin();
+ m_PreLaunchModuleList.end() != l_itr; l_itr++) {
+ if ((-1 == l_itr->pid) && (l_itr->critical)) { // LCOV_EXCL_BR_LINE 200: all prelaunch mode is not critical // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 200: all prelaunch mode is not critical
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Module %s is not launched", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_itr->name.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_bModuleConnMissed = true;
+ l_ProcName.assign(l_itr->name);
+ }
+ // LCOV_EXCL_STOP
+ }
+
+ l_NumTimesChecked++;
+ if (true == l_bModuleConnMissed) {
+ if (l_NumTimesChecked < m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck) {
+ char l_cFormat[] =
+ " l_NumTimesChecked %d < ModuleConnectionNumTimesToCheck %d, "
+ "will re-check in %d seconds. ";
+ char l_cBuf[sizeof(l_cFormat) + 1 + 1 + 1];
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_NumTimesChecked,
+ m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck,
+ m_SMConfig.MCConfig.ModuleConnectionTimeOutSec);
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, l_cBuf);
+
+ } else {
+ l_eStatus = eFrameworkunifiedStatusBadConnection;
+ char l_cFormat[] =
+ " Module connection timeout for %s and "
+ "l_NumTimesChecked %d == ModuleConnectionNumTimesToCheck %d. "
+ " Stopping ModuleConnectTimeOut timer and resetting _CWORD102_.";
+ char l_cBuf[sizeof(l_cFormat) + MAX_NAME_SIZE_APP + 1 + 1];
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_ProcName.c_str(),
+ l_NumTimesChecked,
+ m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck);
+ LOG_ERROR(l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER]); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_GENERIC_ERR; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ // initiate error event logging
+ l_eStatus = ErrorEventEnqueue(hApp, eErrorEventTypeModConnFailed,
+ l_ProcName, eErrorEventResetTypeHard, l_loggingInfo);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: ModConnFailed %s",
+ l_ProcName.c_str());
+ fprintf(stderr, "SS_SysManager/%s/Error: ModConnFailed %s\n", // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ __FUNCTION__, l_ProcName.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeModConnFailed)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+ } else {
+ char l_cFormat[] =
+ " l_NumTimesChecked = %d, ModuleConnectionNumTimesToCheck = %d. "
+ "All modules connected. Stopping ModuleConnectTimeOut timer.";
+ char l_cBuf[sizeof(l_cFormat) + 1 + 1];
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_NumTimesChecked,
+ m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, l_cBuf);
+
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER]); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnModuleConnectWaitTimeout( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnClientStartMonitorTimerExpiry
+///
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnClientStartMonitorTimerExpiry(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from group %d"
+ //, m_ActiveGroupId);
+ , m_SystemStarter.get_id());
+
+ char cBuf[100];
+ SetCmdHist("SM_TIMER_CLIENT_START_MONITOR", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ // sprintf( cBuf, "ProcessGroupAsStarted(%d)", m_ActiveGroupId);
+ sprintf(cBuf, "ProcessGroupAsStarted(%d)", m_SystemStarter.get_id()); // NOLINT
+ l_eStatus = ProcessGroupAsStarted(hApp, m_SystemStarter.get_id());
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup send_power_request_complete_response
+/// send power request completion response to power
+///
+/// \param [in]
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::send_power_request_complete_response(HANDLE hApp, std::string pStr) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // send Wake-up complete response to Power
+ l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession,
+ SS_SM_WAKEUP_MODULES_CMPL_RSPN, sizeof(wakeInfo), (PVOID) & m_Wake);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "FrameworkunifiedSendMsg(SS_SM_WAKEUP_MODULES_CMPL_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ LogAllGroupModulesState(pStr);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::send_power_request_complete_response( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnNPPStatusCheckMonitorTimerExpiry
+///
+/// \brief Called when NPP fails to provide a ready status in the specified.
+/// amount of time. This function will periodically request a new status
+/// ACK from NPP service until one is received. See OnNPPReadyStatusCallback().
+///
+/// Note: NPP usually pushes a ready event to SM and the reversion to
+/// polling the NPP ready ACK is for additional robustness. Failure
+/// to receive an NPP ready ACK will prevent system startup.
+///
+/// \param [in] hApp - Handle to framework application.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnNPPStatusCheckMonitorTimerExpiry(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ SetCmdHist("SM_TIMER_NPP_STATUS_CHECK_MONITOR", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_bIsNPP_ServicesStarted is '%s'",
+ GetStr(m_bIsNPP_ServicesStarted).c_str());
+
+ if (FALSE == m_bIsNPP_ServicesStarted) {
+ l_eStatus = FrameworkunifiedNPGetReadyStatusOfNPP(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "FrameworkunifiedNPGetReadyStatusOfNPP()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnNPPReadyStatusCallback
+///
+/// \brief Called when NPP returns a status ACK indicating that the service is
+/// operational and ready to respond to subsequent requests.
+///
+/// \param [in] hApp - Handle to framework application.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnNPPReadyStatusCallback(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ SetCmdHist("NPS_GET_READYSTATUS_ACK", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ l_eStatus = OnNPPReadyEventCallback(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnNPPReadyEventCallback()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CSystemManager::OnNPPReadyEventCallback(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", l_moduleName);
+
+ SetCmdHist("NPS_NPP_READY_EVENT", m_SMCmdHist, m_SMHistIter, l_moduleName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (TRUE == m_bIsNPP_ServicesStarted) {
+ l_eStatus = eFrameworkunifiedStatusMsgNotProcessed;
+ LOG_ERROR("TRUE == m_bIsNPP_ServicesStarted"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ ModuleLaunchListIter l_ModuleListIter;
+ m_bIsNPP_ServicesStarted = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_bIsNPP_ServicesStarted set 'TRUE'");
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_NPP_STATUS_CHECK_MONITOR]);
+
+ UI_32 l_cbCmdIdArrayNPPService[] = { NPS_NPP_READY_EVENT, NPS_GET_READYSTATUS_ACK };
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp, FRAMEWORKUNIFIED_NS_NPSERVICE, l_cbCmdIdArrayNPPService, static_cast<UI_32>(_countof(l_cbCmdIdArrayNPPService))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedDetachCallbacksFromDispatcher()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = register_all_notification_callbacks(hApp))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("register_all_notification_callbacks()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = GetModuleIterator(l_moduleName, l_ModuleListIter))) { // LCOV_EXCL_BR_LINE 200:NPP always in launch map //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 200 : NPP service always in launch map
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " Error: Module %s not found in Group Launch Map", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_moduleName); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ l_ModuleListIter->SetModuleState(MODULE_STATE_STARTED);
+
+ if (m_oSystemLauncher.get_id() == 1) {
+ m_oSystemLauncher.advance_id();
+ }
+
+ l_eStatus = OnLaunchGroup(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnLaunchGroup(hApp)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200: OnLaunchGroup() return ok
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " successful");
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnNPPReadyEventCallback( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnBackupMgrAvailCallback
+/// BackupManager Availability Notification Callback
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnBackupMgrAvailCallback(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (sizeof(ServiceAvailability) != FrameworkunifiedGetMsgLength(hApp)) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else if (strcmp(FrameworkunifiedGetLastNotification(hApp), NTFY_BackupMgr_Availability) != 0) { // LCOV_EXCL_BR_LINE 200:cannot be false //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 200: cannot be false
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ m_bIsBackupAvail = FrameworkunifiedIsServiceAvailable(hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "BackupAvail:%s", m_bIsBackupAvail ? "T" : "F");
+
+ l_eStatus = OnLaunchGroup(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnLaunchGroup(hApp)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnBackupMgrAvailCallback(HANDLE hApp)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnPowerRequestCallback
+/// PowerRequest callback handler
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnPowerRequestCallback(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ Pwr_ServiceSetInterface tServiceIf;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ SetCmdHist("SS_SM_POWER_REQUEST_MSG", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ // OnSystemManagerDebugDump(hApp);
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, tServiceIf))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ // NOTE: interface_unified always set userMode as 0. so don't use m_lastUserMode.
+ m_lastUserMode = tServiceIf.data.powerRequestMsg.userMode;
+ //
+ // 2012 December 04 Temporary hack ( I hope ) to set m_Wake to nominal
+ // values. At present, the 'Power Request Message Response' is sent
+ // back to Power Services via the 'send_power_request_complete_response()'
+ // function, which uses m_Wake.
+ m_Wake.powerupType =
+ m_SSBool_to_PowerTypeEnumMap[m_SSUserMode_to_SSBoolEnumMap[m_lastUserMode]];
+
+ m_Wake.up.factor = tServiceIf.data.powerRequestMsg.startupReason;
+
+ if (epswfINVALID != m_Wake.up.factor) {
+ m_StartUpReason = m_Wake.up.factor;
+ }
+
+ m_userModeChangeReason = tServiceIf.data.powerRequestMsg.userModeChangeReason;
+ m_Wake.up.userModeChangeReason = m_userModeChangeReason;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "UserMode:%s, SM State:%s",
+ GetStr(m_lastUserMode).c_str(),
+ GetStr(m_SMCurrentState).c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "UserMode:%s, SM State:%s",
+ GetStr(m_lastUserMode).c_str(),
+ GetStr(m_SMCurrentState).c_str());
+ CALL_AND_LOG_STATUS(PublishPowerOnOffNotification(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ switch (m_SMCurrentState) { // LCOV_EXCL_BR_LINE 6: As not all cases can be passed through
+ case SS_SM_READY_TO_LAUNCH_APP:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Received a PowerRequest command while still in "
+ "the '%s' state !!!",
+ GetStr(m_SMCurrentState).c_str());
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ break;
+
+ case SS_SM_APPS_LAUNCH_IN_PROGRESS:
+ // When Start is received while processes are launching, we
+ // need to send the Start request later, once the 'Open
+ // Session Request' is received from the application.
+ //*****
+ // Deliberate commenting-out of case-break to allow this case to
+ // use following case's logic.
+ // break;
+ //*****
+
+ case SS_SM_APPS_LAUNCHED_READY_TO_START:
+ case SS_SM_APPS_START_COMPLETE:
+ case SS_SM_APPS_PRE_RUN_COMPLETE:
+ case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
+ case SS_SM_APPS_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "Startup Reason is '%s'", GetStr(m_StartUpReason).c_str());
+ if ((m_userModeChangeReason == epsumcrPARKING_B)
+ || ((m_userModeChangeReason == epsumcrPRE_BA) && (m_SMCurrentState == SS_SM_APPS_PRE_RUN_COMPLETE))
+ || ((m_userModeChangeReason == epsumcrNORMAL) && (m_SMCurrentState == SS_SM_APPS_START_COMPLETE))
+ || ((m_userModeChangeReason == epsumcrBACKGROUND_BA)
+ && (m_SMCurrentState == SS_SM_APPS_BACKGROUND_RUN_COMPLETE))) {
+ // send the Power Request complete response to PowerService
+ // LCOV_EXCL_BR_START 15: Excluded due to inlined functions
+ CALL_AND_LOG_STATUS_IF_ERRORED(send_power_request_complete_response(hApp, "Power Request"));
+ // LCOV_EXCL_BR_STOP 15: Excluded due to inlined functions
+ } else {
+ //
+ // Publish the UserMode 'Off' notification now for those
+ // applications that need immediate notification ( HMI )
+ if (m_lastUserMode == epsumOFF) {
+ CALL_AND_LOG_STATUS(PublishUserModeNotification(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ CALL_AND_LOG_STATUS(BeginStartup(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ break;
+
+ case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
+ // Abort the Stop.
+ // Reset System Manager to handle (re)starting as if this is a
+ // nominal start.
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR]);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Aborted %s, resetting to %s,"
+ " restarting Application groups at group %d",
+ GetStr(m_SMCurrentState).c_str(),
+ GetStr(SS_SM_APPS_START_IN_PROGRESS).c_str()
+ , m_SystemStarter.get_id());
+
+ CALL_AND_LOG_STATUS(BeginStartup(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ break;
+
+ case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ: // LCOV_EXCL_START 8: As no value is set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: System Manager state is %d/'%s', ignoring "
+ "PowerRequest command", m_SMCurrentState,
+ GetStr(m_SMCurrentState).c_str());
+ break;
+ } // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnPowerRequestCallback( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+/// Begin the Startup process
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::BeginStartup(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if ((m_userModeChangeReason != epsumcrPARKING_B) &&
+ (m_userModeChangeReason != epsumcrPRE_BA) &&
+ (m_userModeChangeReason != epsumcrNORMAL) &&
+ (m_userModeChangeReason != epsumcrBACKGROUND_BA)) {
+ // Not a power state transition request.
+ return eFrameworkunifiedStatusOK;
+ }
+
+ switch (m_userModeChangeReason) { // LCOV_EXCL_BR_LINE 6: Excluded because it has been guarded to prevent out-of-range values from entering immediately before.
+ case epsumcrPRE_BA:
+ // LCOV_EXCL_BR_START 6: This function is an internal function, and it is guarded so that the value outside the range is not entered by the caller, so it is excluded.
+ if ((m_SMCurrentState == SS_SM_APPS_START_COMPLETE) || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_RUN_COMPLETE)) {
+ // LCOV_EXCL_BR_STOP 6: This function is an internal function, and it is guarded so that the value outside the range is not entered by the caller, so it is excluded.
+ m_SystemStarter.to_end();
+ SMSetState(hApp, SS_SM_APPS_PRE_STOP_IN_PROGRESS);
+ } else {
+ m_SystemStarter.to_begin();
+ SMSetState(hApp, SS_SM_APPS_PRE_START_IN_PROGRESS);
+ }
+ break;
+ case epsumcrNORMAL:
+ m_SystemStarter.to_begin();
+ SMSetState(hApp, SS_SM_APPS_START_IN_PROGRESS);
+ break;
+ case epsumcrBACKGROUND_BA:
+ if (m_SMCurrentState == SS_SM_APPS_START_COMPLETE) {
+ m_SystemStarter.to_end();
+ SMSetState(hApp, SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS);
+ } else {
+ m_SystemStarter.to_begin();
+ SMSetState(hApp, SS_SM_APPS_BACKGROUND_START_IN_PROGRESS);
+ }
+ break;
+ default:
+ break;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Starting 'Start Resp Monitor' Timer with '%d' sec",
+ m_SMConfig.MCConfig.ModuleStartRespTimeOutSec);
+
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_START_RESP_MONITOR_WAIT_TIMER],
+ m_SMConfig.MCConfig.ModuleStartRespTimeOutSec, 0, 0, 0);
+
+ l_eStatus = start_all_modules_of_group(hApp, m_SystemStarter.get_id());
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: start_all_modules_of_group(%d) errored: %d/'%s'",
+ m_SystemStarter.get_id(), l_eStatus, GetStr(l_eStatus).c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::BeginStartup( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnWakeupCallback
+/// WakeUp callback handler
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnWakeupCallback(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "Received from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnWakeupCallback( HANDLE hApp )
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnModuleStartCompleteResponse
+/// Start Response\Ack Handlers
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnModuleStartCompleteResponse(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "%s", FrameworkunifiedGetMsgSrc(hApp));
+
+ SetCmdHist("system_manager protocol completion response", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ ModuleLaunchListIter l_ModuleListIter;
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
+ l_eStatus = GetModuleIterator(l_moduleName.c_str(), l_ModuleListIter);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:always be eFrameworkunifiedStatusOK
+ // LCOV_EXCL_START 200: always be eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Module %s not found in Group Launch Map",
+ l_moduleName.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ switch (m_SMCurrentState) { // LCOV_EXCL_BR_LINE 200: cannot be SS_SM_READY_TO_LAUNCH_APP
+ case SS_SM_READY_TO_LAUNCH_APP:
+ // LCOV_EXCL_START 200: cannot be SS_SM_READY_TO_LAUNCH_APP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Received while in the '%s' state !!!",
+ GetStr(m_SMCurrentState).c_str());
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ break;
+ // LCOV_EXCL_STOP
+
+ case SS_SM_APPS_LAUNCH_IN_PROGRESS:
+ case SS_SM_APPS_LAUNCHED_READY_TO_START:
+ case SS_SM_APPS_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
+ {
+ const SMModuleState l_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ if (l_state != MODULE_STATE_INVALID) {
+ const PCSTR l_loglist[] = {"start", "pre start", "pre stop", "background start", "background stop", ""};
+ PCSTR l_logtxt;
+ switch (l_state) { // LCOV_EXCL_BR_LINE 6: As no other value is returned
+ case MODULE_STATE_STARTED:
+ l_logtxt = l_loglist[0];
+ break;
+ case MODULE_STATE_STARTED_PRE:
+ l_logtxt = l_loglist[1];
+ break;
+ case MODULE_STATE_STOPPED_PRE:
+ l_logtxt = l_loglist[2];
+ break;
+ case MODULE_STATE_STARTED_BACKGROUND:
+ l_logtxt = l_loglist[3];
+ break;
+ case MODULE_STATE_STOPPED_BACKGROUND:
+ l_logtxt = l_loglist[4];
+ break;
+ // LCOV_EXCL_START 6: As no other value is returned
+ default:
+ AGL_ASSERT_NOT_TESTED();
+ l_logtxt = l_loglist[5];
+ break;
+ // LCOV_EXCL_STOP 6: As no other value is returned
+ }
+ l_eStatus = ModuleCompleteResponse(hApp, l_ModuleListIter, l_state, // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ SysMgrCbType3<CSystemManager, &CSystemManager::IsGroupStarted>,
+ SysMgrCbType2<CSystemManager, &CSystemManager::ProcessGroupAsStarted>,
+ l_logtxt);
+ }
+ }
+ break;
+
+ case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
+ case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
+ // SystemManager changed state while this module was starting;
+ // tell this module to stop.
+ if (!l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_SENT)
+ && !l_ModuleListIter->IsModuleState(MODULE_STATE_STOPPED)) {
+ T_SS_SM_STOP_DataStructType l_SM_STOP_Struct;
+ l_SM_STOP_Struct.shutdownTrigger = m_shutdownTrigger;
+ l_SM_STOP_Struct.lastUserMode = m_lastUserMode;
+
+ CALL_AND_LOG_STATUS( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_ModuleListIter->SendMsgAndUpdateState(
+ &l_SM_STOP_Struct));
+ }
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Received while in the '%s' state !!!", GetStr(m_SMCurrentState).c_str());
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ break;
+ } // End switch ( m_SMCurrentState )
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnModuleStartCompleteResponse( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ModuleCompleteResponse
+/// Start Response\Ack Handlers
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::ModuleCompleteResponse(HANDLE hApp,
+ ModuleLaunchListIter f_ModuleListIter, SMModuleState f_moduleState,
+ FncCbType3 f_isGroupDoneFnc, FncCbType2 f_groupDoneFnc,
+ PCSTR f_sCompleteTypeText) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Received from %s, m_SystemStarter.get_id() is %d",
+ l_moduleName.c_str()
+ , m_SystemStarter.get_id());
+
+ f_ModuleListIter->SetModuleState(f_moduleState);
+ if (f_ModuleListIter->group_id != m_SystemStarter.get_id()) {
+ // In PastModel002, it is assumed that there is no service that returns a FrameworkunifiedOnStop reply after the NPP service.
+ // However, since _CWORD71_ does not assume this, completion of waiting for termination of the CRITICAL service must be
+ // judged even when services other than the Group1 service terminate last.
+ // Initially, SS_SM_WAITING_FOR_CRITICAL_APPS_AT_XXXX should be handled separately by ProcessModuleStopCompleteResponse(),
+ // but this is limited to ModuleCompleteResponse in order to avoid code deviation from PastModel002 and limit the scope of effect.
+ // LCOV_EXCL_BR_START 200 : m_SMCurrentState can't be SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ and SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ // NOLINT(whitespace/line_length)
+ if ((MODULE_STATE_STOPPED == f_moduleState)
+ && ((m_SMCurrentState
+ == SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ)
+ || (m_SMCurrentState
+ == SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ))) {
+ // LCOV_EXCL_BR_STOP 200 : m_SMCurrentState can't be SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ and SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 200 : m_SMCurrentState can't be SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ and SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ check_all_groups_have_stopped(hApp);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " %s ( group %d ) received out-of-synch; m_SystemStarter.get_id() is %d",
+ l_moduleName.c_str(), f_ModuleListIter->group_id
+ , m_SystemStarter.get_id());
+ }
+ } else {
+ if ((*f_isGroupDoneFnc)(f_ModuleListIter->group_id)) { // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ l_eStatus = (*f_groupDoneFnc)(hApp, f_ModuleListIter->group_id); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ } else if (IS_ZONE_SET(ZONE_INFO)) { // LCOV_EXCL_BR_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " Group %d %s incomplete, m_SystemStarter.get_id() is %d", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ f_ModuleListIter->group_id, f_sCompleteTypeText // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ , m_SystemStarter.get_id()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ char cBuf[100];
+ sprintf(cBuf, "%s incomplete", f_sCompleteTypeText); // NOLINT
+ LogGroupModulesState(f_ModuleListIter->group_id, cBuf); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ const SMModuleState l_transition_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ if (l_transition_state == f_moduleState) { // LCOV_EXCL_BR_LINE 6: As no other value is returned
+ if (have_all_services_start_completed(l_transition_state) == TRUE) {
+ if ((m_SMCurrentState == SS_SM_APPS_PRE_START_IN_PROGRESS)
+ || (m_SMCurrentState == SS_SM_APPS_PRE_STOP_IN_PROGRESS)) {
+ SMSetState(hApp, SS_SM_APPS_PRE_RUN_COMPLETE); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ } else if ((m_SMCurrentState == SS_SM_APPS_BACKGROUND_START_IN_PROGRESS)
+ || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS)) {
+ SMSetState(hApp, SS_SM_APPS_BACKGROUND_RUN_COMPLETE); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ } else {
+ SMSetState(hApp, SS_SM_APPS_START_COMPLETE); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::ModuleCompleteResponse(
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnStartRespMonitorTimeout
+/// SM maintains timer to check if all modules sent start response to him whoever requires Start.
+/// This timer is common to all modules. After timeout it checks the status of every module in group map.
+/// If a module sent start and does not respond, SM will initiate error event logging followed by Soft Reset
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnStartRespMonitorTimeout(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ std::string l_ProcName;
+ BOOL l_isStartRespNotReceived = false;
+
+ SetCmdHist("SM_TIMER_START_RESP_MONITOR_WAIT_TIMER", m_TimerCmdHist,
+ m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp));
+ GroupLaunchMap::reverse_iterator l_grp_riter = m_MapProclaunchGrps.rbegin();
+ ModuleLaunchList::reverse_iterator l_mod_riter;
+
+ if (l_grp_riter == m_MapProclaunchGrps.rend()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Group Map is Empty");
+ } else {
+ // scan the group map in reverse order
+ for (; l_grp_riter != m_MapProclaunchGrps.rend(); l_grp_riter++) {
+ l_mod_riter = l_grp_riter->second.modules.rbegin();
+ for (; l_mod_riter != l_grp_riter->second.modules.rend(); l_mod_riter++) {
+ // if a module sent start and not received response from module SM wait for "ModuleStartRespTimeout"
+ // and initiated error event
+ // logging followed by soft reset
+
+ if (l_mod_riter->is_start_required) {
+ if (l_mod_riter->IsModuleState(MODULE_STATE_START_SENT)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Module [%s] did not respond(%s) to SM in allocated time [%d] sec",
+ l_mod_riter->name.c_str(),
+ l_mod_riter->ModuleStateStr().c_str(),
+ m_SMConfig.MCConfig.ModuleStartRespTimeOutSec);
+ l_isStartRespNotReceived = true;
+ l_ProcName.assign(l_mod_riter->name);
+ }
+ }
+ }
+ }
+ }
+
+ if (true == l_isStartRespNotReceived) {
+ char l_cFormat[] = " Error. Module '%s' start response timeout.";
+ char l_cBuf[sizeof(l_cFormat) + MAX_NAME_SIZE_APP];
+ snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_ProcName.c_str());
+ TEXT(__FUNCTION__, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, l_cBuf);
+
+ SMLoggingInfo l_loggingInfo;
+ l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_GENERIC_ERR;
+
+ // initate error event logging
+ l_eStatus = ErrorEventEnqueue(hApp, eErrorEventTypeStartRespFailed,
+ l_ProcName, eErrorEventResetTypeHard, l_loggingInfo);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: StartRespFailed %s", l_ProcName.c_str());
+ fprintf(stderr, "SS_SysManager/%s/Error: StartRespFailed %s\n",
+ __FUNCTION__, l_ProcName.c_str());
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeStartRespFailed)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__,
+ " All modules returned Start Response.");
+
+ l_eStatus = FrameworkunifiedSendChild(hApp, m_hHeartbeatThread.m_ThreadHdl,
+ SS_HEARTBEAT_AVAIL_CHECK_REQ, 0, NULL);
+ SS_ASERT(l_eStatus == eFrameworkunifiedStatusOK); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnStartRespMonitorTimeout(HANDLE hApp)
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnShutdownCompleteMonitorTimeout
+/// SM maintains timer to check if all modules sent start response to him whoever requires Start.
+/// This timer is common to all modules. After timeout it checks the status of every module in group map.
+/// If a module sent start and does not respond, SM will initiate error event logging followed by Soft Reset
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnShutdownCompleteMonitorTimeout(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Reset Timeout");
+
+ l_eStatus = SecureChipOff();
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: SecureChipOff Failed");
+ }
+
+ m_ResetFactor = PSM_FACTOR_AGL_WITH_HISTORY;
+
+ l_eStatus = perform_force_reset(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnShutdownCompleteMonitorTimeout(HANDLE hApp)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup start_all_modules_of_group
+/// Send START to all modules of the given group
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::start_all_modules_of_group(HANDLE hApp, UI_32 f_ui32GroupNumber) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(
+ f_ui32GroupNumber);
+ if (l_GroupIterator == m_MapProclaunchGrps.end()) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,
+ __FUNCTION__
+ , " Error: Group %d not found; 'm_MapProclaunchGrps' is empty",
+ f_ui32GroupNumber);
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: Because the condition cannot be set
+ } else {
+ T_SS_SM_START_DataStructType f_startupData(m_StartUpReason,
+ m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType],
+ m_DataResetMode, m_startUpConfirmationMsg.securityStatus,
+ m_startUpConfirmationMsg.wakeupType, m_DramBackupStatus,
+ m_ResetStatus, m_ResetCount);
+
+ UI_32 l_numModulesMessaged = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Attempting to send Start Requests to Group %d/'%s'",
+ f_ui32GroupNumber, l_GroupIterator->second.name.c_str());
+
+ for (ModuleLaunchListIter l_ModuleListIterator =
+ l_GroupIterator->second.modules.begin();
+ l_ModuleListIterator != l_GroupIterator->second.modules.end();
+ l_ModuleListIterator++) {
+ //
+ // Every branch below must ZONE_INFO log how it dispenses w/
+ // the module.
+ // Note: ModuleLaunchParams::SetModuleState() performs that
+ // ZONE_INFO logging internally.
+ if (!l_ModuleListIterator->is_start_required) {
+ if (FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIterator->name) {
+ const SMModuleState l_transition_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ l_ModuleListIterator->SetModuleState(l_transition_state); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ } else {
+ // Not an error
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " %s 'is_start_required' is False;"
+ " leaving state as '%s'",
+ l_ModuleListIterator->name.c_str(),
+ l_ModuleListIterator->ModuleStateStr().c_str());
+ }
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (NULL == l_ModuleListIterator->hsession) { // LCOV_EXCL_BR_LINE 6: hsession can not be null.
+ l_eStatus = eFrameworkunifiedStatusOK; // Log a message. But its not a failure
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning: NULL == hsession;"
+ " %s not connected yet",
+ l_ModuleListIterator->name.c_str());
+ } else {
+ switch (l_ModuleListIterator->GetModuleState()) { // LCOV_EXCL_BR_LINE 6: As not all cases can be passed through
+ case MODULE_STATE_INVALID:
+ case MODULE_STATE_SKIPPED:
+ case MODULE_STATE_LAUNCH_FAILED:
+ // LCOV_EXCL_START 6: Because the state of the corresponding variable cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusOK; // Log a message. But its not a failure
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " %s is %s, NOT sending system_manager protocol message",
+ l_ModuleListIterator->name.c_str(),
+ l_ModuleListIterator->ModuleStateStr().c_str());
+ break;
+ // LCOV_EXCL_STOP
+
+ case MODULE_STATE_START_SENT:
+ case MODULE_STATE_START_PRE_SENT:
+ case MODULE_STATE_STOP_PRE_SENT:
+ case MODULE_STATE_START_BACKGROUND_SENT:
+ case MODULE_STATE_STOP_BACKGROUND_SENT:
+ l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " %s is %s, NOT sending system_manager protocol message",
+ l_ModuleListIterator->name.c_str(),
+ l_ModuleListIterator->ModuleStateStr().c_str());
+ l_numModulesMessaged++;
+ break;
+
+ case MODULE_STATE_LAUNCHING:
+ case MODULE_STATE_LAUNCHED:
+ // LCOV_EXCL_START 6: Because the state of the corresponding variable cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusOK; // Log a message. But its not a failure
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " %s is %s, NOT sending system_manager protocol message",
+ l_ModuleListIterator->name.c_str(),
+ l_ModuleListIterator->ModuleStateStr().c_str());
+ break;
+ // LCOV_EXCL_STOP
+
+ case MODULE_STATE_CONNECTED:
+ case MODULE_STATE_STARTED:
+ case MODULE_STATE_START_FAILED:
+ case MODULE_STATE_STOP_FAILED:
+ case MODULE_STATE_STOP_SENT:
+ case MODULE_STATE_STOPPED:
+ case MODULE_STATE_STARTED_PRE:
+ case MODULE_STATE_START_PRE_FAILED:
+ case MODULE_STATE_STOPPED_PRE:
+ case MODULE_STATE_STOP_PRE_FAILED:
+ case MODULE_STATE_STARTED_BACKGROUND:
+ case MODULE_STATE_START_BACKGROUND_FAILED:
+ case MODULE_STATE_STOPPED_BACKGROUND:
+ case MODULE_STATE_STOP_BACKGROUND_FAILED:
+ {
+ const UI_32 l_iCmd = InProgressStateToSendMsg(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ if (l_iCmd != SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX) { // LCOV_EXCL_BR_LINE 6: Excluded due to value never returned at present
+ // LCOV_EXCL_BR_START 15: Excluded due to inlined functions
+ CALL_AND_LOG_STATUS_IF_ERRORED(l_ModuleListIterator->SendMsgAndUpdateState(l_iCmd, &f_startupData));
+ // LCOV_EXCL_BR_STOP 15: Excluded due to inlined functions
+ l_numModulesMessaged++;
+ }
+ }
+ break;
+ // default: Don't code a 'default' here - let the compiler
+ // detect when the set of module_state enumerations changes -
+ // then the System Service's System Manager maintainer will
+ // automagically know to update this switch statement.
+ }
+ }
+ }
+
+ if (0 == l_numModulesMessaged) {
+ LogGroupModulesState(f_ui32GroupNumber, " Warning: NO modules were sent system_manager protocol message"); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+
+ char l_cBuf[100];
+ snprintf(l_cBuf, sizeof(l_cBuf), "ProcessGroupAsStarted(%d)", l_GroupIterator->second.id);
+ l_eStatus = ProcessGroupAsStarted(hApp, l_GroupIterator);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
+ } else {
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR],
+ SS_CLIENT_START_MONITOR_TIMER_CONFIG, 0, 0, 0);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::start_all_modules_of_group(HANDLE hApp, UI_32 f_ui32GroupNumber)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup start_all_modules_of_group
+/// mark the specified group as started. If there is another group to start,
+/// do so, else send Start Complete Response to the Start Requester.
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted(HANDLE hApp, UI_32 f_groupId) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(f_groupId);
+ if (l_GroupIterator == m_MapProclaunchGrps.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Group %d not found; 'm_MapProclaunchGrps' is empty", f_groupId);
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ l_eStatus = ProcessGroupAsStarted(hApp, l_GroupIterator);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted( HANDLE hApp, UI_32 f_groupId )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup start_all_modules_of_group
+/// mark the specified group as started. If there is another group to start,
+/// do so, else send Start Complete Response to the Start Requester.
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted(HANDLE hApp,
+ GroupLaunchMapIter f_GroupIterator) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ UI_32 l_groupID = m_SystemStarter.get_id();
+
+
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR]);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Group %d/%s start completed, m_SystemStarter.get_id() is %d",
+ f_GroupIterator->second.id, f_GroupIterator->second.name.c_str(),
+ l_groupID);
+
+ if (f_GroupIterator->second.id != l_groupID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO,
+ __FUNCTION__
+ , " The just-started group ( %d/%s ) is not the current Active "
+ " Group ( %d ); not starting next group's modules",
+ f_GroupIterator->second.id,
+ f_GroupIterator->second.name.c_str(), l_groupID);
+ } else {
+ if ((m_SMCurrentState == SS_SM_APPS_START_IN_PROGRESS)
+ || (m_SMCurrentState == SS_SM_APPS_PRE_START_IN_PROGRESS)
+ || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_START_IN_PROGRESS)) {
+ // check if WakeUp Level has been achieved
+ if (m_SystemStarter.is_end() == FALSE) {
+ // Start modules from next group
+ l_groupID = m_SystemStarter.advance_id(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ char l_cBuf[100] = {0};
+ snprintf(l_cBuf, sizeof(l_cBuf), "start_all_modules_of_group(%u)", l_groupID);
+ l_eStatus = start_all_modules_of_group(hApp, l_groupID); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
+ }
+ } else if ((m_SMCurrentState == SS_SM_APPS_PRE_STOP_IN_PROGRESS)
+ || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS)) {
+ if (m_SystemStarter.is_begin() == FALSE) {
+ // Stop modules from next group
+ l_groupID = m_SystemStarter.decrement_id(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ char l_cBuf[100] = {0};
+ snprintf(l_cBuf, sizeof(l_cBuf), "stop_all_modules_of_group(%u)", l_groupID);
+ l_eStatus = start_all_modules_of_group(hApp, l_groupID); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
+ }
+ } else {
+ // MISRA C++-2008 Rule 6-4-2
+ // NOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted( GroupLaunchMapIter f_GroupIterator )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup calculate_max_shutdown_time
+/// Calculate maximum shutdown time of apps critical to shutdown
+/// from the launch group map
+///
+/// \param [in]
+///
+/// \return UI_32
+/// Max Value of critical shutdown apps shutdown time
+///////////////////////////////////////////////////////////////////////////////
+UI_32 CSystemManager::calculate_max_shutdown_time() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ UI_32 l_MaxShutdownTimeValue = 0;
+ std::string moduleName;
+
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
+ for (; l_GroupIterator != m_MapProclaunchGrps.end(); l_GroupIterator++) {
+ ModuleLaunchListIter l_ModuleListIterator =
+ l_GroupIterator->second.modules.begin();
+ for (; l_ModuleListIterator != l_GroupIterator->second.modules.end();
+ l_ModuleListIterator++) {
+ if (l_ModuleListIterator->shutdown_critical) {
+ if (l_MaxShutdownTimeValue < l_ModuleListIterator->shutdown_wait_time) {
+ moduleName = l_ModuleListIterator->name;
+ l_MaxShutdownTimeValue = l_ModuleListIterator->shutdown_wait_time;
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Max time: Module %s, time %d s",
+ moduleName.c_str(), l_MaxShutdownTimeValue);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_MaxShutdownTimeValue;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnShutdownModulesRequest
+/// Send Shutdown to all modules in reverse order of group
+///
+/// \param [in]
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnShutdownModulesRequest(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
+ " Received from %s, m_SystemStarter.get_id() is %d",
+ FrameworkunifiedGetMsgSrc(hApp)
+ , m_SystemStarter.get_id());
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "m_SystemStarter.get_id() is %d", m_SystemStarter.get_id());
+
+ SetCmdHist("SS_SM_SHUTDOWN_MODULES", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ Pwr_ServiceSetInterface l_tServiceSetIf;
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, l_tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ BOOL isImmShutdown = FALSE;
+
+ // If the Shutdown is not completed after the Shutdown is requested, it is forcibly reset.
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_SHUTDOWN_COMPLETE_MONITOR],
+ SM_SHUTDOWN_COMPLETE_MONITOR_TIMEOUT, 0, 0, 0);
+
+ if (m_isImmResetReq) {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " ImmReset");
+ isImmShutdown = TRUE;
+ }
+
+ switch (l_tServiceSetIf.data.shutdownRequestMsg.lastUserMode) {
+ case epsumINVALID:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: shutdownRequestMsg.lastUserMode == epsumINVALID");
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+
+ case epsumOFF:
+ case epsumON: {
+ switch (m_SMCurrentState) {
+ case SS_SM_READY_TO_LAUNCH_APP:
+ case SS_SM_APPS_LAUNCH_IN_PROGRESS:
+ case SS_SM_APPS_LAUNCHED_READY_TO_START:
+ isImmShutdown = TRUE;
+ case SS_SM_APPS_START_COMPLETE:
+ case SS_SM_APPS_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
+ case SS_SM_APPS_PRE_RUN_COMPLETE:
+ case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
+
+ if (l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger ==
+ epssdmsdtIGN_OFF) {
+ m_ResetCount = 0;
+ if (PowerHalSetResetInfo(AGL_RESET_COUNTER, m_ResetCount)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not back up m_ResetCount(%lu) to power_hal", m_ResetCount);
+ }
+
+ if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, 0)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not reset AGL_ERRLOG_COUNTER");
+ }
+ }
+ if (!m_isPrevErrEventCompleted
+ || ((!((m_SMCurrentState == SS_SM_APPS_START_COMPLETE)
+ || (m_SMCurrentState == SS_SM_APPS_PRE_RUN_COMPLETE)
+ || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_RUN_COMPLETE)))
+ && (l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger
+ == epssdmsdtIGN_OFF
+ || l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger
+ == epssdmsdtNORMAL_RESET))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "shutdown pending");
+ if (!m_dqDeferMsg.empty()) {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ SM_POWER_EVENT_INFO deferMsg(SS_SM_SHUTDOWN_MODULES, l_tServiceSetIf);
+ m_dqDeferMsg.push(deferMsg);
+ }
+ } else {
+ // The shutdownTrigger has already been validated by
+ // Power::OnShutdownRequestMsg()
+ m_shutdownTrigger = l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger;
+ m_lastUserMode = l_tServiceSetIf.data.shutdownRequestMsg.lastUserMode;
+
+ // Notify services ShutDownTrigger the FrameworkunifiedOnStop, if dataResetMode is configured
+ // When using FastSleep, be aware that it may be overwritten here
+ switch (m_DataResetMode) {
+ case e_SS_SM_DATA_RESET_MODE_FACTORY:
+ m_shutdownTrigger = epssdmsdtFACTORY_DATA_RESET;
+ break;
+ case e_SS_SM_DATA_RESET_MODE_USER:
+ m_shutdownTrigger = epssdmsdtUSER_DATA_RESET;
+ break;
+ default:
+ break;
+ }
+
+ if (isImmShutdown) {
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_GROUP_LAUNCH_WAIT_TIMER]);
+
+ // Do not use m_shutdownTrigger because it is updated on DataReset
+ switch (l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger) {
+ case epssdmsdtGENERIC_ERROR_RESET:
+ case epssdmsdtFATAL_ERROR_RESET:
+ CALL_AND_LOG_STATUS((*m_pfStopCompleteHandler)(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Received a Shutdown command while in "
+ "the '%s' state - returning Shutdown "
+ "Response msg now",
+ GetStr(m_SMCurrentState).c_str());
+
+ CALL_AND_LOG_STATUS(SendShutdownResponseMessage(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ break;
+ }
+
+ } else {
+ InitiateAllGroupsShutdown(hApp);
+ }
+ }
+ break;
+
+ case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
+ case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Received a Shutdown command while already in "
+ "the '%s' state !!!",
+ GetStr(m_SMCurrentState).c_str());
+ break;
+ } // End switch ( m_SMCurrentState )
+ break;
+ } // End case epsumOFF | epsumON
+ } // End switch (m_lastUserMode )
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnShutdownModulesRequest( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup SendSystemModeInfoResponse
+/// send SystemModeInfo to
+/// _CWORD56_ ( via Power Service-> PSMShadow ) as an IPC 'Start Notification'
+/// message, informing _CWORD56_ of the startup state of the _CWORD102_.
+///
+/// \param [in] HANDLE hApp
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::SendSystemModeInfoResponse(HANDLE hApp, EPWR_STARTUP_STAGE_TYPE f_startupStage) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SystemModeInfo l_SystemModeInfo;
+
+ memcpy(&l_SystemModeInfo, &m_SystemModeInfo, sizeof(l_SystemModeInfo));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "stage:%d", f_startupStage);
+ l_SystemModeInfo.startupStage = f_startupStage;
+
+ l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_SYSTEM_MODE_INFO_RSPN,
+ sizeof(l_SystemModeInfo), (PVOID) & l_SystemModeInfo);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SendSystemModeInfoResponse(%s) errored: 0x%X",
+ GetStr(l_SystemModeInfo.startupStage).c_str(), l_eStatus);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " SendSystemModeInfoResponse(%s) successful",
+ GetStr(l_SystemModeInfo.startupStage).c_str());
+ // LCOV_EXCL_STOP
+ }
+
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_SM_SYSTEM_MODE_INFO_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::SendSystemModeInfoResponse( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnSystemModeInfoRequest
+/// Handle System Mode Info request. Send System Mode Info read from NVM
+///
+/// \param [in] HANDLE hApp
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnSystemModeInfoRequest(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+ m_isRcvModeInfo = TRUE;
+
+ SetCmdHist("SS_SM_SYSTEM_MODE_INFO_REQ", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ if (m_SystemModeInfo.startupStage == epssusfINVALID) {
+ // Transitioning to SYSTEM_SERVICES_STARTED if startupStage == INVALID
+ m_SystemModeInfo.startupStage = epssusSYSTEM_SERVICES_STARTED;
+ }
+
+ l_eStatus = SendSystemModeInfoResponse(hApp, epssusSYSTEM_SERVICES_STARTED);
+ LOG_STATUS(l_eStatus, "SendSystemModeInfoResponse()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ if (TRUE == m_isRstPending) {
+ ESMCpuResetReason l_resetReason = m_rstPendingInfo.resetReason;
+ std::string l_messageStr = m_rstPendingInfo.messageStr;
+
+ m_isRstPending = FALSE;
+ m_rstPendingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_INVALID;
+ memset(m_rstPendingInfo.messageStr, 0, sizeof(m_rstPendingInfo.messageStr));
+
+ l_eStatus = PerformCpuReset(hApp, l_resetReason, l_messageStr);
+ LOG_STATUS(l_eStatus, "PerformCpuReset()"); // LCOV_EXCL_BR_LINE 6: Because it is executed only once and cannot see all branches
+ }
+
+ if (m_SystemModeInfo.startupStage == epssusALL_SERVICES_LAUNCHED) {
+ // If startupStage == ALL_SERVICES_LAUNCHED
+ // Notify here because Launch of all SVCs is completed first.
+ l_eStatus = SendSystemModeInfoResponse(hApp, epssusALL_SERVICES_LAUNCHED);
+ LOG_STATUS(l_eStatus, "SendSystemModeInfoResponse()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnSystemModeInfoRequest( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnInitCompReportCallback
+/// Handle InitComp report.
+///
+/// \param [in] HANDLE hApp
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnInitCompReportCallback(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ SetCmdHist("SS_SM_INITCOMP_REP", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnInitCompReportCallback( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup have_all_services_start_completed
+/// check if state of all services is MODULE_STATE_STARTED
+///
+/// \param [in]
+///
+///
+/// \return BOOL
+/// Success ==> TRUE
+/// Failure ==> FALSE
+///////////////////////////////////////////////////////////////////////////////
+BOOL CSystemManager::have_all_services_start_completed(const SMModuleState f_moduleState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL bIsStartCompleted = TRUE;
+ SMModuleState l_failedState = MODULE_STATE_INVALID;
+
+ switch (f_moduleState) {
+ case MODULE_STATE_STARTED:
+ l_failedState = MODULE_STATE_START_FAILED;
+ break;
+ case MODULE_STATE_STARTED_PRE:
+ l_failedState = MODULE_STATE_START_PRE_FAILED;
+ break;
+ case MODULE_STATE_STOPPED_PRE:
+ l_failedState = MODULE_STATE_STOP_PRE_FAILED;
+ break;
+ case MODULE_STATE_STARTED_BACKGROUND:
+ l_failedState = MODULE_STATE_START_BACKGROUND_FAILED;
+ break;
+ case MODULE_STATE_STOPPED_BACKGROUND:
+ l_failedState = MODULE_STATE_STOP_BACKGROUND_FAILED;
+ break;
+ default:
+ bIsStartCompleted = FALSE;
+ break;
+ }
+ if (l_failedState != MODULE_STATE_INVALID) {
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
+ for (; l_GroupIterator != m_MapProclaunchGrps.end(); l_GroupIterator++) {
+ ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
+ for (; l_ModuleListIterator != l_GroupIterator->second.modules.end(); l_ModuleListIterator++) {
+ if ((l_ModuleListIterator->is_start_required == TRUE)
+ && ((l_ModuleListIterator->IsModuleState(f_moduleState) == FALSE) // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ && (l_ModuleListIterator->IsModuleState(MODULE_STATE_SKIPPED) == FALSE) // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ && (l_ModuleListIterator->IsModuleState(l_failedState) == FALSE))) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ // Allow _SKIPPED/START_FAILED for StartRespMonitor conditions
+ bIsStartCompleted = FALSE;
+ break;
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return bIsStartCompleted;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup is_critical_service_stopped
+///
+///
+/// \param [in]
+///
+///
+/// \return BOOL
+/// Success ==> TRUE
+/// Failure ==> FALSE
+///////////////////////////////////////////////////////////////////////////////
+BOOL CSystemManager::is_service_shutdown_ready(ModuleLaunchListIter &modIte) {
+ if (((modIte->shutdown_critical && modIte->is_start_required)
+ || (modIte->name == FRAMEWORKUNIFIED_NS_NPSERVICE))
+ && modIte->IsModuleState(MODULE_STATE_STOPPED) == FALSE) {
+ // Not shutdown_ready if NPP or shutdown_critical services are not STOPPED.
+ return FALSE;
+ }
+ return TRUE;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup have_critical_services_stopped
+/// check if state of all critical services is MODULE_STATE_STOPPED
+///
+/// \param [in]
+///
+///
+/// \return BOOL
+/// Success ==> TRUE
+/// Failure ==> FALSE
+///////////////////////////////////////////////////////////////////////////////
+BOOL CSystemManager::have_critical_services_stopped() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ uint numStoppingModules = 0;
+
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
+ for (; l_GroupIterator != m_MapProclaunchGrps.end(); l_GroupIterator++) {
+ ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
+ for (; l_ModuleListIterator != l_GroupIterator->second.modules.end(); l_ModuleListIterator++) {
+ if (l_ModuleListIterator->IsModuleState(MODULE_STATE_STOP_SENT)
+ && l_ModuleListIterator->shutdown_critical) {
+ numStoppingModules++;
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (numStoppingModules == 0);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup perform_force_reset
+///
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::perform_force_reset(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "+");
+
+ // Since initialization must be performed by the PSMs during FactReset, do not NaviDet them as much as possible.
+ if (e_SS_SM_DATA_RESET_MODE_FACTORY == m_DataResetMode) {
+ fprintf(stderr,
+ "SS_SysManager/%s/NO NAVIDET!! but SendShutdownComp for FactReset\n", __FUNCTION__);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "NO NAVIDET!! but SendShutdownComp for FactReset");
+ CALL_AND_LOG_STATUS(send_shutdown_complete_response(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ sleep(60);
+ } else if (access("/nv/BS/ss/system_manager/rwdata/ss_debug", F_OK) == 0) {
+ fprintf(stderr, "SS_SysManager/%s/NO NAVIDET!! but SendShutdownComp\n", __FUNCTION__);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NO NAVIDET!! but SendShutdownComp");
+ CALL_AND_LOG_STATUS(send_shutdown_complete_response(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ sleep(60);
+ }
+
+ fflush(stderr);
+ usleep(100 * 1000);
+
+ if (0 == PsmNaviResetPower(hApp, m_ResetFactor)) { // LCOV_EXCL_BR_LINE 200: power_hal if, can not to be error.
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ usleep(300 * 1000);
+ fprintf(stderr, "SS_SysManager/%s/Error: Not Reset !!!\n", __FUNCTION__);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ send_shutdown_complete_response(hApp); // Try to NAVI_RESET even if ignored
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup send_shutdown_complete_response
+///
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::send_shutdown_complete_response(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CALL_AND_LOG_STATUS(ResetModulesStateToConnected(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ SMSetState(hApp, SS_SM_APPS_LAUNCHED_READY_TO_START);
+ // m_ActiveGroupId = SS_SM_INITIAL_GROUP;
+
+ // all the modules have stopped, send Shutdown Response to Power Service
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " All critical services have stopped, Active Group ID is now %d",
+ m_SystemStarter.get_id());
+#if 1
+ CALL_AND_LOG_STATUS(SendShutdownResponseMessage(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+#else
+ //
+ // Normal, production flow is to call SendShutdownResponseMessage(), which
+ // sends the Shutdown Response message to the _CWORD56_, causing the _CWORD56_ to
+ // remove power from the _CWORD102_ before queued-up FRAMEWORKUNIFIEDLOG messages can be // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ // processed by SS_LoggerService.
+ //
+ // Optional development flow is to NOT call SendShutdownResponseMessage(),
+ // thus giving the _CWORD102_ time to process its FRAMEWORKUNIFIEDLOG messages. Since this is an // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ // abnormal, 'bad' condition of NOT sending a Shutdown Response message to
+ // the _CWORD56_, be very obvious about this state by displaying both
+ // compile-time and run-time warning messages.
+ //
+#warning NOT calling SendShutdownResponseMessage(hApp) !
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " Warning: SendShutdownResponseMessage( hApp ) "
+ "#def'f out; ShutdownResponse NOT sent to _CWORD56_");
+#endif
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::SendShutdownResponseMessage(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ SS_SM_SHUTDOWN_MODULES_CMPL_RSPN, 0, (PVOID) NULL); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "FrameworkunifiedSendMsg(PowerService,SS_SM_SHUTDOWN_MODULES_CMPL_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::SendShutdownResponseMessage( HANDLE hApp )
+
+
+PsmFactorT CSystemManager::GetResetFactor(PCSTR f_module_name, BOOL f_user_reset) {
+ PsmFactorT l_reset_factor = PSM_FACTOR_NONE;
+ EFrameworkunifiedStatus l_eStatus;
+ ModuleLaunchListIter l_moduleIter;
+ l_eStatus = GetModuleIterator(f_module_name, l_moduleIter); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("GetModuleIterator()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ l_reset_factor = GetResetFactor(l_moduleIter, f_user_reset);
+ }
+ return l_reset_factor;
+} // End of PsmFactorT CSystemManager::GetResetFactor(PCSTR f_module_name)
+
+
+PsmFactorT CSystemManager::GetResetFactor(const ModuleLaunchListIter f_module_iter, BOOL f_user_reset) {
+ PsmFactorT l_reset_factor;
+ if (f_module_iter->IsAGLUnit() == TRUE) {
+ if (f_module_iter->IsAGLResetHistoryDisable() == TRUE) {
+ l_reset_factor = PSM_FACTOR_AGL;
+ } else {
+ l_reset_factor = PSM_FACTOR_AGL_WITH_HISTORY;
+ }
+ } else {
+ if (f_module_iter->IsNonAGLResetHistoryDisable() == TRUE) {
+ l_reset_factor = PSM_FACTOR_TIER1;
+ } else {
+ l_reset_factor = PSM_FACTOR_TIER1_WITH_HISTORY;
+ }
+ }
+
+ if (f_user_reset == TRUE) {
+ if ((l_reset_factor == PSM_FACTOR_AGL) || (l_reset_factor == PSM_FACTOR_TIER1)) {
+ l_reset_factor = PSM_FACTOR_USER;
+ } else {
+ l_reset_factor = PSM_FACTOR_USER_WITH_HISTORY;
+ }
+ }
+ return l_reset_factor;
+} // End of PsmFactorT GetResetFactor(ModuleLaunchListIter & f_module_iter)
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnClientStopMonitorTimerExpiry
+///
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnClientStopMonitorTimerExpiry(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from group %d", m_SystemStarter.get_id());
+
+ SetCmdHist("SM_TIMER_CLIENT_STOP_MONITOR", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if ((m_SMCurrentState == SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ)
+ || (m_SMCurrentState == SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ)
+ || m_SystemStarter.get_id() <= SS_SM_THIRD_GROUP) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: StopCompTimeout:gid:%d", m_SystemStarter.get_id());
+ fprintf(stderr, "SS_SysManager/%s/Error: StopCompTimeout:gid:%d\n", __FUNCTION__, m_SystemStarter.get_id());
+
+ for (GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
+ l_GroupIterator != m_MapProclaunchGrps.end();
+ l_GroupIterator++) {
+ for (ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
+ l_ModuleListIterator != l_GroupIterator->second.modules.end();
+ l_ModuleListIterator++) {
+ if (l_ModuleListIterator->group_id >= m_SystemStarter.get_id()
+ && is_service_shutdown_ready(l_ModuleListIterator) == FALSE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s", l_ModuleListIterator->name.c_str());
+ fprintf(stderr, "SS_SysManager/%s/Error: %s\n", __FUNCTION__, l_ModuleListIterator->name.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+
+ if (!m_SystemStarter.is_begin()) {
+ // Continue termination processing to perform BackupManager termination processing.
+ m_SystemStarter.decrement_id();
+ check_all_groups_have_stopped(hApp);
+ } else {
+ // DEAD CODE
+ fprintf(stderr, "SS_SysManager/%s:SVC stop timeout\n", __FUNCTION__);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " SVC stop timeout");
+ l_eStatus = CallStopCompleteHandler(hApp);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "CallStopCompleteHandler( hApp )"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+ } else {
+ // The current m_ActiveGroupId group just timed out. If possible,
+ // decrement it, and then see if there are more groups to send
+ // stop requests to.
+ if (!m_SystemStarter.is_begin()) {
+ m_SystemStarter.decrement_id();
+ }
+ check_all_groups_have_stopped(hApp);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnClientStopMonitorTimerExpiry( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup check_all_groups_have_stopped
+/// check that all the groups has stopped
+///
+/// \param [in]
+///
+///
+/// \return VOID
+///////////////////////////////////////////////////////////////////////////////
+VOID CSystemManager::check_all_groups_have_stopped(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_ActiveGroupId = m_SystemStarter.get_id();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " m_SystemStarter.get_id() is %d, 'm_NPPStopSent' is '%s'"
+ , m_SystemStarter.get_id(), GetStr(m_NPPStopSent).c_str());
+
+ // send stop to next group in reverse order
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_NPPStopSent is %s", GetStr(m_NPPStopSent).c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ if (!m_NPPStopSent) {
+ l_eStatus = stop_all_modules_of_group(hApp);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: stop_all_modules_of_group(%d) errored: %d/'%s'",
+ l_ActiveGroupId, l_eStatus, GetStr(l_eStatus).c_str());
+ }
+ } else { // (m_ActiveGroupId < SS_SM_INITIAL_GROUP)
+ BOOL l_bIsDetectTimeout;
+
+ if ((l_bIsDetectTimeout = !have_critical_services_stopped())) {
+ // If the Critical service is not terminated even when the final GROUP is completed, DUMP the applicable service and issue NAVI_DET.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FinalCriticalCheck");
+ fprintf(stderr, "SS_SysManager/%s:FinalCriticalCheck\n", __FUNCTION__); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ for (GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
+ l_GroupIterator != m_MapProclaunchGrps.end();
+ l_GroupIterator++) {
+ for (ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
+ l_ModuleListIterator != l_GroupIterator->second.modules.end();
+ l_ModuleListIterator++) {
+ if (is_service_shutdown_ready(l_ModuleListIterator) == FALSE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s",
+ l_ModuleListIterator->name.c_str());
+ fprintf(stderr, "SS_SysManager/%s/Error: %s\n", // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ __FUNCTION__,
+ l_ModuleListIterator->name.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+ fprintf(stderr, "SS_SysManager/%s:critical service no stop\n", __FUNCTION__);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "critical service no stop");
+ }
+
+ CALL_AND_LOG_STATUS(CallStopCompleteHandler(hApp, l_bIsDetectTimeout)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ // In PastModel002, there was a transition to WAITING_FOR_CRITICAL_APPS in the following processing, but in _CWORD71_,
+ // the transition to WAITING_FOR_CRITICAL_APPS was eliminated by revising the termination processing.
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return;
+} // End of VOID CSystemManager::check_all_groups_have_stopped( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup MarkModuleStateStopped
+/// Sets Module State to STOP COMPLETE
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnNppStopComplete
+/// Npp Stop Complete complete Response\Ack Handlers
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnNppStopComplete(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ SetCmdHist("NPS_NPP_STOP_ACK", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ char l_cBuf[100];
+ snprintf(l_cBuf, sizeof(l_cBuf), "ProcessModuleStopCompleteResponse(%s)", FRAMEWORKUNIFIED_NS_NPSERVICE);
+ l_eStatus = ProcessModuleStopCompleteResponse(hApp, FRAMEWORKUNIFIED_NS_NPSERVICE);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus CSystemManager::GetModuleIterator(PCSTR f_moduleName, ModuleLaunchListIter &f_moduleIter) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ ModuleLaunchListIter l_moduleIter;
+// static int l_numTimesEntered = 0 ;
+// l_numTimesEntered++ ;
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__ // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+// , " NTE %d: Looking for %s"
+// , l_numTimesEntered
+// , f_moduleName);
+
+ BOOL l_bIsFound = FALSE;
+ for (GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.begin();
+ !l_bIsFound && l_GroupIter != m_MapProclaunchGrps.end();
+ l_GroupIter++) {
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__ // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+// , " NTE %d: Checking group %d/%s"
+// , l_numTimesEntered
+// , l_GroupIter->second.id
+// , l_GroupIter->second.name.c_str());
+
+ for (l_moduleIter = l_GroupIter->second.modules.begin();
+ !l_bIsFound && (l_moduleIter != l_GroupIter->second.modules.end());
+ l_moduleIter++) {
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__ // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+// , " NTE %d: Checking PCSTR '%s' against std::string '%s': %d, %s"
+// , l_numTimesEntered
+// , f_moduleName
+// , l_moduleIter->name.c_str()
+// , strcmp(l_moduleIter->name.c_str(), f_moduleName)
+// , (0 == strcmp(l_moduleIter->name.c_str(), f_moduleName) ? "True" : "False"));
+
+ l_bIsFound =
+ (0 == strcmp(l_moduleIter->name.c_str(), f_moduleName));
+ if (l_bIsFound) {
+ f_moduleIter = l_moduleIter;
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+//// " NTE %d:"
+// " '%s' is in group %d/%s"
+//// , l_numTimesEntered
+// , f_moduleIter->name.c_str()
+// , l_GroupIter->second.id
+// , l_GroupIter->second.name.c_str());
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+
+ if (!l_bIsFound) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+// " NTE %d:"
+ " Error: '%s' is not in group map 'm_MapProclaunchGrps'"
+// , l_numTimesEntered
+ , f_moduleName);
+ if (0 != strcmp(f_moduleName, SERVICE_SYSMANAGER)) {
+ SysMgrConfiguration m_launchConfig;
+ m_launchConfig.PrintAllInfo(m_MapProclaunchGrps);
+ }
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::GetModuleIterator( PCSTR f_moduleName
+
+BOOL CSystemManager::IsGroupStarted(UI_32 f_groupID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bIsStarted = TRUE;
+
+ GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.find(f_groupID);
+ if (l_GroupIter == m_MapProclaunchGrps.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Group Map Empty; was looking for group %d", f_groupID);
+ } else {
+ ModuleLaunchListIter l_ModuleListIter = l_GroupIter->second.modules.begin();
+ const SMModuleState l_dest_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
+ if (l_dest_state != MODULE_STATE_INVALID) {
+ for (; l_ModuleListIter != l_GroupIter->second.modules.end(); l_ModuleListIter++) {
+ if (((l_ModuleListIter->IsModuleState(l_dest_state) == FALSE) // LCOV_EXCL_BR_START 11:Gcov constraints (because exception-handling routes are automatically generated)
+ && (l_ModuleListIter->IsModuleState(MODULE_STATE_START_FAILED) == FALSE)
+ && (l_ModuleListIter->IsModuleState(MODULE_STATE_START_PRE_FAILED) == FALSE)
+ && (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_PRE_FAILED) == FALSE)
+ && (l_ModuleListIter->IsModuleState(MODULE_STATE_START_BACKGROUND_FAILED) == FALSE)
+ && (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_BACKGROUND_FAILED) == FALSE)
+ && (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_FAILED) == FALSE))
+ // LCOV_EXCL_BR_STOP 11:Gcov constraints (because exception-handling routes are automatically generated)
+ || ((l_ModuleListIter->is_start_required == TRUE)
+ // LCOV_EXCL_START 6: Because the value cannot be stored to make the condition true
+ && ((l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHING) == TRUE)
+ || (l_ModuleListIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)
+ || (l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)))) {
+ // LCOV_EXCL_STOP 6: Because the value cannot be stored to make the condition true
+ l_bIsStarted = FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " No: '%s' in group %d/%s is '%s'", l_ModuleListIter->name.c_str(),
+ l_GroupIter->second.id, l_GroupIter->second.name.c_str(),
+ l_ModuleListIter->ModuleStateStr().c_str());
+ break;
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bIsStarted;
+} // End of BOOL CSystemManager::IsGroupStarted(UI_32 f_groupId)
+
+BOOL CSystemManager::IsGroupStopped(UI_32 f_groupID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bIsStopped = TRUE;
+ ModuleLaunchListIter l_ModuleListIter;
+
+ GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.find(f_groupID);
+ if (l_GroupIter == m_MapProclaunchGrps.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Group Map Empty; was looking for group %d",
+ f_groupID);
+ } else {
+ for (l_ModuleListIter = l_GroupIter->second.modules.begin();
+ l_bIsStopped
+ && l_ModuleListIter != l_GroupIter->second.modules.end();
+ l_ModuleListIter++) {
+ if (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_SENT)) {
+ l_bIsStopped = FALSE;
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bIsStopped;
+} // End of BOOL CSystemManager::IsGroupStopped(UI_32 f_groupId)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnStopComplete
+/// Shutdown complete Response\Ack Handlers
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnModuleStopCompleteResponse(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusErrOther;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", l_moduleName);
+ SetCmdHist("SS_SM_STOP_COMPL_RSPN", m_SMCmdHist, m_SMHistIter, l_moduleName);
+
+ char l_cBuf[100];
+ snprintf(l_cBuf, sizeof(l_cBuf), "ProcessModuleStopCompleteResponse(%s)", l_moduleName);
+ l_eStatus = ProcessModuleStopCompleteResponse(hApp, l_moduleName);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnModuleStopCompleteResponse( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnGetStartExtInfo
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnGetStartExtInfo(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ T_SS_SM_START_ExtDataStructType l_extInfo = { 0 };
+
+ SS_STATIC_ASERT(sizeof(T_SS_SM_START_ExtDataStructType) == SS_SM_START_EXT_INFO_SIZE); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+ ");
+
+ SetCmdHist("SS_SM_GET_START_EXT_INFO", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ l_extInfo.isProgUpdated =
+ (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_UPDATED) ? TRUE : FALSE;
+ l_extInfo.isMapUpdated =
+ (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_MAP_UPDATED) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_extInfo.isMapDiffUpdated =
+ (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_MAPDIFF_UPDATED) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ ModuleLaunchListIter l_ModuleListIter;
+
+ l_eStatus = GetModuleIterator(FrameworkunifiedGetMsgSrc(hApp), l_ModuleListIter);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s not found", FrameworkunifiedGetMsgSrc(hApp));
+ } else {
+ switch (l_ModuleListIter->relaunch_status) {
+ case NotRelaunched:
+ l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_NONE;
+ break;
+ case RelaunchSafe:
+ // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_SAFE;
+ break;
+ case RelaunchErr:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_ERR;
+ break;
+ default:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_NONE;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
+ // because this request is sent by FrameworkunifiedInvokeSync()
+ l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_extInfo, sizeof(l_extInfo));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnGetStartExtInfo( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnGetStopExtInfo
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnGetStopExtInfo(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ T_SS_SM_STOP_ExtDataStructType l_extInfo = { 0 };
+
+ SS_STATIC_ASERT(sizeof(T_SS_SM_STOP_ExtDataStructType) == SS_SM_STOP_EXT_INFO_SIZE); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+ ");
+
+ SetCmdHist("SS_SM_GET_STOP_EXT_INFO", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ l_extInfo.isProgUpdated =
+ (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_UPDATED) ? TRUE : FALSE;
+
+ // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
+ // because this request is sent by FrameworkunifiedInvokeSync()
+ l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_extInfo, sizeof(l_extInfo));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnGetStopExtInfo( HANDLE hApp )
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnModuleStopCompleteNotification
+///
+/// \param [in]
+///
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnModuleStopCompleteNotification(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+ ");
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ ShutdownComplete l_shutdownNotif; /// \file frameworkunified_framework_types.h
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ // Report any errors found. *
+ // *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < ShutdownComplete > (hApp, l_shutdownNotif))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ PCSTR l_moduleName = l_shutdownNotif.cServiceName;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " '%s' 'Shutdown Complete Status' is 0x%X", l_moduleName,
+ l_shutdownNotif.eShutdownCompleteStatus);
+
+ char l_cBuf[100];
+ snprintf(l_cBuf, sizeof(l_cBuf),
+ "ProcessModuleStopCompleteResponse(%s)", l_moduleName);
+ l_eStatus = ProcessModuleStopCompleteResponse(hApp, l_moduleName);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::onmodulestopcompletenotification( HANDLE hApp )
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CSystemManager::ProcessModuleStopCompleteResponse(HANDLE hApp, PCSTR f_moduleName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ ModuleLaunchListIter l_ModuleListIter;
+ l_eStatus = GetModuleIterator(f_moduleName, l_ModuleListIter);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Module %s not found in Group Launch Map", f_moduleName);
+ } else {
+ switch (m_SMCurrentState) {
+ case SS_SM_READY_TO_LAUNCH_APP:
+ case SS_SM_APPS_LAUNCH_IN_PROGRESS:
+ case SS_SM_APPS_LAUNCHED_READY_TO_START:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Received from client while in "
+ "the '%s' state !!!",
+ GetStr(m_SMCurrentState).c_str());
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ break;
+
+ case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
+ case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
+ case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
+ if (m_SystemStarter.get_id() == SS_SM_THIRD_GROUP) {
+ // Execute shutdown_critical services termination synchronization prior to CoreModule(backupManager termination processing
+ l_ModuleListIter->SetModuleState(MODULE_STATE_STOPPED);
+ if (have_critical_services_stopped()) { // Transition after all critical services have ended
+ ProcessGroupOnModuleStopResponse(hApp, m_SystemStarter.get_id());
+ }
+ } else {
+ l_eStatus = ModuleCompleteResponse(hApp, l_ModuleListIter,
+ MODULE_STATE_STOPPED,
+ (SysMgrCbType3<CSystemManager,
+ &CSystemManager::IsGroupStopped>),
+ (SysMgrCbType2<CSystemManager,
+ &CSystemManager::ProcessGroupOnModuleStopResponse>),
+ "stop");
+ }
+ break;
+
+ case SS_SM_APPS_START_COMPLETE:
+ case SS_SM_APPS_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_RUN_COMPLETE:
+ case SS_SM_APPS_PRE_START_IN_PROGRESS:
+ case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
+ case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
+ case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Received from client while in "
+ "the '%s' state !!!",
+ GetStr(m_SMCurrentState).c_str());
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ break;
+ } // End switch ( m_SMCurrentState )
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::ProcessModuleStopCompleteResponse(
+
+EFrameworkunifiedStatus CSystemManager::ProcessGroupOnModuleStopResponse(HANDLE hApp, UI_32 f_groupID) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ UI_32 l_ActiveGroupId = m_SystemStarter.get_id();
+
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR]);
+
+ if (f_groupID != l_ActiveGroupId) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Group %d stop complete, but m_SystemStarter.get_id() is %d",
+ f_groupID
+ // , m_ActiveGroupId); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ , l_ActiveGroupId);
+ } else {
+ if (!m_SystemStarter.is_begin()) {
+ m_SystemStarter.decrement_id();
+ }
+ check_all_groups_have_stopped(hApp);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::ProcessGroupOnModuleStopResponse( HANDLE hApp
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup stop_all_modules_of_group
+/// Send SS_SM_STOP to all modules of the given group
+///
+/// \param [in]
+///
+///
+/// \return VOID
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::stop_all_modules_of_group(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ModuleLaunchList::reverse_iterator l_revIter;
+
+ UI_32 l_uiMaxGroupWaitTime_sec = 0;
+ UI_32 l_uiMaxGroupWaitTime_msec = 0;
+ UI_32 l_uiModuleWaitTime = 0;
+
+ // GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(m_ActiveGroupId);
+ GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(m_SystemStarter.get_id());
+ if (l_GroupIterator == m_MapProclaunchGrps.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Group %d not found; 'm_MapProclaunchGrps' is empty"
+ //, m_ActiveGroupId); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ , m_SystemStarter.get_id());
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ } else {
+ int l_numModulesMessaged = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopReq grp:%d", m_SystemStarter.get_id());
+
+ T_SS_SM_STOP_DataStructType l_SM_STOP_Struct;
+ l_SM_STOP_Struct.shutdownTrigger = m_shutdownTrigger;
+ l_SM_STOP_Struct.lastUserMode = m_lastUserMode;
+
+ for (l_revIter = l_GroupIterator->second.modules.rbegin();
+ l_revIter != l_GroupIterator->second.modules.rend();
+ l_revIter++) {
+ // LCOV_EXCL_BR_START 11: Excluded due to gcov constraints (others)
+ if ((l_revIter->IsModuleState(MODULE_STATE_START_SENT) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_STARTED) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_START_PRE_SENT) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_STARTED_PRE) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_STOP_PRE_SENT) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_STOPPED_PRE) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_START_BACKGROUND_SENT) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_STARTED_BACKGROUND) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_STOP_BACKGROUND_SENT) == TRUE)
+ || (l_revIter->IsModuleState(MODULE_STATE_STOPPED_BACKGROUND) == TRUE)) {
+ // LCOV_EXCL_BR_STOP 11: Excluded due to gcov constraints (others)
+ if (FRAMEWORKUNIFIED_NS_NPSERVICE == l_revIter->name) {
+ if (epssdmsdtFACTORY_DATA_RESET == m_shutdownTrigger) {
+ CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedDataResetShutdown, eFrameworkunifiedUserData | eFrameworkunifiedFactoryData)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else if (epssdmsdtUSER_DATA_RESET == m_shutdownTrigger) {
+ CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedDataResetShutdown, eFrameworkunifiedUserData)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else if (epssdmsdtFAST_SLEEP_MODE == m_shutdownTrigger) {
+ CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedQuickShutdown)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedNormalShutdown)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ l_revIter->SetModuleState(MODULE_STATE_STOP_FAILED);
+ } else {
+ l_revIter->SetModuleState(MODULE_STATE_STOP_SENT);
+ l_numModulesMessaged++;
+ }
+
+ m_NPPStopSent = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_NPPStopSent is %s", GetStr(m_NPPStopSent).c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ // End else if ( FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIter->name )
+ } else {
+ l_eStatus = l_revIter->SendMsgAndUpdateState(&l_SM_STOP_Struct);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "l_revIter->SendMsgAndUpdateState(&l_SM_STOP_Struct)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (epssdmsdtFAST_SLEEP_MODE == m_shutdownTrigger) {
+ l_uiModuleWaitTime = l_revIter->fast_shutdown_wait_time;
+
+ } else {
+ l_uiModuleWaitTime = l_revIter->shutdown_wait_time;
+ }
+ if (l_uiModuleWaitTime > l_uiMaxGroupWaitTime_sec) {
+ l_uiMaxGroupWaitTime_sec = l_uiModuleWaitTime;
+ }
+ l_numModulesMessaged++;
+ }
+ } // End if MODULE_STATE_STARTED || MODULE_STATE_START_SENT
+ } else if (l_revIter->IsModuleState(MODULE_STATE_INVALID)
+ && FRAMEWORKUNIFIED_NS_NPSERVICE == l_revIter->name) {
+ m_NPPStopSent = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopNotSent:%s is INVALID", FRAMEWORKUNIFIED_NS_NPSERVICE);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopNotSent:%s is %s",
+ l_revIter->name.c_str(),
+ l_revIter->ModuleStateStr().c_str());
+ }
+ }
+
+ if (0 == l_numModulesMessaged) {
+ LogGroupModulesState(m_SystemStarter.get_id() // m_ActiveGroupId // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ , " Warning: NO modules were sent SS_SM_STOP");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopComp grp:%d", l_GroupIterator->second.id);
+
+ if (m_SystemStarter.get_id() > SS_SM_INITIAL_GROUP) {
+ m_SystemStarter.decrement_id();
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " m_ActiveGroupId is now %d", m_SystemStarter.get_id());
+
+ check_all_groups_have_stopped(hApp);
+ }
+ } else {
+ if (epssdmsdtFAST_SLEEP_MODE == m_shutdownTrigger) {
+ // fast shutdown wait time always comes in milli seconds
+ UI_32 l_uiTotalWaitTime = l_uiMaxGroupWaitTime_sec;
+ l_uiMaxGroupWaitTime_sec = l_uiTotalWaitTime / 1000;
+ l_uiMaxGroupWaitTime_msec = l_uiTotalWaitTime % 1000;
+ } else {
+ // Other types of shutdown except fast shutdown always comes in seconds.
+ l_uiMaxGroupWaitTime_msec = 0;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopTimer grp:%d time:%d.%d",
+ m_SystemStarter.get_id(), l_uiMaxGroupWaitTime_sec,
+ l_uiMaxGroupWaitTime_msec);
+ m_GroupLaunchTimer->StartTimerMulti(
+ m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR],
+ l_uiMaxGroupWaitTime_sec, l_uiMaxGroupWaitTime_msec, 0, 0,
+ m_SystemStarter.get_id());
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of VOID CSystemManager::stop_all_modules_of_group(HANDLE hApp)
+
+EFrameworkunifiedStatus CSystemManager::ValidateUserModeMessage(HANDLE hApp, EPWR_USER_MODE_TYPE &l_eUserModeState) { // LCOV_EXCL_START 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ Pwr_ServiceSetInterface tServiceSetIf;
+ EPWR_USER_MODE_TYPE l_my_eUserModeState;
+
+ // ReadMsg(): *
+ // Check hApp ptr, msg size, msg reception, read msg if all ok. *
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, tServiceSetIf))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ l_my_eUserModeState = tServiceSetIf.data.user_mode.mode;
+ switch (l_my_eUserModeState) {
+ case epsumINVALID:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: l_eUserModeState == epsumINVALID");
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+
+ case epsumOFF:
+ case epsumON:
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Validated '%s'",
+ l_my_eUserModeState == epsumON ? "epsumON" : "epsumOFF");
+ l_eUserModeState = l_my_eUserModeState;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ } // End switch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::ValidateUserModeMessage( HANDLE hApp, EPWR_USER_MODE_TYPE &l_eUserModeState )
+// LCOV_EXCL_STOP
+
+//*****************************************************************************
+// Next Wakeup Type Set Protocol functions *
+// *
+EFrameworkunifiedStatus CSystemManager::OnSetNextWakeupTypeRequest(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ ESMNextWakeupType l_wakeupType;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+ SetCmdHist("SS_SM_NEXT_WAKEUP_TYPE_SET_REQ", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < ESMNextWakeupType > (hApp, l_wakeupType))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ switch (l_wakeupType) {
+ case e_SS_SM_NEXT_WAKEUP_TYPE_NONE:
+ case e_SS_SM_NEXT_WAKEUP_TYPE_COLD:
+ case e_SS_SM_NEXT_WAKEUP_TYPE_HOT:
+ break;
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "unknown type(%d)", l_wakeupType);
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ }
+ l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_eStatus, sizeof(l_eStatus));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnSetNextWakeupTypeRequest( HANDLE hApp )
+
+// *
+// End of Boot Mode Protocol functions *
+//*****************************************************************************
+
+
+//*****************************************************************************
+// Data Reset Mode Protocol functions *
+// *
+EFrameworkunifiedStatus CSystemManager::OnSetDataResetModeRequest(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ ESMDataResetModeInfo l_dataResetMode;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ SetCmdHist("SS_SM_DATA_RESET_MODE_SET_REQ", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < ESMDataResetModeInfo > (hApp, l_dataResetMode))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ uint32_t tmp;
+ m_DataResetMode = l_dataResetMode;
+ tmp = static_cast<uint32_t>(m_DataResetMode);
+ if (PowerHalSetResetInfo(AGL_DATARESET_STATE, tmp)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not set AGL_DATARESET_STATE.");
+ // Return error to client of system_manager.
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ //
+ // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
+ // because this request is sent by FrameworkunifiedInvokeSync()
+ //
+ l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_eStatus, sizeof(l_eStatus));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnSetDataResetModeRequest( HANDLE hApp )
+
+EFrameworkunifiedStatus CSystemManager::OnSetProgUpdateStateRequest(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus;
+ SMProgUpdateState l_progUpdateState;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
+
+ SetCmdHist("SS_SM_PROG_UPDATE_STATE_SET_REQ", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < SMProgUpdateState > (hApp, l_progUpdateState))) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ m_ProgUpdateState |= l_progUpdateState;
+ if (PowerHalSetResetInfo(AGL_PROGUPDATE_STATE, m_ProgUpdateState)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not set AGL_PROGUPDATE_STATE.");
+ // return Error to client of system_manager.
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
+ // because this request is sent by FrameworkunifiedInvokeSync()
+ l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_eStatus, sizeof(l_eStatus));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnSetProgUpdateStateRequest( HANDLE hApp )
+
+EFrameworkunifiedStatus CSystemManager::CallStopCompleteHandler(HANDLE hApp, BOOL bIsDetectTimeout /* = FALSE */) {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+
+ if (bIsDetectTimeout) {
+ fprintf(stderr, "SS_SysManager/%s/State StopComplete(timeout)\n", __FUNCTION__);
+ } else {
+ fprintf(stderr, "SS_SysManager/%s/State StopComplete\n", __FUNCTION__);
+ }
+
+ l_eStatus = SecureChipOff();
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: SecureChipOff Failed");
+ }
+
+ l_eStatus = (*m_pfStopCompleteHandler)(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::CallStopCompleteHandler( HANDLE hApp )
+
+
+//*****************************************************************************
+// Soft Reset Protocol functions *
+// *
+static char *get_line(const char *filepath) {
+ char line[LINE_MAX];
+ FILE *fp;
+
+ if ((fp = fopen(filepath, "rb")) == NULL)
+ return NULL;
+ if (fgets(line, LINE_MAX, fp) == NULL) { // LCOV_EXCL_BR_LINE 5:fgets error
+ // LCOV_EXCL_START 5: fgets error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ fclose(fp);
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ fclose(fp);
+
+ return strdup(line);
+}
+
+EFrameworkunifiedStatus CSystemManager::PerformCpuReset(HANDLE hApp,
+ ESMCpuResetReason f_eSmCpuResetReason, std::string f_messageStr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (FALSE == m_isRcvModeInfo) {
+ // If the condition for implementing the CpuReset request is not satisfied, keep the request.
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Cpu Reset Pending");
+ m_isRstPending = TRUE;
+ m_rstPendingInfo.resetReason = f_eSmCpuResetReason;
+ snprintf(m_rstPendingInfo.messageStr,
+ sizeof(m_rstPendingInfo.messageStr), "%s", f_messageStr.c_str());
+ } else {
+ switch (f_eSmCpuResetReason) {
+ case e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR:
+ case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR:
+ case e_SS_SM_CPU_RESET_REASON_DSP_ERR:
+ m_isImmResetReq = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " will reset immediately");
+ // The break is omitted because the same process as for a normal reboot is performed.
+ case e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET:
+ m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager, &CSystemManager::perform_force_reset>);
+ case e_SS_SM_CPU_RESET_REASON_NORMAL: {
+ TSystemManagerCpuResetInfo l_resetInfo;
+
+ l_resetInfo.resetReason = f_eSmCpuResetReason;
+ snprintf(l_resetInfo.messageStr, SS_SM_RESET_MSG_STR_SIZE, "%s", f_messageStr.c_str());
+ l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_CPU_RESET_REQ,
+ sizeof(l_resetInfo), (PVOID) & l_resetInfo);
+ LOG_STATUS(l_eStatus, // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
+ "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_CPU_RESET_REQ)");
+ }
+ break;
+ case e_SS_SM_CPU_RESET_REASON_DATA_RESET: {
+ ESMDataResetType l_eSmDataResetType;
+
+ switch (m_DataResetMode) {
+ case e_SS_SM_DATA_RESET_MODE_FACTORY:
+ l_eSmDataResetType = e_SS_SM_DATA_RESET_TYPE_FACTORY;
+ break;
+ case e_SS_SM_DATA_RESET_MODE_USER:
+ l_eSmDataResetType = e_SS_SM_DATA_RESET_TYPE_USER;
+ l_eStatus = FrameworkunifiedBroadcastEvent(hApp, SS_SM_EVENT_USER_DATA_RESET, NULL, 0);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedBroadcastEvent(SS_SM_EVENT_USER_DATA_RESET)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ break;
+ default:
+ SS_ASERT_LOG(0, "unexpected data reset mode : %d", m_DataResetMode); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+ }
+ if (l_eStatus == eFrameworkunifiedStatusOK) {
+ l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession,
+ SS_SM_REMOTE_DATA_RESET_REQ, sizeof(l_eSmDataResetType),
+ (PVOID) & l_eSmDataResetType);
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_REMOTE_DATA_RESET_REQ)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+ break;
+ case e_SS_SM_CPU_RESET_REASON_INVALID:
+ default:
+ SS_ASERT_LOG(0, " Error: Unknown CPU reset request type: 0x%X/%d", // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ f_eSmCpuResetReason, f_eSmCpuResetReason);
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::PerformCpuReset( ESMCpuResetReason f_eSmCpuResetReason )
+
+//*****************************************************************************
+// CPU Reset Protocol functions *
+// *
+EFrameworkunifiedStatus CSystemManager::OnCpuResetRequest(HANDLE hApp) { // SS_SM_CPU_RESET_REQ
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", l_moduleName.c_str());
+
+ // If you implement FastSleep,
+ // ShutdownTrigger of FrameworkunifiedOnStop needs to be changed to FAST_SLEEP_MODE,
+ // and also MaxShutdownTime needs to be changed to CriticalAppsMaxShutdownTimeFastSleep
+
+ try {
+ TSystemManagerCpuResetInfo l_resetInfo;
+ SetCmdHist("SS_SM_CPU_RESET_REQ", m_SMCmdHist, m_SMHistIter, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < TSystemManagerCpuResetInfo > (hApp, l_resetInfo))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ char l_cBuf[100];
+ EErrorEventType l_errorEventType;
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_loggingInfo.messageStr = l_resetInfo.messageStr;
+ l_loggingInfo.suffixStr = l_resetInfo.suffixStr;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
+ " CPU Reset Reason: '%d'/'%s' from %s",
+ l_resetInfo.resetReason,
+ GetStr(l_resetInfo.resetReason).c_str(),
+ FrameworkunifiedGetMsgSrc(hApp));
+
+ if (e_SS_SM_CPU_RESET_REASON_IMMRESET_NORMAL == l_resetInfo.resetReason) {
+ m_isImmResetReq = TRUE;
+ l_resetInfo.resetReason = e_SS_SM_CPU_RESET_REASON_NORMAL;
+ }
+ switch (l_resetInfo.resetReason) {
+ case e_SS_SM_CPU_RESET_REASON_DATA_RESET:
+ switch (m_DataResetMode) {
+ case e_SS_SM_DATA_RESET_MODE_FACTORY:
+ case e_SS_SM_DATA_RESET_MODE_USER:
+ break;
+ case e_SS_SM_DATA_RESET_MODE_NONE:
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "unexpected data reset mode : %d", m_DataResetMode);
+ throw eFrameworkunifiedStatusInvldParam;
+ }
+ case e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR:
+ case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR:
+ case e_SS_SM_CPU_RESET_REASON_DSP_ERR:
+ case e_SS_SM_CPU_RESET_REASON_NORMAL:
+ l_errorEventType = eErrorEventTypeModuleInvokedResetRequest;
+ l_loggingInfo.resetReason = l_resetInfo.resetReason;
+ break;
+ case e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET:
+ // Separate ErrorEventType only for USER_FORCE_RESET, because the logs to be saved differ.
+ l_errorEventType = eErrorEventTypeUserInvokedUserForceReset;
+ l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET;
+ break;
+ case e_SS_SM_CPU_RESET_REASON_INVALID:
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Unknown CPU reset request type: 0x%X/%d",
+ l_resetInfo.resetReason, l_resetInfo.resetReason);
+ throw eFrameworkunifiedStatusInvldParam;
+ }
+
+ l_eStatus = ErrorEventEnqueue(hApp, l_errorEventType, l_moduleName,
+ eErrorEventResetTypeHard, l_loggingInfo);
+
+ snprintf(l_cBuf, sizeof(l_cBuf), "ErrorEventEnqueue(%s)",
+ GetStr(l_errorEventType).c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+ } catch (EFrameworkunifiedStatus e) {
+ l_eStatus = e;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// *
+// End of CPU Reset Protocol functions *
+//*****************************************************************************
+
+VOID CSystemManager::InitiateAllGroupsShutdown(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ // Prioritize safe termination sequence and do not save logs during termination
+ m_errorEventQueueLocked = TRUE;
+
+ m_MaxShutdownTime = calculate_max_shutdown_time();
+
+ l_eStatus = FrameworkunifiedNPPublishNotification(hApp, NTFY_SSSystemMgrShutdownStarted, NULL, 0);
+
+ SetCmdHist(NTFY_SSSystemMgrShutdownStarted, m_PubCmdHist, m_PubHistIter, ""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "FrameworkunifiedNPPublishNotification(" NTFY_SSSystemMgrShutdownStarted ")");
+
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_START_RESP_MONITOR_WAIT_TIMER]);
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR]);
+
+ // Stop Heartbeat thread activity
+ l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_STOP, NULL, 0);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToHeartBeat(SS_HEARTBEAT_STOP)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ SMSetState(hApp, SS_SM_APPS_STOPPING_AT__CWORD56__REQ);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "shutdownTrigger:%s, lastUserMode:%s",
+ GetStr(m_shutdownTrigger).c_str(), GetStr(m_lastUserMode).c_str());
+
+ fprintf(stderr, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ "SS_SysManager/%s/State shutdownTrigger:%s, lastUserMode:%s\n", // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ __FUNCTION__, GetStr(m_shutdownTrigger).c_str(), // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ GetStr(m_lastUserMode).c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ /// Send SS_SM_STOP to all modules, starting with the m_ActiveGroupId group
+ m_NPPStopSent = FALSE;
+ check_all_groups_have_stopped(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return;
+} // End of EFrameworkunifiedStatus CSystemManager::InitiateAllGroupsShutdown(HANDLE hApp)
+
+VOID CSystemManager::SendDeferMsg(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (!m_dqDeferMsg.empty()) {
+ EFrameworkunifiedStatus l_eStatus;
+ SM_POWER_EVENT_INFO deferMsg;
+
+ deferMsg = m_dqDeferMsg.front();
+ m_dqDeferMsg.pop();
+
+ HANDLE hSender = McOpenSender(SERVICE_SYSMANAGER);
+ if (hSender == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: McOpenSender(SERVICE_SYSMANAGER)");
+ // LCOV_EXCL_STOP
+ } else {
+ CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ McSend(hSender, SERVICE_POWER, deferMsg.first,
+ sizeof(Pwr_ServiceSetInterface),
+ (PVOID) & deferMsg.second));
+ CALL_AND_LOG_STATUS_IF_ERRORED(McClose(hSender)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ return;
+} // End of VOID CSystemManager::SendDeferMsg(HANDLE hApp)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup PublishPowerOnOffNotification
+/// Power Off notification handler
+///
+/// \param [in]
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::PublishPowerOnOffNotification(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = PerformPowerOnOffUserModePublication(hApp, NTFY_SSSystemMgrPowerOnOff);
+
+ SetCmdHist(NTFY_SSSystemMgrPowerOnOff, m_PubCmdHist, m_PubHistIter, "");
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformPowerOnOffUserModePublication()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CSystemManager::PublishUserModeNotification(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = PerformPowerOnOffUserModePublication(hApp, NTFY_SSSystemMgrUserMode);
+
+ SetCmdHist(NTFY_SSSystemMgrUserMode, m_PubCmdHist, m_PubHistIter, "");
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformPowerOnOffUserModePublication()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::PublishUserModeNotification(
+
+EFrameworkunifiedStatus CSystemManager::PerformPowerOnOffUserModePublication(HANDLE hApp, const char * p_NotificationStr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ char l_cBuf[500] = { 0 };
+
+ if (m_SMConfig.UMConfig.IsUserModeNotificationABOOL) {
+ BOOL l_bUuserMode(m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType]);
+
+ snprintf(l_cBuf, sizeof(l_cBuf), "FrameworkunifiedNPPublishNotification(%s, %s)",
+ p_NotificationStr, GetStr(l_bUuserMode).c_str());
+ l_eStatus = FrameworkunifiedNPPublishNotification(hApp, p_NotificationStr,
+ &l_bUuserMode, sizeof(l_bUuserMode));
+ } else {
+ T_SS_SM_UserModeOnOffNotification_Struct l_UserModeOnOffStruct(
+ m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType],
+ m_StartUpReason, m_userModeChangeReason);
+
+ snprintf(l_cBuf, sizeof(l_cBuf),
+ "FrameworkunifiedNPPublishNotification(%s, %s, %s, %s)", p_NotificationStr,
+ GetStr(l_UserModeOnOffStruct.isUserModeOn).c_str(),
+ GetStr(m_StartUpReason).c_str(),
+ GetStr(m_userModeChangeReason).c_str());
+ l_eStatus = FrameworkunifiedNPPublishNotification(hApp, p_NotificationStr,
+ &l_UserModeOnOffStruct, sizeof(l_UserModeOnOffStruct));
+ }
+
+ SetCmdHist(p_NotificationStr, m_PubCmdHist, m_PubHistIter, "");
+ LOG_STATUS(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::PerformPowerOnOffUserModePublication(
+
+EFrameworkunifiedStatus CSystemManager::ResetModulesStateToConnected(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ModuleLaunchListIter l_moduleIter;
+ for (GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.begin();
+ l_GroupIter != m_MapProclaunchGrps.end(); l_GroupIter++) {
+ for (l_moduleIter = l_GroupIter->second.modules.begin();
+ l_moduleIter != l_GroupIter->second.modules.end();
+ l_moduleIter++) {
+ if (l_moduleIter->name == FRAMEWORKUNIFIED_NS_NPSERVICE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s ( Group %d/%s ) is %s",
+ l_moduleIter->name.c_str(), l_GroupIter->second.id,
+ l_GroupIter->second.name.c_str(),
+ l_moduleIter->ModuleStateStr().c_str());
+ l_moduleIter->SetModuleState(MODULE_STATE_STARTED); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ // End else if ( FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIter->name )
+ } else {
+ switch (l_moduleIter->GetModuleState()) {
+ case MODULE_STATE_INVALID:
+ case MODULE_STATE_SKIPPED:
+ case MODULE_STATE_LAUNCHING:
+ case MODULE_STATE_LAUNCHED:
+ case MODULE_STATE_LAUNCH_FAILED:
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " %s ( Group %d/%s ) is %s, NOT setting to "
+ "MODULE_STATE_CONNECTED",
+ l_moduleIter->name.c_str(), l_GroupIter->second.id,
+ l_GroupIter->second.name.c_str(),
+ l_moduleIter->ModuleStateStr().c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ break;
+
+ case MODULE_STATE_STARTED:
+ case MODULE_STATE_START_SENT:
+ case MODULE_STATE_CONNECTED:
+ case MODULE_STATE_START_FAILED:
+ case MODULE_STATE_STOP_FAILED:
+ case MODULE_STATE_STOP_SENT:
+ case MODULE_STATE_STOPPED:
+ case MODULE_STATE_START_PRE_SENT:
+ case MODULE_STATE_START_PRE_FAILED:
+ case MODULE_STATE_STARTED_PRE:
+ case MODULE_STATE_STOP_PRE_SENT:
+ case MODULE_STATE_STOP_PRE_FAILED:
+ case MODULE_STATE_STOPPED_PRE:
+ case MODULE_STATE_START_BACKGROUND_SENT:
+ case MODULE_STATE_START_BACKGROUND_FAILED:
+ case MODULE_STATE_STARTED_BACKGROUND:
+ case MODULE_STATE_STOP_BACKGROUND_SENT:
+ case MODULE_STATE_STOP_BACKGROUND_FAILED:
+ case MODULE_STATE_STOPPED_BACKGROUND:
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s ( Group %d/%s ) is %s",
+ l_moduleIter->name.c_str(), l_GroupIter->second.id,
+ l_GroupIter->second.name.c_str(),
+ l_moduleIter->ModuleStateStr().c_str());
+ l_moduleIter->SetModuleState(MODULE_STATE_CONNECTED);
+ break;
+ // default: Don't code a 'default' here - let the compiler
+ // issue a warning ( set via -Wall or -Wswitch ) when the set of
+ // enumerations changes - then the maintainer will
+ // automagically know to update this switch statement.
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::ResetModulesStateToConnected(HANDLE hApp)
+
+EFrameworkunifiedStatus CSystemManager::On_CWORD56_HeartBeatRequest(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ PCSTR l_senderName = FrameworkunifiedGetMsgSrc(hApp);
+
+ SetCmdHist("SS_SM__CWORD56__HEARTBEAT_REQ", m_SMCmdHist, m_SMHistIter, l_senderName);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, " Received from %s", l_senderName);
+ EPWR_HB_REQ_MSG_STRUCT l_hbReq;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < EPWR_HB_REQ_MSG_STRUCT > (hApp, l_hbReq))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+
+ m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER__CWORD56__HEARTBEAT_RESPONSE]);
+
+ if (l_hbReq.IntervalSec > 0) {
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER__CWORD56__HEARTBEAT_RESPONSE], 0, 0,
+ l_hbReq.IntervalSec, 0);
+ } else if (l_hbReq.IntervalSec == 0) { // LCOV_EXCL_BR_LINE 8: As the condition is never false
+ l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN, 0, NULL);
+
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSystemManager::On_CWORD56_HeartBeatResponseIntervalTimerExpiry(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ SetCmdHist("SM_TIMER__CWORD56__HEARTBEAT_RESPONSE", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN, 0, NULL);
+
+ LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+// EOF of /SS_SystemManager/src/ss_system_manager_callbacks.cpp
+
diff --git a/systemservice/system_manager/server/src/ss_system_manager_error_event.cpp b/systemservice/system_manager/server/src/ss_system_manager_error_event.cpp
new file mode 100755
index 0000000..131b86a
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_system_manager_error_event.cpp
@@ -0,0 +1,945 @@
+/*
+ * @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 IAT error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/mman.h>
+#include <sys/procfs.h>
+#include <libgen.h>
+#include <spawn.h>
+#include <errno.h>
+#include <sys/timeb.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_client_names.h>
+#include <system_service/ss_power_service_if.h>
+#include <processlauncher/ProcessLauncher_if.h>
+#include <processlauncher/ss_sm_process_launcher_protocol.h>
+#include <processlauncher/ss_sm_process_launcher.h>
+#include <heartbeat/ss_hb_if.h>
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <stub/ss_diag.h>
+#include <system_service/ss_test_clients.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/frameworkunified_application.h>
+
+#include <system_service/ss_sm_thread_names.h>
+#include <system_service/ss_templates.h>
+#include <native_service/ns_plogger_if.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <native_service/ns_np_service_nor_persistence.h>
+#include <boost/bind.hpp>
+#include <string>
+#include "ss_system_manager.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_sm_default_paths.h"
+#include "ss_sm_version.h"
+
+template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)>
+ EFrameworkunifiedStatus SysMgrCallback(HANDLE hApp) { // LCOV_EXCL_START 6: Can not set condition
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
+ if (pObj) {
+ l_eStatus = (pObj->*M)(hApp);
+ }
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+//******************************************************************************
+void Init_EErrorEventReset_StrMap(std::map<EErrorEventResetType, SS_String> & m_strMap) { // NOLINT
+ MAP_ENTRY(m_strMap, eErrorEventResetTypeNone); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ MAP_ENTRY(m_strMap, eErrorEventResetTypeHard); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+}
+class EnumStringMap<EErrorEventResetType, Init_EErrorEventReset_StrMap> m_oEErrorEventResetTypeMap;
+SS_String GetStr(EErrorEventResetType f_enum) { // LCOV_EXCL_START 6: Can not set condition
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_oEErrorEventResetTypeMap.GetStr(f_enum);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ErrorEventInit
+/// This function initializes the error event handling subsystem.
+/// This function MUST be called by System Manager initialization.
+///
+/// \param HANDLE f_hApp AGL FW application handle.
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::ErrorEventInit(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ Timer *l_pTimer;
+
+ m_isPrevErrEventCompleted = TRUE;
+ m_errorEventResult = eFrameworkunifiedStatusOK;
+ m_errorEventQueueLocked = FALSE;
+ m_errorEventCurrentIter = m_errorEventQueue.end();
+
+ l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ];
+ l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_LOGGER_START_REQ,
+ boost::bind(&CSystemManager::OnErrorEventLoggerStartRequestTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN];
+ l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_DEBUG_DUMP_RSPN,
+ boost::bind(&CSystemManager::OnDebugDumpCompleteTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_BOOT_MICRO_LOG_RSPN];
+ l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_BOOT_MICRO_LOG_RSPN,
+ boost::bind(&CSystemManager::OnErrorEventBootMicroLogResponseTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_pTimer = &m_errorEventTimers[eSM_ERROR_EVENT_TIMER_CORE_FILE_POLL];
+ l_pTimer->Initialize(f_hApp, SS_SM_ERROR_EVENT_TIMER_ID_CORE_FILE_POLL,
+ boost::bind(&CSystemManager::OnErrorEventCoreFilePollTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ErrorEventEnqueue
+/// Conditional queue error events for processing by the error event state
+/// machine.
+///
+/// \param f_hApp Handle to AGL application.
+///
+/// \param f_eventType Error event type.
+///
+/// \param f_moduleQueueName Error event trigger module queue name.
+///
+/// \param f_resetType Error event reset type (none, hard).
+///
+/// \param f_loggingInfo Logging information if applicable (optional).
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::ErrorEventEnqueue(HANDLE f_hApp,
+ EErrorEventType f_eventType, std::string &f_moduleQueueName,
+ EErrorEventResetType f_resetType, const SMLoggingInfo &f_loggingInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ERROR_EVENT_INFO l_errorEventInfo;
+ ERROR_EVENT_QUEUE_ITER l_errorEventIter;
+ ERROR_EVENT_QUEUE_RET l_retVal;
+ BOOL isErrorReset = FALSE;
+
+ if (eErrorEventResetTypeHard == f_resetType) {
+ // Forced reset if shutdown process is not completed after Reboot requesting
+ m_GroupLaunchTimer->StartTimer(
+ m_aTimerIDs[eSM_TIMER_SHUTDOWN_COMPLETE_MONITOR],
+ SM_SHUTDOWN_COMPLETE_MONITOR_TIMEOUT, 0, 0, 0);
+
+ switch (f_loggingInfo.resetReason) {
+ case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR:
+ case e_SS_SM_CPU_RESET_REASON_DSP_ERR:
+ isErrorReset = TRUE;
+ break;
+ default:
+ break;
+ }
+ // LCOV_EXCL_START 6:This variable cannot be modified by external API
+ if ((m_ResetCount > SS_SM_ERR_NAVI_RESET_LIMIT) && isErrorReset) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6:This variable cannot be modified by external API (evaluated only initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ fprintf(stderr,
+ "SS_SysManager/%s:will NAVIDET as continuous error(%d) \n", __FUNCTION__, m_ResetCount);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "will NAVIDET as continuous error(%d)", m_ResetCount);
+ m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager, &CSystemManager::perform_force_reset>);
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (TRUE == m_errorEventQueueLocked) {
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. The Error Event Queue has been locked. No further items may be enqueued. System reset pending."); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ } else {
+ GetTimeStamp(l_errorEventInfo.m_eventEnqueueTimeStamp);
+
+ l_errorEventInfo.m_moduleQueueName = f_moduleQueueName;
+ l_errorEventInfo.m_eventType = f_eventType;
+ l_errorEventInfo.m_errorEventResetType = f_resetType;
+ l_errorEventInfo.m_loggingInfo = f_loggingInfo;
+ l_errorEventInfo.m_prio = eErrorEventPrioDefault; // Make Prios of all ErrorEvent first-win as default
+ // It needs to add eErrorEventPrioxxx properly if design modification about priority required
+
+ if (eErrorEventResetTypeNone != f_resetType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " System will reset after logging");
+ }
+
+ l_retVal = m_errorEventQueue.insert(l_errorEventInfo);
+ if (FALSE == l_retVal.second) {
+ std::string l_errorEventName = GetStr(l_errorEventInfo.m_eventType);
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: %s is already queued or is in progress. Event dropped.", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_errorEventName.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ }
+
+ l_eStatus = ErrorEventProcessNext(f_hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "ErrorEventProcessNext()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup PerformResetAfterLogging
+/// perform CPU reset after logging complete
+///
+/// \param f_hApp Handle to AGL application.
+/// f_eCpuResetReason CPU reset reason
+/// f_messageStr Error message string
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::PerformResetAfterLogging(HANDLE f_hApp,
+ ESMCpuResetReason f_eCpuResetReason, std::string f_messageStr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = PerformCpuReset(f_hApp, f_eCpuResetReason, f_messageStr);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformCpuReset()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_BR_START 200: Can not satisfy the condition for calling from caller
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 200: Can not satisfy the condition for calling from caller
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT_LOG(0, "PerformCpuReset() : %d", l_eStatus);
+ // Erasing ErrorEvent only if resetting process is failed
+ m_errorEventQueue.erase(m_errorEventCurrentIter); // Erase last processed event.
+ // LCOV_EXCL_STOP
+ } else {
+ m_errorEventQueueLocked = TRUE; // Permanent lock until post reset.
+ m_errorEventQueue.clear(); // Drop queued events.
+ SendDeferMsg(f_hApp);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ErrorEventProcessNext
+/// Process the next error event from error event queue.
+///
+/// \param f_hApp Handle to AGL application.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///
+/// \Notes (1) Removal from the queue occurs AFTER the entry has been processed
+/// AND just before the NEXT entry is to be obtained. Therefore,
+/// the first item enqueued MUST not be removed since it has not
+/// been processed. This is ensured by setting the iterator to END
+/// during module initialization. After processing the first event,
+/// the iterator will no longer be END until all events have been
+/// processed.
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::ErrorEventProcessNext(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ERROR_EVENT_QUEUE_ITER l_errorEventIter;
+ SMErrorEventNtfData l_errorEventNtfData;
+
+ if (TRUE == m_isPrevErrEventCompleted) { // Remove last completed item from front of queue.
+ // See Note #1.
+ if ((0 != m_errorEventQueue.size()) &&
+ (m_errorEventQueue.end() != m_errorEventCurrentIter)) {
+ // Completed logging by ErrorEvent
+ switch (m_errorEventCurrentIter->m_errorEventResetType) {
+ case eErrorEventResetTypeNone:
+ switch (m_errorEventCurrentIter->m_eventType) {
+ case eErrorEventTypeInterfaceunifiedEmmcLogs:
+ case eErrorEventTypeUserInvokedClearLogs:
+ if (eFrameworkunifiedStatusOK == m_errorEventResult) {
+ if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, 0)) {
+ // Logging only.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not reset AGL_ERRLOG_COUNTER");
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (eErrorEventTypeInterfaceunifiedEmmcLogs == m_errorEventCurrentIter->m_eventType) {
+ HANDLE hSession = FrameworkunifiedMcOpenSender(f_hApp,
+ m_errorEventCurrentIter->m_moduleQueueName.c_str());
+
+ if (hSession == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK // LCOV_EXCL_BR_LINE 4: NSFW error case
+ != FrameworkunifiedSendMsg(hSession,
+ SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_RSPN,
+ sizeof(m_errorEventResult),
+ &m_errorEventResult)) {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedMcClose(hSession)) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ m_errorEventQueue.erase(m_errorEventCurrentIter); // Erase last processed event.
+ break;
+ case eErrorEventResetTypeHard:
+ TEXT(__FUNCTION__, "ERROR EVENT: Hard reset required for previously processed error event." // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ "Initiating reset and flushing logging queue."); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != m_errorEventResult) {
+ // Logging at next launching by setting L to NaviDet if logging failed before rebooting
+ fprintf(stderr,
+ "SS_SysManager/%s:will NAVIDET as LOG save failed\n", __FUNCTION__);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "will NAVIDET as LOG save failed");
+ m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager,
+ &CSystemManager::perform_force_reset>);
+ }
+
+ if ((m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR) ||
+ (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_GENERIC_ERR) ||
+ (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_DSP_ERR) ||
+ (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET)) {
+ BOOL l_user_reset = FALSE;
+ if (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET) {
+ l_user_reset = TRUE;
+ }
+ m_ResetFactor = GetResetFactor(m_errorEventCurrentIter->m_moduleQueueName.c_str(), l_user_reset);
+ }
+
+ l_eStatus = PerformResetAfterLogging(f_hApp,
+ m_errorEventCurrentIter->m_loggingInfo.resetReason,
+ m_errorEventCurrentIter->m_loggingInfo.messageStr); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "PerformResetAfterLogging()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ break;
+ // LCOV_EXCL_START 6:Can not satisfy condition to branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unknown reset type encountered: 0x%X/%d. No action taken.",
+ m_errorEventCurrentIter->m_errorEventResetType,
+ m_errorEventCurrentIter->m_errorEventResetType);
+ break;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ // Check if a new work item exists.
+ if (0 != m_errorEventQueue.size()) {
+ // ErrorEvent startup process
+ m_errorEventCurrentIter = m_errorEventQueue.begin();
+
+ l_errorEventNtfData.EventType = m_errorEventCurrentIter->m_eventType;
+
+ if (eErrorEventResetTypeHard == m_errorEventCurrentIter->m_errorEventResetType) {
+ l_errorEventNtfData.isNeedReboot = TRUE;
+ } else {
+ l_errorEventNtfData.isNeedReboot = FALSE;
+ }
+
+ // Check BufferSize
+ size_t modl_len = sizeof(l_errorEventNtfData.ModuleName) - 1;
+
+ // SS Logger uses the l_errorEventNtfData.ModuleName as the LOGGERSERVICE_EMMC_LOGS and
+ // EEL_EXPORT destination path. eErrorEventTypeDiagEvent sends the destination path.
+ // For all other event types, the binary name is sent to logger.
+ // LCOV_EXCL_BR_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ if ((eErrorEventTypeInterfaceunifiedEmmcLogs
+ == m_errorEventCurrentIter->m_eventType) ||
+ (eErrorEventTypeEelExport
+ == m_errorEventCurrentIter->m_eventType) ||
+ (eErrorEventTypeDiagEvent
+ == m_errorEventCurrentIter->m_eventType)) {
+ // LCOV_EXCL_BR_STOP
+ strncpy(l_errorEventNtfData.ModuleName,
+ m_errorEventCurrentIter->m_loggingInfo.path.c_str(),
+ sizeof(l_errorEventNtfData.ModuleName) - 1);
+
+ size_t path_len = strlen(m_errorEventCurrentIter->m_loggingInfo.path.c_str());
+ if (path_len > modl_len) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Input buffer size over. input : %ld, enable : %ld",
+ path_len, modl_len);
+ }
+ l_errorEventNtfData.ModuleName[sizeof(l_errorEventNtfData.ModuleName) - 1] = 0;
+ } else {
+ strncpy(l_errorEventNtfData.ModuleName,
+ m_errorEventCurrentIter->m_loggingInfo.suffixStr.c_str(),
+ sizeof(l_errorEventNtfData.ModuleName) - 1);
+ }
+
+ // When the Reboot process is started during the execution of the LOG save sequence, an undefined value was set
+ // in m_errorEventCurrentIter. Therefore, the Reboot start timing due to an error in SS_Loger was changed from
+ // the time of ErrorEvent queuing to the time of dequeuing.
+
+ // LCOV_EXCL_BR_START 6: Because the following conditions cannot be satisfied when called from an external API
+ if ((SERVICE_LOGGER == m_errorEventCurrentIter->m_moduleQueueName)
+ && ((eErrorEventTypeProcessCrash
+ == m_errorEventCurrentIter->m_eventType)
+ || (eErrorEventTypeProcessExit
+ == m_errorEventCurrentIter->m_eventType)
+ || (eErrorEventTypeHeartBeatFailure
+ == m_errorEventCurrentIter->m_eventType)
+ || (eErrorEventTypeModConnFailed
+ == m_errorEventCurrentIter->m_eventType)
+ || (eErrorEventTypeStartRespFailed
+ == m_errorEventCurrentIter->m_eventType))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: Because the following conditions cannot be satisfied when called from an external API
+ // Note: If logger crashes, a core file will exist.
+ std::string l_hmiDispStr;
+ l_hmiDispStr = SERVICE_LOGGER;
+ if (eErrorEventResetTypeNone != m_errorEventCurrentIter->m_errorEventResetType) {
+ l_hmiDispStr += " - Shutting down, check for core file.";
+
+ // Since LOG save cannot be performed when an SSL error is detected, the LOG is saved at the next startup
+ // by rebooting with NaviDet = L after completion of the process.
+ fprintf(stderr, "SS_SysManager/%s:will NAVIDET as SSL dead\n", __FUNCTION__);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "will NAVIDET as SSL dead");
+ m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager,
+ &CSystemManager::perform_force_reset>);
+
+ m_ResetFactor = GetResetFactor(SERVICE_LOGGER, FALSE);
+
+ l_eStatus = PerformResetAfterLogging(f_hApp,
+ e_SS_SM_CPU_RESET_REASON_GENERIC_ERR);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformResetAfterLogging()");
+ } else {
+ l_hmiDispStr += " - Check for core file.";
+ }
+
+ SMErrorEventNtfData l_errorEventNtfData;
+ l_errorEventNtfData.EventType = m_errorEventCurrentIter->m_eventType;
+ l_errorEventNtfData.isNeedReboot = FALSE;
+ snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName), "%s",
+ l_hmiDispStr.c_str());
+
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, // Show indication on HMI.
+ SS_SM_EVENT_ERROR,
+ NULL, &l_errorEventNtfData, sizeof(l_errorEventNtfData));
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR)");
+ } else if (m_errorEventCurrentIter->m_eventType == eErrorEventTypeModuleInvokedResetRequest
+ && (m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_NORMAL
+ || m_errorEventCurrentIter->m_loggingInfo.resetReason == e_SS_SM_CPU_RESET_REASON_DATA_RESET)) {
+ l_eStatus = PerformResetAfterLogging(f_hApp,
+ m_errorEventCurrentIter->m_loggingInfo.resetReason,
+ m_errorEventCurrentIter->m_loggingInfo.messageStr); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformResetAfterLogging()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ } else {
+ BOOL bIsNeedLogging = TRUE;
+
+ {
+ UI_32 l_ErrLogCount = 0;
+ if (PowerHalGetResetInfo(AGL_ERRLOG_COUNTER, &l_ErrLogCount)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not get AGL_ERRLOG_COUNTER form power_hal, assume to 0.");
+ l_ErrLogCount = 0;
+ }
+
+ {
+ if ((l_ErrLogCount >= SS_SM_ERR_LOGGING_LIMIT)
+ && (eErrorEventResetTypeHard == m_errorEventCurrentIter->m_errorEventResetType)) {
+ fprintf(stderr, "SS_SysManager/%s:Skip Logging by continuous error \n", __FUNCTION__);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Skip Logging by continuous error ");
+
+ m_ResetFactor = PSM_FACTOR_AGL_WITH_HISTORY;
+
+ l_eStatus =
+ PerformResetAfterLogging(f_hApp,
+ m_errorEventCurrentIter->m_loggingInfo.resetReason,
+ m_errorEventCurrentIter->m_loggingInfo.messageStr);
+ LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformResetAfterLogging()");
+ bIsNeedLogging = FALSE;
+ } else if (eErrorEventResetTypeHard
+ == m_errorEventCurrentIter->m_errorEventResetType) {
+ l_ErrLogCount++;
+ if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, l_ErrLogCount)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not set AGL_ERRLOG_COUNTER to power_hal.");
+ }
+ }
+ }
+ }
+
+ if (bIsNeedLogging) {
+ m_isPrevErrEventCompleted = FALSE;
+ m_errorEventResult = eFrameworkunifiedStatusOK;
+ BOOL result =
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ].Start(
+ SS_ERROR_EVENT_START_REQ_TO_SEC, 0, 0, 0);
+ if (FALSE == result) { // LCOV_EXCL_BR_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed to start timer eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ.");
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp,
+ SS_SM_EVENT_ERROR_TO_SSL,
+ NULL, &l_errorEventNtfData,
+ sizeof(l_errorEventNtfData));
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR_TO_SSL, "
+ "module name (optional): '%s', "
+ "event type: %d) returned '%d'/'%s'",
+ l_errorEventNtfData.ModuleName,
+ l_errorEventNtfData.EventType, l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ }
+ }
+ }
+
+ // If Reboot has been started up to this point, m_errorEventQueue is cleared and checking is performed at the end because m_errorEventQueue is cleared.
+ if (0 == m_errorEventQueue.size()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Error Event queue empty. Error logging complete.");
+ m_errorEventCurrentIter = m_errorEventQueue.end(); // Invalidate iterator in case of spurious events.
+ SendDeferMsg(f_hApp);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnLoggingStartRequestFromSL
+/// This function gets called when System Logger initiates artifact
+/// collection for a trigger source that originates within System
+/// Logger or as a result of System Manager raising a logging
+/// event notification to System Logger.
+///
+/// \param [in] hApp
+/// HANDLE - Handle of the Client Application
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnLoggingStartRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ModuleLaunchListIter l_ModuleListIter;
+ HANDLE l_hLoggerServiceSession;
+ EErrorEventType l_eventType;
+ SMErrorEventNtfData l_errorEventNtfData;
+
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ].Stop();
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp);
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg < EErrorEventType > (f_hApp, l_eventType))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (0 == m_errorEventQueue.size()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Logging start request received for event type: %d/'%s', "
+ "but the logging queue is empty.!", l_eventType,
+ GetStr(l_eventType).c_str());
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else if (m_errorEventCurrentIter == m_errorEventQueue.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Logging start request received for event type: %d/'%s', "
+ "but the current event iterator is invalid.",
+ l_eventType, GetStr(l_eventType).c_str());
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else if (m_errorEventCurrentIter->m_eventType != l_eventType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Logging start request received for event type: %d/'%s', "
+ "but current work item is for event type: %d/'%s'.",
+ l_eventType, GetStr(l_eventType).c_str(),
+ m_errorEventCurrentIter->m_eventType,
+ GetStr(m_errorEventCurrentIter->m_eventType).c_str());
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ l_errorEventNtfData.EventType = l_eventType;
+ l_errorEventNtfData.isNeedReboot = FALSE;
+
+ // For boot micro reset, customize the string as per the reset reason.
+ if (l_eventType == eErrorEventTypeBootMicroReset) {
+ switch (m_BootMicroResetReason) {
+ case SS_SM_BOOT_MICRO_RESET_REASON_SELF_RESET:
+ (void) snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName),
+ "Boot Micro Reset. Reason: %d, Self Reset",
+ m_BootMicroResetReason);
+ break;
+
+ case SS_SM_BOOT_MICRO_RESET_REASON_USER_FORCE_RESET: // User Force Reset timeout.
+ (void) snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName),
+ "Boot Micro Reset. Reason: %d, UFR Timeout",
+ m_BootMicroResetReason);
+ break;
+
+ case SS_SM_BOOT_MICRO_RESET_REASON_DSP_RESET:
+ (void) snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName),
+ "Boot Micro Reset. Reason: %d, DSP Reset",
+ m_BootMicroResetReason);
+ break;
+
+ case SS_SM_BOOT_MICRO_RESET_REASON_HB_TIMEOUT:
+ (void) snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName),
+ "Boot Micro Reset. Reason: %d, HB Timeout",
+ m_BootMicroResetReason);
+ break;
+
+ default:
+ (void) snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName),
+ "Boot Micro Reset. Reason: %d, Unknown",
+ m_BootMicroResetReason);
+ break;
+ }
+ } else {
+ // All other error event types format =
+ // Binary Name <circumstantial> PID: TID: Additional info: </circumstantial>
+ std::string l_hmiDispStr = ErrorEventCreateHmiDisplayString();
+
+ (void) snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName), "%s",
+ l_hmiDispStr.c_str());
+ }
+
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_SM_EVENT_ERROR, // To HMI
+ NULL, &l_errorEventNtfData, sizeof(l_errorEventNtfData));
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR)");
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = GetModuleIterator(SERVICE_LOGGER, l_ModuleListIter))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: GetModuleIterator(%s) errored: %d/'%s'",
+ SERVICE_LOGGER, l_eStatus, GetStr(l_eStatus).c_str());
+ } else {
+ l_hLoggerServiceSession = l_ModuleListIter->hsession;
+
+ l_eStatus = FrameworkunifiedSendMsg(l_hLoggerServiceSession,
+ SS_SM_ERROR_EVENT_LOGGING_START_RSPN, 0, NULL);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedSendMsg(SS_SM_ERROR_EVENT_LOGGING_START_RSPN)");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnErrorEventLoggerStartRequestTimeout
+///
+/// \brief This function is called if System Logger fails to respond in a
+/// timely fashion to the published logger start request event
+/// SS_SM_EVENT_ERROR_TO_SSL. See OnLoggingStartRequest() which
+/// is the expected path should the timer period NOT expire.
+///
+/// \param [in] hApp
+/// HANDLE - Handle of the Client Application
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnErrorEventLoggerStartRequestTimeout(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SMErrorEventNtfData l_errorEventNtfData;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Logger failed to respond to message SS_SM_EVENT_ERROR_TO_SSL in a timely fashion. Logging aborted.");
+
+ // Publish to HMI even if the error event will not be processed.
+ // In this way, developers can be made aware of the error condition
+ // and determine why logging did not proceed as expected.
+ if (m_errorEventCurrentIter != m_errorEventQueue.end()) {
+ l_errorEventNtfData.EventType = m_errorEventCurrentIter->m_eventType;
+ l_errorEventNtfData.isNeedReboot = FALSE;
+
+ std::string l_hmiDispStr = ErrorEventCreateHmiDisplayString();
+ snprintf(l_errorEventNtfData.ModuleName,
+ sizeof(l_errorEventNtfData.ModuleName), "%s.", l_hmiDispStr.c_str());
+
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_SM_EVENT_ERROR, // To HMI
+ NULL, &l_errorEventNtfData, sizeof(l_errorEventNtfData)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_SM_EVENT_ERROR)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ m_isPrevErrEventCompleted = TRUE;
+ m_errorEventResult = eFrameworkunifiedStatusFail;
+ l_eStatus = ErrorEventProcessNext(f_hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "ErrorEventProcessNext()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSystemManager::OnErrorEventLoggingComplete(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hLoggerServiceSession;
+ ModuleLaunchListIter l_ModuleListIter;
+
+ // If logger does not send a logging start and instead immediately
+ // sends a logging complete response, then the start timer must be
+ // stopped to prevent a start response timeout from occuring.
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_LOGGER_START_REQ].Stop();
+
+ m_errorEventResult = eFrameworkunifiedStatusFail;
+ if (sizeof(m_errorEventResult) != FrameworkunifiedGetMsgLength(f_hApp)) {
+ LOG_ERROR("DataSize mismatch");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &m_errorEventResult,
+ sizeof(m_errorEventResult), eSMRRelease))) {
+ LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "m_errorEventResult = %d", m_errorEventResult);
+ }
+ m_isPrevErrEventCompleted = TRUE;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = GetModuleIterator(SERVICE_LOGGER, l_ModuleListIter))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: GetModuleIterator(%s) errored: %d/'%s'",
+ SERVICE_LOGGER, l_eStatus, GetStr(l_eStatus).c_str());
+ } else {
+ l_hLoggerServiceSession = l_ModuleListIter->hsession;
+
+ l_eStatus = FrameworkunifiedSendMsg(l_hLoggerServiceSession,
+ SS_SM_ERROR_EVENT_LOGGING_COMPLETE_RSPN, 0, NULL);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedSendMsg(SS_SM_ERROR_EVENT_LOGGING_START_RSPN)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " Info. Done processing error event %s.",
+ GetStr(m_errorEventCurrentIter->m_eventType).c_str());
+
+ l_eStatus = ErrorEventProcessNext(f_hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "ErrorEventProcessNext()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ActOnModuleFailure
+/// This function is called to take appropriate action of the failure
+/// reported by heart beat or crash detector. Attributes set in
+/// Launch configuration file are considered while taking action
+/// on the failed module.
+///
+/// \param f_hApp AGL FW application handle.
+/// f_moduleName Failed module name.
+/// f_refSoftResetRequired Return parameter indicating if a
+/// soft reset will be required.
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+const CHAR RestartModule[] = "me";
+
+EFrameworkunifiedStatus CSystemManager::ActOnModuleFailure(HANDLE f_hApp,
+ SS_String f_moduleName, BOOL &f_refResetRequired) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ ModuleLaunchListIter l_ModuleListIter;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ESMPLThreadCommandIds l_PLCmd = ePLThrdCmd_NONE;
+ SS_String l_PLCmdStr = "";
+
+ f_refResetRequired = FALSE;
+
+ l_eStatus = GetModuleIterator(f_moduleName.c_str(), l_ModuleListIter);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Module %s not found in Group Launch Map", f_moduleName.c_str());
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (eFrameworkunifiedStatusDbRecNotFound);
+ }
+
+ // LCOV_EXCL_BR_START 6: Because the condition cannot be set
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = RemoveModuleEntryFromHB(f_hApp,
+ l_ModuleListIter->name.c_str()))) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: RemoveModuleEntryFromHB(%s) errored: %d/'%s'",
+ l_ModuleListIter->name.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ }
+
+ if (TRUE == l_ModuleListIter->critical
+ && (l_ModuleListIter->relaunch_count >= l_ModuleListIter->retry_cnt)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Critical module '%s' re-launch counter exceeded limit (%d).",
+ l_ModuleListIter->name.c_str(), l_ModuleListIter->retry_cnt);
+
+ l_ModuleListIter->SetModuleState(MODULE_STATE_SKIPPED);
+
+ // Module has crossed re-launched limit and is not going to be re-launched.
+ // It must however still be terminated.
+ l_PLCmd = ePLThrdCmd_TERMINATE_MODULE_REQST;
+ l_PLCmdStr = "ePLThrdCmd_TERMINATE_MODULE_REQST";
+
+ // Module is critical. Restart system.
+ f_refResetRequired = TRUE;
+ // Restart required?
+ } else if (0 == std::strcmp(l_ModuleListIter->restart.c_str(), RestartModule)) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Module: %s, relaunch_count: %d",
+ l_ModuleListIter->name.c_str(),
+ l_ModuleListIter->relaunch_count);
+
+ if (l_ModuleListIter->relaunch_count < l_ModuleListIter->retry_cnt) {
+ SS_String l_ModulePath = (m_BinaryFilesPath + l_ModuleListIter->path);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
+ " Requesting ReLaunch of '%s' '%s'",
+ l_ModuleListIter->name.c_str(), l_ModulePath.c_str());
+
+ l_PLCmd = ePLThrdCmd_RELAUNCH_MODULE_REQST;
+ l_PLCmdStr = "ePLThrdCmd_RELAUNCH_MODULE_REQST";
+ l_ModuleListIter->relaunch_count++;
+ l_ModuleListIter->relaunch_status = RelaunchErr;
+ } else if ((FALSE == l_ModuleListIter->critical)
+ && (l_ModuleListIter->relaunch_count
+ >= l_ModuleListIter->retry_cnt)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: Skipping re-launch of non-critical %s module, "
+ "re-launch counter exceeded limit(%d). Terminating module.",
+ l_ModuleListIter->name.c_str(),
+ l_ModuleListIter->retry_cnt);
+
+ l_ModuleListIter->SetModuleState(MODULE_STATE_SKIPPED);
+
+ // non critical module has crossed re-launched limit and is not going to be re-launched.
+ // We must terminate the module in the event that it has become non responsive.
+ l_PLCmd = ePLThrdCmd_TERMINATE_MODULE_REQST;
+ l_PLCmdStr = "ePLThrdCmd_TERMINATE_MODULE_REQST";
+ }
+ // LCOV_EXCL_STOP
+ } else { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
+ // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: %s is not required to be re-launched, "
+ "skipping re-launch and terminating module.",
+ l_ModuleListIter->name.c_str());
+
+ l_ModuleListIter->SetModuleState(MODULE_STATE_SKIPPED);
+
+ // Module restart not required.
+ // We must terminate the module in the event that it has become non responsive.
+ l_PLCmd = ePLThrdCmd_TERMINATE_MODULE_REQST;
+ l_PLCmdStr = "ePLThrdCmd_TERMINATE_MODULE_REQST";
+ // LCOV_EXCL_STOP
+ }
+
+
+ if (ePLThrdCmd_NONE != l_PLCmd) {
+ l_eStatus = SendRequestToLauncher(f_hApp, l_ModuleListIter, l_PLCmd, l_PLCmdStr); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToLauncher()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ErrorEventCreateHmiDisplayString
+///
+/// \brief Create error event HMI colored square display string.
+///
+/// \return Error Display String.
+///////////////////////////////////////////////////////////////////////////////
+std::string CSystemManager::ErrorEventCreateHmiDisplayString(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::stringstream l_displayNamess; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::stringstream l_pidss; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::stringstream l_hmiDispStr; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (0 != strncmp("",
+ m_errorEventCurrentIter->m_loggingInfo.binaryFileName,
+ sizeof(m_errorEventCurrentIter->m_loggingInfo.binaryFileName))) {
+ l_displayNamess << m_errorEventCurrentIter->m_loggingInfo.binaryFileName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ } else {
+ l_displayNamess << m_errorEventCurrentIter->m_moduleQueueName;
+ }
+
+ if (m_errorEventCurrentIter->m_loggingInfo.pid != 0) {
+ l_pidss << " PID: " << m_errorEventCurrentIter->m_loggingInfo.pid;
+ }
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_hmiDispStr.str());
+} // LCOV_EXCL_BR_LINE 10:The final line
+
diff --git a/systemservice/system_manager/server/src/ss_system_manager_error_event_responses.cpp b/systemservice/system_manager/server/src/ss_system_manager_error_event_responses.cpp
new file mode 100755
index 0000000..28e8dbf
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_system_manager_error_event_responses.cpp
@@ -0,0 +1,1007 @@
+/*
+ * @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 SS_SM_Logging
+/// \brief This file supports SM logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_plogger_if.h>
+#include <stub/ss_diag.h>
+#include <system_service/ss_ver.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_client_names.h>
+#include <system_service/ss_sm_client_if.h>
+
+#include <stdint.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/statvfs.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <boost/algorithm/string.hpp>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <list>
+
+#include "ss_system_manager.h"
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+static int getExecedString(char* const argv[], std::stringstream &ss) {
+ int ret;
+ int pipeFd[2]; // 0:read, 1:write
+ pid_t pid;
+ ret = pipe(pipeFd);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5:pipe's error case
+ // LCOV_EXCL_START 5:pipe's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ goto error_exit;
+ // LCOV_EXCL_STOP
+ }
+
+ pid = fork();
+ if (pid == -1) { // LCOV_EXCL_BR_LINE 5:fork's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else if (pid == 0) {
+ close(pipeFd[0]); // unnecessary pile (closing read)
+ close(1); // closing stdout
+ dup2(pipeFd[1], 1); // take stdout to pipe
+ execve(argv[0], argv, environ);
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ exit(EXIT_FAILURE);
+ } else {
+ char readBuf[256];
+ ssize_t rs;
+ SS_ASERT_ERRNO(0 == close(pipeFd[1])); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ fd_set rfds;
+ FD_ZERO(&rfds); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ FD_SET(pipeFd[0], &rfds); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ struct timeval timeout;
+ timeout.tv_sec = 2;
+ timeout.tv_usec = 0;
+
+ int selRet = select(pipeFd[0] + 1, &rfds, NULL, NULL, &timeout);
+ switch (selRet) {
+ case 1:
+ if (FD_ISSET(pipeFd[0], &rfds)) {
+ do {
+ rs = read(pipeFd[0], readBuf, sizeof(readBuf) - 1);
+ if (rs > 0) {
+ readBuf[rs] = '\0';
+ ss << readBuf;
+ } else if (rs == -1) { // LCOV_EXCL_BR_LINE 5:read's error case
+ // LCOV_EXCL_START 5:read's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ if (errno != EINTR) {
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ ret = -1;
+ break;
+ }
+ // LCOV_EXCL_STOP
+ }
+ } while (rs != 0);
+ } else {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ break;
+ case -1:
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ break;
+ default:
+ // LCOV_EXCL_START 5:never be this case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ if (0 == selRet) {
+ ss << "timeout" << std::endl;
+ } else {
+ ss << "ERR:rslt=" << selRet << std::endl;
+ }
+ break;
+ // LCOV_EXCL_STOP
+ }
+
+ // SM leaves processing to OnProcessExitDetected when using child process
+ // SS_ASERT_ERRNO(-1 != waitpid(pid,&status,0));
+ }
+ SS_ASERT_ERRNO(0 == close(pipeFd[0])); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+error_exit:
+ return ret;
+}
+
+static int saveProcsMemInfo(std::ofstream &fo) {
+ DIR *dir = NULL;
+ int ret = 0;
+
+ try {
+ struct dirent dent, *next;
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ {
+ fo << "******** mem info **********" << std::endl;
+ std::ifstream fin("/proc/meminfo");
+ std::string line;
+ while (fin && std::getline(fin, line)) {
+ fo << line << endl;
+ }
+ }
+
+ {
+ fo << "******** slab info **********" << std::endl;
+ std::ifstream fin("/proc/slabinfo");
+ std::string line;
+ while (fin && std::getline(fin, line)) {
+ fo << line << endl;
+ }
+ }
+
+ {
+ fo << "******** zone info **********" << std::endl;
+ std::ifstream fin("/proc/zoneinfo");
+ std::string line;
+ while (fin && std::getline(fin, line)) {
+ fo << line << endl;
+ }
+ }
+ // LCOV_EXCL_BR_STOP
+
+ // Linux dependency codes
+ dir = opendir("/proc"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (dir == NULL) { // LCOV_EXCL_BR_LINE 5:opendir's error case
+ // LCOV_EXCL_START 11:opendir's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ throw eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ fo << "******** proc status **********" << std::endl;
+ while (0 == readdir_r(dir, &dent, &next) && next) {
+ if (DT_DIR == dent.d_type) {
+ struct stat statbuf;
+ std::string statPath("/proc/"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ statPath += dent.d_name;
+ statPath += "/status";
+
+ if (stat(statPath.c_str(), &statbuf) == 0) {
+ std::ifstream fin(statPath.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::string line;
+ while (fin && std::getline(fin, line)) {
+ if (strstr(line.c_str(), "Name") != NULL
+ || strstr(line.c_str(), "Pid") != NULL
+ || strstr(line.c_str(), "Vm") != NULL) {
+ fo << line << endl;
+ }
+ }
+ fo << "************************************" << std::endl;
+ }
+ }
+ }
+ SS_ASERT_ERRNO(0 == closedir(dir)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } catch (...) {
+ if (dir) { // LCOV_EXCL_BR_LINE 5:opendir's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ SS_ASERT_ERRNO(0 == closedir(dir)); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ ret = -1;
+ }
+ return ret;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::SendLogArtifactResponseToLogger(HANDLE f_hApp,
+ EArtifactId f_artifactId, std::string f_artifactFilePathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ HANDLE l_hLoggerServiceSession;
+ ModuleLaunchListIter l_ModuleListIter;
+ ARTIFACT_RESPONSE l_artifactResponse;
+
+ l_artifactResponse.ArtifactId = f_artifactId;
+
+ strncpy(l_artifactResponse.FilePathAndName,
+ f_artifactFilePathAndName.c_str(),
+ sizeof(l_artifactResponse.FilePathAndName) - 1);
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = GetModuleIterator(SERVICE_LOGGER, l_ModuleListIter))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: GetModuleIterator(%s) errored: %d/'%s'",
+ SERVICE_LOGGER, l_eStatus, GetStr(l_eStatus).c_str());
+ } else {
+ l_hLoggerServiceSession = l_ModuleListIter->hsession;
+
+ l_eStatus = FrameworkunifiedSendMsg(l_hLoggerServiceSession,
+ SS_SM_ERROR_EVENT_ARTIFACT_RSPN, sizeof(l_artifactResponse),
+ &l_artifactResponse);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "FrameworkunifiedSendMsg(SS_SM_ERROR_EVENT_ARTIFACT_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnErrorEventArtifactRequest
+/// Dispatch logging requests to the various handlers.
+///
+/// \param f_hApp Framework application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnErrorEventArtifactRequest(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg < EArtifactId
+ > (hApp, m_requestedArtifactId))) { // LCOV_EXCL_BR_LINE 200:NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ switch (m_requestedArtifactId) {
+ case eArtifactIdBootMicroLog:
+ l_eStatus = OnObtainBootMicroLog(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainBootMicroLog()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ break;
+
+ case eArtifactIdSystemDataCsv:
+ l_eStatus = OnObtainSystemmanagerSystemDataCsv(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainSystemmanagerSystemDataCsv()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ break;
+
+ case eArtifactIdShowMemTxt:
+ l_eStatus = OnObtainShowMemTxt(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainShowMemTxt()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ break;
+
+ case eArtifactIdProcessCore:
+ SS_ASERT(0); // Never called in Linux PF // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ break;
+
+ case eArtifactIdDebugDumpLog:
+ l_eStatus = OnObtainDebugDumpLog(hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnObtainDebugDumpLog()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Unsupported logging artifact requested: %d.",
+ m_requestedArtifactId);
+ break;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnObtainBootMicroLog
+/// Obtain the boot micro log content, write file to disk, and send filename to SL.
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnObtainBootMicroLog(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(f_hApp));
+
+ l_eStatus = RequestBootMicroLog(f_hApp);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "RequestBootMicroLog"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnBootMicroLogResponse
+/// Boot micro log response sent from the logging shadow.
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnBootMicroLogResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_len;
+ std::string l_artifactFilePathAndName;
+
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_BOOT_MICRO_LOG_RSPN].Stop(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(f_hApp));
+
+ if (0 == strcmp(TIMER_SERVICE_NAME, FrameworkunifiedGetMsgSrc(f_hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Timer expired while waiting for the boot micro log.");
+ } else if (0 == (l_len = FrameworkunifiedGetMsgLength(f_hApp))) { // LCOV_EXCL_BR_LINE 200:restricted by ss_sm_client
+ // LCOV_EXCL_START 200:restricted by ss_sm_client
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Invalid log response received. Length cannot be 0.");
+ // LCOV_EXCL_STOP
+ } else {
+ char l_buf[l_len]; // NOLINT
+ l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, l_buf, static_cast<UI_32>(sizeof(l_buf)), eSMRRelease); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()"); // LCOV_EXCL_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ l_artifactFilePathAndName = "/tmp/bootmicro.log";
+ l_len = static_cast<UI_32>(strlen((const char *) l_buf));
+ std::ofstream l_stream(l_artifactFilePathAndName.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.write(l_buf, l_len); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.close(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ }
+
+ l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
+ l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
+ "errored: %d/'%s'", m_requestedArtifactId,
+ l_artifactFilePathAndName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ }
+
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnErrorEventBootMicroLogResponseTimeout
+/// Called when the boot micro log request timer expires (e.g. no response).
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnErrorEventBootMicroLogResponseTimeout(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_artifactFilePathAndName = "";
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Boot micro log response timed out. Sending empty artifact response to SSL.");
+
+ l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
+ l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
+ "errored: %d/'%s'", m_requestedArtifactId,
+ l_artifactFilePathAndName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnObtainSystemmanagerSystemDataCsv
+/// Obtain system content, write file to disk, and send filename to SL.
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnObtainSystemmanagerSystemDataCsv(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // std::string l_artifactFilePathAndName = "/tmp/frameworkunified_systemdata.csv";
+ // std::ofstream l_stream(l_artifactFilePathAndName.c_str());
+ std::stringstream l_stream;
+ char *l_pSignalName;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ // Output version info
+ {
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ CSSVer ver;
+ l_stream << "********** PACKAGE VERSIONS **********\n";
+ l_stream << left;
+ l_stream << setw(16) << "PACKAGE" << setw(24) << "VERSION" << setw(10)
+ << "DATE" << endl;
+ for (SSVerPkgListIter ite = ver.begin(); ite != ver.end(); ite++) {
+ l_stream << setw(16) << ite->first;
+ l_stream << setw(24) << ite->second.version;
+ l_stream << setw(10) << ite->second.date << std::endl;
+ }
+ // LCOV_EXCL_BR_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
+ l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << "********** Error Description Start ***********" << endl;
+ l_stream << "Error Event Type,"
+ << GetStr(m_errorEventCurrentIter->m_eventType) << endl;
+ l_stream << m_errorEventCurrentIter->m_eventEnqueueTimeStamp.c_str() << endl;
+ l_stream << "MessageStr,"
+ << m_errorEventCurrentIter->m_loggingInfo.messageStr.c_str() << endl;
+ // LCOV_EXCL_BR_STOP
+
+ {
+ UI_32 l_ErrLogCount = 0;
+ if (PowerHalGetResetInfo(AGL_ERRLOG_COUNTER, &l_ErrLogCount)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__,
+ "Could not get AGL_ERRLOG_COUNTER from power_hal.");
+ }
+
+ {
+ l_stream << "ErrLogCount," << l_ErrLogCount << "/"
+ << SS_SM_ERR_LOGGING_LIMIT << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ }
+
+ switch (m_errorEventCurrentIter->m_eventType) {
+ case eErrorEventTypeProcessCrash:
+ l_stream << "Crash Failure Binary Name,"
+ << m_errorEventCurrentIter->m_loggingInfo.binaryFileName << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << "Module PID," << m_errorEventCurrentIter->m_loggingInfo.pid << endl;
+ l_stream << "Exit Value,"
+ << m_errorEventCurrentIter->m_loggingInfo.exitValue << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_pSignalName = strsignal(
+ m_errorEventCurrentIter->m_loggingInfo.signalNumber);
+ if (NULL != l_pSignalName) {
+ l_stream << "Exit Signal,"
+ << m_errorEventCurrentIter->m_loggingInfo.signalNumber // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ << "," << l_pSignalName << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ break;
+
+ case eErrorEventTypeProcessExit:
+ l_stream << "Exit Binary Name,"
+ << m_errorEventCurrentIter->m_loggingInfo.binaryFileName << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << "Module PID," << m_errorEventCurrentIter->m_loggingInfo.pid << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << "Exit Value,"
+ << m_errorEventCurrentIter->m_loggingInfo.exitValue << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ break;
+
+ case eErrorEventTypeHeartBeatFailure:
+ l_stream << "HB Failure Module Queue Name,"
+ << m_errorEventCurrentIter->m_moduleQueueName.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << "***************** HB Information Start *******************" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << "Entire State," << m_HBReport.eEntireState << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << "Module Name,HB State,Retry Count" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ for (UI_32 i = 0; i < m_HBReport.nNumOfModules; i++) {
+ if (0 != m_HBReport.tModuleList[i].HeartBeatRetryCount) {
+ l_stream << m_HBReport.tModuleList[i].ProcQueueName << "," // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ << m_HBReport.tModuleList[i].ProcHBState << "," // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ << m_HBReport.tModuleList[i].HeartBeatRetryCount // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ }
+ l_stream << "***************** HB Information End *******************" << endl;
+ break;
+
+ case eErrorEventTypeSystemLowMemory:
+ l_stream << "Free Memory Available (Byte)," << m_FreeMemAvailable << endl;
+ break;
+
+ case eErrorEventTypeBootMicroReset:
+ l_stream << "Boot Micro Reset Reason," << m_BootMicroResetReason << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ break;
+
+ case eErrorEventTypeModConnFailed:
+ l_stream << "Failed Module Queue Name,"
+ << m_errorEventCurrentIter->m_moduleQueueName.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ break;
+
+ case eErrorEventTypeStartRespFailed:
+ l_stream << "Failed Module Queue Name,"
+ << m_errorEventCurrentIter->m_moduleQueueName.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ break;
+
+ // No additional event specific log information to add.
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ default:
+ break;
+ }
+
+ {
+ std::ifstream finNum("/proc/sys/vm/nr_oom_kill_process");
+ std::string strNum;
+ if (finNum && std::getline(finNum, strNum)) { // LCOV_EXCL_BR_LINE 200:will not be this case
+ // LCOV_EXCL_START 200:will not be this case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ char *endptr = NULL;
+ long lNum = strtol(strNum.c_str(), &endptr, 10); // NOLINT
+ if (('\0' != *endptr) || (lNum < 0)) {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ l_stream << "nr_oom_kill_process," << strNum.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (0 != lNum) {
+ std::ifstream finLast("/proc/sys/vm/last_oom_kill_victim"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::string strLast;
+ if (finLast && std::getline(finLast, strLast)) {
+ l_stream << "last_oom_kill_victim," << strLast.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+ }
+ // LCOV_EXCL_STOP
+ }
+
+ l_stream << "********** Error Description End ***********" << endl << endl;
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
+
+ fprintf(stderr, "SS_SysManager/\n%s", l_stream.str().c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_stream << "********** Variant Code Start ***********" << endl;
+ if (NULL != m_pVarCodeStr) {
+ l_stream << m_pVarCodeStr << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ } else {
+ l_stream << "Variant coding not available." << endl;
+ }
+ l_stream << "********** Variant Code End ***********" << endl << endl;
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
+ l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_stream << "********** File System Information Start ***********" << endl;
+ l_stream << "== mounts info start==" << endl;
+ {
+ std::ifstream fin("/proc/mounts"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ std::string line;
+ while (fin && std::getline(fin, line)) {
+ l_stream << line << endl;
+ }
+ }
+ l_stream << "== mounts info end ==" << endl;
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
+ l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_stream << "== DF info start==" << endl;
+ {
+ char* const argv[] = { const_cast<char*>("/bin/df"), const_cast<char*>("-a"), static_cast<char*>(NULL), };
+ SS_ASERT(0 == getExecedString(argv, l_stream)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ l_stream << "== DF info end==" << endl;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
+ l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+#if 0 // Need to install lsblk if requested so that it is not installed
+ l_stream << "== lsblk info start==" << endl;
+ {
+ char* const argv[] = {
+ const_cast<char*>("/usr/debug/bin/lsblk"),
+ const_cast<char*>("-o"),
+ const_cast<char*>("NAME,KNAME,MAJ:MIN,FSTYPE,PARTLABEL,MODEL,SERIAL,REV,VENDOR"),
+ const_cast<char*>(NULL),
+ };
+ SS_ASERT(0 == getExecedString(argv, l_stream));
+ }
+ l_stream << "== lsblk info end==" << endl;
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", l_stream.str().c_str());
+ l_stream.str("");
+ l_stream.clear();
+#endif
+
+ l_stream << "== proc info start==" << endl;
+ {
+ char* const argv[] = { const_cast<char*>("/bin/ps"), const_cast<char*>("auxc"),
+ const_cast<char*>("-L"), static_cast<char*>(NULL), };
+ SS_ASERT(0 == getExecedString(argv, l_stream)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ l_stream << "== proc info end==" << endl;
+ {
+ // Output is splitted so that the FRAMEWORKUNIFIEDLOG can not write data over 4K Bytes at a time
+ std::list<std::string> strList;
+ boost::split(strList, static_cast<const std::string>(l_stream.str()),
+ boost::is_any_of("\n")); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ int ii = 0;
+ std::stringstream ss; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ for (std::list<std::string>::iterator ite = strList.begin();
+ ite != strList.end(); ite++) {
+ ss << *ite << endl;
+ ii++;
+ if (ii > 20) {
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", ss.str().c_str());
+ ss.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ ss.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ ii = 0;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSLOG, __FUNCTION__, "\n%s", ss.str().c_str());
+ }
+ l_stream.str(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.clear(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId, ""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SendLogArtifactResponseToLogger(Artifact '%d') "
+ "errored: %d/'%s'", m_requestedArtifactId, l_eStatus,
+ GetStr(l_eStatus).c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnObtainShowMemTxt
+/// Obtain showmem content, write file to disk, and send filename to SL.
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnObtainShowMemTxt(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ std::string l_artifactFilePathAndName = "/tmp/showmem.txt";
+ {
+ std::ofstream fo(l_artifactFilePathAndName.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ saveProcsMemInfo(fo); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
+ l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
+ "errored: %d/'%s'", m_requestedArtifactId,
+ l_artifactFilePathAndName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnErrorEventCoreFilePollTimeout
+/// Called periodically to verify whether the process core file has completed
+/// being written to disk. When complete, this function sends an artifact
+/// response to SSL.
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnErrorEventCoreFilePollTimeout(HANDLE f_hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_sendResponse = FALSE;
+ std::string l_artifactFilePathAndName = "";
+ std::ostringstream l_coreFilePathAndName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+// struct stat l_fileInfo;
+ struct stat64 l_fileInfo;
+ int l_result;
+ off_t l_coreFileSize;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ l_coreFilePathAndName << "/debug/"
+ << m_errorEventCurrentIter->m_loggingInfo.binaryFileName << ".core.gz"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+
+// l_result = stat(l_coreFilePathAndName.str().c_str(), &l_fileInfo);
+ l_result = stat64(l_coreFilePathAndName.str().c_str(), &l_fileInfo);
+ if (l_result == 0) {
+ l_coreFileSize = l_fileInfo.st_size;
+ if ((l_coreFileSize > m_coreFileSizeBytes) || // Core file grew from last read.
+ (l_coreFileSize == 0)) { // Core file not yet updated externally.
+ m_coreFileSizeBytes = l_coreFileSize; // Wait until file stops growing.
+ bool result =
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_CORE_FILE_POLL].Start( // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ 0, SS_ERROR_EVENT_CORE_FILE_POLL_TO_MS, 0, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (FALSE == result) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Failed to start timer SS_ERROR_EVENT_CORE_FILE_POLL_TO_MS.");
+ l_sendResponse = TRUE;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Core file: %s, size: %ld still growing.",
+ l_coreFilePathAndName.str().c_str(),
+ m_coreFileSizeBytes);
+
+ l_sendResponse = FALSE;
+ }
+ } else { // File has stopped growing.
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Core file: %s, size: %ld write complete. Sending artifact response.",
+ l_coreFilePathAndName.str().c_str(), m_coreFileSizeBytes);
+
+ l_artifactFilePathAndName = l_coreFilePathAndName.str();
+ l_sendResponse = TRUE;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Info. Core file: %s, unable to determine size. Sending empty artifact response to SSL.",
+ l_coreFilePathAndName.str().c_str());
+
+ l_sendResponse = TRUE;
+ }
+
+ if (TRUE == l_sendResponse) {
+ l_eStatus = SendLogArtifactResponseToLogger(f_hApp, // Error getting file size. Send empty path to SSL.
+ m_requestedArtifactId, l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
+ "errored: %d/'%s'", m_requestedArtifactId,
+ l_artifactFilePathAndName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnObtainDebugDumpLog
+/// Obtain debug dump content, write file to disk, and send filename to SL.
+/// See OnModuleDebugDumpResponse().
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnObtainDebugDumpLog(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ ModuleLaunchListIter l_moduleIter;
+
+ m_NbrDebugDumpRspnRecv = 0;
+
+ for (GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.begin();
+ l_GroupIter != m_MapProclaunchGrps.end(); l_GroupIter++) {
+ for (l_moduleIter = l_GroupIter->second.modules.begin();
+ l_moduleIter != l_GroupIter->second.modules.end();
+ l_moduleIter++) {
+ const BOOL isModuleConnected = l_moduleIter->IsModuleConnected(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
+ if ((SERVICE_NS_NPP != l_moduleIter->name) && // NPP is a special case and does NOT session connect with SM.
+ (TRUE == isModuleConnected)) {
+ l_eStatus = FrameworkunifiedSendMsg(l_moduleIter->hsession, SS_SM_DEBUG_DUMP,
+ 0, NULL);
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200:NSFW error case
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. FrameworkunifiedSendMsg(SS_SM_DEBUG_DUMP) to %s succeeded.", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_moduleIter->name.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ } else {
+ // LCOV_EXCL_START 200:NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: FrameworkunifiedSendMsg(%p, SS_SM_DEBUG_DUMP) to %s errored: %d/'%s'",
+ (void *) l_moduleIter->hsession,
+ l_moduleIter->name.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+
+ // Call debug dump handler for SM.
+ l_eStatus = OnSystemManagerDebugDump(f_hApp);
+ LOG_STATUS(l_eStatus, "OnSystemManagerDebugDump()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ // Refresh debug dump timeout timer after each debug dump response received.
+ // Non AGL framework modules will have the remaining time after the last
+ // received response to complete their debug dump.
+ bool result =
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN].Start(
+ SS_ERROR_EVENT_DEBUG_DUMP_RSPN_TO_SEC, 0, 0, 0);
+ if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:will not be this case
+ // LCOV_EXCL_START 200:will not be this case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Failed to start timer eSM_TIMER_DEBUG_DUMP_RSPN_MONITOR.");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnDebugDumpResponseReceived
+/// Debug Dump complete Response handler.
+/// See OnDebugDumpCompleteTimeout().
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnDebugDumpResponseReceived(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ModuleLaunchListIter l_ModuleListIter;
+ UI_32 l_len;
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", l_moduleName.c_str());
+
+ SetCmdHist("SS_SM_DEBUG_DUMP_RSPN", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(f_hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ // SM is not launched by SM and is therefore not in the process list.
+ // SM does however use the same debug dump mechanism as other processes.
+ if (l_moduleName != SERVICE_SYSMANAGER) {
+ l_eStatus = GetModuleIterator(l_moduleName.c_str(), l_ModuleListIter);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Module %s not found in Group Launch Map", l_moduleName.c_str());
+ } else {
+ l_ModuleListIter->SetModuleDebugDumpState(MODULE_DEBUG_DUMP_STATE_RESPONSE_RECEIVED);
+ }
+ }
+
+ if (0 == (l_len = FrameworkunifiedGetMsgLength(f_hApp))) { // LCOV_EXCL_BR_LINE 200:restricted by ss_sm_client
+ // LCOV_EXCL_START 200:restricted by ss_sm_client
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ l_eStatus = eFrameworkunifiedStatusInvldBufSize;
+ LOG_ERROR("0 == FrameworkunifiedGetMsgLength(f_hApp)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Received debug dump response from %s, size: %d bytes. "
+ "Total number of responses received: %d",
+ l_moduleName.c_str(), l_len, m_NbrDebugDumpRspnRecv);
+
+ UI_8 l_buf[l_len]; // NOLINT
+ l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, l_buf, static_cast<UI_32>(sizeof(l_buf)),
+ eSMRRelease);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ ios_base::openmode l_mode;
+ if (0 == m_NbrDebugDumpRspnRecv) {
+ // Create new file.
+ l_mode = std::ios_base::trunc;
+ } else {
+ // Append existing file.
+ l_mode = std::ios_base::app;
+ }
+
+ std::ofstream l_stream("/tmp/systemmanager_debugdump.log", l_mode); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream << l_buf << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_stream.close(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ m_NbrDebugDumpRspnRecv++;
+
+ // Refresh debug dump timeout timer after each debug dump response received.
+ // Non AGL framework modules will have the remaining time after the last
+ // received response to complete their debug dump.
+ bool result =
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN].Start( // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ SS_ERROR_EVENT_DEBUG_DUMP_RSPN_TO_SEC, 0, 0, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:will not be this case
+ // LCOV_EXCL_START 200:will not be this case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Failed to start timer eSM_TIMER_DEBUG_DUMP_RSPN_MONITOR.");
+ l_eStatus = OnDebugDumpCompleteTimeout(f_hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "OnDebugDumpCompleteTimeout()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnDebugDumpCompleteTimeout
+/// Called after the last debug dump message is received, or when the debug
+/// dump monitor timer expires.
+///
+/// \param [in] f_hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnDebugDumpCompleteTimeout(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_artifactFilePathAndName = "/tmp/systemmanager_debugdump.log";
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_DEBUG_DUMP_RSPN].Stop(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Received '%d' Debug Dump responses.",
+ m_NbrDebugDumpRspnRecv);
+
+ l_eStatus = SendLogArtifactResponseToLogger(f_hApp, m_requestedArtifactId,
+ l_artifactFilePathAndName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: SendLogArtifactResponseToLogger(Artifact '%d', '%s') "
+ "errored: %d/'%s'", m_requestedArtifactId,
+ l_artifactFilePathAndName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
diff --git a/systemservice/system_manager/server/src/ss_system_manager_error_event_triggers.cpp b/systemservice/system_manager/server/src/ss_system_manager_error_event_triggers.cpp
new file mode 100755
index 0000000..385a628
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_system_manager_error_event_triggers.cpp
@@ -0,0 +1,1093 @@
+/*
+ * @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 IAT error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <system_service/ss_system_manager_notifications.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_client_names.h>
+#include <system_service/ss_power_service_if.h>
+#include <processlauncher/ProcessLauncher_if.h>
+#include <processlauncher/ss_sm_process_launcher_protocol.h>
+#include <processlauncher/ss_sm_process_launcher.h>
+#include <heartbeat/ss_hb_if.h>
+#include <system_service/ss_heartbeat_service_protocol.h>
+#include <string.h>
+#include <system_service/ss_power_service_notifications.h>
+#include <system_service/ss_power_service_protocol.h>
+#include <stub/ss_diag.h>
+#include <system_service/ss_test_clients.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/frameworkunified_application.h>
+#include <system_service/ss_sm_thread_names.h>
+#include <system_service/ss_templates.h>
+#include <native_service/ns_plogger_if.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <native_service/ns_np_service_nor_persistence.h>
+#include <native_service/cl_process.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/mman.h>
+#include <sys/procfs.h>
+#include <libgen.h>
+#include <spawn.h>
+#include <errno.h>
+#include <sys/timeb.h>
+#include <string>
+#include "ss_system_manager.h"
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_sm_signals.h"
+#include "ss_sm_default_paths.h"
+#include "ss_sm_version.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnHeartBeatErrorDetected
+/// This function gets called when a heartbeat failure is detected.
+///
+/// \param [in] f_hApp
+/// HANDLE - Handle of the Client Application
+///
+/// \return Status
+/// EFrameworkunifiedStatus - success or error
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnHeartBeatErrorDetected(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_resetRequired;
+ EErrorEventResetType l_resetType;
+ SMLoggingInfo l_loggingInfo;
+ std::string l_moduleBinaryName;
+ UI_32 l_ix;
+ THbReportData l_HBReport;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < THbReportData > (f_hApp, l_HBReport))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Report contains : %d entries.", l_HBReport.nNumOfModules);
+
+ for (l_ix = 0; l_ix < l_HBReport.nNumOfModules; l_ix++) {
+ if (HB_STATUS_TIMEOUT == l_HBReport.tModuleList[l_ix].ProcHBState) {
+ std::string l_moduleQueueName = l_HBReport.tModuleList[l_ix].ProcQueueName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ m_HBReport.eEntireState = l_HBReport.eEntireState;
+ m_HBReport.nNumOfModules = l_HBReport.nNumOfModules;
+ memcpy(&m_HBReport.tModuleList[l_ix], &l_HBReport.tModuleList[l_ix], sizeof(TSmModuleInfo));
+
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: Heartbeat error detected from: %s.", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_moduleQueueName.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ l_eStatus = GetBinaryNameOfProcess(l_moduleQueueName, l_moduleBinaryName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. Unable to identify binary name for SM child process with queue name: %s."
+ " The process name will be missing from the .csv and the core file will not be archived.",
+ l_moduleQueueName.c_str());
+ } else {
+ strncpy(l_loggingInfo.binaryFileName,
+ l_moduleBinaryName.c_str(),
+ sizeof(l_loggingInfo.binaryFileName) - 1);
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ActOnModuleFailure(f_hApp, l_moduleQueueName, l_resetRequired))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. ActOnModuleFailure(%s,%d) errored: %d/'%s'",
+ l_moduleQueueName.c_str(), l_resetRequired,
+ l_eStatus, GetStr(l_eStatus).c_str());
+ }
+
+ l_resetType =
+ (FALSE == l_resetRequired) ?
+ eErrorEventResetTypeNone :
+ eErrorEventResetTypeHard;
+
+ if (eErrorEventResetTypeNone != l_resetType) {
+ l_loggingInfo.resetReason =
+ e_SS_SM_CPU_RESET_REASON_GENERIC_ERR;
+ }
+
+ l_eStatus = ErrorEventEnqueue(f_hApp,
+ eErrorEventTypeHeartBeatFailure, l_moduleQueueName,
+ l_resetType, l_loggingInfo);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeHeartBeatFailure)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnProcessTermDetected
+///
+///
+///
+/// \param Handle to AGL application.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnProcessTermDetected(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int l_clRet;
+ int l_count = 0;
+
+ // When multiple child processes terminate, CL_ProcessCleanup() returns 1. If 1 is returned, it repeats.
+ do {
+ CL_ProcessCleanupInfo_t l_procInfo;
+
+ l_count++;
+
+ l_clRet = CL_ProcessCleanup(m_ClProcessSigFd, &l_procInfo);
+ if (l_clRet != 0 && l_clRet != 1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning: CL_ProcessCleanup(%d):%s", l_clRet,
+ strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "PID:%d code:%d status:%d",
+ l_procInfo.pid, l_procInfo.code, l_procInfo.status);
+
+ // Terminate a process group to reclaim descendants of an anomaly terminated process
+ SS_ASERT_ERRNO(0 == CL_ProcessAbortGroup(l_procInfo.pid)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ BOOL bIsExited = (CLD_EXITED == l_procInfo.code) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ SMProcessExitInfo l_procExitInfo;
+ memset(&l_procExitInfo, 0, sizeof(l_procExitInfo));
+ l_procExitInfo.pid = l_procInfo.pid;
+ // Process exit value when si_code == CLD_EXITED, else delivered signal number.
+ l_procExitInfo.exitValue = l_procInfo.status;
+ l_procExitInfo.signalNumber = SS_SM_ABORT_SIGNAL;
+
+ // If GroupRelaunch is required, kill the remaining services
+ SS_String l_moduleQueueName("");
+ if (eFrameworkunifiedStatusOK == FindNameOfTerminatedProcess(l_procExitInfo.pid, l_moduleQueueName)) {
+ for (GroupRelaunchModuleListIter l_itr =
+ m_GroupRelaunchModuleList.begin();
+ m_GroupRelaunchModuleList.end() != l_itr; l_itr++) {
+ if (l_itr->name == l_moduleQueueName) {
+ if (l_itr->bIsKilled) { // LCOV_EXCL_BR_LINE 200: relaunch module bIsKilled is always false
+ // LCOV_EXCL_START 200: relaunch module bIsKilled is always false
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // Normal during forced Relaunch
+ l_procExitInfo.exitValue = SS_SM_EXIT_RELAUNCH;
+ bIsExited = TRUE;
+ l_itr->bIsKilled = FALSE;
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "GroupRelaunch(%d/%d)",
+ m_GroupRelaunchCount, m_GroupRelaunchLimit);
+
+ if (m_GroupRelaunchCount < m_GroupRelaunchLimit) {
+ SS_ASERT( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ FrameworkunifiedNPPublishNotification(f_hApp, // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ NTFY_SSNeedAplRestart, NULL, 0)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ // Issue ErrorEvent
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ SS_String l_moduleBinaryName(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_loggingInfo.pid = l_procExitInfo.pid;
+ l_loggingInfo.exitValue = l_procExitInfo.exitValue;
+ l_loggingInfo.signalNumber = SS_SM_ABORT_SIGNAL;
+ if (eFrameworkunifiedStatusOK != GetBinaryNameOfProcess(l_moduleQueueName, l_moduleBinaryName)) { // LCOV_EXCL_BR_LINE 200: cannot be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_LINE 200: cannot be error
+ } else {
+ snprintf(l_loggingInfo.binaryFileName,
+ sizeof(l_loggingInfo.binaryFileName),
+ "%s", l_moduleBinaryName.c_str());
+ }
+
+ l_eStatus = ErrorEventEnqueue(f_hApp,
+ eErrorEventTypeGroupRelaunch, l_itr->name,
+ eErrorEventResetTypeNone, l_loggingInfo);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ // Relaunch normally and do not leave anomaly LOGs
+ l_procExitInfo.exitValue = SS_SM_EXIT_RELAUNCH;
+ bIsExited = TRUE;
+
+ for (GroupRelaunchModuleListIter l_itr =
+ m_GroupRelaunchModuleList.begin();
+ m_GroupRelaunchModuleList.end() != l_itr;
+ l_itr++) {
+ if (l_itr->name != l_moduleQueueName) { // LCOV_EXCL_BR_LINE 200: name always be equal because of outer if judge // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 200: name always be equal
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ModuleLaunchListIter l_ModuleListIter;
+ if (eFrameworkunifiedStatusOK
+ != GetModuleIterator(
+ l_itr->name.c_str(),
+ l_ModuleListIter)) {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ killpg(l_ModuleListIter->pid,
+ SS_SM_TERMINATE_SIGNAL);
+ l_itr->bIsKilled = TRUE;
+ }
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ m_GroupRelaunchCount++;
+ } else {
+ // Reboot system
+ ModuleLaunchListIter l_ModuleListIter;
+ if (eFrameworkunifiedStatusOK == GetModuleIterator(l_moduleQueueName.c_str(), l_ModuleListIter)) { // LCOV_EXCL_BR_LINE 200:cannot be error // NOLINT(whitespace/line_length)
+ l_ModuleListIter->relaunch_count = l_ModuleListIter->retry_cnt;
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_LINE 200: cannot be error
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ if (isPreLaunchedProcess(l_procExitInfo.pid)) { // LCOV_EXCL_BR_LINE 200:prelaunch mode is not valid at UT test //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 200 :prelaunch mode is not valid at UT test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = OnPreLaunchedProcessTermDetected(f_hApp, l_procExitInfo, bIsExited); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("OnPreLaunchedProcessTermDetected()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // If an error occurs here, the zombie process may be collected and continued.
+ }
+ // LCOV_EXCL_STOP
+ } else if (bIsExited) {
+ l_eStatus = OnProcessExitDetected(f_hApp, l_procExitInfo); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("OnProcessExitDetected()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // If an error occurs here, the zombie process may be collected and continued.
+ }
+ } else {
+ l_eStatus = OnProcessCrashDetected(f_hApp, l_procExitInfo); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ LOG_ERROR("OnProcessCrashDetected()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // If an error occurs here, the zombie process may be collected and continued.
+ }
+ }
+ } while (l_clRet == 1 && l_count < 50);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+BOOL CSystemManager::isPreLaunchedProcess(int f_pid) {
+ BOOL l_bIsExist = FALSE;
+
+ PreLaunchModuleListIter l_itr;
+ for (l_itr = m_PreLaunchModuleList.begin();
+ m_PreLaunchModuleList.end() != l_itr; l_itr++) {
+ if (l_itr->pid == f_pid) { // LCOV_EXCL_BR_LINE 200:prelaunch mode is not valid at UT test //NOLINT (whitespace/line_length)
+ // LCOV_EXCL_START 200 :prelaunch mode is not valid at UT test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_bIsExist = TRUE;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ }
+ return l_bIsExist;
+}
+
+EFrameworkunifiedStatus CSystemManager::OnPreLaunchedProcessTermDetected(HANDLE f_hApp, SMProcessExitInfo &f_procExitInfo, BOOL f_bIsExited) { // LCOV_EXCL_START 200 :prelaunch mode is not valid at UT test // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ PreLaunchModuleListIter l_itr;
+ for (l_itr = m_PreLaunchModuleList.begin();
+ m_PreLaunchModuleList.end() != l_itr; l_itr++) {
+ if (l_itr->pid == static_cast<int>(f_procExitInfo.pid)) {
+ break;
+ }
+ }
+
+ try {
+ if (m_PreLaunchModuleList.end() == l_itr) {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ throw eFrameworkunifiedStatusFail;
+ }
+
+ BOOL l_bIsNeedRelaunched = FALSE;
+
+ if ((SS_SM_RELAUNCH_NO_LIMIT == l_itr->relaunchLimit)
+ || (l_itr->relaunchLimit > l_itr->relaunchCount)) {
+ l_itr->relaunchCount++;
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Relaunch %s(%d/%d)",
+ l_itr->name.c_str(), l_itr->relaunchCount,
+ l_itr->relaunchLimit);
+ if (-1 == (l_itr->pid = l_itr->LaunchFunc())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Relaunch %s Failed",
+ l_itr->name.c_str());
+ } else {
+ l_bIsNeedRelaunched = TRUE;
+ }
+ }
+
+ if (!l_bIsNeedRelaunched) {
+ if (l_itr->critical) {
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ EErrorEventType l_ErrorType;
+
+ l_itr->pid = -1;
+
+ l_loggingInfo.pid = f_procExitInfo.pid;
+ l_loggingInfo.exitValue = f_procExitInfo.exitValue;
+ l_loggingInfo.signalNumber = f_procExitInfo.signalNumber;
+ l_loggingInfo.resetReason =
+ e_SS_SM_CPU_RESET_REASON_GENERIC_ERR;
+ snprintf(l_loggingInfo.binaryFileName,
+ sizeof(l_loggingInfo.binaryFileName), "%s",
+ l_itr->binaryFileName.c_str());
+
+ if (f_bIsExited) {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s exited",
+ l_itr->name.c_str());
+ l_ErrorType = eErrorEventTypeProcessExit;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s crashed",
+ l_itr->name.c_str());
+ l_ErrorType = eErrorEventTypeProcessCrash;
+ }
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, l_ErrorType, l_itr->name,
+ eErrorEventResetTypeHard, l_loggingInfo);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "ErrorEventEnqueue()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s removed",
+ l_itr->name.c_str());
+ l_itr->pid = -1;
+ }
+ }
+ } catch (EFrameworkunifiedStatus e) {
+ l_eStatus = e;
+ }
+
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnProcessCrashDetected
+/// Initiate logging and recovery for an abnormal process termination.
+/// The terminated process may or may not be a child of system manager.
+/// If the process is a child of SM, then a validation check must ensue
+/// to ensure that the process crash is not the result of a failed heartbeat
+/// and subsequent termination signal sent from System Manager. This function
+/// is NOT called for processes that exit normally.
+///
+/// See OnProcessCrashDetected.
+///
+/// \param Handle to AGL application.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnProcessCrashDetected(HANDLE f_hApp,
+ SMProcessExitInfo &f_procExitInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ BOOL l_resetRequired = TRUE;
+ SS_String l_moduleQueueName("");
+ SS_String l_moduleBinaryName(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ EErrorEventResetType l_resetType;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ TEXT(__FUNCTION__, " PROCESS CRASH: Process PID: %d", f_procExitInfo.pid); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FindNameOfTerminatedProcess(f_procExitInfo.pid, l_moduleQueueName))) {
+ // Normally, logging COULD continue, but stopping logging also solves a PosixBasedOS001 errata
+ // where a process crashes and is removed from the SM process launch map and is ALSO
+ // detected by the exit detector as a 'normal' exit. The FindNameOfTerminatedProcess()
+ // will continue properly IF a crash and removal from the map has not occurred
+ // for the same process.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. FindNameOfTerminatedProcess() returned error: %d/'%s' for PID: %d."
+ " No recovery possible. Logging has been suspended for this event.",
+ l_eStatus, GetStr(l_eStatus).c_str(), f_procExitInfo.pid);
+ } else {
+ l_eStatus = GetBinaryNameOfProcess(l_moduleQueueName, l_moduleBinaryName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200: cannot be error
+ // LCOV_EXCL_START 200: cannot be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. Unable to identify binary for SM child process PID: %d, Queue Name: %s."
+ " The process binary name will be missing from the .csv file.",
+ f_procExitInfo.pid, l_moduleQueueName.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ strncpy(f_procExitInfo.binaryFileName, l_moduleBinaryName.c_str(),
+ sizeof(f_procExitInfo.binaryFileName) - 1);
+
+ f_procExitInfo.binaryFileName[sizeof(f_procExitInfo.binaryFileName) - 1] = '\0';
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ActOnModuleFailure(f_hApp, l_moduleQueueName,
+ l_resetRequired))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. ActOnModuleFailure(%s,%d) errored: %d/'%s'",
+ l_moduleQueueName.c_str(), l_resetRequired, l_eStatus,
+ GetStr(l_eStatus).c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
+ "Info. ActOnModuleFailure() returned reset status: %d/'%s'.",
+ l_resetRequired, GetStr(l_resetRequired).c_str());
+ }
+
+ l_resetType =
+ (FALSE == l_resetRequired) ?
+ eErrorEventResetTypeNone : eErrorEventResetTypeHard;
+
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_loggingInfo.pid = f_procExitInfo.pid;
+ l_loggingInfo.exitValue = f_procExitInfo.exitValue;
+ l_loggingInfo.signalNumber = f_procExitInfo.signalNumber;
+ snprintf(l_loggingInfo.binaryFileName,
+ sizeof(l_loggingInfo.binaryFileName), "%s",
+ f_procExitInfo.binaryFileName);
+ if (eErrorEventResetTypeNone != l_resetType) {
+ l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_GENERIC_ERR;
+ }
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, eErrorEventTypeProcessCrash,
+ l_moduleQueueName, l_resetType, l_loggingInfo);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeProcessCrash)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnProcessExitDetected
+/// Initiate logging and recovery for System Manager child processes that
+/// exit normally via the last brace of main(), exit(), or have their last
+/// thread exit. This function is NOT called for processes that terminate
+/// unexpectedly.
+///
+/// See OnProcessExitDetected.
+///
+/// \param Handle to AGL application.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnProcessExitDetected(HANDLE f_hApp,
+ SMProcessExitInfo &f_procExitInfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ SS_String l_moduleQueueName("");
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ TEXT(__FUNCTION__, "PROCESS EXIT: PID:%d exitValue:%d", f_procExitInfo.pid, // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ f_procExitInfo.exitValue); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FindNameOfTerminatedProcess(f_procExitInfo.pid,
+ l_moduleQueueName))) {
+ // This happens when SMs to EXEC debugging commands, etc.
+ // Since this is not an error, set LOGs to WARN levels and set the return codes to OK.
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "%s: pid:%d is unknown service",
+ GetStr(l_eStatus).c_str(), f_procExitInfo.pid);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ if (0 == f_procExitInfo.exitValue) {
+ ModuleLaunchListIter l_moduleListIter;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = RemoveModuleEntryFromHB(f_hApp, l_moduleQueueName.c_str()))) { // LCOV_EXCL_BR_LINE 4: NSFW // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 4: NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: RemoveModuleEntryFromHB(%s) errored: %d/'%s'",
+ l_moduleQueueName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = GetModuleIterator(l_moduleQueueName.c_str(),
+ l_moduleListIter);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:cannot be error
+ // LCOV_EXCL_START 200:cannot be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Module %s not found in Group Launch Map",
+ l_moduleQueueName.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = SendRequestToLauncher(f_hApp, l_moduleListIter, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ ePLThrdCmd_TERMINATE_MODULE_REQST, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ "ePLThrdCmd_TERMINATE_MODULE_REQST"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "SendRequestToLauncher()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ // Do not add relaunch_count for normal termination.
+ l_moduleListIter->relaunch_status = RelaunchSafe;
+ }
+ } else if (SS_SM_EXIT_RELAUNCH == f_procExitInfo.exitValue) {
+ ModuleLaunchListIter l_moduleListIter;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = RemoveModuleEntryFromHB(f_hApp, l_moduleQueueName.c_str()))) { // LCOV_EXCL_BR_LINE 4: nsfw error // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 4: nsfw error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: RemoveModuleEntryFromHB(%s) errored: %d/'%s'",
+ l_moduleQueueName.c_str(), l_eStatus,
+ GetStr(l_eStatus).c_str());
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = GetModuleIterator(l_moduleQueueName.c_str(),
+ l_moduleListIter);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:cannot be error
+ // LCOV_EXCL_START 200:cannot be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: Module %s not found in Group Launch Map",
+ l_moduleQueueName.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = SendRequestToLauncher(f_hApp, l_moduleListIter, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ ePLThrdCmd_RELAUNCH_MODULE_REQST, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ "ePLThrdCmd_RELAUNCH_MODULE_REQST"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "SendRequestToLauncher()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ // Do not add relaunch_count for normal Relaunch
+ l_moduleListIter->relaunch_status = RelaunchSafe;
+ }
+ } else {
+ SS_String l_moduleBinaryName(""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ BOOL l_resetRequired = TRUE;
+ EErrorEventResetType l_resetType;
+
+ l_eStatus = GetBinaryNameOfProcess(l_moduleQueueName, l_moduleBinaryName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200: cannot be error
+ // LCOV_EXCL_START 200: cannot be error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. Unable to identify binary for SM child process PID: %d, Queue Name: %s."
+ " The process binary name will be missing from the .csv file.",
+ f_procExitInfo.pid, l_moduleQueueName.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ strncpy(f_procExitInfo.binaryFileName,
+ l_moduleBinaryName.c_str(),
+ sizeof(f_procExitInfo.binaryFileName) - 1);
+
+ f_procExitInfo.binaryFileName[sizeof(f_procExitInfo.binaryFileName)
+ - 1] = '\0';
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ActOnModuleFailure(f_hApp,
+ l_moduleQueueName, l_resetRequired))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. ActOnModuleFailure(%s,%d) errored: %d/'%s'",
+ l_moduleQueueName.c_str(), l_resetRequired, l_eStatus,
+ GetStr(l_eStatus).c_str());
+ }
+
+ l_resetType =
+ (FALSE == l_resetRequired) ?
+ eErrorEventResetTypeNone : eErrorEventResetTypeHard;
+
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_loggingInfo.pid = f_procExitInfo.pid;
+ l_loggingInfo.exitValue = f_procExitInfo.exitValue;
+ l_loggingInfo.signalNumber = f_procExitInfo.signalNumber;
+ snprintf(l_loggingInfo.binaryFileName,
+ sizeof(l_loggingInfo.binaryFileName), "%s",
+ f_procExitInfo.binaryFileName);
+ if (eErrorEventResetTypeNone != l_resetType) {
+ l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_GENERIC_ERR;
+ }
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, eErrorEventTypeProcessExit,
+ l_moduleQueueName, l_resetType, l_loggingInfo);
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeProcessExit)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnBootMicroResetNotification
+/// Called from the logging shadow when the boot micro notifies the shadow of
+/// an unexpected boot micro reset during the last power cycle.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnBootMicroResetNotification(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_moduleName;
+ EFrameworkunifiedStatus l_eStatus;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < eSMBootMicroResetReason > (hApp, m_BootMicroResetReason))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ l_moduleName = FrameworkunifiedGetMsgSrc(hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: A boot micro reset has occurred. Reset reason: %d/'%s'.", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ m_BootMicroResetReason, GetStr(m_BootMicroResetReason).c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ l_eStatus = ErrorEventEnqueue(hApp, eErrorEventTypeBootMicroReset, l_moduleName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeBootMicroReset)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup RequestBootMicroLog
+/// Request boot micro log from the logging shadow.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::RequestBootMicroLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = FrameworkunifiedPublishEvent(hApp, // Event received by PS Logging Shadow
+ SS_SM_BOOT_MICRO_LOG_REQ,
+ NULL,
+ NULL, 0);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "FrameworkunifiedPublishEvent(SS_SM_BOOT_MICRO_LOG_REQ)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ bool result =
+ m_errorEventTimers[eSM_ERROR_EVENT_TIMER_BOOT_MICRO_LOG_RSPN].Start(
+ SS_ERROR_EVENT_BOOT_MICRO_LOG_RESPONSE_TO_SEC, 0, 0, 0);
+ if (FALSE == result) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed to start timer eSM_TIMER_BOOT_MICRO_LOG_RESPONSE.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnLowSystemMemory
+/// Called when a low memory error has been detected.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnLowSystemMemory(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SysMem l_SysMem;
+ std::string l_moduleName;
+ EFrameworkunifiedStatus l_eStatus;
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < SysMem > (hApp, l_SysMem))) {
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ } else {
+ m_FreeMemAvailable = l_SysMem.FreeMemoryBytes;
+
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: System Low Memory detected. Remaining memory: %d.", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ m_FreeMemAvailable); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ l_moduleName = FrameworkunifiedGetMsgSrc(hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_GENERIC_ERR;
+ l_eStatus = ErrorEventEnqueue(hApp, eErrorEventTypeSystemLowMemory,
+ l_moduleName, eErrorEventResetTypeHard, l_loggingInfo);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeSystemLowMemory)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+} // End of EFrameworkunifiedStatus CSystemManager::OnLowSystemMemory( HANDLE hApp )
+
+EFrameworkunifiedStatus CSystemManager::OnPropagateSystemError(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnUserInvokedLoggingRequest
+/// Called when the end user invokes a error event logging request by means
+/// of hard key or other direct input method.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnUserInvokedLoggingRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ TSystemManagerLoggingRequestInfo l_logInfo;
+ EErrorEventType l_errorEventType;
+ std::string l_moduleName;
+ EFrameworkunifiedStatus l_eStatus;
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < TSystemManagerLoggingRequestInfo > (f_hApp, l_logInfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case
+ } else {
+ l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_loggingInfo.messageStr = l_logInfo.messageStr;
+ l_loggingInfo.suffixStr = l_logInfo.suffixStr;
+
+ switch (l_logInfo.logType) {
+ case e_SS_SM_CAPTURE_ALL_LOGS:
+ l_errorEventType = eErrorEventTypeUserInvokedCollectAllLogs;
+ break;
+
+ case e_SS_SM_SCREEN_CAPTURE:
+ l_errorEventType = eErrorEventTypeUserInvokedCollectScreenShot;
+ break;
+
+ case e_SS_SM_CAPTURE_INTERFACEUNIFIED_LOGS:
+ l_errorEventType = eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs;
+ break;
+
+ case e_SS_SM_CAPTURE_DEV_LOGS:
+ l_errorEventType = eErrorEventTypeUserInvokedCollectDevLogs;
+ break;
+
+ case e_SS_SM_CAPTURE_MODULE_LOGS:
+ l_errorEventType = eErrorEventTypeModuleInvokedCollectDebugLogs;
+ break;
+
+ case e_SS_SM_CAPTURE_DTC_LOGS:
+ l_errorEventType = eErrorEventTypeDtcEvent;
+ break;
+
+ case e_SS_SM_CAPTURE_NAVI_LOGS:
+ l_errorEventType = eErrorEventTypeUserInvokedCollectNaviLog;
+ break;
+
+ case e_SS_SM_CAPTURE_GROUP_RELAUNCH:
+ l_errorEventType = eErrorEventTypeGroupRelaunch;
+ break;
+
+ default:
+ l_errorEventType = eErrorEventTypeMaxValue;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Received unknown user invoked log type: %d. Dropping request.",
+ l_logInfo.logType);
+ break;
+ }
+
+ if (eErrorEventTypeMaxValue != l_errorEventType) { // LCOV_EXCL_BR_LINE 200: will not be the else case
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: User invoked logging request %d/'%s' received. " // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "Adding the request to the event queue.", // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ l_logInfo.logType, GetStr(l_logInfo.logType).c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, l_errorEventType,
+ l_moduleName, eErrorEventResetTypeNone, l_loggingInfo);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(UserInvoked)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnEelExportRequest
+/// Called when a removable device is inserted and contains the EEL_Export
+/// trigger.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnEelExportRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_strlen = FrameworkunifiedGetMsgLength(f_hApp);
+ CHAR l_path[l_strlen]; // NOLINT
+
+ if (l_strlen == 0) { // LCOV_EXCL_BR_LINE 200: restricted by iterface_unified
+ // LCOV_EXCL_START 200: restricted by iterface_unified
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (sizeof(l_path) != FrameworkunifiedGetMsgLength(f_hApp)) { // LCOV_EXCL_BR_LINE 6: must be equal
+ // LCOV_EXCL_START 6: must be equal
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("DataSize mismatch"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK // LCOV_EXCL_BR_LINE 4: NSFW error case
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_path[0],
+ static_cast<UI_32>(sizeof(l_path)), eSMRRelease))) {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ TEXT(__FUNCTION__,
+ " ERROR EVENT: EelExport request received. Adding the request to the event queue."); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp);
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_path[l_strlen - 1] = '\0';
+ l_loggingInfo.path = l_path;
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, eErrorEventTypeEelExport,
+ l_moduleName, eErrorEventResetTypeNone, l_loggingInfo);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeEelExport)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnSystemmanagerEmmcLogsRequest
+/// Called when a removable device is inserted and contains the LOGGERSERVICE_EMMC_LOGS
+/// trigger.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnSystemmanagerEmmcLogsRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_strlen = FrameworkunifiedGetMsgLength(f_hApp);
+ CHAR l_path[l_strlen]; // NOLINT
+
+ if (l_strlen == 0) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0);
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (sizeof(l_path) != FrameworkunifiedGetMsgLength(f_hApp)) { // LCOV_EXCL_BR_LINE 8: CHAR l_path[l_strlen]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("DataSize mismatch"); // LCOV_EXCL_LINE 8: CHAR l_path[l_strlen]
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_path[0], static_cast<UI_32>(sizeof(l_path)), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW error case // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()"); // LCOV_EXCL_LINE 4:NSFW error case
+ } else {
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: LOGGERSERVICE_EMMC_LOGS request received. Adding the request to the event queue."); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ SMLoggingInfo l_loggingInfo;
+
+ l_path[l_strlen - 1u] = '\0';
+ l_loggingInfo.path = l_path;
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, eErrorEventTypeInterfaceunifiedEmmcLogs,
+ l_moduleName, eErrorEventResetTypeNone, l_loggingInfo);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeInterfaceunifiedEmmcLogs)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnSystemmanagerClearLogsRequest
+/// Called when a clear LOGGERSERVICE_EMMC_LOGS requested
+/// trigger.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnSystemmanagerClearLogsRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp);
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, eErrorEventTypeUserInvokedClearLogs, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ l_moduleName, eErrorEventResetTypeNone); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeUserInvokedClearLogs)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnDiagLoggingRequest
+/// Called by logger to initiate log artifact collection and storage on behalf
+/// of diagnostic services.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnDiagLoggingRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_strlen = FrameworkunifiedGetMsgLength(f_hApp);
+ CHAR l_path[l_strlen]; // NOLINT
+
+ if (l_strlen == 0) { // LCOV_EXCL_BR_LINE 200: restricted by iterface_unified
+ // LCOV_EXCL_START 200: restricted by iterface_unified
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200:test assert
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (sizeof(l_path) != FrameworkunifiedGetMsgLength(f_hApp)) { // LCOV_EXCL_BR_LINE 6: must be equal
+ // LCOV_EXCL_START 6: must be equal
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("DataSize mismatch"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK // LCOV_EXCL_BR_LINE 4: NSFW error case
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_path[0],
+ static_cast<UI_32>(sizeof(l_path)), eSMRRelease))) { // NOLINT
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedGetMsgDataOfSize()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_STOP
+ } else {
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: SS_SM_ERROR_EVENT_DIAG_LOG_REQ request received. Adding the request to the event queue."); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ std::string l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp);
+ SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_path[l_strlen - 1u] = '\0';
+ l_loggingInfo.path = l_path;
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, eErrorEventTypeDiagEvent,
+ l_moduleName, eErrorEventResetTypeNone, l_loggingInfo);
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeDiagEvent)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup OnCanLoggingRequest
+/// This function is called by logger to initiate log artifact collection
+/// and storage when signaled via CAN.
+///
+/// \param [in] hApp - Application handle.
+///
+/// \return EFrameworkunifiedStatus
+/// Success ==> eFrameworkunifiedStatusOK
+/// Failure ==> Other values
+///////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CSystemManager::OnCANLoggingRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+ std::string l_moduleName;
+
+ l_moduleName = FrameworkunifiedGetMsgSrc(f_hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ " ERROR EVENT: SS_SM_ERROR_EVENT_CAN_LOG_REQ received from %s.", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ l_moduleName.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+
+ l_eStatus = ErrorEventEnqueue(f_hApp, eErrorEventTypeCanEvent, l_moduleName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+ "ErrorEventEnqueue(eErrorEventTypeCanEvent)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
diff --git a/systemservice/system_manager/server/src/ss_system_memory_monitor.cpp b/systemservice/system_manager/server/src/ss_system_memory_monitor.cpp
new file mode 100755
index 0000000..7ea9b71
--- /dev/null
+++ b/systemservice/system_manager/server/src/ss_system_memory_monitor.cpp
@@ -0,0 +1,362 @@
+/*
+ * @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.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <system_service/ss_sm_thread_names_local.h>
+#include <system_service/ss_templates.h>
+#include <stub/Clock_API.h>
+
+#include <sys/stat.h>
+#include <errno.h>
+#include <sys/resource.h>
+#include <boost/bind.hpp>
+#include <fstream>
+#include <sstream>
+#include <string>
+
+#include "ss_system_memory_monitor.h"
+#include "ss_sm_systemmanagerlog.h"
+
+CSysMemoryMonitor::CSysMemoryMonitor() :
+ m_hThread(NULL),
+ m_hParentApp(NULL),
+ m_SLMCheckCounter(0),
+ m_siPriority(-1),
+ m_NbrSamplesBeforeSystemmanagerlog(0),
+ m_memMonitorThreadName(SS_SMLowMemMonitor),
+ m_resmSession(-1) { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_SLMConfig.SLMTimerValue = 0;
+ m_SLMConfig.SLMMaxRetryCount = 0;
+ m_SLMConfig.SLMThresholdValue = 0;
+ m_SLMConfig.SLMSystemmanagerLogIntervalMs = 0;
+ bzero(&m_sysMemInfoLast, sizeof(m_sysMemInfoLast));
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CSysMemoryMonitor::~CSysMemoryMonitor(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ StopAndFreeObjects(m_hParentApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::Initialize(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == f_hApp) { // LCOV_EXCL_BR_LINE 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 4:NSFW
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Argument f_hApp passed NULL pointer.");
+ } else if (NULL == (m_hThread = FrameworkunifiedCreateChildThreadWithPriority(f_hApp, SS_SMLowMemMonitor, boost::bind(&CSysMemoryMonitor::CPUMemThreadStart, this, _1), boost::bind(&CSysMemoryMonitor::CPUMemThreadStop, this, _1), PR_SMLOWMEMMON))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle; // LCOV_EXCL_LINE 4:NSFW
+ LOG_ERROR("FrameworkunifiedCreateChildThreadWithPriority()"); // LCOV_EXCL_LINE 4:NSFW
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(f_hApp, m_hThread, 0, NULL))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedStartChildThread()"); // LCOV_EXCL_LINE 4:NSFW
+ } else {
+ m_hParentApp = f_hApp;
+ m_sysMemInfoLast.TotalMemoryBytes = GetSystemRamSize();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. SLM thread successfully initialized.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::StopAndFreeObjects(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ CALL_AND_LOG_STATUS(FrameworkunifiedStopChildThread(f_hApp, m_hThread, 0, NULL)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ CALL_AND_LOG_STATUS(FrameworkunifiedDestroyChildThread(f_hApp, m_hThread)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+const std::string CSysMemoryMonitor::GetThreadName(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (m_memMonitorThreadName);
+}
+
+void CSysMemoryMonitor::SetSLMConfigData(SLMConfigParameters & f_ConfigData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_SLMConfig.SLMTimerValue = f_ConfigData.SLMTimerValue;
+ m_SLMConfig.SLMMaxRetryCount = f_ConfigData.SLMMaxRetryCount;
+ m_SLMConfig.SLMThresholdValue = f_ConfigData.SLMThresholdValue;
+ m_SLMConfig.SLMSystemmanagerLogIntervalMs = f_ConfigData.SLMSystemmanagerLogIntervalMs;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Timer value '%d', Retry Count '%d', threshold '%d', log interval '%dms'",
+ m_SLMConfig.SLMTimerValue, m_SLMConfig.SLMMaxRetryCount,
+ m_SLMConfig.SLMThresholdValue, m_SLMConfig.SLMSystemmanagerLogIntervalMs);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::CPUMemThreadStart(HANDLE f_hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(f_hThread,
+ NTFY_ResourceMgr_Availability,
+ boost::bind(&CSysMemoryMonitor::OnAvailability, this, _1));
+ if (l_eStatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SS_ASERT(0); // LCOV_EXCL_LINE 4:NSFW
+ }
+
+ if (FALSE == (m_memMonitorTimer.Initialize(f_hThread, SS_SLM_MEM_MONITOR_TIMER_ID, boost::bind(&CSysMemoryMonitor::OnMemoryTimerExpiry, this, _1)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusBadConnection; // LCOV_EXCL_LINE 4:NSFW
+ LOG_ERROR("m_memMonitorTimer.Initialize() returned 'FALSE'"); // LCOV_EXCL_LINE 4:NSFW
+ } else if (FALSE == (m_systemmanagerlogTimer.Initialize(f_hThread, SS_SLM_SYSTEMMANAGERLOG_TIMER_ID, boost::bind(&CSysMemoryMonitor::OnSystemmanagerlogTimerExpiry, this, _1)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusBadConnection; // LCOV_EXCL_LINE 4:NSFW
+ LOG_ERROR("m_systemmanagerlogTimer.Initialize() returned 'FALSE'"); // LCOV_EXCL_LINE 4:NSFW
+ } else {
+ if (m_SLMConfig.SLMTimerValue > 0) {
+ m_memMonitorTimer.SetTime(m_SLMConfig.SLMTimerValue / 1000,
+ m_SLMConfig.SLMTimerValue % 1000,
+ m_SLMConfig.SLMTimerValue / 1000,
+ m_SLMConfig.SLMTimerValue % 1000);
+ } else {
+ // default timer settings
+ m_memMonitorTimer.SetTime(SS_MEMORY_TIMER_CONFIG_MS / 1000,
+ SS_MEMORY_TIMER_CONFIG_MS % 1000,
+ SS_MEMORY_TIMER_CONFIG_MS / 1000,
+ SS_MEMORY_TIMER_CONFIG_MS % 1000);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. SLM monitor timer configuration invalid. Using default values.");
+ }
+
+ if (m_SLMConfig.SLMSystemmanagerLogIntervalMs > 0) {
+ m_systemmanagerlogTimer.SetTime(m_SLMConfig.SLMSystemmanagerLogIntervalMs / 1000,
+ m_SLMConfig.SLMSystemmanagerLogIntervalMs % 1000,
+ m_SLMConfig.SLMSystemmanagerLogIntervalMs / 1000,
+ m_SLMConfig.SLMSystemmanagerLogIntervalMs % 1000);
+ } else {
+ // default timer settings
+ m_systemmanagerlogTimer.SetTime(SS_SYSTEMMANAGERLOG_TIMER_CONFIG_MS / 1000,
+ SS_SYSTEMMANAGERLOG_TIMER_CONFIG_MS % 1000,
+ SS_SYSTEMMANAGERLOG_TIMER_CONFIG_MS / 1000,
+ SS_SYSTEMMANAGERLOG_TIMER_CONFIG_MS % 1000);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. SLM FRAMEWORKUNIFIEDLOG timer configuration invalid. Using default values.");
+ }
+
+ if (FALSE == (m_memMonitorTimer.Start())) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFault;
+ LOG_ERROR("m_memMonitorTimer.Start() returned 'FALSE'");
+ // LCOV_EXCL_STOP 4:NSFW
+ } else if (FALSE == (m_systemmanagerlogTimer.Start())) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFault;
+ LOG_ERROR("m_systemmanagerlogTimer.Start() returned 'FALSE'");
+ // LCOV_EXCL_STOP 4:NSFW
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Success.");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::CPUMemThreadStop(HANDLE f_hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ l_eStatus = StopTimers();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "StopTimers"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ if ((uint32_t) -1 != m_resmSession) {
+ if (RESM_E_OK != RESM_Close(m_resmSession)) {
+ l_eStatus = eFrameworkunifiedStatusFault;
+ LOG_ERROR("RESM_Close()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::StopTimers(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (FALSE == (m_memMonitorTimer.Stop())) { // LCOV_EXCL_BR_LINE 4:NSFW's error
+ l_eStatus = eFrameworkunifiedStatusFault;
+ LOG_ERROR("m_memMonitorTimer.Stop() returned 'FALSE'"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ if (FALSE == (m_systemmanagerlogTimer.Stop())) { // LCOV_EXCL_BR_LINE 4:NSFW's error
+ l_eStatus = eFrameworkunifiedStatusFault;
+ LOG_ERROR("m_systemmanagerlogTimer.Stop() returned 'FALSE'"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::OnMemoryTimerExpiry(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ RESM_STATUS_t l_resmStatus;
+
+ if ((uint32_t) -1 == m_resmSession) {
+ return eFrameworkunifiedStatusOK;
+ }
+
+ if (RESM_E_OK != RESM_GetStatus(m_resmSession, &l_resmStatus)) {
+ LOG_ERROR("RESM_GetStatus()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ m_sysMemInfoLast.FreeMemoryBytes = l_resmStatus.restMemSize;
+ if ((m_sysMemInfoLast.FreeMemoryBytes * 1024)
+ < (UI_32) m_SLMConfig.SLMThresholdValue) {
+ m_SLMCheckCounter++;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Low Memory detected(%d/%d).",
+ m_SLMCheckCounter, m_SLMConfig.SLMMaxRetryCount);
+
+ if (m_SLMCheckCounter >= m_SLMConfig.SLMMaxRetryCount) {
+ l_eStatus = FrameworkunifiedSendParent(hThread,
+ eSysMemThrdCmd_SYS_LOW_MEMORY, sizeof(m_sysMemInfoLast),
+ &m_sysMemInfoLast);
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
+ "FrameworkunifiedSendParent(eSysMemThrdCmd_SYS_LOW_MEMORY)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+
+ l_eStatus = StopTimers();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "StopTimers"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ } else {
+ m_SLMCheckCounter = 0;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::OnSystemmanagerlogTimerExpiry(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_freeMemoryObfuscated;
+ UI_32 l_totalMemoryObfuscated;
+
+ l_freeMemoryObfuscated = BitReverse32(m_sysMemInfoLast.FreeMemoryBytes);
+ l_totalMemoryObfuscated = BitReverse32(m_sysMemInfoLast.TotalMemoryBytes);
+
+ // Print to ZONE_WARN as per IAT requirement see WI 219056.
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "FM: [%d/%d].", l_freeMemoryObfuscated,
+ l_totalMemoryObfuscated);
+
+ static int count = 0;
+
+ if (!(count %= 2)) {
+ CHAR l_format[256];
+ uint32_t timebuf;
+ uint8_t status;
+ struct tm gmt;
+ struct tm local;
+ Clock_getSystemTimeY2K38(&timebuf, &status);
+ Clock_CnvSecToDateY2K38(&timebuf, &gmt);
+ Clock_getLocalTimeY2K38(&timebuf, &local);
+
+ sprintf(l_format, " G%02d %02d%02d%02d L%02d %02d%02d%02d", gmt.tm_mday, // NOLINT
+ gmt.tm_hour, gmt.tm_min, gmt.tm_sec, local.tm_mday,
+ local.tm_hour, local.tm_min, local.tm_sec);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s", l_format);
+ }
+
+ count++;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CSysMemoryMonitor::OnAvailability(HANDLE hThread) {
+ if (FrameworkunifiedIsServiceAvailable(hThread)) {
+ if (m_resmSession == (uint32_t) -1) {
+ if (RESM_E_OK != RESM_Open(NULL, &m_resmSession)) {
+ m_resmSession = -1;
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+UI_32 CSysMemoryMonitor::GetSystemRamSize(void) {
+ UI_32 l_ramTotalBytes = 0;
+ std::ifstream l_sFile("/proc/meminfo");
+
+ if (l_sFile.fail()) { // LCOV_EXCL_BR_LINE 5: Standard lib error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Open /proc/meminfo");
+ } else {
+ ssize_t l_position;
+ std::string l_str;
+
+ while (getline(l_sFile, l_str)) {
+
+// if (std::string::npos
+// != (l_position = static_cast<unsigned int>(l_str.find("MemTotal:", 0)))) {
+ if (0 <= (l_position = l_str.find("MemTotal:", 0))) { // LCOV_EXCL_BR_LINE 200:linux system information
+
+ l_str.erase(l_position, l_position + strlen("MemTotal:")); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ if (std::string::npos != (l_position = static_cast<unsigned int>(l_str.find("kB", 0)))) { // LCOV_EXCL_BR_LINE 200:linux system information
+ l_str.erase(l_position, l_position + strlen("kB")); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ std::istringstream l_istr(l_str); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ l_istr >> l_ramTotalBytes;
+
+ break;
+ }
+ }
+ }
+
+ return (l_ramTotalBytes);
+}
+
+UI_32 CSysMemoryMonitor::BitReverse32(UI_32 f_val) {
+ // Don't print FRAMEWORKUNIFIEDLOG(ZONE_FUNC) to prevent obfuscation method from being revealed.
+ f_val = (((f_val & 0xaaaaaaaa) >> 1) | ((f_val & 0x55555555) << 1));
+ f_val = (((f_val & 0xcccccccc) >> 2) | ((f_val & 0x33333333) << 2));
+ f_val = (((f_val & 0xf0f0f0f0) >> 4) | ((f_val & 0x0f0f0f0f) << 4));
+ f_val = (((f_val & 0xff00ff00) >> 8) | ((f_val & 0x00ff00ff) << 8));
+ f_val = (f_val >> 16) | (f_val << 16);
+ return (f_val);
+}
diff --git a/systemservice/system_manager/server/src/systemmanager_application.cpp b/systemservice/system_manager/server/src/systemmanager_application.cpp
new file mode 100755
index 0000000..506bb2c
--- /dev/null
+++ b/systemservice/system_manager/server/src/systemmanager_application.cpp
@@ -0,0 +1,237 @@
+/*
+ * @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 contains the standard set functions called by the NS
+// dispatcher on application initialization, cleanup and wakeup.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <system_service/ss_templates.h>
+
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_system_manager.h"
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnInitialization
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ eStatus = CSystemManager::GetInstance().Initialize(hApp);
+ struct rlimit setrl = {RLIM_INFINITY, RLIM_INFINITY};
+ struct rlimit getrl = {};
+ int ret = prlimit(getpid(), RLIMIT_MSGQUEUE, &setrl, &getrl);
+ if (ret != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "prlimit ret%d", ret);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Previous limits: soft=%lld; hard=%lld", (long long) getrl.rlim_cur,
+ (long long) getrl.rlim_max);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnWakeup
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnShutdown
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnDestroy
+/// \todo Add behavior to this function
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) { // LCOV_EXCL_START 14:Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEShutdown
+/// \todo Add behavior to this function
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp) { // LCOV_EXCL_START 7:Debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CSystemManager* l_instance = &CSystemManager::GetInstance();
+ if (l_instance !=NULL) {
+ l_instance->SystemManagerDebugDump(hApp);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_STATUS(l_eStatus, "Unable to acquire SM instance. Debug Dump handler not called."); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+*/
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+*/
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE h_app)
+ *
+ * @param h_app Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+*/
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SystemmanagerCloseApplication(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = CSystemManager::GetInstance().CloseApplication(hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// EOF
+
diff --git a/systemservice/system_manager/server/src/systemmanager_main.cpp b/systemservice/system_manager/server/src/systemmanager_main.cpp
new file mode 100755
index 0000000..d12aecc
--- /dev/null
+++ b/systemservice/system_manager/server/src/systemmanager_main.cpp
@@ -0,0 +1,120 @@
+/*
+ * @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 Application entry point.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <system_service/ss_system_if.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/ns_version_if.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_version.h>
+#include <system_service/ss_system_types.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <cstdlib>
+#include <fstream>
+
+#include "ss_sm_systemmanagerlog.h"
+#include "ss_system_manager.h"
+
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
+
+/// \brief: Name of the Queue that will be used to read data from.
+const CHAR AppName[] = SERVICE_SYSMANAGER;
+
+static EFrameworkunifiedStatus ArgumentParser(SI_32 cc, PCHAR str) {
+ switch (cc) {
+ case 'b':
+ CSystemManager::m_bootOpt += str;
+ break;
+ default:
+ break;
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+//////////////////////////////////////////
+// Function : main
+//////////////////////////////////////////
+int main(int argc, char *argv[]) {
+ EFrameworkunifiedStatus l_eStatus;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cbFuncs); // LCOV_EXCL_BR_LINE 15: marco defined in ss-system_if.h // NOLINT(whitespace/line_length)
+ int fd;
+/*
+ if (geteuid() == 0) { // LCOV_EXCL_BR_LINE 200: process cannot be executed by root
+ // LCOV_EXCL_START 200: process cannot be executed by root
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ printf("System cannot be started by root user!!\n"
+ "You can start system: \n"
+ " # sm > /dev/null &\n"
+ " or \n"
+ " # sm &\n");
+ // LCOV_EXCL_STOP
+ return -1;
+ }
+*/
+ fd = open("/dev/null", O_RDONLY); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (fd > 0) { // LCOV_EXCL_BR_LINE 5: open file error case.
+ int ret;
+ ret = dup2(fd, 0);
+ if (ret == -1) perror("dup2"); // LCOV_EXCL_BR_LINE 5: dup2 error case.
+ ret = close(fd); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ if (ret == -1) perror("close"); // LCOV_EXCL_BR_LINE 5: close error case.
+ } else {
+ // LCOV_EXCL_START 5: open file error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ perror("open"); // LCOV_EXCL_LINE 5: open file error case.
+ // LCOV_EXCL_STOP
+ }
+
+ // This allows overriding the already-passed-in System Manager's command
+ // line arguments by having a file exist named
+ // "/agl/rwdata/<this_file's_base_name>.args".
+ // For example, when this file is named 'SS_SystemManager', then
+ // if '/agl/rwdata/SS_SystemManager.args' is present, then the
+ // '/agl/rwdata/SS_SystemManager.args' strings are read as command line
+ // values and are passed to the FrameworkunifiedDispatcher() function.
+ // -m
+ // 0xFFFFFFFF,0xFFFFFFFF, where each bit represents a logging Zone.
+ // -c
+ // [configuration file..]
+
+ struct sched_param l_schedParam;
+
+ l_schedParam.sched_priority = PR_SS_SYSMANAGER;
+
+ if (0 != sched_setscheduler(getpid(), SCHED_FIFO, &l_schedParam)) { // LCOV_EXCL_BR_LINE 5: sched_setscheduler error case. // NOLINT(whitespace/line_length)
+ printf("ASSERT %d:%s\n", errno, strerror(errno)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+
+ CustomCommandLineOptions l_tCmdLineOptions = { "b:", NULL, ArgumentParser }; // cShortOptions,rsv,callback
+ {
+ l_eStatus = FrameworkunifiedDispatcherWithArguments(AppName, argc, argv, &cbFuncs, &l_tCmdLineOptions); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ }
+ printf("SM: Line %d: FrameworkunifiedDispatcherWithArguments() returned l_eStatus: '%d'/'%s'\n", // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+ __LINE__, l_eStatus, GetStr(l_eStatus).c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
+
+ return l_eStatus;
+} // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
diff --git a/systemservice/system_manager/server/version.txt b/systemservice/system_manager/server/version.txt
new file mode 100755
index 0000000..7fe8299
--- /dev/null
+++ b/systemservice/system_manager/server/version.txt
@@ -0,0 +1,2 @@
+AGL Sample
+20191026_release
diff --git a/systemservice/system_service.mk b/systemservice/system_service.mk
new file mode 100755
index 0000000..5444eb4
--- /dev/null
+++ b/systemservice/system_service.mk
@@ -0,0 +1,44 @@
+#############################################################
+#
+# Common Makefile for system_service
+# Copyright (C) 2017-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.
+#
+#############################################################
+
+CURRENT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
+#############################################################
+# COMPONENT_NAME must not be blank and be named snake_case
+
+COMPONENT_NAME := system_service
+
+#############################################################
+
+
+
+#############################################################
+# You can add several flags and libraries.
+# When you add -I or -L path, DO NOT USE relative path.
+# Instead, use $(CURRENT_DIR) variable
+# that indicates the path this .mk file is stored.
+
+COMPONENT_CFLAGS :=
+COMPONENT_CXXFLAGS :=
+COMPONENT_LDLIBS :=
+COMPONENT_LDFLAGS :=
+
+##############################################################
+
+include $(SDKTARGETSYSROOT)/usr/agl/share/agl.mk
diff --git a/systemservice/task_manager/LICENSE b/systemservice/task_manager/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/task_manager/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/task_manager/Makefile.client b/systemservice/task_manager/Makefile.client
new file mode 100755
index 0000000..2c1628d
--- /dev/null
+++ b/systemservice/task_manager/Makefile.client
@@ -0,0 +1,21 @@
+#
+# @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.
+#
+
+SUBDIRS := client
+
+include ../system_service.mk
+
+
diff --git a/systemservice/task_manager/Makefile.server b/systemservice/task_manager/Makefile.server
new file mode 100755
index 0000000..245dcc5
--- /dev/null
+++ b/systemservice/task_manager/Makefile.server
@@ -0,0 +1,21 @@
+#
+# @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.
+#
+
+SUBDIRS := server
+
+include ../system_service.mk
+
+
diff --git a/systemservice/task_manager/client/Makefile b/systemservice/task_manager/client/Makefile
new file mode 100755
index 0000000..7d90745
--- /dev/null
+++ b/systemservice/task_manager/client/Makefile
@@ -0,0 +1,26 @@
+#
+# @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.
+#
+
+SUBDIRS = libtskmcfg ss_data_init libtskm libprimary
+
+VPATH = ../server/include/$(COMPONENT_NAME)
+
+######### install headers(*.h) #############
+INST_HEADERS = INI_API.h INI_API.hpp Primary_common.h tskm.h tskm_type.h tskm_local_type.h
+INST_HEADERS += sysup_from.h sysup.h tskm_svc.h
+INST_HEADERS += task_manager.h
+
+include ../../system_service.mk
diff --git a/systemservice/task_manager/client/libprimary/Makefile b/systemservice/task_manager/client/libprimary/Makefile
new file mode 100755
index 0000000..f58737c
--- /dev/null
+++ b/systemservice/task_manager/client/libprimary/Makefile
@@ -0,0 +1,37 @@
+#
+# @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.
+#
+VPATH = ./src ./../../server/src
+#######################################
+INST_SHLIBS = libprimary
+
+libprimary_SRCS = pri_main.c pri_api.c tskm_port_pf.c tskm_comm.c tskm_debug.c
+LDFLAGS += -Wl,--no-as-needed
+######### linked library (dynamic) #############
+LDLIBS += -lpthread
+LDLIBS += -lstdc++
+LDLIBS += -lrt
+LDLIBS += -lSS_SystemIfUnified
+LDLIBS += -lNS_FrameworkUnified
+LDLIBS += -lcommon
+
+######### add library path #############
+
+
+CPPFLAGS = -I./include/ -I./../../include-share -I./../../server/include -I./../libtskmcfg/include
+
+CPPFLAGS += -fno-exceptions
+
+include ../../../system_service.mk
diff --git a/systemservice/task_manager/client/libprimary/include/pri_main.h b/systemservice/task_manager/client/libprimary/include/pri_main.h
new file mode 100755
index 0000000..c29a337
--- /dev/null
+++ b/systemservice/task_manager/client/libprimary/include/pri_main.h
@@ -0,0 +1,48 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_CLIENT_LIBPRIMARY_INCLUDE_PRI_MAIN_H_
+#define TASK_MANAGER_CLIENT_LIBPRIMARY_INCLUDE_PRI_MAIN_H_
+
+#include <native_service/frameworkunified_types.h>
+
+#include "system_service/tskm_type.h"
+#include "system_service/Primary_common.h"
+#include "system_service/INI_API.hpp"
+
+int pri_main(T_PRIM_PRM* p_prm, int argc, char* argv[]);
+void pri_exitStart(void* rsv);
+void pri_exitDone(int status);
+void* pri_getPrivate();
+HANDLE pri_getHandle();
+int32_t pri_setMonitorTimeout(uint32_t timeout);
+
+int32_t pri_stepForkComp(uint64_t id);
+int32_t pri_accOffComp(uint64_t id);
+
+int32_t pri_getBootInfo(T_SS_SM_START_DataStructType *info);
+int32_t pri_getExtBootInfo(T_SS_SM_START_ExtDataStructType *info);
+void pri_sendDebugDumpRes(const char *buf);
+
+void pri_init(T_PRIM_PRM* p_prm, int argc, char* argv[], int *fdNum,
+ int fdlist[INI_FD_MAX]);
+BOOL pri_handler(fd_set* p_fds);
+void pri_term(void);
+int pri_setMonitorState(BOOL bIsRun, uint32_t timeout);
+void pri_getAppHandle(void);
+
+#endif // TASK_MANAGER_CLIENT_LIBPRIMARY_INCLUDE_PRI_MAIN_H_
+
diff --git a/systemservice/task_manager/client/libprimary/libprimary.ver b/systemservice/task_manager/client/libprimary/libprimary.ver
new file mode 100755
index 0000000..bebdc98
--- /dev/null
+++ b/systemservice/task_manager/client/libprimary/libprimary.ver
@@ -0,0 +1,22 @@
+/*
+ * @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.
+ */
+
+{
+ global:
+ INI_*;
+ _INI_DEBUGDUMP*;
+ local: *;
+};
diff --git a/systemservice/task_manager/client/libprimary/src/pri_api.cpp b/systemservice/task_manager/client/libprimary/src/pri_api.cpp
new file mode 100755
index 0000000..ca1b40e
--- /dev/null
+++ b/systemservice/task_manager/client/libprimary/src/pri_api.cpp
@@ -0,0 +1,224 @@
+/*
+ * @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.
+ */
+
+#include "system_service/tskm_local_type.h"
+#include "system_service/INI_API.hpp"
+#include "tskm_debug.h"
+#include "pri_main.h"
+
+BOOL __thread isMain = FALSE; // Check for accessibility from the main thread context
+
+TSKM_STATIC BOOL isInitPrmValid(const T_PRIM_PRM* p_prm) {
+ if (p_prm == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ } else if (p_prm->shmTbl == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ } else if (p_prm->wakeupExFuncTbl == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ } else if (p_prm->downExFuncTbl == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ } else if (p_prm->onInit == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ } else if (p_prm->onDestory == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ } else if (p_prm->onDebugDump == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ } else if (p_prm->onTouch == NULL) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/******************************************************************************
+ * APIs for implementing the main thread on the service side
+ *******************************************************************************/
+/*********************************************************
+ * Primary library initialization
+ *********************************************************/
+int32_t INI_Init(T_PRIM_PRM* p_prm, int argc, char* argv[], int *fdNum,
+ int fdlist[INI_FD_MAX]) {
+ isMain = TRUE;
+ if (isInitPrmValid(p_prm) == FALSE) {
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+ pri_init(p_prm, argc, argv, fdNum, fdlist);
+ return INI_SUCCESS;
+}
+
+/***********************************************************
+ * Primary library / Event handler
+ * ret:TRUE Running
+ * ret:FALSE Finished (Terminated a process with INI_Term())
+ ************************************************************/
+BOOL INI_Handler(fd_set* p_fds) {
+ if (!isMain || NULL == p_fds) {
+ TSKM_ASSERT(0);
+ return FALSE;
+ }
+
+ return pri_handler(p_fds);
+}
+
+/***********************************************************
+ * Primary (Processing finished)
+ ************************************************************/
+void INI_Term(void) {
+ pri_term();
+}
+
+/***********************************************************
+ * Primary (State setting for watching Services)
+ ************************************************************/
+int32_t INI_SetMonitorState(T_PRIM_MONITOR_PRM *p_prm) {
+ if (!p_prm) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ return pri_setMonitorState(p_prm->bIsRun, p_prm->timeout);
+ ERROR: return INI_FALSE;
+}
+
+/******************************************************************************
+ * Hiding the Main Thread in the Primary Library
+ *******************************************************************************/
+/************************************
+ * Startup FW MainLoop
+ ************************************/
+int INI_Main(T_PRIM_PRM* p_prm, int argc, char* argv[]) {
+ if (isInitPrmValid(p_prm) == FALSE) { // LCOV_EXCL_BR_LINE 6: Checked by Init()
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+
+ isMain = TRUE;
+
+ return pri_main(p_prm, argc, argv);
+}
+
+/******************************************************************************
+ * Common API
+ *******************************************************************************/
+/************************************
+ * Process termination
+ ************************************/
+void INI_ExitStart(void * rsv) {
+ static int isCalled = 0;
+ if (isCalled) {
+ return;
+ }
+ isCalled = 1;
+ pri_exitStart(rsv);
+}
+
+void INI_ExitDone(int status) {
+ static int isCalled = 0;
+ if (isCalled) {
+ return;
+ }
+ isCalled = 1;
+ pri_exitDone(status);
+}
+
+/************************************
+ * Private Info Acquisition
+ ************************************/
+void* INI_GetPrivate() {
+ return pri_getPrivate();
+}
+
+/************************************
+ * Applicastion Handle Aquisition
+ ************************************/
+HANDLE INI_GetHandle() {
+ return pri_getHandle();
+}
+
+/************************************
+ * Timeout setting for service monitoring status setting
+ ************************************/
+int32_t INI_SetMonitorTimeout(uint32_t timeout) {
+ return pri_setMonitorTimeout(timeout);
+}
+
+/************************************
+ * Event completion notification at startup
+ ************************************/
+int32_t INI_StepForkComp(uint64_t compId) {
+ return pri_stepForkComp(compId);
+}
+
+/************************************
+ * Event completion notification at termination
+ ************************************/
+int32_t INI_AccOffComp(uint64_t compId) {
+ return pri_accOffComp(compId);
+}
+
+/************************************
+ * BOOT Info Acquisition
+ ************************************/
+int32_t INI_GetBootInfo(T_SS_SM_START_DataStructType *info) {
+ if (info == NULL) {
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+ return pri_getBootInfo(info);
+}
+
+/************************************
+ * Extended BOOT Info Acquisition
+ ************************************/
+int32_t INI_GetExtBootInfo(T_SS_SM_START_ExtDataStructType *info) {
+ if (info == NULL) {
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+ return pri_getExtBootInfo(info);
+}
+
+/************************************
+ * DebugDump Responding
+ ************************************/
+void _INI_DEBUGDUMP(BOOL bIsNeedSvcName, PCSTR cFormat, ...) { // LCOV_EXCL_START 7: for debugging
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ va_list argList;
+ char buf[TSKM_EV_DEBUGDUMP_SIZE] = { 0 };
+
+ if (bIsNeedSvcName) {
+ snprintf(buf, TSKM_EV_DEBUGDUMP_SIZE, "%s/",
+ FrameworkunifiedGetAppName(pri_getHandle()));
+ }
+
+ va_start(argList, cFormat);
+ vsnprintf(&buf[strlen(buf)], TSKM_EV_DEBUGDUMP_SIZE - strlen(buf), cFormat,
+ argList);
+ va_end(argList);
+
+ return pri_sendDebugDumpRes(buf);
+}
+// LCOV_EXCL_STOP 7
+
diff --git a/systemservice/task_manager/client/libprimary/src/pri_main.cpp b/systemservice/task_manager/client/libprimary/src/pri_main.cpp
new file mode 100755
index 0000000..9c0dd95
--- /dev/null
+++ b/systemservice/task_manager/client/libprimary/src/pri_main.cpp
@@ -0,0 +1,873 @@
+/*
+ * @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.
+ */
+
+#include "pri_main.h"
+#include <sys/eventfd.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <system_service/ss_system_if.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include "tskm_debug.h"
+#include "tskm_comm.h"
+#include "tskm_port_pf.h"
+#include "tskm_port_subsys.h"
+#include "tskm_util.h"
+
+
+#define PRI_PROC_NAME_MAX 32
+
+// Context
+typedef struct {
+ T_PRIM_PRM prm;
+
+ TSKM_SVCID_t svcId; // Set valid value by REQ_WAKEUP
+ char procName[PRI_PROC_NAME_MAX];
+ // State
+ TSKM_BOOL_t isExec;
+ T_SS_SM_START_DataStructType bootInfo;
+ T_SS_SM_START_ExtDataStructType extBootInfo; TSKM_BOOL_t isDynamic;
+ uint32_t wakeupStepDone; // Performed Local Step
+ TSKM_BOOL_t shmDone;
+ uint32_t downStepDone; // Performed Local Step
+ TSKM_BOOL_t isExitStart;
+
+#define PRI_MONITOR_DEFAULT_TIMEOUT 50
+ uint32_t timeout; // Service monitoring timeout period (valid only for the INI_Main type service)
+
+ // Resources
+ int connFd; // TSKM communication sockets
+ int nsFd; // NSFW sockets
+ int pipeFd[2]; // For exitDone
+ HANDLE hApp; // appHandle
+} PRI_CTX_t;
+
+static PRI_CTX_t g_pri;
+
+/*********************************************
+ * Create Shared Memory
+ *********************************************/
+TSKM_STATIC void shmMake(PRI_CTX_t* p_ctx) {
+ const PRIM_SHAREDATA_TBL* shmEntry;
+ for (shmEntry = p_ctx->prm.shmTbl; shmEntry->shmName[0] != '\0'; shmEntry++) {
+ int ret;
+ ret = tskm_pf_shmCreate(shmEntry->shmName, shmEntry->size, NULL);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+ p_ctx->shmDone = TSKM_TRUE;
+ return;
+
+ // LCOV_EXCL_START 6: Checked by Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************
+ * Call Backup Check CB
+ *********************************************/
+TSKM_STATIC uint32_t wakeupExFuncCallback(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ const PRIM_EXFUNC_TBL* funcEntry;
+ uint32_t maxStep = 0;
+
+ for (funcEntry = p_ctx->prm.wakeupExFuncTbl; funcEntry->localStep != 0;
+ funcEntry++) {
+ if (funcEntry->localStep == p_prm->localStep) {
+ funcEntry->func(funcEntry->prm);
+ }
+ maxStep = TSKM_MAX(maxStep, funcEntry->localStep);
+ }
+ return maxStep;
+}
+
+/*********************************************
+ * Gradual Start Request
+ *********************************************/
+TSKM_STATIC void wakeupRequest(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t prm = *p_prm;
+ uint32_t max = 0;
+
+ // Execute one step at a time
+ for (prm.localStep = p_ctx->wakeupStepDone + 1;
+ (prm.localStep <= p_prm->localStep && prm.localStep < PRIM_STEPFORK_MAX);
+ prm.localStep++) {
+ max = wakeupExFuncCallback(p_ctx, &prm);
+ }
+
+ if (max <= p_prm->localStep) {
+ // Gradual start completed
+ p_ctx->wakeupStepDone = PRIM_STEPFORK_MAX;
+ } else {
+ p_ctx->wakeupStepDone = p_prm->localStep;
+ }
+}
+
+/*********************************************
+ * All startup requests
+ *********************************************/
+TSKM_STATIC void allWakeup(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ if (!p_ctx->shmDone) {
+ shmMake(p_ctx);
+ }
+
+ if (p_ctx->wakeupStepDone < PRIM_STEPFORK_MAX) {
+ wakeupRequest(p_ctx, p_prm);
+ }
+}
+
+/*********************************************
+ * Startup request handle
+ *********************************************/
+TSKM_STATIC void wakeupRequestHandle(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+
+ bzero(&ev, sizeof(ev));
+
+ p_ctx->svcId = p_prm->svcId;
+ memcpy(&p_ctx->bootInfo, &p_prm->bootInfo, sizeof(p_ctx->bootInfo));
+ memcpy(&p_ctx->extBootInfo, &p_prm->extBootInfo, sizeof(p_ctx->extBootInfo));
+ p_ctx->isDynamic = p_prm->isDynamic;
+
+ if (p_prm->localStep == TSKM_LSTEP_ALL) {
+ allWakeup(p_ctx, p_prm);
+ } else if (p_prm->localStep == TSKM_LSTEP_LAST) {
+ wakeupRequest(p_ctx, p_prm);
+ } else if (p_prm->localStep == TSKM_LSTEP_SHM) {
+ shmMake(p_ctx);
+ } else {
+ wakeupRequest(p_ctx, p_prm);
+ }
+
+ ev.prm.resWakeup.isShmDone = p_ctx->shmDone;
+ ev.prm.resWakeup.isStepDone =
+ (p_ctx->wakeupStepDone >= PRIM_STEPFORK_MAX) ?
+ TSKM_TRUE : TSKM_FALSE;
+
+ // LCOV_EXCL_BR_START 6: Because it depends on the test order
+ if (ev.prm.resWakeup.isShmDone && ev.prm.resWakeup.isStepDone) {
+ // LCOV_EXCL_BR_STOP
+ ev.prm.resWakeup.isLast = TSKM_TRUE;
+ }
+
+ ev.event = TSKM_EV_PRI_RES_WAKEUP;
+ ev.errCode = TSKM_E_OK;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+ }
+}
+
+/*********************************************
+ * Gradual Termination CALLBACK
+ *********************************************/
+TSKM_STATIC uint32_t downExFuncCallback(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
+ const PRIM_EXFUNC_TBL* funcEntry;
+ uint32_t maxStep = 0;
+
+ for (funcEntry = p_ctx->prm.downExFuncTbl; funcEntry->localStep != 0;
+ funcEntry++) {
+ if (funcEntry->localStep == p_prm->localStep) {
+ funcEntry->func(funcEntry->prm);
+ }
+ maxStep = TSKM_MAX(maxStep, funcEntry->localStep);
+ }
+ return maxStep;
+}
+
+/*********************************************
+ * Gradual Termination Request
+ *********************************************/
+TSKM_STATIC void downRequest(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
+ TSKM_EV_PRI_REQ_DOWN_PRM_t prm = *p_prm;
+ uint32_t max = 0;
+
+ // Execute one step at a time
+ for (prm.localStep = p_ctx->downStepDone + 1;
+ (prm.localStep <= p_prm->localStep && prm.localStep < PRIM_ACCOFF_MAX);
+ prm.localStep++) {
+ max = downExFuncCallback(p_ctx, &prm);
+ }
+
+ if (max <= p_prm->localStep) {
+ p_ctx->downStepDone = PRIM_ACCOFF_MAX; // Completed all steps
+ } else {
+ p_ctx->downStepDone = p_prm->localStep;
+ }
+}
+
+TSKM_STATIC void downRequestHandle(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+
+ bzero(&ev, sizeof(ev));
+
+ if (p_prm->localStep == TSKM_LSTEP_ALL || p_prm->localStep == TSKM_LSTEP_LAST) {
+ downRequest(p_ctx, p_prm);
+ } else if (p_prm->localStep == TSKM_LSTEP_SHM) {
+ TSKM_ASSERT(0);
+ } else if (p_prm->localStep == TSKM_LSTEP_BUPCHK) {
+ TSKM_ASSERT(0);
+ } else {
+ downRequest(p_ctx, p_prm);
+ }
+
+ if (p_ctx->downStepDone >= PRIM_ACCOFF_MAX) {
+ /* It is not notified when the last function is executed, and it is left to the exitDone.
+ TSKM_PRINTF(TSKM_LOG_DEBUG,"ACCOFF DONE");
+ ev.prm.resDown.isLast = TSKM_TRUE;
+ p_ctx->isExec = TSKM_FALSE;
+ ret = tskm_sockSend(p_ctx->connFd,&ev);
+ if(ret <= 0){
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ }
+ */
+ } else {
+ ev.event = TSKM_EV_PRI_RES_DOWN;
+ ev.errCode = TSKM_E_OK;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+ }
+ }
+}
+
+/*********************************************
+ * Termination completion is notified to the TSKM
+ *********************************************/
+TSKM_STATIC void sendLastDoneRes(PRI_CTX_t* p_ctx) {
+ int ret;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+
+ ev.event = TSKM_EV_PRI_RES_DOWN;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.resDown.isLast = TSKM_TRUE;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Termination completion is notified to the TSKM.
+ // LCOV_EXCL_START 5: Termination completion is notified to the TSKM.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+ }
+}
+
+/*********************************************
+ * Invocation of Touch CB
+ *********************************************/
+TSKM_STATIC void touchService(PRI_CTX_t* p_ctx) {
+ char touchName[32];
+
+ if (p_ctx->isExitStart) {
+ // If termination processing has already begun, the system does not respond Touch but TIMEOUT the processing for retrying.
+ return;
+ }
+
+ p_ctx->prm.onTouch(p_ctx->hApp);
+
+ tskm_pf_mkTouchFileName(getpid(), touchName);
+
+ if ((access(touchName, F_OK) == 0)) {
+ // Synchronize by deleting files.
+ TSKM_PRINTF(TSKM_LOG_STATE, "del:%s", touchName);
+ unlink(touchName);
+ } else {
+ TSKM_ASSERT_PRINT(0, "%s", touchName);
+ }
+}
+
+/*********************************************
+ * Invocation of Debugdump CB
+ *********************************************/
+TSKM_STATIC void callDebugDump(PRI_CTX_t* p_ctx) {
+ if (!p_ctx->prm.onDebugDump) { // LCOV_EXCL_BR_LINE 6: As NULL checked by INI_Init
+ // LCOV_EXCL_START 6: As NULL checked by INI_Init
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ // LCOV_EXCL_STOP
+ } else {
+ p_ctx->prm.onDebugDump(p_ctx->hApp);
+ }
+}
+
+/*********************************************
+ * Invocation of LowMemory detection CB
+ *********************************************/
+TSKM_STATIC void callLowMem(PRI_CTX_t* p_ctx) {
+ if (!p_ctx->prm.onLowMem) {
+ TSKM_ASSERT(0);
+ } else if (!p_ctx->isExitStart) {
+ // Notify LowMemory only when the process is finished
+ p_ctx->prm.onLowMem(p_ctx->hApp);
+ }
+}
+
+/*********************************************
+ * Event Handle
+ *********************************************/
+TSKM_STATIC void eventHandle(PRI_CTX_t* p_ctx, TSKM_EVENT_INFO_t* p_ev) {
+ // Processing according to the request
+ switch (p_ev->event) {
+ case TSKM_EV_PRI_REQ_WAKEUP:
+ wakeupRequestHandle(p_ctx, &p_ev->prm.reqWakeup);
+ break;
+ case TSKM_EV_PRI_REQ_DOWN:
+ downRequestHandle(p_ctx, &p_ev->prm.reqDown);
+ break;
+ case TSKM_EV_PRI_REQ_TOUCH:
+ touchService(p_ctx);
+ break;
+ case TSKM_EV_PRI_REQ_DEBUGDUMP:
+ callDebugDump(p_ctx);
+ break;
+ case TSKM_EV_PRI_REP_LOWMEM:
+ callLowMem(p_ctx);
+ break;
+ default:
+ TSKM_ASSERT(0);
+ break;
+ }
+}
+
+/*********************************************
+ * Initialize Context
+ *********************************************/
+TSKM_STATIC void initCtx(T_PRIM_PRM* p_prm, PRI_CTX_t* p_ctx, int argc,
+ char* argv[]) {
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+
+ p_ctx->prm = *p_prm;
+
+ cbFuncs.onInitilization = p_ctx->prm.onInit;
+ cbFuncs.onDestroy = p_ctx->prm.onDestory;
+ cbFuncs.onDebugDump = p_ctx->prm.onDebugDump;
+ cbFuncs.onStart = FrameworkunifiedOnStart;
+ cbFuncs.onStop = FrameworkunifiedOnStop;
+ cbFuncs.onPreStart = FrameworkunifiedOnPreStart;
+ cbFuncs.onPreStop = FrameworkunifiedOnPreStop;
+ cbFuncs.onBackgroundStart = FrameworkunifiedOnBackgroundStart;
+ cbFuncs.onBackgroundStop = FrameworkunifiedOnBackgroundStop;
+ cbFuncs.createStateMachine = FrameworkunifiedCreateStateMachine;
+ cbFuncs.ssFrameworkInterface = FrameworkunifiedSSFrameworkInterface;
+
+ EFrameworkunifiedStatus taskmanagerRet;
+ taskmanagerRet = FrameworkunifiedCreateDispatcherWithoutLoop(p_ctx->prm.name, p_ctx->hApp, argc,
+ argv, &cbFuncs, FALSE);
+ if (eFrameworkunifiedStatusOK != taskmanagerRet) { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ taskmanagerRet = FrameworkunifiedGetDispatcherFD(p_ctx->hApp, &p_ctx->nsFd);
+ if (taskmanagerRet != eFrameworkunifiedStatusOK) {
+ TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
+ exit(EXIT_FAILURE);
+ }
+
+ p_ctx->connFd = tskm_cliSockConnect(TSKM_SOCKET_NAME);
+ if (p_ctx->connFd < 0) { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ if (pipe(p_ctx->pipeFd) != 0) { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ return;
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************
+ * Destroy Context
+ *********************************************/
+TSKM_STATIC void termCtx(PRI_CTX_t* p_ctx) {
+ if (p_ctx->shmDone) { // LCOV_EXCL_BR_LINE 6: Since it has been set to True by INI_Handler and cannot be changed
+ const PRIM_SHAREDATA_TBL* shmEntry = p_ctx->prm.shmTbl;
+ for (shmEntry = p_ctx->prm.shmTbl; shmEntry->shmName[0] != '\0';
+ shmEntry++) {
+ TSKM_ASSERT(0 == tskm_pf_shmDelete(shmEntry->shmName)); // LCOV_EXCL_BR_LINE 8: For processing in which only return value 0 is set
+ }
+ }
+
+ if (p_ctx->connFd > 0) { // LCOV_EXCL_BR_LINE 6: As it is already set by INI_Init and cannot be changed
+ tskm_sockDestory(p_ctx->connFd);
+ }
+
+ EFrameworkunifiedStatus taskmanagerRet;
+ taskmanagerRet = FrameworkunifiedDestroyDispatcherWithoutLoop(p_ctx->hApp);
+ TSKM_ASSERT(taskmanagerRet == eFrameworkunifiedStatusOK);
+
+ if (p_ctx->isDynamic) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "EXIT %s", p_ctx->procName);
+ } else {
+ // Hung up running services to prevent adversely affecting to system termination processing during process termination processing
+ sleep(TSKM_CFG_WAIT_SHUTDOWN);
+ }
+}
+
+/*******************************************************************
+ * PRI Context Initialization
+ *******************************************************************/
+void pri_init(T_PRIM_PRM* p_prm, int argc, char* argv[], int *fdNum,
+ int fdlist[INI_FD_MAX]) {
+ int ret = 0;
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ strncpy(p_ctx->procName, basename(argv[0]), sizeof(p_ctx->procName) - 1);
+
+ ret = tskm_pf_procInit();
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 6: Return value of 0 only
+ // LCOV_EXCL_START 6: Return value of 0 only
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ ret = tskm_comm_procInit();
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ initCtx(p_prm, p_ctx, argc, argv);
+
+ *fdNum = 3;
+ fdlist[0] = p_ctx->connFd;
+ fdlist[1] = p_ctx->pipeFd[0];
+ fdlist[2] = p_ctx->nsFd;
+
+ p_ctx->svcId = TSKM_SVCID_NONE;
+ p_ctx->isExec = TSKM_TRUE;
+
+ p_ctx->bootInfo.startupReason = epswfINVALID;
+ p_ctx->bootInfo.isUserModeOn = FALSE;
+ p_ctx->bootInfo.dataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
+ p_ctx->bootInfo.securityStatus = epsssINVALID;
+ p_ctx->bootInfo.wakeupType = epsstINVALID;
+ p_ctx->bootInfo.dramBackupStatus = e_SS_SM_DRAM_BACKUP_UNSET;
+ p_ctx->bootInfo.resetStatus = e_SS_SM_RESET_STATUS_UNSET;
+
+ memset(&p_ctx->extBootInfo, 0, sizeof(p_ctx->extBootInfo));
+
+ p_ctx->timeout = PRI_MONITOR_DEFAULT_TIMEOUT;
+
+ return;
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort(); // ABORT
+ // LCOV_EXCL_STOP
+}
+
+/*******************************************************************
+ * Primary Library Handler
+ *******************************************************************/
+BOOL pri_handler(fd_set* p_fds) {
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ if (FD_ISSET(p_ctx->connFd, p_fds)) {
+ int ret;
+ TSKM_EVENT_INFO_t ev;
+ ret = tskm_sockRcv(p_ctx->connFd, &ev);
+ // LCOV_EXCL_BR_START 5: Condition is true. False condition is checked in Death tests, but not reflected in coverage and excluded
+ if (ret > 0) {
+ // LCOV_EXCL_BR_STOP
+ eventHandle(p_ctx, &ev);
+ } else { // LCOV_EXCL_BR_LINE 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (FD_ISSET(p_ctx->pipeFd[0], p_fds)) {
+ // only use exitDone
+ uint32_t tmp;
+ TSKM_ASSERT(sizeof(tmp) == read(p_ctx->pipeFd[0], &tmp, sizeof(tmp)));
+ TSKM_ASSERT(p_ctx->downStepDone == PRIM_ACCOFF_MAX); // Check if all exit functions are complete
+ if (p_ctx->isDynamic) {
+ // A nonresident service completes its termination processing by terminating the process.
+ // (because the SIGNAL will overtake the sockets)
+ } else {
+ // The resident service is a termination notice and completes termination processing.
+ // (Do not terminate processes to reduce the impact on system termination)
+ sendLastDoneRes(p_ctx);
+ }
+ p_ctx->isExec = TSKM_FALSE;
+ }
+
+ if (FD_ISSET(p_ctx->nsFd, p_fds)) {
+ FrameworkunifiedDispatchProcessWithoutLoop(p_ctx->hApp);
+ }
+ return p_ctx->isExec;
+
+ // LCOV_EXCL_START 5: Checked by Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort(); // ABORT
+ return 0;
+ // LCOV_EXCL_STOP
+}
+
+/*******************************************************************
+ * Process termination
+ *******************************************************************/
+void pri_term(void) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ termCtx(p_ctx);
+}
+
+/*******************************************************************
+ * Service Monitoring Status Setting
+ *******************************************************************/
+int pri_setMonitorState(BOOL bIsRun, uint32_t timeout) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ int ret = INI_SUCCESS;
+
+ if (TSKM_SVCID_NONE == p_ctx->svcId) {
+ // Ignore requests until svcId is acquired.
+ } else if ((TRUE == bIsRun) && (0 == timeout)) {
+ // When RUN is specified with timeout = 0, monitoring is disabled.
+ } else {
+ ret = tskm_comm_setSvcWatchState(p_ctx->svcId, bIsRun, timeout);
+ if (INI_SUCCESS != ret) {
+ TSKM_ASSERT(0);
+ }
+ }
+
+ return ret;
+}
+
+/*******************************************************************
+ * MAIN Function
+ *******************************************************************/
+int pri_main(T_PRIM_PRM* p_prm, int argc, char* argv[]) {
+ int mainRet = -1;
+ int fdlist[INI_FD_MAX];
+ int fdNum;
+ int ii;
+ BOOL isExec = TRUE;
+
+ pri_init(p_prm, argc, argv, &fdNum, fdlist);
+
+ while (isExec) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ int maxFd = 0;
+ fd_set fds;
+ int ret;
+
+ FD_ZERO(&fds);
+
+ for (ii = 0; ii < fdNum; ii++) {
+ FD_SET(fdlist[ii], &fds);
+ maxFd = TSKM_MAX(fdlist[ii], maxFd);
+ }
+
+ TSKM_ASSERT(INI_SUCCESS == pri_setMonitorState(FALSE, 0));
+ ret = select(maxFd + 1, &fds, NULL, NULL, NULL);
+ TSKM_ASSERT(INI_SUCCESS == pri_setMonitorState(TRUE, p_ctx->timeout));
+ if (ret < 1) {
+ // LCOV_EXCL_START 5: Select's Error-Handling Process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno != EINTR) {
+ TSKM_ASSERT(0);
+ }
+ continue;
+ // LCOV_EXCL_STOP
+ }
+
+ isExec = pri_handler(&fds);
+ }
+
+ mainRet = 0;
+
+ pri_term();
+ return mainRet;
+}
+
+/*******************************************************************
+ * Termination Request
+ *******************************************************************/
+void pri_exitStart(void *rsv) {
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+ p_ctx->isExitStart = TRUE;
+ ev.event = TSKM_EV_PRI_REQ_EXIT;
+ ev.errCode = TSKM_E_OK;
+
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: The caller's external API does not execute the second or subsequent processing and cannot be checked.
+ // LCOV_EXCL_START 5: The caller's external API does not execute the second or subsequent processing and cannot be checked.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ return;
+ // LCOV_EXCL_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked.
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+}
+
+void pri_exitDone(int status) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ uint32_t l_status = (uint32_t) status;
+
+ if (p_ctx->pipeFd[1] > 0) { // LCOV_EXCL_BR_LINE 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
+ // LCOV_EXCL_BR_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
+ TSKM_ASSERT_ERRNO(
+ write(p_ctx->pipeFd[1], &l_status, sizeof(l_status))
+ == sizeof(l_status));
+ // LCOV_EXCL_BR_STOP
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: The caller's external API does not execute the second or subsequent processing and cannot be checked.
+ }
+}
+
+/*******************************************************************
+ * Event completion notification at startup
+ *******************************************************************/
+int32_t pri_stepForkComp(uint64_t id) {
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+ ev.event = TSKM_EV_PRI_REP_WAKEUP_COMP;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.repWakeupComp.compId = id;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ return INI_SUCCESS;
+ ERROR: return INI_FALSE;
+}
+
+/*******************************************************************
+ * Event completion notification at termination
+ *******************************************************************/
+int32_t pri_accOffComp(uint64_t id) {
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+
+ ev.event = TSKM_EV_PRI_REP_DOWN_COMP;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.repDownComp.compId = id;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ return INI_SUCCESS;
+ ERROR: return INI_FALSE;
+}
+
+/*******************************************************************
+ * Private Information Acquisition
+ *******************************************************************/
+void*
+pri_getPrivate() {
+ PRI_CTX_t* p_ctx = &g_pri;
+ return p_ctx->prm.priv;
+}
+
+/*******************************************************************
+ * App Handle Acquisition
+ *******************************************************************/
+HANDLE pri_getHandle() {
+ PRI_CTX_t* p_ctx = &g_pri;
+ return p_ctx->hApp;
+}
+
+/*******************************************************************
+ * Timeout setting for Service monitoring status setting
+ *******************************************************************/
+int32_t pri_setMonitorTimeout(uint32_t timeout) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ p_ctx->timeout = timeout;
+ return INI_SUCCESS;
+}
+
+/*******************************************************************
+ * BOOT Info Acquisition
+ *******************************************************************/
+int32_t pri_getBootInfo(T_SS_SM_START_DataStructType *info) {
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ if (p_ctx->bootInfo.startupReason == epswfINVALID) {
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+
+ *info = p_ctx->bootInfo;
+
+ return INI_SUCCESS;
+}
+
+/*******************************************************************
+ * Extended BOOT Info Acquisition
+ *******************************************************************/
+int32_t pri_getExtBootInfo(T_SS_SM_START_ExtDataStructType *info) {
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ if (p_ctx->bootInfo.startupReason == epswfINVALID) {
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+
+ *info = p_ctx->extBootInfo;
+
+ return INI_SUCCESS;
+}
+
+/*******************************************************************
+ * DebugDump Responding
+ *******************************************************************/
+void pri_sendDebugDumpRes(const char *buf) { // LCOV_EXCL_START 7: for debugging
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+ TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *p_prm;
+
+ ev.event = TSKM_EV_PRI_RES_DEBUGDUMP;
+ ev.errCode = TSKM_E_OK;
+ ev.hasExtend = TSKM_TRUE;
+
+ ev.extendPrm = malloc(sizeof(TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t));
+ if (!ev.extendPrm) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ ev.extendSize = sizeof(TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t);
+
+ p_prm = (TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *) ev.extendPrm; // NOLINT ( )
+ snprintf(p_prm->dumpMsg, TSKM_EV_DEBUGDUMP_SIZE, "%s", buf);
+
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ }
+
+ ERROR: return;
+}
+// LCOV_EXCL_STOP
+/*************************************************
+ * Empty functions implemented for building software
+ **************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
diff --git a/systemservice/task_manager/client/libtskm/Makefile b/systemservice/task_manager/client/libtskm/Makefile
new file mode 100755
index 0000000..b0f7e2f
--- /dev/null
+++ b/systemservice/task_manager/client/libtskm/Makefile
@@ -0,0 +1,35 @@
+#
+# @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.
+#
+
+VPATH = ./ ./src
+
+INST_SHLIBS = libtskm
+
+RPC_API := TSKM
+
+libtskm_SRCS = tskm_api_stub.c
+libtskm_SRCS += tskm_api_lib.cpp
+
+CPPFLAGS += -I. -I../../include-share -I./ -I../../server/include -I./../libtskmcfg/include
+
+######## add compile option ########
+CPPFLAGS += -fno-exceptions
+LDFLAGS += -Wl,--no-as-needed
+######### linked library (dynamic) #############
+LDLIBS += -lrpc
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+
+include ../../../system_service.mk
diff --git a/systemservice/task_manager/client/libtskm/TSKM.api b/systemservice/task_manager/client/libtskm/TSKM.api
new file mode 100755
index 0000000..023f53b
--- /dev/null
+++ b/systemservice/task_manager/client/libtskm/TSKM.api
@@ -0,0 +1,9 @@
+INCLUDE <system_service/tskm.h>
+
+RPC_Result _TSKM_SvcCtl(TSKM_SVCID_t svcId,const TSKM_SVC_CTL_t* ctl);
+RPC_Result TSKM_SvcGetInfo(TSKM_SVCID_t svcId,TSKM_SVC_INFO_t* svcInfo);
+RPC_Result _TSKM_ErrorReboot(const TSKM_ERROR_REBOOT_t* p_info);
+RPC_Result TSKM_Reboot(const TSKM_RSV_t * p_rsv);
+RPC_Result TSKM_Logging(const TSKM_LOGGING_INFO_t* p_info);
+RPC_Result TSKM_SetWakeupOrder(const TSKM_WAKEUP_ORDER_t* p_order);
+
diff --git a/systemservice/task_manager/client/libtskm/libtskm.ver b/systemservice/task_manager/client/libtskm/libtskm.ver
new file mode 100755
index 0000000..4d68cee
--- /dev/null
+++ b/systemservice/task_manager/client/libtskm/libtskm.ver
@@ -0,0 +1,21 @@
+/*
+ * @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.
+ */
+
+{
+ global:
+ TSKM_*;
+ local: *;
+};
diff --git a/systemservice/task_manager/client/libtskm/src/tskm_api_lib.cpp b/systemservice/task_manager/client/libtskm/src/tskm_api_lib.cpp
new file mode 100755
index 0000000..625b639
--- /dev/null
+++ b/systemservice/task_manager/client/libtskm/src/tskm_api_lib.cpp
@@ -0,0 +1,90 @@
+/*
+ * @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.
+ */
+
+#include <unistd.h>
+#include <signal.h>
+
+#include <native_service/frameworkunified_framework_if.h>
+
+#include "tskm_debug.h"
+#include "tskm_api.h"
+
+TSKM_ERR_t TSKM_SvcCtl(TSKM_SVCID_t svcId, const TSKM_SVC_CTL_t* ctl) {
+ TSKM_ERR_t tskmRet;
+ int ii;
+
+ for (ii = 0; ii < 3; ii++) {
+ // Retry three times
+ tskmRet = _TSKM_SvcCtl(svcId, ctl);
+ if (tskmRet == TSKM_E_RETRY) {
+ usleep(300 * 1000); // 300ms wait
+ } else {
+ break;
+ }
+ }
+
+ return tskmRet;
+}
+
+TSKM_ERR_t TSKM_ErrorReboot(const TSKM_ERROR_REBOOT_t* p_info) {
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+ RPC_Result rpcRet;
+
+ rpcRet = _TSKM_ErrorReboot(p_info);
+ if (RPC_OK != rpcRet) {
+ tskmRet = TSKM_E_PAR;
+ }
+
+ return tskmRet;
+}
+
+TSKM_ERR_t TSKM_DataInit(HANDLE hApp, const TSKM_DATAINIT_t *p_info) {
+ TSKM_ERR_t tskmRet = TSKM_E_NG;
+ TSKM_PRINTF(TSKM_LOG_API, "%s()", __FUNCTION__)
+
+ if (!p_info || !hApp || (p_info->type != TSKM_DATAINIT_TYPE_USER)
+ || !(p_info->onCompInit)) {
+ TSKM_ASSERT(0);
+ return TSKM_E_PAR;
+ }
+
+ // LCOV_EXCL_BR_START 10: Due to compiler dependency
+ EFrameworkunifiedStatus l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp,
+ SS_TASK_MANAGER,
+ TSKM_DATAINIT_RESP,
+ p_info->onCompInit);
+ // LCOV_EXCL_BR_STOP
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ } else {
+ HANDLE hSvc = FrameworkunifiedOpenService(hApp, SS_TASK_MANAGER);
+ if (hSvc == NULL) {
+ TSKM_ASSERT(0);
+ tskmRet = TSKM_E_STATE;
+ } else {
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hSvc, TSKM_DATAINIT_REQ, 0, NULL)) {
+ TSKM_ASSERT(0);
+ } else {
+ tskmRet = TSKM_E_OK;
+ }
+ }
+
+ TSKM_ASSERT(eFrameworkunifiedStatusOK == FrameworkunifiedCloseService(hApp, hSvc));
+ }
+
+ return tskmRet;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/client/libtskmcfg/Makefile b/systemservice/task_manager/client/libtskmcfg/Makefile
new file mode 100755
index 0000000..9fe2ed3
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/Makefile
@@ -0,0 +1,93 @@
+#
+# @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.
+#
+
+WAKESHUTCONF_DIR=./conf
+
+VPATH = ./src ./include/$(COMPONENT_NAME)
+
+INST_SHLIBS = libtskmcfg
+INST_HEADERS = tskm_xml_data.h tskm_svcid.h task_manager_libtskmcfg.h
+libtskmcfg_SRCS = tskm_xml_data.cpp
+
+
+CPPFLAGS = -I./ -I./include -I./../../include-share -I./../../server/include
+LDFLAGS += -Wl,--no-as-needed
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+
+
+#============ XML PARSE ============
+XMLOUTFILE= tskm_auto_build.h
+
+CLEAN_FILES+=$(XMLOUTFILE) $(PARSEXMLCMD) $(CONFIG_FILES) top.xml
+
+#TOOLS
+HOST_CPP=cpp
+XMLCHECKER=xmllint
+XMLCHECKEROPT=--noout --valid
+PARSEXMLCMD=parsexml
+HOSTCC=gcc
+XMLFILETOP=tskm_cfg.xml
+
+install:install-pre install-pre-header
+build-lib:install-pre install-pre-header
+install-lib:install-pre install-pre-header
+install-pre:
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/BS/ss/task_manager/rodata;\
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/BS/ss/task_manager/rodata $(WAKESHUTCONF_DIR)/tskm_launch.xml;\
+
+CONFIG_FILES:=tskm_wakeup.xml tskm_shutdown.xml tskm_wakeup_vup.xml tskm_shutdown_vup.xml tskm_launch.xml tskm_svcid.h agl_thread.h
+
+#install-header:$(XMLOUTFILE)
+install-pre-header:$(XMLOUTFILE)
+
+#TOPFILE
+top.xml:$(XMLFILETOP)
+ ln -fs $< $@
+
+#CONFIG RULES
+tskm_wakeup.xml:$(WAKESHUTCONF_DIR)/tskm_wakeup.xml
+ ln -fs $< $@
+
+tskm_shutdown.xml:$(WAKESHUTCONF_DIR)/tskm_shutdown.xml
+ ln -fs $< $@
+
+tskm_wakeup_vup.xml:$(WAKESHUTCONF_DIR)/tskm_wakeup_vup.xml
+ ln -fs $< $@
+
+tskm_shutdown_vup.xml:$(WAKESHUTCONF_DIR)/tskm_shutdown_vup.xml
+ ln -fs $< $@
+
+#tskm_svcid.h:$(SVCONF_DIR)/tskm_svcid.h
+# ln -fs $< $@
+
+agl_thread.h:$(WAKESHUTCONF_DIR)/agl_thread.h
+ ln -fs $< $@
+
+
+tskm_launch.xml:$(WAKESHUTCONF_DIR)/tskm_launch.xml agl_thread.h
+ $(HOST_CPP) -P -include agl_thread.h $< > $@
+#tskm_launch.xml:$(SVCONF_DIR)/tskm_launch.xml $(SDKTARGETSYSROOT)/usr/agl/include/agl_thread.h
+# $(HOST_CPP) -P -include agl_thread.h $< > $@
+
+$(XMLOUTFILE):top.xml $(PARSEXMLCMD) $(CONFIG_FILES)
+ $(XMLCHECKER) $(XMLCHECKEROPT) $<
+ ./$(PARSEXMLCMD) $<
+
+$(PARSEXMLCMD):$(PARSEXMLCMD).c
+ $(HOSTCC) -o $@ $< -lexpat
+
+include ../../../system_service.mk
+
diff --git a/systemservice/task_manager/client/libtskmcfg/conf/agl_thread.h b/systemservice/task_manager/client/libtskmcfg/conf/agl_thread.h
new file mode 100755
index 0000000..83ac087
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/conf/agl_thread.h
@@ -0,0 +1,1377 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ */
+
+#ifndef __AGL_THREAD_H__
+#define __AGL_THREAD_H__
+
+//MACRO
+#define PR_TSS_S "0"
+#define PR_TSS 0
+
+/*
+ Main thread name. It need to be same as service name in sm_launch.xml or tskm_launch.xml
+ Max name length is 15
+ #define MN_XXXXX "MainName"
+
+ Thread name
+ Max name length is 15
+ #define TN_XXXXX "ThreadName"
+
+ Thread priority 0:TSS 1-99:FIFO
+ #define PR_XXXXX_S "(0-99)" //for xml
+ #define PR_XXXXX 0-99 //for program
+*/
+
+#define MN_SS_SYSMANAGER "SS_SysManager"
+#define PR_SS_SYSMANAGER_S "20"
+#define PR_SS_SYSMANAGER (20)
+
+ #define TN_SMHEARTBEAT "SM.Heartbeat"
+ #define PR_SMHEARTBEAT_S "20"
+ #define PR_SMHEARTBEAT (20)
+
+ #define TN_SMPROCLAUNCH "SM.ProcLaunch"
+ #define PR_SMPROCLAUNCH_S "20"
+ #define PR_SMPROCLAUNCH (20)
+
+ #define TN_SMLOWMEMMON "SM.LowMemMon"
+ #define PR_SMLOWMEMMON_S "20"
+ #define PR_SMLOWMEMMON (20)
+
+ #define TN_LOGGERRTIME "LoggerRtime"
+ #define PR_LOGGERRTIME_S PR_TSS_S
+ #define PR_LOGGERRTIME PR_TSS
+
+
+//======= exec from system manager =============
+#define MN_NS_SHAREDMEM "NS_SharedMem"
+#define PR_NS_SHAREDMEM_S "25"
+#define PR_NS_SHAREDMEM (25)
+
+
+#define MN_NS_NPPSERVICE "NS_NPPService"
+#define PR_NS_NPPSERVICE_S "25"
+#define PR_NS_NPPSERVICE (25)
+
+ #define TN_NS_NPPREADWKR "NS_NPPReadWkr"
+ #define PR_NS_NPPREADWKR_S "25"
+ #define PR_NS_NPPREADWKR (25)
+
+ #define TN_NS_NPPWRITEWKR "NS_NPPWriteWkr"
+ #define PR_NS_NPPWRITEWKR_S "25"
+ #define PR_NS_NPPWRITEWKR (25)
+
+ #define TN_NS_NPPIPWKR "NS_NPPIPWkr"
+ #define PR_NS_NPPIPWKR_S "25"
+ #define PR_NS_NPPIPWKR (25)
+
+#define MN_NS_BACKUPMGR "NS_BackupMgr"
+#define PR_NS_BACKUPMGR_S "25"
+#define PR_NS_BACKUPMGR (25)
+
+ #define TN_NS_BKUPNAND "NS_BkupNAND"
+ #define PR_NS_BKUPNAND_S "25"
+ #define PR_NS_BKUPNAND (25)
+
+ #define TN_NS_BKUPDELAY "NS_BkupDelay"
+ #define PR_NS_BKUPDELAY_S "25"
+ #define PR_NS_BKUPDELAY (25)
+
+#define MN_SS_DEVDETECTSRV "SS_DevDetectSrv"
+#define PR_SS_DEVDETECTSRV_S "20"
+#define PR_SS_DEVDETECTSRV (20)
+
+ #define TN_SS_DETECT_USB "SS_Detect_USB"
+ #define PR_SS_DETECT_USB_S "20"
+ #define PR_SS_DETECT_USB (20)
+
+ #define TN_SS_DETECT_SD "SS_Detect_SD"
+ #define PR_SS_DETECT_SD_S "20"
+ #define PR_SS_DETECT_SD (20)
+
+ #define TN_SS_MONITOR_OVC "SS_Monitor_OVC"
+ #define PR_SS_MONITOR_OVC_S "20"
+ #define PR_SS_MONITOR_OVC (20)
+
+#define MN_SS_LOGGERSRV "SS_LoggerSrv"
+#define PR_SS_LOGGERSRV_S PR_TSS_S
+#define PR_SS_LOGGERSRV PR_TSS
+
+ #define TN_PDGLOGQUER "pdg.LogQueR"
+ #define PR_PDGLOGQUER_S PR_TSS_S
+ #define PR_PDGLOGQUER PR_TSS
+
+ #define TN_PDGTRANSQUER "pdg.TransQueR"
+ #define PR_PDGTRANSQUER_S PR_TSS_S
+ #define PR_PDGTRANSQUER PR_TSS
+
+ #define TN_PDGEVNTLOGQUE "pdg.EvntLogQue"
+ #define PR_PDGEVNTLOGQUE_S PR_TSS_S
+ #define PR_PDGEVNTLOGQUE PR_TSS
+
+ #define TN_SSLOGGERSTRAGE "SSLoggerStrage"
+ #define PR_SSLOGGERSTRAGE_S PR_TSS_S
+ #define PR_SSLOGGERSTRAGE PR_TSS
+
+ #define TN_PFDRECTHREAD "PFDRECThread"
+ #define PR_PFDRECTHREAD_S PR_TSS_S
+ #define PR_PFDRECTHREAD PR_TSS
+
+#define MN_PS_LOGGERSHADOW "PS_LoggerShadow"
+ #define PR_PSLOGGERSHADOW_S PR_TSS_S
+ #define PR_PSLOGGERSHADOW PR_TSS
+
+#define MN_UDEVD "udevd"
+#define PR_UDEVD_S "1"
+#define PR_UDEVD (1)
+
+#define MN_COMMUNICATION "Communication"
+#define PR_COMMUNICATION_S "30"
+#define PR_COMMUNICATION (30)
+
+ #define TN_DEV_SYSCOM_TMR "DEV_SYSCOM_TMR"
+ #define PR_DEV_SYSCOM_TMR_S "30"
+ #define PR_DEV_SYSCOM_TMR (30)
+
+ #define TN_DEV_SYSCOM_RCV "DEV_SYSCOM_RCV"
+ #define PR_DEV_SYSCOM_RCV_S "30"
+ #define PR_DEV_SYSCOM_RCV (30)
+
+ #define TN_DEV_SYSCOM_MAIN "DEV_SYSCOM_MAIN"
+ #define PR_DEV_SYSCOM_MAIN_S "30"
+ #define PR_DEV_SYSCOM_MAIN (30)
+
+ #define TN_TGWCOM "TGWCOM"
+ #define PR_TGWCOM_S "30"
+ #define PR_TGWCOM (30)
+
+ #define TN_ICM "ICM"
+ #define PR_ICM_S "30"
+ #define PR_ICM (30)
+
+ #define TN_CAN_COM_PROT "CAN_COM_PROT"
+ #define PR_CAN_COM_PROT_S "30"
+ #define PR_CAN_COM_PROT (30)
+
+#define MN_PS_PSMSHADOW "PS_PSMShadow"
+#define PR_PS_PSMSHADOW_S "30"
+#define PR_PS_PSMSHADOW (30)
+
+#define MN_COMMSH4A "CommSH4A"
+#define PR_COMMSH4A_S "30"
+#define PR_COMMSH4A (30)
+
+ #define TN_DEV_SH4A_SND "DEV_SH4ACOM_SND"
+ #define PR_DEV_SH4A_SND_S "30"
+ #define PR_DEV_SH4A_SND (30)
+
+ #define TN_DEV_SH4A_RCV "DEV_SH4ACOM_RCV"
+ #define PR_DEV_SH4A_RCV_S "30"
+ #define PR_DEV_SH4A_RCV (30)
+
+ #define TN_DEV_SH4A_MON "DEV_SH4ACOM_MON"
+ #define PR_DEV_SH4A_MON_S "30"
+ #define PR_DEV_SH4A_MON (30)
+
+#define MN_PS_COMMUSB "PS_CommUSB"
+#define PR_PS_COMMUSB_S "30"
+#define PR_PS_COMMUSB (30)
+
+ #define TN_COMMUSB_RCV "COMMUSB_RCV"
+ #define PR_COMMUSB_RCV_S "30"
+ #define PR_COMMUSB_RCV (30)
+
+ #define TN_COMMUSB_DIAG "COMMUSB_DIAG"
+ #define PR_COMMUSB_DIAG_S "30"
+ #define PR_COMMUSB_DIAG (30)
+
+#define MN_PS_CANGW_M "CANGW_M"
+#define PR_PS_CANGW_M_S PR_TSS_S
+#define PR_PS_CANGW_M PR_TSS
+
+ #define TN_CANGW_M_RCV "CANGW_M_RCV"
+ #define PR_CANGW_M_RCV_S PR_TSS_S
+ #define PR_CANGW_M_RCV PR_TSS
+
+ #define TN_CANGW_M_DIAG "CANGW_M_DIAG"
+ #define PR_CANGW_M_DIAG_S PR_TSS_S
+ #define PR_CANGW_M_DIAG PR_TSS
+
+#define MN_PS_CANGW_S "CANGW_S"
+#define PR_PS_CANGW_S_S PR_TSS_S
+#define PR_PS_CANGW_S PR_TSS
+
+ #define TN_CANGW_S_SND "CANGW_S_SND"
+ #define PR_CANGW_S_SND_S PR_TSS_S
+ #define PR_CANGW_S_SND PR_TSS
+
+ #define TN_CANGW_S_DIAG "CANGW_S_DIAG"
+ #define PR_CANGW_S_DIAG_S PR_TSS_S
+ #define PR_CANGW_S_DIAG PR_TSS
+
+#define MN_LANSERVER "LanServer"
+#define PR_LANSERVER_S "20"
+#define PR_LANSERVER (20)
+
+#define MN_PS_CDR "ps_cdr"
+#define PR_PS_CDR_S PR_TSS_S
+#define PR_PS_CDR PR_TSS
+
+ #define TN_PS_CDR_NBD "ps_cdr_nbd"
+ #define PR_PS_CDR_NBD_S PR_TSS_S
+ #define PR_PS_CDR_NBD PR_TSS
+
+ #define TN_PS_CDR_DOIT "ps_cdr_doit"
+ #define PR_PS_CDR_DOIT_S PR_TSS_S
+ #define PR_PS_CDR_DOIT PR_TSS
+
+ #define TN_PS_CDR_READ "ps_cdr_read"
+ #define PR_PS_CDR_READ_S PR_TSS_S
+ #define PR_PS_CDR_READ PR_TSS
+
+#define MN_POSITIONING "Positioning"
+#define PR_POSITIONING_S PR_TSS_S
+#define PR_POSITIONING PR_TSS
+
+ #define TN_POSITIONING_GPS_MAIN "POS_Main"
+ #define PR_POSITIONING_GPS_MAIN_S PR_TSS_S
+ #define PR_POSITIONING_GPS_MAIN PR_TSS
+
+ #define TN_POSITIONING_GPS_RECV "POS_Gps_Recv"
+ #define PR_POSITIONING_GPS_RECV_S PR_TSS_S
+ #define PR_POSITIONING_GPS_RECV PR_TSS
+
+ #define TN_POSITIONING_GPS "POS_Gps"
+ #define PR_POSITIONING_GPS_S PR_TSS_S
+ #define PR_POSITIONING_GPS PR_TSS
+
+ #define TN_POSITIONING_SENS "POS_Sens"
+ #define PR_POSITIONING_SENS_S PR_TSS_S
+ #define PR_POSITIONING_SENS PR_TSS
+
+ #define TN_POSITIONING_GPS_ROLOVR "POS_Gps_Rolovr"
+ #define PR_POSITIONING_GPS_ROLOVR_S PR_TSS_S
+ #define PR_POSITIONING_GPS_ROLOVR PR_TSS
+
+#define MN_CLOCK "clock"
+#define PR_CLOCK_S "20"
+#define PR_CLOCK (20)
+
+ #define TN_CLOCK_MNG "ClockMng"
+ #define PR_CLOCK_MNG_S "20"
+ #define PR_CLOCK_MNG (20)
+
+#define MN_VEHICLE "vehicle"
+#define PR_VEHICLE_S "20"
+#define PR_VEHICLE (20)
+
+ #define TN_VEHICLE_SENS "VehicleSens"
+ #define PR_VEHICLE_SENS_S "20"
+ #define PR_VEHICLE_SENS (20)
+
+ #define TN_LINE_SENS_DRV "LineSensDrv"
+ #define PR_LINE_SENS_DRV_S "20"
+ #define PR_LINE_SENS_DRV (20)
+
+#define MN_SS_POWERSERVICE "SS_PowerService"
+#define PR_SS_POWERSERVICE_S "30"
+#define PR_SS_POWERSERVICE (30)
+
+#define MN_SS_TASKMANAGER "SS_TaskManager"
+#define PR_SS_TASKMANAGER_S "20"
+#define PR_SS_TASKMANAGER (20)
+
+ #define TN_SS_TSKMTIMER "SS_TskmTimer"
+ #define PR_SS_TSKMTIMER_S "20"
+ #define PR_SS_TSKMTIMER (20)
+
+#define MN_SOUND "Sound"
+#define PR_SOUND_S "45"
+#define PR_SOUND (45)
+
+ #define TN_VG_SNDSRCMGR "VG_SNDSRCMGR"
+ #define PR_VG_SNDSRCMGR_S "40"
+ #define PR_VG_SNDSRCMGR (40)
+
+ #define TN_SND_INPUTCTRL "SND_INPUTCTRL"
+ #define PR_SND_INPUTCTRL_S "40"
+ #define PR_SND_INPUTCTRL (40)
+
+ #define TN_SND_DEVCTRL "SND_DEVCTRL"
+ #define PR_SND_DEVCTRL_S "40"
+ #define PR_SND_DEVCTRL (40)
+
+ #define TN_SND_VCETRFCTRL "SND_VCETRFCTRL"
+ #define PR_SND_VCETRFCTRL_S "45"
+ #define PR_SND_VCETRFCTRL (45)
+
+ #define TN_SND_VCETRFWRT1 "SND_VCETRFWRT1"
+ #define PR_SND_VCETRFWRT1_S "45"
+ #define PR_SND_VCETRFWRT1 (45)
+
+ #define TN_SND_VCETRFWRT2 "SND_VCETRFWRT2"
+ #define PR_SND_VCETRFWRT2_S "45"
+ #define PR_SND_VCETRFWRT2 (45)
+
+ #define TN_VG_SNDCTRL_BSCF "VG_SNDCTRL_BSCF"
+ #define PR_VG_SNDCTRL_BSCF_S "25"
+ #define PR_VG_SNDCTRL_BSCF (25)
+
+ #define TN_VG_SNDCTRL_BSCR "VG_SNDCTRL_BSCR"
+ #define PR_VG_SNDCTRL_BSCR_S "25"
+ #define PR_VG_SNDCTRL_BSCR (25)
+
+ #define TN_VG_SNDCTRL_ITRT "VG_SNDCTRL_ITRT"
+ #define PR_VG_SNDCTRL_ITRT_S "25"
+ #define PR_VG_SNDCTRL_ITRT (25)
+
+ #define TN_CVRS_OPRT_OUT_1 "CVRS_OPRT_OUT_1"
+ #define PR_CVRS_OPRT_OUT_1_S "45"
+ #define PR_CVRS_OPRT_OUT_1 (45)
+
+ #define TN_CVRS_OPRT_OUT_2 "CVRS_OPRT_OUT_2"
+ #define PR_CVRS_OPRT_OUT_2_S "45"
+ #define PR_CVRS_OPRT_OUT_2 (45)
+
+ #define TN_CVRS_OPRT_OUT_3 "CVRS_OPRT_OUT_3"
+ #define PR_CVRS_OPRT_OUT_3_S "45"
+ #define PR_CVRS_OPRT_OUT_3 (45)
+
+ #define TN_CVRS_OPRT_OUT_4 "CVRS_OPRT_OUT_4"
+ #define PR_CVRS_OPRT_OUT_4_S "45"
+ #define PR_CVRS_OPRT_OUT_4 (45)
+
+ #define TN_CVRS_OPRT_IN_1 "CVRS_OPRT_IN_1"
+ #define PR_CVRS_OPRT_IN_1_S "45"
+ #define PR_CVRS_OPRT_IN_1 (45)
+
+ #define TN_CVRS_OPRT_IN_2 "CVRS_OPRT_IN_2"
+ #define PR_CVRS_OPRT_IN_2_S "45"
+ #define PR_CVRS_OPRT_IN_2 (45)
+
+ #define TN_CVRS_OPRT_IN_3 "CVRS_OPRT_IN_3"
+ #define PR_CVRS_OPRT_IN_3_S "45"
+ #define PR_CVRS_OPRT_IN_3 (45)
+
+ #define TN_CVRS_OPRT_IN_4 "CVRS_OPRT_IN_4"
+ #define PR_CVRS_OPRT_IN_4_S "45"
+ #define PR_CVRS_OPRT_IN_4 (45)
+
+ #define TN_CVRS_OPRT_IN_5 "CVRS_OPRT_IN_5"
+ #define PR_CVRS_OPRT_IN_5_S "45"
+ #define PR_CVRS_OPRT_IN_5 (45)
+
+ #define TN_CVRS_OPRT_IN_6 "CVRS_OPRT_IN_6"
+ #define PR_CVRS_OPRT_IN_6_S "45"
+ #define PR_CVRS_OPRT_IN_6 (45)
+
+ #define TN_CVRS_OPRT_IN_7 "CVRS_OPRT_IN_7"
+ #define PR_CVRS_OPRT_IN_7_S "45"
+ #define PR_CVRS_OPRT_IN_7 (45)
+
+ #define TN_CVRS_OPRT_IN_8 "CVRS_OPRT_IN_8"
+ #define PR_CVRS_OPRT_IN_8_S "45"
+ #define PR_CVRS_OPRT_IN_8 (45)
+
+ #define TN_CVRS_OPRT_BS_I "CVRS_OPRT_BS_I"
+ #define PR_CVRS_OPRT_BS_I_S "45"
+ #define PR_CVRS_OPRT_BS_I (45)
+
+ #define TN_VR_NVR_RECO "VR_NVR_RECO"
+ #define PR_VR_NVR_RECO_S "20"
+ #define PR_VR_NVR_RECO (20)
+
+ #define TN_SND_ECNR "SND_ECNR"
+ #define PR_SND_ECNR_S "40"
+ #define PR_SND_ECNR (40)
+
+ #define TN_SNDAGENT_000 "SNDAGENT_000"
+ #define PR_SNDAGENT_000_S "45"
+ #define PR_SNDAGENT_000 (45)
+
+ #define TN_SNDAGENT_001 "SNDAGENT_001"
+ #define PR_SNDAGENT_001_S "45"
+ #define PR_SNDAGENT_001 (45)
+
+ #define TN_SNDAGENT_002 "SNDAGENT_002"
+ #define PR_SNDAGENT_002_S "45"
+ #define PR_SNDAGENT_002 (45)
+
+ #define TN_SNDAGENT_003 "SNDAGENT_003"
+ #define PR_SNDAGENT_003_S "45"
+ #define PR_SNDAGENT_003 (45)
+
+ #define TN_SNDAGENT_004 "SNDAGENT_004"
+ #define PR_SNDAGENT_004_S "45"
+ #define PR_SNDAGENT_004 (45)
+
+ #define TN_SNDAGENT_005 "SNDAGENT_005"
+ #define PR_SNDAGENT_005_S "45"
+ #define PR_SNDAGENT_005 (45)
+
+ #define TN_SNDAGENT_006 "SNDAGENT_006"
+ #define PR_SNDAGENT_006_S "45"
+ #define PR_SNDAGENT_006 (45)
+
+ #define TN_SNDAGENT_007 "SNDAGENT_007"
+ #define PR_SNDAGENT_007_S "45"
+ #define PR_SNDAGENT_007 (45)
+
+ #define TN_SNDAGENT_008 "SNDAGENT_008"
+ #define PR_SNDAGENT_008_S "45"
+ #define PR_SNDAGENT_008 (45)
+
+ #define TN_SNDAGENT_009 "SNDAGENT_009"
+ #define PR_SNDAGENT_009_S "45"
+ #define PR_SNDAGENT_009 (45)
+
+ #define TN_SNDAGENT_010 "SNDAGENT_010"
+ #define PR_SNDAGENT_010_S "45"
+ #define PR_SNDAGENT_010 (45)
+
+ #define TN_SNDAGENT_011 "SNDAGENT_011"
+ #define PR_SNDAGENT_011_S "45"
+ #define PR_SNDAGENT_011 (45)
+
+ #define TN_SNDAGENT_012 "SNDAGENT_012"
+ #define PR_SNDAGENT_012_S "45"
+ #define PR_SNDAGENT_012 (45)
+
+ #define TN_SNDAGENT_013 "SNDAGENT_013"
+ #define PR_SNDAGENT_013_S "45"
+ #define PR_SNDAGENT_013 (45)
+
+ #define TN_SNDAGENT_014 "SNDAGENT_014"
+ #define PR_SNDAGENT_014_S "45"
+ #define PR_SNDAGENT_014 (45)
+
+ #define TN_SNDAGENT_015 "SNDAGENT_015"
+ #define PR_SNDAGENT_015_S "45"
+ #define PR_SNDAGENT_015 (45)
+
+ #define TN_SNDAGENT_016 "SNDAGENT_016"
+ #define PR_SNDAGENT_016_S "45"
+ #define PR_SNDAGENT_016 (45)
+
+ #define TN_SNDAGENT_017 "SNDAGENT_017"
+ #define PR_SNDAGENT_017_S "45"
+ #define PR_SNDAGENT_017 (45)
+
+ #define TN_SNDAGENT_018 "SNDAGENT_018"
+ #define PR_SNDAGENT_018_S "45"
+ #define PR_SNDAGENT_018 (45)
+
+ #define TN_SNDAGENT_019 "SNDAGENT_019"
+ #define PR_SNDAGENT_019_S "45"
+ #define PR_SNDAGENT_019 (45)
+
+ #define TN_SNDAGENT_020 "SNDAGENT_020"
+ #define PR_SNDAGENT_020_S "45"
+ #define PR_SNDAGENT_020 (45)
+
+ #define TN_SNDAGENT_021 "SNDAGENT_021"
+ #define PR_SNDAGENT_021_S "45"
+ #define PR_SNDAGENT_021 (45)
+
+ #define TN_SNDAGENT_022 "SNDAGENT_022"
+ #define PR_SNDAGENT_022_S "45"
+ #define PR_SNDAGENT_022 (45)
+
+ #define TN_SNDAGENT_023 "SNDAGENT_023"
+ #define PR_SNDAGENT_023_S "45"
+ #define PR_SNDAGENT_023 (45)
+
+ #define TN_SNDAGENT_024 "SNDAGENT_024"
+ #define PR_SNDAGENT_024_S "45"
+ #define PR_SNDAGENT_024 (45)
+
+ #define TN_SNDAGENT_025 "SNDAGENT_025"
+ #define PR_SNDAGENT_025_S "45"
+ #define PR_SNDAGENT_025 (45)
+
+#define MN_SS_RESOURCEMGR "SS_ResourceMgr"
+#define PR_SS_RESOURCEMGR_S "49"
+#define PR_SS_RESOURCEMGR (49)
+
+ #define TN_RESOURCEHWDT "ResourceHWDT"
+ #define PR_RESOURCEHWDT_S "1"
+ #define PR_RESOURCEHWDT (1)
+
+#define MN_AS_AUDIOMANAGER "AS_AudioManager"
+#define PR_AS_AUDIOMANAGER_S PR_TSS_S
+#define PR_AS_AUDIOMANAGER PR_TSS
+
+ #define TN_AS_SOUNDBEEP "AS_SoundBeep"
+ #define PR_AS_SOUNDBEEP_S PR_TSS_S
+ #define PR_AS_SOUNDBEEP PR_TSS
+
+#define MN_GRAPHICS "Graphics"
+#define PR_GRAPHICS_S "4"
+#define PR_GRAPHICS (4)
+
+ #define TN_GR_MAIN_CTRL "Graphics_main"
+ #define PR_GR_MAIN_CTRL_S PR_TSS_S
+ #define PR_GR_MAIN_CTRL PR_TSS
+
+ #define TN_GR_SEQ_CTRL "Graphics_seq"
+ #define PR_GR_SEQ_CTRL_S PR_TSS_S
+ #define PR_GR_SEQ_CTRL PR_TSS
+
+ #define TN_GR_DEV_RCV_CTRL "Graphics_rcv"
+ #define PR_GR_DEV_RCV_CTRL_S PR_TSS_S
+ #define PR_GR_DEV_RCV_CTRL PR_TSS
+
+ #define TN_GR_VCAP1_CTRL "Graphics_cap1"
+ #define PR_GR_VCAP1_CTRL_S "4"
+ #define PR_GR_VCAP1_CTRL (4)
+
+ #define TN_GR_VCAP2_CTRL "Graphics_cap2"
+ #define PR_GR_VCAP2_CTRL_S "4"
+ #define PR_GR_VCAP2_CTRL (4)
+
+#define MN_VUPSERVICE "vupservice"
+#define PR_VUPSERVICE_S PR_TSS_S
+#define PR_VUPSERVICE PR_TSS
+
+#define MN_SS_UPDATESERVICE "UpdateService"
+#define PR_SS_UPDATESERVICE_S PR_TSS_S
+#define PR_SS_UPDATESERVICE PR_TSS
+
+ #define TN_UPSERVICE_VERI "t_update_veri"
+ #define PR_UPSERVICE_VERI_S PR_TSS_S
+ #define PR_UPSERVICE_VERI PR_TSS
+
+#define MN_NW_MICSERVICE "NW_MicService"
+#define PR_NW_MICSERVICE_S PR_TSS_S
+#define PR_NW_MICSERVICE PR_TSS
+
+#define MN_NS_LOCKMGR "LockMgr"
+#define PR_NS_LOCKMGR_S PR_TSS_S
+#define PR_NS_LOCKMGR PR_TSS
+
+#define MN_PS_SWITCHHANDLER "SwitchHandler"
+#define PR_PS_SWITCHHANDLER_S "30"
+#define PR_PS_SWITCHHANDLER (30)
+
+#define MN_SS_WINSYS "SS_WinSys"
+#define PR_SS_WINSYS_S "5"
+#define PR_SS_WINSYS 5
+
+#define MN_MODEMANAGER "modemanager"
+#define PR_MODEMANAGER_S PR_TSS_S
+#define PR_MODEMANAGER PR_TSS
+
+#define MN_BTSTACKMAIN "btstackmain"
+#define PR_BTSTACKMAIN_S PR_TSS_S
+#define PR_BTSTACKMAIN PR_TSS
+
+#define MN_MEDIASERVICE "MediaService"
+#define PR_MEDIASERVICE_S PR_TSS_S
+#define PR_MEDIASERVICE PR_TSS
+
+// REPRO START
+#define MN_REPROSERVICE "ReproService"
+#define PR_REPROSERVICE_S PR_TSS_S
+#define PR_REPROSERVICE PR_TSS
+
+ #define TN_REPROSEQUENCER "RPRS_Sequencer"
+ #define PR_REPROSEQUENCER_S PR_TSS_S
+ #define PR_REPROSEQUENCER PR_TSS
+
+ #define TN_REPROCTRL "RPRS_Control"
+ #define PR_REPROCTRL_S PR_TSS_S
+ #define PR_REPROCTRL PR_TSS
+
+ #define TN_REPROCENTERCOMM "RPRS_CenterComm"
+ #define PR_REPROCENTERCOMM_S PR_TSS_S
+ #define PR_REPROCENTERCOMM PR_TSS
+
+ #define TN_REPROUNITCOMM "RPRS_UnitComm"
+ #define PR_REPROUNITCOMM_S PR_TSS_S
+ #define PR_REPROUNITCOMM PR_TSS
+
+ #define TN_REPROWEBDAVMGR "RPRS_WebDAVMgr"
+ #define PR_REPROWEBDAVMGR_S PR_TSS_S
+ #define PR_REPROWEBDAVMGR PR_TSS
+
+#define MN_REPROAENDTEST "Repro_Testpro_Sender"
+#define PR_REPROAENDTEST_S PR_TSS_S
+#define PR_REPROAENDTEST PR_TSS
+
+ #define TN_REPROAENDTESTTN "Repro_TestproT"
+ #define PR_REPROAENDTESTTN_S PR_TSS_S
+ #define PR_REPROAENDTESTTN PR_TSS
+
+#define MN_REPROBACKVUP "BackVupCtrl"
+#define PR_REPROBACKVUP_S PR_TSS_S
+#define PR_REPROBACKVUP PR_TSS
+
+#define MN_REPRODEVELOP "DevReproService"
+#define PR_REPRODEVELOP_S PR_TSS_S
+#define PR_REPRODEVELOP PR_TSS
+// REPRO END
+
+ #define TN_MED_MMCOM_PLAY "mmcom_play"
+ #define PR_MED_MMCOM_PLAY_S PR_TSS_S
+ #define PR_MED_MMCOM_PLAY PR_TSS
+
+ #define TN_MED_MMCOM_MEDIA "mmcom_media"
+ #define PR_MED_MMCOM_MEDIA_S PR_TSS_S
+ #define PR_MED_MMCOM_MEDIA PR_TSS
+
+ #define TN_MED_MMCOM_DB "mmcom_db"
+ #define PR_MED_MMCOM_DB_S PR_TSS_S
+ #define PR_MED_MMCOM_DB PR_TSS
+
+ #define TN_MED_MMCOM_LIST "mmcom_list"
+ #define PR_MED_MMCOM_LIST_S PR_TSS_S
+ #define PR_MED_MMCOM_LIST PR_TSS
+
+ #define TN_MED_MMCOM_DBUSB "mmcom_dbusb"
+ #define PR_MED_MMCOM_DBUSB_S PR_TSS_S
+ #define PR_MED_MMCOM_DBUSB PR_TSS
+
+ #define TN_MED_MMCOM_DBSD "mmcom_dbsd"
+ #define PR_MED_MMCOM_DBSD_S PR_TSS_S
+ #define PR_MED_MMCOM_DBSD PR_TSS
+
+ #define TN_MED_MMCOM_DBCD "mmcom_dbcd"
+ #define PR_MED_MMCOM_DBCD_S PR_TSS_S
+ #define PR_MED_MMCOM_DBCD PR_TSS
+
+ #define TN_MED_MMCOM_PLAYRCV "mmcom_playrcv"
+ #define PR_MED_MMCOM_PLAYRCV_S PR_TSS_S
+ #define PR_MED_MMCOM_PLAYRCV PR_TSS
+
+ #define TN_MED_RIPCOM_MNG "MngRipComm"
+ #define PR_MED_RIPCOM_MNG_S PR_TSS_S
+ #define PR_MED_RIPCOM_MNG PR_TSS
+
+ #define TN_MED_RIPCOM_EXE01 "ExeRipComm01"
+ #define PR_MED_RIPCOM_EXE01_S PR_TSS_S
+ #define PR_MED_RIPCOM_EXE01 PR_TSS
+
+ #define TN_MED_RIPCOM_EXE02 "ExeRipComm02"
+ #define PR_MED_RIPCOM_EXE02_S PR_TSS_S
+ #define PR_MED_RIPCOM_EXE02 PR_TSS
+
+ #define TN_MED_DISCCOM_MAIN "disccom_main"
+ #define PR_MED_DISCCOM_MAIN_S PR_TSS_S
+ #define PR_MED_DISCCOM_MAIN PR_TSS
+
+ #define TN_MED_DISCCOM_DB "disccom_db"
+ #define PR_MED_DISCCOM_DB_S PR_TSS_S
+ #define PR_MED_DISCCOM_DB PR_TSS
+
+#define MN_PLAYBACKSERVICE "PlaybackService"
+#define PR_PLAYBACKSERVICE_S PR_TSS_S
+#define PR_PLAYBACKSERVICE PR_TSS
+
+ #define TN_PLAYSRV_AUDIO "playsrv_audio"
+ #define PR_PLAYSRV_AUDIO_S PR_TSS_S
+ #define PR_PLAYSRV_AUDIO PR_TSS
+
+ #define TN_PLAYSRV_RIP "playsrv_rip"
+ #define PR_PLAYSRV_RIP_S PR_TSS_S
+ #define PR_PLAYSRV_RIP PR_TSS
+
+ #define TN_PLAYSRV_PLAY "playsrv_play"
+ #define PR_PLAYSRV_PLAY_S PR_TSS_S
+ #define PR_PLAYSRV_PLAY PR_TSS
+
+ #define TN_PLAYSRV_DISC "playsrv_disc"
+ #define PR_PLAYSRV_DISC_S PR_TSS_S
+ #define PR_PLAYSRV_DISC PR_TSS
+
+ #define TN_PLAYSRV_ARTWORK "playsrv_artwork"
+ #define PR_PLAYSRV_ARTWORK_S PR_TSS_S
+ #define PR_PLAYSRV_ARTWORK PR_TSS
+
+#define MN_DISCSERVICE "DiscService"
+#define PR_DISCSERVICE_S PR_TSS_S
+#define PR_DISCSERVICE PR_TSS
+
+#define MN_RADIOSERVICE "RadioService"
+#define PR_RADIOSERVICE_S PR_TSS_S
+#define PR_RADIOSERVICE PR_TSS
+
+#define MN_RADIOHDARBITER "RadioHDArbiter"
+#define PR_RADIOHDARBITER_S "20"
+#define PR_RADIOHDARBITER (20)
+
+#define MN_HRDS_MANAGER "hrds_manager"
+#define PR_HRDS_MANAGER_S PR_TSS_S
+#define PR_HRDS_MANAGER PR_TSS
+
+ #define TN_HRDS_HDMNG "hrds_hdmng"
+ #define PR_HRDS_HDMNG_S PR_TSS_S
+ #define PR_HRDS_HDMNG PR_TSS
+
+ #define TN_HRDS_HDDEC "hrds_hddec"
+ #define PR_HRDS_HDDEC_S PR_TSS_S
+ #define PR_HRDS_HDDEC PR_TSS
+
+ #define TN_HRDS_WEBMNG "hrds_webmng"
+ #define PR_HRDS_WEBMNG_S PR_TSS_S
+ #define PR_HRDS_WEBMNG PR_TSS
+
+ #define TN_HRDS_WEBCOM "hrds_webcom"
+ #define PR_HRDS_WEBCOM_S PR_TSS_S
+ #define PR_HRDS_WEBCOM PR_TSS
+
+#define MN_BT_CONNECTIONSERVICE "BT_CnctSrv"
+#define PR_BT_CONNECTIONSERVICE_S PR_TSS_S
+#define PR_BT_CONNECTIONSERVICE PR_TSS
+
+#define MN_BT_PHONESERVICE "BT_PhoneSrv"
+#define PR_BT_PHONESERVICE_S PR_TSS_S
+#define PR_BT_PHONESERVICE PR_TSS
+
+#define MN_BT_PHONEBOOKSERVICE "BT_PbkSrv"
+#define PR_BT_PHONEBOOKSERVICE_S PR_TSS_S
+#define PR_BT_PHONEBOOKSERVICE PR_TSS
+
+#define MN_BT_MESSAGINGSERVICE "BT_MsgSrv"
+#define PR_BT_MESSAGINGSERVICE_S PR_TSS_S
+#define PR_BT_MESSAGINGSERVICE PR_TSS
+
+#define MN_BT_BLLSERVICE "TEL_BLLSrv"
+#define PR_BT_BLLSERVICE_S PR_TSS_S
+#define PR_BT_BLLSERVICE PR_TSS
+
+#define MN_BT_DCMPHONESERVICE "DCM_PhoneSrv"
+#define PR_BT_DCMPHONESERVICE_S PR_TSS_S
+#define PR_BT_DCMPHONESERVICE PR_TSS
+
+ #define TN_BT_CONSRV_HFPMULTIQ1 "HFPMultiQ1"
+ #define PR_TN_BT_CONSRV_HFPMULTIQ1_S PR_TSS_S
+ #define PR_TN_BT_CONSRV_HFPMULTIQ1 PR_TSS
+
+ #define TN_BT_CONSRV_HFPMULTIQ2 "HFPMultiQ2"
+ #define PR_TN_BT_CONSRV_HFPMULTIQ2_S PR_TSS_S
+ #define PR_TN_BT_CONSRV_HFPMULTIQ2 PR_TSS
+
+ #define TN_BT_PBKSRV_DATABASE "BTPB_Database"
+ #define PR_TN_BT_PBKSRV_DATABASE_S PR_TSS_S
+ #define PR_TN_BT_PBKSRV_DATABASE PR_TSS
+
+ #define TN_BT_PBKSRV_LOCALPBINST "LocalPBINST"
+ #define PR_TN_BT_PBKSRV_LOCALPBINST_S PR_TSS_S
+ #define PR_TN_BT_PBKSRV_LOCALPBINST PR_TSS
+
+ #define TN_BT_PBKSRV_RESOLVENAME "ResolveName"
+ #define PR_TN_BT_PBKSRV_RESOLVENAME_S PR_TSS_S
+ #define PR_TN_BT_PBKSRV_RESOLVENAME PR_TSS
+
+ #define TN_BT_PBKSRV_PBAPMULTIQ1 "PBAPMultiQ1"
+ #define PR_TN_BT_PBKSRV_PBAPMULTIQ1_S PR_TSS_S
+ #define PR_TN_BT_PBKSRV_PBAPMULTIQ1 PR_TSS
+
+ #define TN_BT_PBKSRV_OPPMULTI "OPPMulti"
+ #define PR_TN_BT_PBKSRV_OPPMULTI_S PR_TSS_S
+ #define PR_TN_BT_PBKSRV_OPPMULTI PR_TSS
+
+ #define TN_BT_PBKSRV_VCARDPARSER "VCardParser"
+ #define PR_TN_BT_PBKSRV_VCARDPARSER_S PR_TSS_S
+ #define PR_TN_BT_PBKSRV_VCARDPARSER PR_TSS
+
+ #define TN_BT_MSGSRV_MSGCNTRLTHREAD0 "MsgCntrlThread0"
+ #define PR_TN_BT_MSGSRV_MSGCNTRLTHREAD0_S PR_TSS_S
+ #define PR_TN_BT_MSGSRV_MSGCNTRLTHREAD0 PR_TSS
+
+ #define TN_BT_MSGSRV_MSGCNTRLTHREAD1 "MsgCntrlThread1"
+ #define PR_TN_BT_MSGSRV_MSGCNTRLTHREAD1_S PR_TSS_S
+ #define PR_TN_BT_MSGSRV_MSGCNTRLTHREAD1 PR_TSS
+
+ #define TN_BT_MSGSRV_MAPMULTI "MapMulti"
+ #define PR_TN_BT_MSGSRV_MAPMULTI_S PR_TSS_S
+ #define PR_TN_BT_MSGSRV_MAPMULTI PR_TSS
+
+#define MN_DTVSERVICE "DtvService"
+#define PR_DTVSERVICE_S PR_TSS_S
+#define PR_DTVSERVICE PR_TSS
+
+ #define TN_DTVTNC_TX "dtvtnc_tx"
+ #define PR_DTVTNC_TX_S PR_TSS_S
+ #define PR_DTVTNC_TX PR_TSS
+
+ #define TN_DTVTNC_RCV "dtvtnc_rcv"
+ #define PR_DTVTNC_RCV_S PR_TSS_S
+ #define PR_DTVTNC_RCV PR_TSS
+
+ #define TN_DTVTNC_TIMER "dtvtnc_timer"
+ #define PR_DTVTNC_TIMER_S PR_TSS_S
+ #define PR_DTVTNC_TIMER PR_TSS
+
+ #define TN_DTVTNC_CTL "dtvtnc_ctl"
+ #define PR_DTVTNC_CTL_S PR_TSS_S
+ #define PR_DTVTNC_CTL PR_TSS
+
+#define MN_DTVVUPSERVICE "DtvVupService"
+#define PR_DTVVUPSERVICE_S PR_TSS_S
+#define PR_DTVVUPSERVICE PR_TSS
+
+#define MN_SETTINGSERVICE "SettingService"
+#define PR_SETTINGSERVICE_S PR_TSS_S
+#define PR_SETTINGSERVICE PR_TSS
+
+#define MN_INFOSETTINGSRV "InfoSettingSrv"
+#define PR_INFOSETTINGSRV_S PR_TSS_S
+#define PR_INFOSETTINGSRV PR_TSS
+
+ #define TN_INFS_UIC "infs_uic"
+ #define PR_INFS_UIC_S PR_TSS_S
+ #define PR_INFS_UIC PR_TSS
+
+#define MN_DELPERSONALSRV "DelPersonalSrv"
+#define PR_DELPERSONALSRV_S PR_TSS_S
+#define PR_DELPERSONALSRV PR_TSS
+
+#define MN_MENUSERVICE "MenuService"
+#define PR_MENUSERVICE_S PR_TSS_S
+#define PR_MENUSERVICE PR_TSS
+
+#define MN_NAVIPROXY "NaviProxy"
+#define PR_NAVIPROXY_S PR_TSS_S
+#define PR_NAVIPROXY PR_TSS
+
+#define MN_AWBPROXY "AwbProxy"
+#define PR_AWBPROXY_S PR_TSS_S
+#define PR_AWBPROXY PR_TSS
+
+#define MN_TFFPROXY "TFFProxy"
+#define PR_TFFPROXY_S PR_TSS_S
+#define PR_TFFPROXY PR_TSS
+
+#define MN_TFFPROXYSLAVE "TFFProxySlave"
+#define PR_TFFPROXYSLAVE_S PR_TSS_S
+#define PR_TFFPROXYSLAVE PR_TSS
+
+#define MN_AWNPRIMARY "AwnPrimary"
+#define PR_AWNPRIMARY_S PR_TSS_S
+#define PR_AWNPRIMARY PR_TSS
+
+#define MN_AWBPRIMARY "AwbPrimary"
+#define PR_AWBPRIMARY_S PR_TSS_S
+#define PR_AWBPRIMARY PR_TSS
+
+#define MN_AWMPRIMARY "AwmPrimary"
+#define PR_AWMPRIMARY_S PR_TSS_S
+#define PR_AWMPRIMARY PR_TSS
+
+#define MN_AWTPRIMARY "AwtPrimary"
+#define PR_AWTPRIMARY_S PR_TSS_S
+#define PR_AWTPRIMARY PR_TSS
+
+#define MN_MISINKSERVICE "MisinkService"
+#define PR_MISINKSERVICE_S PR_TSS_S
+#define PR_MISINKSERVICE PR_TSS
+
+#define MN_TEXTCONVERTER "TextConverter"
+#define PR_TEXTCONVERTER_S PR_TSS_S
+#define PR_TEXTCONVERTER PR_TSS
+
+#define MN_HANDWRITING "HandWriting"
+#define PR_HANDWRITING_S PR_TSS_S
+#define PR_HANDWRITING PR_TSS
+
+#define MN_EXTUNITAUTH_D "EXTUNITAUTH_D"
+#define PR_EXTUNITAUTH_D_S "29"
+#define PR_EXTUNITAUTH_D 29
+
+ #define TN_VPSVC__CWORD84_ "VPSVC_D"
+ #define PR_VPSVC__CWORD84__S PR_TSS_S
+ #define PR_VPSVC__CWORD84_ PR_TSS
+
+#define MN_PROXYSERVICE "ProxyService"
+#define PR_PROXYSERVICE_S PR_TSS_S
+#define PR_PROXYSERVICE PR_TSS
+
+#define MN_FUELSERVICE "VS_FUCSrv"
+#define PR_FUELSERVICE_S PR_TSS_S
+#define PR_FUELSERVICE PR_TSS
+
+#define MN_ENERGYSERVICE "VS_ENMSrv"
+#define PR_ENERGYSERVICE_S PR_TSS_S
+#define PR_ENERGYSERVICE PR_TSS
+
+#define MN_CUSTOMIZESERVICE "VS_VSDSrv"
+#define PR_CUSTOMIZESERVICE_S PR_TSS_S
+#define PR_CUSTOMIZESERVICE PR_TSS
+
+#define MN_DMSSERVICE "VS_DMSSrv"
+#define PR_DMSSERVICE_S PR_TSS_S
+#define PR_DMSSERVICE PR_TSS
+
+#define MN_AIRCONSERVICE "VS_ACNSrv"
+#define PR_AIRCONSERVICE_S PR_TSS_S
+#define PR_AIRCONSERVICE PR_TSS
+
+#define MN_SEATSERVICE "VS_NMSSrv"
+#define PR_SEATSERVICE_S PR_TSS_S
+#define PR_SEATSERVICE PR_TSS
+
+#define MN_CAMERASERVICE "VS_CMRSrv"
+#define PR_CAMERASERVICE_S PR_TSS_S
+#define PR_CAMERASERVICE PR_TSS
+
+ #define TN_CAMERAQUICKRVC "QuickRVCThread"
+ #define PR_CAMERAQUICKRVC_S PR_TSS_S
+ #define PR_CAMERAQUICKRVC PR_TSS
+
+#define MN_METSERVICE "VS_METSrv"
+#define PR_METSERVICE_S PR_TSS_S
+#define PR_METSERVICE PR_TSS
+
+#define MN_TMCSERVICE "VS_TMCSrv"
+#define PR_TMCSERVICE_S PR_TSS_S
+#define PR_TMCSERVICE PR_TSS
+
+#define MN_DASSERVICE "VS_DASSrv"
+#define PR_DASSERVICE_S PR_TSS_S
+#define PR_DASSERVICE PR_TSS
+
+#define MN_EXTUNITAUTH_M "EXTUNITAUTH_M"
+#define PR_EXTUNITAUTH_M_S "29"
+#define PR_EXTUNITAUTH_M 29
+
+#define MN_DUMMYREAD "DummyRead"
+#define PR_DUMMYREAD_S PR_TSS_S
+#define PR_DUMMYREAD PR_TSS
+
+#define MN_SSTSERVICE "storage_access"
+#define PR_SSTSERVICE_S PR_TSS_S
+#define PR_SSTSERVICE PR_TSS
+
+#define MN_CCSAUDITD "ccs-auditd"
+#define PR_CCSAUDITD_S PR_TSS_S
+#define PR_CCSAUDITD PR_TSS
+
+//exec from task manager
+#define MN_ACTIVITYMANAGER "ActivityManager"
+#define PR_ACTIVITYMANAGER_S PR_TSS_S
+#define PR_ACTIVITYMANAGER PR_TSS
+
+#define MN_RESIDENT_SVC "RESIDENT_SVC"
+#define PR_RESIDENT_SVC_S PR_TSS_S
+#define PR_RESIDENT_SVC PR_TSS
+
+#define MN_TRANSIENT_SVC "TRANSIENT_SVC"
+#define PR_TRANSIENT_SVC_S PR_TSS_S
+#define PR_TRANSIENT_SVC PR_TSS
+
+#define MN_WLANSERVICE "wlan_ctrl_0700"
+#define PR_WLANSERVICE_S PR_TSS_S
+#define PR_WLANSERVICE PR_TSS
+
+#define MN_WLANEVTTHR "WlanEvtThr"
+#define PR_WLANEVTTHR_S PR_TSS_S
+#define PR_WLANEVTTHR PR_TSS
+
+#define MN_WLANMIDDLESERVICE "WlanMiddle"
+#define PR_WLANMIDDLESERVICE_S PR_TSS_S
+#define PR_WLANMIDDLESERVICE PR_TSS
+
+ #define TN_WLANMIDDLESERVICE0 "WM_MsgCtrlTh0"
+ #define PR_WLANMIDDLESERVICE0_S PR_TSS_S
+ #define PR_WLANMIDDLESERVICE0 PR_TSS
+
+ #define TN_WLANMIDDLESERVICE1 "WM_MsgCtrlTh1"
+ #define PR_WLANMIDDLESERVICE1_S PR_TSS_S
+ #define PR_WLANMIDDLESERVICE1 PR_TSS
+
+ #define TN_WLANMIDDLESERVICE2 "WM_MsgCtrlTh2"
+ #define PR_WLANMIDDLESERVICE2_S PR_TSS_S
+ #define PR_WLANMIDDLESERVICE2 PR_TSS
+
+#define MN_WLANSERVICE2 "wlan_ctrl_0701"
+#define PR_WLANSERVICE2_S PR_TSS_S
+#define PR_WLANSERVICE2 PR_TSS
+
+#define MN_WLANEVTTHR2 "WlanEvtThr2"
+#define PR_WLANEVTTHR2_S PR_TSS_S
+#define PR_WLANEVTTHR2 PR_TSS
+
+//exec from task manager, Test for vup
+#define MN_PS__CWORD52_VUP "_CWORD52_vup"
+#define PR_PS__CWORD52_VUP_S PR_TSS_S
+#define PR_PS__CWORD52_VUP PR_TSS
+
+#define MN_PS_SYSVUP "sysvup"
+#define PR_PS_SYSVUP_S PR_TSS_S
+#define PR_PS_SYSVUP PR_TSS
+
+#define MN_SS_ROOTFSVUP "rootfsvup"
+#define PR_SS_ROOTFSVUP_S PR_TSS_S
+#define PR_SS_ROOTFSVUP PR_TSS
+
+#define MN_SS_VUPPROGUI "vupprogressui"
+#define PR_SS_VUPPROGUI_S PR_TSS_S
+#define PR_SS_VUPPROGUI PR_TSS
+
+#define MN_SS_NORVUP "norvup"
+#define PR_SS_NORVUP_S PR_TSS_S
+#define PR_SS_NORVUP PR_TSS
+
+// OUTER_UPDATE START
+#define MN_XMVUPSERVICE "radio_xm_update"
+#define PR_XMVUPSERVICE_S PR_TSS_S
+#define PR_XMVUPSERVICE PR_TSS
+// OUTER_UPDATE END
+
+#define MN_BTPHONESRV "BT_PhoneSrv"
+#define PR_BTPHONESRV_S PR_TSS_S
+#define PR_BTPHONESRV PR_TSS
+
+#define MN_BTPBKSRV "BT_PbkSrv"
+#define PR_BTPBKSRV_S PR_TSS_S
+#define PR_BTPBKSRV PR_TSS
+
+#define MN_BTMSGSRV "BT_MsgSrv"
+#define PR_BTMSGSRV_S PR_TSS_S
+#define PR_BTMSGSRV PR_TSS
+
+// NON-resident, exec from task manager, Repro update
+#define MN_PS_SYSUPDATE "sysupdate"
+#define PR_PS_SYSUPDATE_S PR_TSS_S
+#define PR_PS_SYSUPDATE PR_TSS
+
+#define MN_SS_NANDUPDATE "nandupdate"
+#define PR_SS_NANDUPDATE_S PR_TSS_S
+#define PR_SS_NANDUPDATE PR_TSS
+
+ #define TN_NANDUPDATE_CLD "t_nandcld"
+ #define PR_NANDUPDATE_CLD_S PR_TSS_S
+ #define PR_NANDUPDATE_CLD PR_TSS
+
+#define MN_BTPHONESRV "BT_PhoneSrv"
+#define PR_BTPHONESRV_S PR_TSS_S
+#define PR_BTPHONESRV PR_TSS
+
+#define MN_BTPBKSRV "BT_PbkSrv"
+#define PR_BTPBKSRV_S PR_TSS_S
+#define PR_BTPBKSRV PR_TSS
+
+#define MN_BTMSGSRV "BT_MsgSrv"
+#define PR_BTMSGSRV_S PR_TSS_S
+#define PR_BTMSGSRV PR_TSS
+
+//exec from diag
+#define MN_DIAGSERVICE "DiagService"
+#define PR_DIAGSERVICE_S PR_TSS_S
+#define PR_DIAGSERVICE PR_TSS
+
+#define MN_DIAGWORKERTSK "diagworker_tsk"
+#define PR_DIAGWORKERTSK_S PR_TSS_S
+#define PR_DIAGWORKERTSK PR_TSS
+
+#define MN_DIAGTSK "diag_tsk"
+#define PR_DIAGTSK_S PR_TSS_S
+#define PR_DIAGTSK PR_TSS
+
+#define MN_DIAGMCTSK "diagmc_tsk"
+#define PR_DIAGMCTSK_S PR_TSS_S
+#define PR_DIAGMCTSK PR_TSS
+
+#define MN_DIAGUTCOL "diagutCol_tsk"
+#define PR_DIAGUTCOL_S PR_TSS_S
+#define PR_DIAGUTCOL PR_TSS
+
+#define MN_DIAGUTUPD "diagutUpd_tsk"
+#define PR_DIAGUTUPD_S PR_TSS_S
+#define PR_DIAGUTUPD PR_TSS
+
+//exec from Connectivity for _CWORD57_
+#define MN__CWORD57_UTILSERVICE "_CWORD57_UtilService"
+#define PR__CWORD57_UTILSERVICE_S PR_TSS_S
+#define PR__CWORD57_UTILSERVICE PR_TSS
+
+ #define TN_CON_IPUT_DETECT "iputsrv_detect"
+ #define PR_CON_IPUT_DETECT_S PR_TSS_S
+ #define PR_CON_IPUT_DETECT PR_TSS
+
+ #define TN_CON_IPUT_AUTH "iputsrv_auth"
+ #define PR_CON_IPUT_AUTH_S PR_TSS_S
+ #define PR_CON_IPUT_AUTH PR_TSS
+
+ #define TN_CON_IPUT_SERIAL "iputsrv_serial"
+ #define PR_CON_IPUT_SERIAL_S PR_TSS_S
+ #define PR_CON_IPUT_SERIAL PR_TSS
+
+ #define TN_CON_IPUT_USB_1 "iputsrv_usb1"
+ #define PR_CON_IPUT_USB_1_S PR_TSS_S
+ #define PR_CON_IPUT_USB_1 PR_TSS
+
+ #define TN_CON_IPUT_USB_2 "iputsrv_usb2"
+ #define PR_CON_IPUT_USB_2_S PR_TSS_S
+ #define PR_CON_IPUT_USB_2 PR_TSS
+
+ #define TN_CON_IPUT_SPP "iputsrv_spp"
+ #define PR_CON_IPUT_SPP_S PR_TSS_S
+ #define PR_CON_IPUT_SPP PR_TSS
+
+#define MN__CWORD57_DTSERVICE "_CWORD57_DTService"
+#define PR__CWORD57_DTSERVICE_S PR_TSS_S
+#define PR__CWORD57_DTSERVICE PR_TSS
+
+ #define TN_CON_IPDT_SERIAL "ipdtsrv_serial"
+ #define PR_CON_IPDT_SERIAL_S PR_TSS_S
+ #define PR_CON_IPDT_SERIAL PR_TSS
+
+ #define TN_CON_IPDT_USB_1 "ipdtsrv_usb1"
+ #define PR_CON_IPDT_USB_1_S PR_TSS_S
+ #define PR_CON_IPDT_USB_1 PR_TSS
+
+ #define TN_CON_IPDT_USB_2 "ipdtsrv_usb2"
+ #define PR_CON_IPDT_USB_2_S PR_TSS_S
+ #define PR_CON_IPDT_USB_2 PR_TSS
+
+ #define TN_CON_IPDT_SPP "ipdtsrv_spp"
+ #define PR_CON_IPDT_SPP_S PR_TSS_S
+ #define PR_CON_IPDT_SPP PR_TSS
+
+#define MN_WEBDAVMGR "webdavmgr"
+#define PR_WEBDAVMGR_S PR_TSS_S
+#define PR_WEBDAVMGR PR_TSS
+
+#define MN_DISPLAYSERVICE "DisplayService"
+#define PR_DISPLAYSERVICE_S PR_TSS_S
+#define PR_DISPLAYSERVICE PR_TSS
+
+#define MN_ENFORMSERVICE "EnformService"
+#define PR_ENFORMSERVICE_S PR_TSS_S
+#define PR_ENFORMSERVICE PR_TSS
+
+#define MN_CONNUTIL "ConnUtil"
+#define PR_CONNUTIL_S PR_TSS_S
+#define PR_CONNUTIL PR_TSS
+
+#define MN_CONNUTILSLAVE "ConnUtilSlave"
+#define PR_CONNUTILSLAVE_S PR_TSS_S
+#define PR_CONNUTILSLAVE PR_TSS
+
+#define MN_CONNMGR "ConnMgr"
+#define PR_CONNMGR_S PR_TSS_S
+#define PR_CONNMGR PR_TSS
+
+#define MN_SERVICEFLAGMGR "ServiceFlagMgr"
+#define PR_SERVICEFLAGMGR_S PR_TSS_S
+#define PR_SERVICEFLAGMGR PR_TSS
+
+//exec from VR
+#define MN_VRMANAGER "vrmanager"
+#define PR_VRMANAGER_S PR_TSS_S
+#define PR_VRMANAGER PR_TSS
+
+ #define TN_VR_WORKER "VrWorkerThread"
+ #define PR_VR_WORKER_S PR_TSS_S
+ #define PR_VR_WORKER PR_TSS
+
+ #define TN_VBT_PROPDISPATCH "PropDispatchThread"
+ #define PR_VBT_PROPDISPATCH_S PR_TSS_S
+ #define PR_VBT_PROPDISPATCH PR_TSS
+
+ #define TN_VBT_PROPRESPONSE "PropResponseThread"
+ #define PR_VBT_PROPRESPONSE_S PR_TSS_S
+ #define PR_VBT_PROPRESPONSE PR_TSS
+
+ #define TN_VBT_PROPAUDIOPLAY "PropAudioPlayThread"
+ #define PR_VBT_PROPAUDIOPLAY_S PR_TSS_S
+ #define PR_VBT_PROPAUDIOPLAY PR_TSS
+
+ #define TN_VBT_PROPAUDIORECORD "PropAudioRecordThread"
+ #define PR_VBT_PROPAUDIORECORD_S PR_TSS_S
+ #define PR_VBT_PROPAUDIORECORD PR_TSS
+
+ #define TN_VBT_MAINTHREADPRIO "MainThreadPriority"
+ #define PR_VBT_MAINTHREADPRIO_S PR_TSS_S
+ #define PR_VBT_MAINTHREADPRIO PR_TSS
+
+ #define TN_VBT_ASRMANAGERGRAMMAR "AsrManagerGrammarGenerationThread"
+ #define PR_VBT_ASRMANAGERGRAMMAR_S PR_TSS_S
+ #define PR_VBT_ASRMANAGERGRAMMAR PR_TSS
+
+ #define TN_VBT_ASRVOCONRECO "AsrVoconRecoProcessThread"
+ #define PR_VBT_ASRVOCONRECO_S PR_TSS_S
+ #define PR_VBT_ASRVOCONRECO PR_TSS
+
+ #define TN_VBT_BROADCASTREAD "BroadCastReadThread"
+ #define PR_VBT_BROADCASTREAD_S PR_TSS_S
+ #define PR_VBT_BROADCASTREAD PR_TSS
+
+ #define TN_VBT_FILEAGGREGATOR "FileAggregatorDecompressThread"
+ #define PR_VBT_FILEAGGREGATOR_S PR_TSS_S
+ #define PR_VBT_FILEAGGREGATOR PR_TSS
+
+ #define TN_VBT_HTTPCURLREQUEST "HttpCurlRequestThread"
+ #define PR_VBT_HTTPCURLREQUEST_S PR_TSS_S
+ #define PR_VBT_HTTPCURLREQUEST PR_TSS
+
+ #define TN_VBT_HTTPDRIVERREQUEST "HttpDriverRequestThread"
+ #define PR_VBT_HTTPDRIVERREQUEST_S PR_TSS_S
+ #define PR_VBT_HTTPDRIVERREQUEST PR_TSS
+
+ #define TN_VBT_HTTPREQUESTSESSION "HttpRequestSessionStateThread"
+ #define PR_VBT_HTTPREQUESTSESSION_S PR_TSS_S
+ #define PR_VBT_HTTPREQUESTSESSION PR_TSS
+
+ #define TN_VBT_PLAYMGRSTOPASYNC "PlayMgrStopAsyncStreamThread"
+ #define PR_VBT_PLAYMGRSTOPASYNC_S PR_TSS_S
+ #define PR_VBT_PLAYMGRSTOPASYNC PR_TSS
+
+ #define TN_VBT_RESOURCEMGRQUEUE "ResourceMgrQueueHandlerThread"
+ #define PR_VBT_RESOURCEMGRQUEUE_S PR_TSS_S
+ #define PR_VBT_RESOURCEMGRQUEUE PR_TSS
+
+ #define TN_VBT_SMURFDRIVERTIMEOUT "SmurfDriverTimeoutThread"
+ #define PR_VBT_SMURFDRIVERTIMEOUT_S PR_TSS_S
+ #define PR_VBT_SMURFDRIVERTIMEOUT PR_TSS
+
+ #define TN_NVR_NVRMAIN "NvrMainThread"
+ #define PR_NVR_NVRMAIN_S PR_TSS_S
+ #define PR_NVR_NVRMAIN PR_TSS
+
+ #define TN_NVR_NVRRECO "NvrRecoThread"
+ #define PR_NVR_NVRRECO_S PR_TSS_S
+ #define PR_NVR_NVRRECO PR_TSS
+
+ #define TN_NVR_NVRDICT "NvrDictThread"
+ #define PR_NVR_NVRDICT_S PR_TSS_S
+ #define PR_NVR_NVRDICT PR_TSS
+
+ #define TN_NVR_NVRENC "NvrEncThread"
+ #define PR_NVR_NVRENC_S PR_TSS_S
+ #define PR_NVR_NVRENC PR_TSS
+
+//exec from VehicleInfo
+#define MN_VEHICLEINFOSERVICE "VehicleInfoSrv"
+#define PR_VEHICLEINFOSERVICE_S PR_TSS_S
+#define PR_VEHICLEINFOSERVICE PR_TSS
+
+//exec from _CWORD76_
+#define MN__CWORD76_SERVICE "_CWORD76_Service"
+#define PR__CWORD76_SERVICE_S PR_TSS_S
+#define PR__CWORD76_SERVICE PR_TSS
+
+ #define TN_APPDOWNLOADER "AppDownloader"
+ #define PR_APPDOWNLOADER_S PR_TSS_S
+ #define PR_APPDOWNLOADER PR_TSS
+
+//exec from _CWORD76_(_CWORD58_)
+#define MN__CWORD58_SERVICE "_CWORD58_Service"
+#define PR__CWORD58_SERVICE_S PR_TSS_S
+#define PR__CWORD58_SERVICE PR_TSS
+
+#define MN__CWORD8_SRV "_CWORD8_Srv"
+#define PR__CWORD8_SRV_S PR_TSS_S
+#define PR__CWORD8_SRV PR_TSS
+
+#define MN_SPCSERVICE "SPCService"
+#define PR_SPCSERVICE_S PR_TSS_S
+#define PR_SPCSERVICE PR_TSS
+
+#define MN_LOCALSERVERPROXY "LSP"
+#define PR_LOCALSERVERPROXY_S PR_TSS_S
+#define PR_LOCALSERVERPROXY PR_TSS
+
+#define MN_EOMSERVICE "eOMService"
+#define PR_EOMSERVICE_S PR_TSS_S
+#define PR_EOMSERVICE PR_TSS
+
+//exec from NetworkManager
+#define MN_NETWORKMANAGER "NetworkManager"
+#define PR_NETWORKMANAGER_S PR_TSS_S
+#define PR_NETWORKMANAGER PR_TSS
+
+ #define TN_NWM_TH_CMDRCV "NWM_Th_CmdRcv"
+ #define PR_NWM_TH_CMDRCV_S PR_TSS_S
+ #define PR_NWM_TH_CMDRCV PR_TSS
+
+ #define TN_NWM_TH_PROCMGR "NWM_Th_ProcMgr"
+ #define PR_NWM_TH_PROCMGR_S PR_TSS_S
+ #define PR_NWM_TH_PROCMGR PR_TSS
+
+ #define TN_NWM_TH_CMDPROC "NWM_Th_CmdProc"
+ #define PR_NWM_TH_CMDPROC_S PR_TSS_S
+ #define PR_NWM_TH_CMDPROC PR_TSS
+
+ #define TN_NWM_TH_DNSMGR "NWM_Th_DnsMgr"
+ #define PR_NWM_TH_DNSMGR_S PR_TSS_S
+ #define PR_NWM_TH_DNSMGR PR_TSS
+
+ #define TN_NWM_TH_DHCPD "NWM_Th_Dhcpd"
+ #define PR_NWM_TH_DHCPD_S PR_TSS_S
+ #define PR_NWM_TH_DHCPD PR_TSS
+
+// DCM Service
+#define MN_DCMSERVICE "DCMService"
+#define PR_DCMSERVICE_S PR_TSS_S
+#define PR_DCMSERVICE PR_TSS
+
+ #define TN_DCM_TH_CMDRCV "DCM_Th_CmdRcv"
+ #define PR_DCM_TH_CMDRCV_S PR_TSS_S
+ #define PR_DCM_TH_CMDRCV PR_TSS
+
+ #define TN_DCM_TH_MSGRCV "DCM_Th_MsgRcv"
+ #define PR_DCM_TH_MSGRCV_S PR_TSS_S
+ #define PR_DCM_TH_MSGRCV PR_TSS
+
+ #define TN_DCM_TH_TIMER "DCM_Th_Timer"
+ #define PR_DCM_TH_TIMER_S PR_TSS_S
+ #define PR_DCM_TH_TIMER PR_TSS
+
+// HELP Service
+#define MN_HELPSERVICE "HELPService"
+#define PR_HELPSERVICE_S PR_TSS_S
+#define PR_HELPSERVICE PR_TSS
+
+//exec from RemoteService
+#define MN_REMOTESERVICE "RemoteService"
+#define PR_REMOTESERVICE_S PR_TSS_S
+#define PR_REMOTESERVICE PR_TSS
+
+ #define TN_RS_TH_CANCTRL "RS_Th_CANCtrl"
+ #define PR_RS_TH_CANCTRL_S PR_TSS_S
+ #define PR_RS_TH_CANCTRL PR_TSS
+
+ #define TN_RS_TH_DISPCTRL "RS_Th_DispCtrl"
+ #define PR_RS_TH_DISPCTRL_S PR_TSS_S
+ #define PR_RS_TH_DISPCTRL PR_TSS
+
+ #define TN_RS_TH_PARTSCTRL "RS_Th_PartsCtrl"
+ #define PR_RS_TH_PARTSCTRL_S PR_TSS_S
+ #define PR_RS_TH_PARTSCTRL PR_TSS
+
+ #define TN_RS_TH_HTTPPROC "RS_Th_HttpProc"
+ #define PR_RS_TH_HTTPPROC_S PR_TSS_S
+ #define PR_RS_TH_HTTPPROC PR_TSS
+
+//exec from VR
+#define MN_CONTENTSMGR "contentsmgr"
+#define PR_CONTENTSMGR_S PR_TSS_S
+#define PR_CONTENTSMGR PR_TSS
+
+ #define TN_CDB_CONTENDB "contendbThread"
+ #define PR_CDB_CONTENDB_S PR_TSS_S
+ #define PR_CDB_CONTENDB PR_TSS
+
+/* COMARB Service */
+#define MN_NW_COMARB "ComArbService"
+#define PR_NW_COMARB_S PR_TSS_S
+#define PR_NW_COMARB PR_TSS
+
+/* ASND_FRthread */
+#define MN_ASND_FRTH "ASND_FRthread"
+#define PR_ASND_FRTH_S PR_SND_VCETRFCTRL_S
+#define PR_ASND_FRTH PR_SND_VCETRFCTRL
+
+/* MLINK Service */
+#define MN_MLINKSERVICE "MlinkService"
+#define PR_MLINKSERVICE_S PR_TSS_S
+#define PR_MLINKSERVICE PR_TSS
+
+#define MN__CWORD74_SERVICE "_CWORD74_Service"
+#define PR__CWORD74_SERVICE_S PR_TSS_S
+#define PR__CWORD74_SERVICE PR_TSS
+#endif //__AGL_THREAD_H__
diff --git a/systemservice/task_manager/client/libtskmcfg/conf/tskm_launch.xml b/systemservice/task_manager/client/libtskmcfg/conf/tskm_launch.xml
new file mode 100755
index 0000000..d4ab06c
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/conf/tskm_launch.xml
@@ -0,0 +1,106 @@
+<service_list>
+ <service
+ svcid="TSKM_SVCID_ACTIVITYMGR"
+ name=MN_ACTIVITYMANAGER
+ path="/usr/agl/bin/acmsrv"
+ prio=PR_ACTIVITYMANAGER_S
+ policy="tss"
+ life_cycle="always"
+ user=""
+ shutdown_wait="yes" />
+
+ <service
+ svcid="TSKM_SVCID_TE_RESIDENT"
+ name=MN_RESIDENT_SVC
+ path="/usr/agl/bin/resident"
+ prio=PR_RESIDENT_SVC_S
+ policy="tss"
+ life_cycle="always"
+ user=""
+ shutdown_wait="no" />
+
+ <service
+ svcid="TSKM_SVCID_TE_TRANSIENT"
+ name =MN_TRANSIENT_SVC
+ path="/usr/agl/bin/transient"
+ prio=PR_TRANSIENT_SVC_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+
+ <service
+ svcid="TSKM_SVCID__CWORD58_"
+ name =MN__CWORD58_SERVICE
+ path="/usr/agl/bin/_CWORD58_Service"
+ prio=PR__CWORD58_SERVICE_S
+ policy="tss"
+ retry_cnt="-1"
+ user=""
+ shutdown_wait="yes" />
+
+ <service
+ svcid="TSKM_SVCID_SYSUPDATE"
+ name =MN_PS_SYSUPDATE
+ path="/usr/bin/sysupdate"
+ prio=PR_PS_SYSUPDATE_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+ <service
+ svcid="TSKM_SVCID_NANDUPDATE"
+ name =MN_SS_NANDUPDATE
+ path="/usr/bin/nandupdate"
+ prio=PR_SS_NANDUPDATE_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+ <service
+ svcid="TSKM_SVCID_XMVUPSRV"
+ name =MN_XMVUPSERVICE
+ path="/usr/agl/bin/radio_xm_update"
+ prio=PR_XMVUPSERVICE_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+ <service
+ svcid="TSKM_SVCID_BTPHONESRV"
+ name =MN_BTPHONESRV
+ path="/usr/agl/bin/BT_PhoneSrv"
+ prio=PR_BTPHONESRV_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+ <service
+ svcid="TSKM_SVCID_BTPBKSRV"
+ name =MN_BTPBKSRV
+ path="/usr/agl/bin/BT_PbkSrv"
+ prio=PR_BTPBKSRV_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+ <service
+ svcid="TSKM_SVCID_BTMSGSRV"
+ name =MN_BTMSGSRV
+ path="/usr/agl/bin/BT_MsgSrv"
+ prio=PR_BTMSGSRV_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+ <service
+ svcid="TSKM_SVCID_DTVVUPSRV"
+ name =MN_DTVVUPSERVICE
+ path="/usr/agl/bin/DtvVupService"
+ prio=PR_DTVVUPSERVICE_S
+ policy="tss"
+ user=""
+ shutdown_wait="no" />
+
+</service_list>
+
diff --git a/systemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown.xml b/systemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown.xml
new file mode 100755
index 0000000..4f724f7
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown.xml
@@ -0,0 +1,11 @@
+<normal_shutdown>
+ <global_step>
+ <request_list>
+ <request svcid="TSKM_SVCID_TE_RESIDENT" local_step="last" />
+ <!-- <request svcid="TSKM_SVCID_ACTIVITYMGR" local_step="last" /> -->
+ </request_list>
+
+ <next_trans_condition cond="INI_TERMCOMP_TRANSIENT" />
+ </global_step>
+</normal_shutdown>
+
diff --git a/systemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown_vup.xml b/systemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown_vup.xml
new file mode 100755
index 0000000..71a30c8
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/conf/tskm_shutdown_vup.xml
@@ -0,0 +1,6 @@
+<vup_shutdown>
+ <global_step>
+ <next_trans_condition cond="INI_TERMCOMP_TRANSIENT" />
+ </global_step>
+</vup_shutdown>
+
diff --git a/systemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup.xml b/systemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup.xml
new file mode 100755
index 0000000..aeb3548
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup.xml
@@ -0,0 +1,8 @@
+<normal_wakeup>
+ <global_step>
+ <next_trans_condition cond="INI_INITCOMP_ON_START" />
+ </global_step>
+ <global_step>
+ <next_trans_condition cond="INI_INITCOMP_NVM_ACCESS" />
+ </global_step>
+</normal_wakeup>
diff --git a/systemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup_vup.xml b/systemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup_vup.xml
new file mode 100755
index 0000000..7162fdf
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/conf/tskm_wakeup_vup.xml
@@ -0,0 +1,5 @@
+<vup_wakeup>
+ <global_step>
+ <next_trans_condition cond="INI_INITCOMP_NVM_ACCESS" />
+ </global_step>
+</vup_wakeup>
diff --git a/systemservice/task_manager/client/libtskmcfg/include/system_service/task_manager_libtskmcfg.h b/systemservice/task_manager/client/libtskmcfg/include/system_service/task_manager_libtskmcfg.h
new file mode 100755
index 0000000..c042fc8
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/include/system_service/task_manager_libtskmcfg.h
@@ -0,0 +1,40 @@
+/*
+ * @copyright Copyright (c) 2017-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.
+ */
+/**
+ * @file task_manager_libtskmcfg.h
+ * @brief \~english This file include tskm_svcid.h file and tskm_xml_data.h file
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SYSTEMSERVICE_TASKMNAGERLIBTASKMCFG_H_ // NOLINT(build/header_guard)
+#define SYSTEMSERVICE_TASKMNAGERLIBTASKMCFG_H_
+
+#include "system_service/tskm_svcid.h"
+#include "system_service/tskm_xml_data.h"
+
+#endif // SYSTEMSERVICE_TASKMNAGERLIBTASKMCFG_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/client/libtskmcfg/include/system_service/tskm_svcid.h b/systemservice/task_manager/client/libtskmcfg/include/system_service/tskm_svcid.h
new file mode 100755
index 0000000..d8f3e3d
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/include/system_service/tskm_svcid.h
@@ -0,0 +1,59 @@
+/*
+ * @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.
+ */
+/**
+ * @file tskm_svcid.h
+ * @brief \~english This file contains declaration of TSKM_SVC ID
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+/*
+ * Service ID
+ */
+#ifndef TASK_MANAGER_CLIENT_LIBTSKMCFG_INCLUDE_SYSTEM_SERVICE_TSKM_SVCID_H_
+#define TASK_MANAGER_CLIENT_LIBTSKMCFG_INCLUDE_SYSTEM_SERVICE_TSKM_SVCID_H_
+
+
+#define TSKM_SVCID_NONE 0x00000000U
+#define TSKM_SVCID_TE_RESIDENT 0x00000001U // for test
+#define TSKM_SVCID_TE_TRANSIENT 0x00000002U // for test
+#define TSKM_SVCID_ACTIVITYMGR 0x00000003U
+#define TSKM_SVCID_SYSVUP 0x00000004U // for vup
+#define TSKM_SVCID__CWORD52_VUP 0x00000005U // for vup
+#define TSKM_SVCID_ROOTFSVUP 0x00000006U // for vup
+#define TSKM_SVCID_VUPPROGUI 0x00000007U // for vup
+#define TSKM_SVCID_NORVUP 0x00000008U // for vup
+#define TSKM_SVCID__CWORD58_ 0x00000009U // for _CWORD76_
+#define TSKM_SVCID_SYSUPDATE 0x0000000AU // for repro vup
+#define TSKM_SVCID_NANDUPDATE 0x0000000BU // for repro vup
+#define TSKM_SVCID_BTPHONESRV 0x0000000CU
+#define TSKM_SVCID_BTPBKSRV 0x0000000DU
+#define TSKM_SVCID_BTMSGSRV 0x0000000EU
+#define TSKM_SVCID_DTVVUPSRV 0x0000000FU // fot peaks vup
+#define TSKM_SVCID_XMVUPSRV 0x00000020U // fot XM_outer_update vup
+
+#endif // TASK_MANAGER_CLIENT_LIBTSKMCFG_INCLUDE_SYSTEM_SERVICE_TSKM_SVCID_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/client/libtskmcfg/include/system_service/tskm_xml_data.h b/systemservice/task_manager/client/libtskmcfg/include/system_service/tskm_xml_data.h
new file mode 100755
index 0000000..0c8b75b
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/include/system_service/tskm_xml_data.h
@@ -0,0 +1,173 @@
+/*
+ * @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.
+ */
+/**
+ * @file tskm_xml_data.h
+ * @brief \~english This file provide api to operating task manager with XML data
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef TASK_MANAGER_CLIENT_LIBTSKMCFG_INCLUDE_SYSTEM_SERVICE_TSKM_XML_DATA_H_
+#define TASK_MANAGER_CLIENT_LIBTSKMCFG_INCLUDE_SYSTEM_SERVICE_TSKM_XML_DATA_H_
+
+#include "system_service/tskm_type.h"
+#include "system_service/tskm_svc.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_initServiceList
+ /// \~english @par Summary
+ /// init started services list
+ /// \~english @param [out] p_svcs
+ /// p_svcs - pointer of service list
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @param [in] iFd
+ /// iFd - the file descriptor return by inotify_init1().
+ /// \~english @par
+ /// p_svcs int
+ /// \~english @retval 0 Success
+ /// \~english @retval -1 Failed
+ /// \~english @par Preconditions
+ /// - called in the ctxCreate()
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - if srvId in serviceList greater than TSKM_SVC_ID_MAX_SIZE. [-1]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// Init started services list\n
+ /// Get the started services list from static variable serviceList and init by input parameter iFd\n
+ /// If envirment is NFS, change the path after /tmp to CAP path.\n
+ ///
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+int tskm_initServiceList(TSKM_SVCS_CTX_t* p_svcs, int iFd);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_initWakeupCtx
+ /// \~english @par Summary
+ /// Get state of started step.
+ /// \~english @param [out] p_wakeup
+ /// p_wakeup - pointer of TSKM_GSTEP_CTX_t
+ /// \~english @par
+ /// p_wakeup TSKM_GSTEP_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t gstepIdx; // step Index
+ /// uint32_t gstepNum; // number of step
+ /// TSKM_GSTEP_t* gstep; // step start/stop info
+ /// uint64_t compState;
+ /// } TSKM_GSTEP_CTX_t;
+ /// @endcode
+ /// \~english @param [in] isVupMode
+ /// isVupMode - version up flag
+ /// \~english @par
+ /// isVupMode BOOL
+ /// TRUE version up mode
+ /// FALSE not versoin up mode
+ /// \~english @retval void
+ ///
+ /// \~english @par Preconditions
+ /// - called in ctxCreate()
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - none
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// Get state of started step.\n
+ /// if version up mode is TRUE, retrun the wakeupGstepVup.\n
+ /// if version up mode is FALSE, return the wakeupGstep.\n
+ ///
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+void tskm_initWakeupCtx(TSKM_GSTEP_CTX_t* p_wakeup, BOOL isVupMode);
+
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_initDownCtx
+ /// \~english @par Summary
+ /// Get state of down step.
+ /// \~english @param [out] p_down
+ /// p_down - pointer of TSKM_GSTEP_CTX_t
+ /// \~english @par
+ /// p_wakeup TSKM_GSTEP_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t gstepIdx; // step Index
+ /// uint32_t gstepNum; // number of step
+ /// TSKM_GSTEP_t* gstep; // step start/stop info
+ /// uint64_t compState;
+ /// } TSKM_GSTEP_CTX_t;
+ /// @endcode
+ /// \~english @param [in] isVupMode
+ /// isVupMode - version up mode flag
+ /// \~english @par
+ /// isVupMode BOOL
+ /// TRUE version up mode
+ /// FALSE not versoin up mode
+ /// \~english @retval
+ /// \~english @par Preconditions
+ /// - called in ctxCreate().
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - none
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// Get state of down step.\n
+ /// if version up mode is TRUE, retrun the downGstepVup.\n
+ /// if version up mode is FALSE, return the downGstep.\n
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+void tskm_initDownCtx(TSKM_GSTEP_CTX_t* p_down, BOOL isVupMode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TASK_MANAGER_CLIENT_LIBTSKMCFG_INCLUDE_SYSTEM_SERVICE_TSKM_XML_DATA_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/client/libtskmcfg/libtskmcfg.ver b/systemservice/task_manager/client/libtskmcfg/libtskmcfg.ver
new file mode 100755
index 0000000..c7bb97b
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/libtskmcfg.ver
@@ -0,0 +1,21 @@
+/*
+ * @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.
+ */
+
+{
+ global:
+ tskm_init*;
+ local: *;
+};
diff --git a/systemservice/task_manager/client/libtskmcfg/src/parsexml.c b/systemservice/task_manager/client/libtskmcfg/src/parsexml.c
new file mode 100755
index 0000000..7cb3929
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/src/parsexml.c
@@ -0,0 +1,879 @@
+/*
+ * @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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <libgen.h>
+
+#include <expat.h>
+
+#define BUFSIZE 4096
+#define OUTFILE "tskm_auto_build.h"
+#define TMPFILE "parsexml.tmp"
+
+typedef uint32_t ELE_STATE_t;
+#define ELE_NONE 0x00000000U
+#define ELE_TSKM_CFG 0x10000000U
+#define ELE_SERVICE_LIST 0x11000000U
+#define ELE_SERVICE 0x11100000U
+#define ELE_SUBGID_LIST 0x11110000U
+
+#define ELE_COMMON_GSTEP 0x00100000U
+#define ELE_COMMON_EXEC 0x00010000U
+#define ELE_COMMON_REQ 0x00020000U
+
+#define ELE_NORMAL_WAKEUP 0x12000000U
+#define ELE_NORMAL_W_GSTEP (ELE_NORMAL_WAKEUP|ELE_COMMON_GSTEP)
+#define ELE_NORMAL_W_EXEC (ELE_NORMAL_WAKEUP|ELE_COMMON_GSTEP|ELE_COMMON_EXEC)
+#define ELE_NORMAL_W_REQ (ELE_NORMAL_WAKEUP|ELE_COMMON_GSTEP|ELE_COMMON_REQ)
+
+#define ELE_NORMAL_SHUTDOWN 0x13000000U
+#define ELE_NORMAL_D_GSTEP (ELE_NORMAL_SHUTDOWN|ELE_COMMON_GSTEP)
+#define ELE_NORMAL_D_REQ (ELE_NORMAL_SHUTDOWN|ELE_COMMON_GSTEP|ELE_COMMON_REQ)
+
+#define ELE_VUP_WAKEUP 0x14000000U
+#define ELE_VUP_W_GSTEP (ELE_VUP_WAKEUP|ELE_COMMON_GSTEP)
+#define ELE_VUP_W_EXEC (ELE_VUP_WAKEUP|ELE_COMMON_GSTEP|ELE_COMMON_EXEC)
+#define ELE_VUP_W_REQ (ELE_VUP_WAKEUP|ELE_COMMON_GSTEP|ELE_COMMON_REQ)
+
+#define ELE_VUP_SHUTDOWN 0x15000000U
+#define ELE_VUP_D_GSTEP (ELE_VUP_SHUTDOWN|ELE_COMMON_GSTEP)
+#define ELE_VUP_D_REQ (ELE_VUP_SHUTDOWN|ELE_COMMON_GSTEP|ELE_COMMON_REQ)
+
+
+#define ELE_MASK0 0xF0000000U
+#define ELE_MASK1 0x0F000000U
+#define ELE_MASK2 0x00F00000U
+#define ELE_MASK3 0x000F0000U
+
+#define PARSE_ASSERT_EXIT(x) \
+ if(!(x)){ \
+ printf("ASSERT %s:%s:%d\n",__FILE__,__FUNCTION__,__LINE__); \
+ exit(-1); \
+ }
+
+#define VALUE_NAME_MAX 255
+typedef struct {
+ int step;
+ char gstepIdStr[VALUE_NAME_MAX];
+ int execSvcNum;
+ int reqNum;
+ char nextStepCondStr[VALUE_NAME_MAX];
+ char execSvcName[VALUE_NAME_MAX];
+ char reqTableName[VALUE_NAME_MAX];
+} PARSE_GSTEP_t;
+
+
+typedef struct {
+ char svcid[VALUE_NAME_MAX];
+ char name[VALUE_NAME_MAX];
+ char path[VALUE_NAME_MAX];
+ char type[VALUE_NAME_MAX];
+ char life_cycle[VALUE_NAME_MAX];
+ char retry_cnt[VALUE_NAME_MAX];
+ char cpu_assign[VALUE_NAME_MAX];
+ char prio[VALUE_NAME_MAX];
+ char policy[VALUE_NAME_MAX];
+ char user[VALUE_NAME_MAX];
+ char runtime_limit[VALUE_NAME_MAX];
+ char cpu_limit[VALUE_NAME_MAX];
+ char mem_limit[VALUE_NAME_MAX];
+ int subgidNum;
+ char args[VALUE_NAME_MAX];
+ char shutdown_wait[VALUE_NAME_MAX];
+} PARSE_SVC_t;
+
+/***************************************
+ * Context
+ **************************************/
+typedef struct {
+ FILE* fp; // Output file pointer
+ FILE* tmpFp; // Temporary file
+ ELE_STATE_t state;
+
+ PARSE_SVC_t svc;
+
+ int svcNum; // Number of services
+ PARSE_GSTEP_t gstep;
+} PARSE_CTX_t;
+
+
+/***************************************
+ * entryTskmCfg
+ **************************************/
+void
+entryTskmCfg(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state = ELE_TSKM_CFG;
+}
+
+/***************************************
+ * exitTskmCfg
+ **************************************/
+void
+exitTskmCfg(PARSE_CTX_t* p_ctx) {
+ p_ctx->state = ELE_NONE;
+}
+
+
+/***************************************
+ * entryServiceList
+ **************************************/
+void
+entryServiceList(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state = ELE_SERVICE_LIST;
+
+ p_ctx->tmpFp = fopen(TMPFILE,"w");
+
+ fprintf(p_ctx->tmpFp,
+ "static TSKM_SVC_ATTR_t serviceAttr[]={"
+ "\n");
+}
+
+/***************************************
+ * exitServiceList
+ **************************************/
+void
+exitServiceList(PARSE_CTX_t* p_ctx) {
+ fprintf(p_ctx->tmpFp,
+ "};"
+ "\n\n");
+
+ fprintf(p_ctx->tmpFp, "#define TSKM_SVC_NUM (%d) \n\n",p_ctx->svcNum);
+
+ fprintf(p_ctx->tmpFp, "static TSKM_SVC_CTX_t serviceList[TSKM_SVC_NUM]; \n\n");
+
+ fclose(p_ctx->tmpFp);
+
+ fprintf(p_ctx->fp,"\n\n");
+
+ p_ctx->state = ELE_TSKM_CFG;
+}
+
+/***************************************
+ * handleServiceList
+ **************************************/
+void
+entryService(PARSE_CTX_t* p_ctx,const XML_Char *name,const XML_Char* atts[]) {
+ PARSE_ASSERT_EXIT(strcmp(name,"service") == 0);
+ int ii;
+ char* tp;
+ p_ctx->state = ELE_SERVICE;
+
+ memset(&p_ctx->svc,0,sizeof(p_ctx->svc));
+
+ for(ii=0; atts[ii]; ii+=2) {
+ const char* attr = atts[ii];
+ const char* value = atts[ii+1];
+ if(strcmp(attr,"svcid")==0) {
+ strcpy(p_ctx->svc.svcid,value);
+ } else if(strcmp(attr,"name")==0) {
+ strcpy(p_ctx->svc.name,value);
+ } else if(strcmp(attr,"path")==0) {
+ strcpy(p_ctx->svc.path,value);
+ } else if(strcmp(attr,"type")==0) {
+ const char* typeName = (strcmp(value,"native")==0) ? "TSKM_SVC_TYPE_NATIVE" : "TSKM_SVC_TYPE_UNKNONW";
+ strcpy(p_ctx->svc.type,typeName);
+ } else if(strcmp(attr,"prio")==0) {
+ strcpy(p_ctx->svc.prio,value);
+ } else if(strcmp(attr,"policy")==0) {
+ const char* polName = (strcmp(value,"fifo")==0) ? "TSKM_SVC_POLICY_FIFO" :
+ (strcmp(value,"tss")==0) ? "TSKM_SVC_POLICY_TSS" :
+ (strcmp(value,"rr")==0) ? "TSKM_SVC_POLICY_RR" : "ERROR";
+ strcpy(p_ctx->svc.policy,polName);
+ } else if(strcmp(attr,"life_cycle")==0) {
+ const char* lcName = (strcmp(value,"always")==0) ? "TSKM_SVC_LC_ALWAYS" :
+ (strcmp(value,"always_recoverable")==0) ? "TSKM_SVC_LC_ALWAYS_RECOVERABLE" :
+ (strcmp(value,"dynamic")==0) ? "TSKM_SVC_LC_DYNAMIC" : "ERROR";
+ strcpy(p_ctx->svc.life_cycle,lcName);
+ } else if(strcmp(attr,"retry_cnt")==0) {
+ strcpy(p_ctx->svc.retry_cnt,value);
+ } else if(strcmp(attr,"cpu_assign")==0) {
+ const char* caName = (strcmp(value,"cpu0")==0) ? "TSKM_SVC_ASSIGN_CPU_0" :
+ (strcmp(value,"cpu1")==0) ? "TSKM_SVC_ASSIGN_CPU_1" :
+ (strcmp(value,"auto")==0) ? "TSKM_SVC_ASSIGN_CPU_AUTO" : "ERROR";
+ strcpy(p_ctx->svc.cpu_assign,caName);
+ } else if(strcmp(attr,"user")==0) {
+ strcpy(p_ctx->svc.user,value);
+ } else if(strcmp(attr,"runtime_limit")==0) {
+ strcpy(p_ctx->svc.runtime_limit,value);
+ } else if(strcmp(attr,"cpu_limit")==0) {
+ strcpy(p_ctx->svc.cpu_limit,value);
+ } else if(strcmp(attr,"mem_limit")==0) {
+ strcpy(p_ctx->svc.mem_limit,value);
+ } else if(strcmp(attr,"args")==0) {
+ strcpy(p_ctx->svc.args,value);
+ } else if(strcmp(attr,"shutdown_wait")==0) {
+ const char* swStr = (strcmp(value,"yes")==0) ? "TSKM_TRUE" :
+ (strcmp(value,"no")==0) ? "TSKM_FALSE" : "ERROR";
+ strcpy(p_ctx->svc.shutdown_wait,swStr);
+ }
+ }
+
+ fprintf(p_ctx->fp,"char const *svcArgs%d[] = {",p_ctx->svcNum);
+ fprintf(p_ctx->fp,"\"%s\",",p_ctx->svc.path);
+
+ // Output arguments
+ tp = strtok(p_ctx->svc.args," ");
+ while(tp != NULL) {
+ fprintf(p_ctx->fp,"\"%s\",",tp);
+ tp = strtok(NULL," ");
+ }
+
+ fprintf(p_ctx->fp,"NULL");
+ fprintf(p_ctx->fp,"};\n");
+}
+
+/***************************************
+ * exitService
+ **************************************/
+void
+exitService(PARSE_CTX_t* p_ctx) {
+ uint32_t ii;
+ fprintf(p_ctx->tmpFp,"{" );
+
+ fprintf(p_ctx->tmpFp,"%s",p_ctx->svc.svcid);
+ fprintf(p_ctx->tmpFp,", (const char *)\"%s\"",p_ctx->svc.name);
+ fprintf(p_ctx->tmpFp,", (const char *)\"%s\"",p_ctx->svc.path);
+ fprintf(p_ctx->tmpFp,", (char**)svcArgs%d",p_ctx->svcNum);
+ fprintf(p_ctx->tmpFp,", %s",p_ctx->svc.type);
+ fprintf(p_ctx->tmpFp,", %s",p_ctx->svc.prio);
+ fprintf(p_ctx->tmpFp,", %s",p_ctx->svc.policy);
+ fprintf(p_ctx->tmpFp,", %s",p_ctx->svc.life_cycle);
+ fprintf(p_ctx->tmpFp,", (uint32_t)%s",p_ctx->svc.retry_cnt);
+ fprintf(p_ctx->tmpFp,", %s",p_ctx->svc.cpu_assign);
+ fprintf(p_ctx->tmpFp,", (const char *)\"%s\"",p_ctx->svc.user);
+ fprintf(p_ctx->tmpFp,", %s",(p_ctx->svc.runtime_limit[0] != '\0') ? p_ctx->svc.runtime_limit : "0");
+ fprintf(p_ctx->tmpFp,", %s",(p_ctx->svc.cpu_limit[0] != '\0') ? p_ctx->svc.cpu_limit : "0");
+ fprintf(p_ctx->tmpFp,", %s",(p_ctx->svc.mem_limit[0] != '\0') ? p_ctx->svc.mem_limit : "0");
+ fprintf(p_ctx->tmpFp,", %s",p_ctx->svc.shutdown_wait);
+ fprintf(p_ctx->tmpFp,", %d",p_ctx->svc.subgidNum);
+ if(p_ctx->svc.subgidNum) {
+ fprintf(p_ctx->tmpFp,", subgidList%d",p_ctx->svcNum);
+ } else {
+ fprintf(p_ctx->tmpFp,", NULL");
+ }
+
+ fprintf(p_ctx->tmpFp,"},\n");
+
+ p_ctx->svcNum++;
+
+ p_ctx->state = ELE_SERVICE_LIST;
+}
+
+/***************************************
+ * entrySubgidList
+ **************************************/
+void
+entrySubgidList(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state = ELE_SUBGID_LIST;
+
+ fprintf(p_ctx->fp,"static gid_t subgidList%d[] = {",p_ctx->svcNum);
+
+
+}
+
+/***************************************
+ * handleSubgidList
+ **************************************/
+void
+handleSubgidList(PARSE_CTX_t* p_ctx,const XML_Char *name,const XML_Char* atts[]) {
+ PARSE_ASSERT_EXIT(strcmp(name,"subgid") == 0);
+ int32_t ii;
+
+ if(p_ctx->svc.subgidNum > 0) {
+ fprintf(p_ctx->fp,",");
+ }
+ for(ii=0; atts[ii]; ii+=2) {
+ const char* attr = atts[ii];
+ const char* value = atts[ii+1];
+ if(strcmp(attr,"gid")==0) {
+ fprintf(p_ctx->fp,"%s",value);
+ } else {
+ PARSE_ASSERT_EXIT(0);
+ }
+ }
+ p_ctx->svc.subgidNum++;
+}
+
+/***************************************
+ * exitSubgidList
+ **************************************/
+void
+exitSubgidList(PARSE_CTX_t* p_ctx) {
+
+ fprintf(p_ctx->fp,"};\n");
+
+ p_ctx->state = ELE_SERVICE;
+}
+
+
+/***************************************
+ * entryNormalWakeup
+ **************************************/
+void
+entryNormalWakeup(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state = ELE_NORMAL_WAKEUP;
+ memset(&p_ctx->gstep,0,sizeof(p_ctx->gstep));
+
+ sprintf(p_ctx->gstep.reqTableName,"wakeupReqList");
+ sprintf(p_ctx->gstep.execSvcName,"wakeupExecSvcId");
+ p_ctx->tmpFp = fopen(TMPFILE,"a");
+ PARSE_ASSERT_EXIT(p_ctx->tmpFp);
+
+ fprintf(p_ctx->tmpFp,"TSKM_GSTEP_t wakeupGstep[]={\n");
+}
+
+/***************************************
+ * exitNormalWakeup
+ **************************************/
+void
+exitNormalWakeup(PARSE_CTX_t* p_ctx) {
+ fprintf(p_ctx->tmpFp,"};\n\n");
+ fclose(p_ctx->tmpFp);
+
+ p_ctx->state = ELE_TSKM_CFG;
+}
+
+/***************************************
+ * entryVupWakeup
+ **************************************/
+void
+entryVupWakeup(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state = ELE_VUP_WAKEUP;
+ memset(&p_ctx->gstep,0,sizeof(p_ctx->gstep));
+
+ sprintf(p_ctx->gstep.reqTableName,"wakeupReqListVup");
+ sprintf(p_ctx->gstep.execSvcName,"wakeupExecSvcIdVup");
+ p_ctx->tmpFp = fopen(TMPFILE,"a");
+ PARSE_ASSERT_EXIT(p_ctx->tmpFp);
+
+ fprintf(p_ctx->tmpFp,"TSKM_GSTEP_t wakeupGstepVup[]={\n");
+}
+
+/***************************************
+ * exitVupWakeup
+ **************************************/
+void
+exitVupWakeup(PARSE_CTX_t* p_ctx) {
+ fprintf(p_ctx->tmpFp,"};\n\n");
+ fclose(p_ctx->tmpFp);
+
+ p_ctx->state = ELE_TSKM_CFG;
+}
+
+void
+entryGstep(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+
+ p_ctx->state &= ~ELE_MASK2;
+ p_ctx->state |= ELE_COMMON_GSTEP;
+
+ PARSE_GSTEP_t *p_gstep = &p_ctx->gstep;
+
+ if(atts[0] && strcmp(atts[0],"stepid") == 0) {
+ sprintf(p_gstep->gstepIdStr,"%s",atts[1]);
+ } else {
+ sprintf(p_gstep->gstepIdStr,"TSKM_GSTEP_NONE");
+ }
+ p_gstep->execSvcNum = 0;
+ p_gstep->reqNum = 0;
+ sprintf(p_gstep->nextStepCondStr,"INI_INITCOMP_NONE");
+}
+
+void
+handleGstep(PARSE_CTX_t* p_ctx,const XML_Char *name,const XML_Char* atts[]) {
+ PARSE_ASSERT_EXIT(strcmp(name,"next_trans_condition") == 0);
+ PARSE_GSTEP_t *p_gstep = &p_ctx->gstep;
+
+ if(atts[0] && strcmp(atts[0],"cond") == 0) {
+ sprintf(p_gstep->nextStepCondStr,"%s",atts[1]);
+ } else {
+ PARSE_ASSERT_EXIT(0);
+ }
+}
+
+void
+exitGstep(PARSE_CTX_t* p_ctx) {
+ PARSE_GSTEP_t *p_gstep = &p_ctx->gstep;
+
+ fprintf(p_ctx->tmpFp,"{");
+ fprintf(p_ctx->tmpFp,"%s,",p_gstep->gstepIdStr);
+ fprintf(p_ctx->tmpFp,"%d,",p_gstep->execSvcNum);
+ if(p_gstep->execSvcNum) {
+ fprintf(p_ctx->tmpFp,"%s%d,",p_gstep->execSvcName,p_gstep->step);
+ } else {
+ fprintf(p_ctx->tmpFp,"NULL,");
+ }
+ fprintf(p_ctx->tmpFp,"%d,",p_gstep->reqNum);
+ if(p_gstep->reqNum) {
+ fprintf(p_ctx->tmpFp,"%s%d,",p_gstep->reqTableName,p_gstep->step);
+ } else {
+ fprintf(p_ctx->tmpFp,"NULL,");
+ }
+ fprintf(p_ctx->tmpFp,"%s",p_gstep->nextStepCondStr);
+ fprintf(p_ctx->tmpFp,"},\n");
+
+ p_gstep->step++;
+
+ p_ctx->state &= ~ELE_MASK2;
+}
+
+void
+entryExec(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state &= ~ELE_MASK3;
+ p_ctx->state |= ELE_COMMON_EXEC;
+
+ PARSE_GSTEP_t *p_gstep = &p_ctx->gstep;
+ fprintf(p_ctx->fp,
+ "static TSKM_SVCID_t %s%d[] = {",p_gstep->execSvcName,p_gstep->step);
+}
+void
+handleExec(PARSE_CTX_t* p_ctx,const XML_Char *name,const XML_Char* atts[]) {
+ PARSE_ASSERT_EXIT(strcmp(name,"exec_svc") == 0);
+ PARSE_GSTEP_t *p_gstep = &p_ctx->gstep;
+ int ii;
+
+ if(p_gstep->execSvcNum > 0) {
+ fprintf(p_ctx->fp,",");
+ }
+
+ for(ii=0; atts[ii]; ii+=2) {
+ const char* attr = atts[ii];
+ const char* value = atts[ii+1];
+ PARSE_ASSERT_EXIT(strcmp(attr,"svcid") == 0);
+ fprintf(p_ctx->fp,"%s",value);
+ }
+ p_gstep->execSvcNum++;
+}
+void
+exitExec(PARSE_CTX_t* p_ctx) {
+ fprintf(p_ctx->fp,"};\n\n");
+ p_ctx->state &= ~ELE_MASK3;
+}
+
+void
+entryReq(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state &= ~ELE_MASK3;
+ p_ctx->state |= ELE_COMMON_REQ;
+ PARSE_GSTEP_t *p_gstep = &p_ctx->gstep;
+
+ fprintf(p_ctx->fp,"static TSKM_GSTEP_REQ_INFO_t %s%d[] ={",p_gstep->reqTableName,p_gstep->step);
+}
+void
+handleReq(PARSE_CTX_t* p_ctx,const XML_Char *name,const XML_Char* atts[]) {
+ PARSE_GSTEP_t *p_gstep = &p_ctx->gstep;
+ PARSE_ASSERT_EXIT(strcmp(name,"request") == 0);
+ int ii;
+
+ fprintf(p_ctx->fp," {");
+
+ for(ii=0; atts[ii]; ii+=2) {
+ const char* attr = atts[ii];
+ const char* value = atts[ii+1];
+ if(strcmp(attr,"local_step") == 0) {
+ if(strcmp(value,"shm") == 0) {
+ fprintf(p_ctx->fp,"TSKM_LSTEP_SHM");
+ } else if(strcmp(value,"bupchk") == 0) {
+ fprintf(p_ctx->fp,"TSKM_LSTEP_BUPCHK");
+ } else if(strcmp(value,"last") == 0) {
+ fprintf(p_ctx->fp,"TSKM_LSTEP_LAST");
+ } else if(strcmp(value,"all") == 0) {
+ fprintf(p_ctx->fp,"TSKM_LSTEP_ALL");
+ } else {
+ fprintf(p_ctx->fp,"%s",value);
+ }
+ } else {
+ fprintf(p_ctx->fp,"%s",value); // Output of ","
+ }
+ fprintf(p_ctx->fp,"%s",(atts[ii+2])?",":""); // Outoput of ","
+ }
+ fprintf(p_ctx->fp,"},");
+ p_gstep->reqNum++;
+}
+void
+exitReq(PARSE_CTX_t* p_ctx) {
+ fprintf(p_ctx->fp,"};\n\n");
+ p_ctx->state &= ~ELE_MASK3;
+}
+
+/***************************************
+ * entryNormalShutdown
+ **************************************/
+void
+entryNormalShutdown(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state = ELE_NORMAL_SHUTDOWN;
+
+ memset(&p_ctx->gstep,0,sizeof(p_ctx->gstep));
+ sprintf(p_ctx->gstep.reqTableName,"downReqList");
+ p_ctx->tmpFp = fopen(TMPFILE,"a");
+ PARSE_ASSERT_EXIT(p_ctx->tmpFp);
+
+ fprintf(p_ctx->tmpFp,"static TSKM_GSTEP_t downGstep[]={\n");
+}
+
+/***************************************
+ * exitNormalShutdown
+ **************************************/
+void
+exitNormalShutdown(PARSE_CTX_t* p_ctx) {
+
+ fprintf(p_ctx->tmpFp,"};\n\n");
+ fclose(p_ctx->tmpFp);
+
+ p_ctx->state = ELE_TSKM_CFG;
+}
+
+/***************************************
+ * entryVupShutdown
+ **************************************/
+void
+entryVupShutdown(PARSE_CTX_t* p_ctx,const XML_Char* atts[]) {
+ p_ctx->state = ELE_VUP_SHUTDOWN;
+ memset(&p_ctx->gstep,0,sizeof(p_ctx->gstep));
+
+ sprintf(p_ctx->gstep.reqTableName,"downReqListVup");
+ p_ctx->tmpFp = fopen(TMPFILE,"a");
+ PARSE_ASSERT_EXIT(p_ctx->tmpFp);
+
+ fprintf(p_ctx->tmpFp,"static TSKM_GSTEP_t downGstepVup[]={\n");
+}
+
+/***************************************
+ * exitVupShutdown
+ **************************************/
+void
+exitVupShutdown(PARSE_CTX_t* p_ctx) {
+ fprintf(p_ctx->tmpFp,"};\n\n");
+ fclose(p_ctx->tmpFp);
+
+ p_ctx->state = ELE_TSKM_CFG;
+}
+
+/***************************************
+ * elementStart
+ **************************************/
+void
+elementStart(void *userData, const XML_Char *name, const XML_Char *atts[]) {
+ PARSE_CTX_t *p_ctx = (PARSE_CTX_t*)userData;
+#if 0
+ int ii;
+ printf("[ELEMENT] %s Start!\n", name);
+ for(ii=0; atts[ii]; ii+=2) {
+ printf(" %s:%s \n", atts[ii],atts[ii+1]);
+ }
+#endif
+ switch(p_ctx->state) {
+ case ELE_NONE:
+ if(strcmp(name,"tskm_cfg") == 0) {
+ entryTskmCfg(p_ctx,atts);
+ } else {
+ PARSE_ASSERT_EXIT(0);
+ }
+ break;
+ case ELE_TSKM_CFG:
+ if(strcmp(name,"service_list") == 0) {
+ entryServiceList(p_ctx,atts);
+ } else if(strcmp(name,"normal_wakeup") == 0) {
+ entryNormalWakeup(p_ctx,atts);
+ } else if(strcmp(name,"normal_shutdown") == 0) {
+ entryNormalShutdown(p_ctx,atts);
+ } else if(strcmp(name,"vup_wakeup") == 0) {
+ entryVupWakeup(p_ctx,atts);
+ } else if(strcmp(name,"vup_shutdown") == 0) {
+ entryVupShutdown(p_ctx,atts);
+ } else {
+ PARSE_ASSERT_EXIT(0);
+ }
+ break;
+ case ELE_SERVICE_LIST:
+ if(strcmp(name,"service") == 0) {
+ entryService(p_ctx,name,atts);
+ }
+ break;
+ case ELE_SERVICE:
+ if(strcmp(name,"subgid_list") == 0) {
+ entrySubgidList(p_ctx,atts);
+ }
+ break;
+ case ELE_SUBGID_LIST:
+ handleSubgidList(p_ctx,name,atts);
+ break;
+ case ELE_NORMAL_WAKEUP:
+ case ELE_NORMAL_SHUTDOWN:
+ case ELE_VUP_WAKEUP:
+ case ELE_VUP_SHUTDOWN:
+ if(strcmp(name,"global_step") == 0) {
+ entryGstep(p_ctx,atts);
+ } else {
+ PARSE_ASSERT_EXIT(0);
+ }
+ break;
+ case ELE_NORMAL_W_GSTEP:
+ case ELE_NORMAL_D_GSTEP:
+ case ELE_VUP_W_GSTEP:
+ case ELE_VUP_D_GSTEP:
+ if(strcmp(name,"exec_list") == 0) {
+ entryExec(p_ctx,atts);
+ } else if(strcmp(name,"request_list") == 0) {
+ entryReq(p_ctx,atts);
+ } else {
+ handleGstep(p_ctx,name,atts);
+ }
+ break;
+ case ELE_NORMAL_W_EXEC:
+ case ELE_VUP_W_EXEC:
+ handleExec(p_ctx,name,atts);
+ break;
+ case ELE_NORMAL_W_REQ:
+ case ELE_NORMAL_D_REQ:
+ case ELE_VUP_W_REQ:
+ case ELE_VUP_D_REQ:
+ handleReq(p_ctx,name,atts);
+ break;
+ }
+}
+
+
+/***************************************
+ * elementEnd
+ **************************************/
+void
+elementEnd(void *userData, const XML_Char *name) {
+ PARSE_CTX_t *p_ctx = (PARSE_CTX_t*)userData;
+ switch(p_ctx->state) {
+ case ELE_NONE:
+ PARSE_ASSERT_EXIT(0);
+ break;
+ case ELE_TSKM_CFG:
+ if(strcmp(name,"tskm_cfg") == 0) {
+ exitTskmCfg(p_ctx);
+ } else {
+ PARSE_ASSERT_EXIT(0);
+ }
+ break;
+ case ELE_SERVICE_LIST:
+ if(strcmp(name,"service_list") == 0) {
+ exitServiceList(p_ctx);
+ }
+ break;
+ case ELE_SERVICE:
+ if(strcmp(name,"service") == 0) {
+ exitService(p_ctx);
+ }
+ break;
+ case ELE_SUBGID_LIST:
+ if(strcmp(name,"subgid_list") == 0) {
+ exitSubgidList(p_ctx);
+ }
+ break;
+ case ELE_NORMAL_WAKEUP:
+ if(strcmp(name,"normal_wakeup") == 0) {
+ exitNormalWakeup(p_ctx);
+ }
+ break;
+ case ELE_NORMAL_SHUTDOWN:
+ if(strcmp(name,"normal_shutdown") == 0) {
+ exitNormalShutdown(p_ctx);
+ }
+ break;
+ case ELE_VUP_WAKEUP:
+ if(strcmp(name,"vup_wakeup") == 0) {
+ exitVupWakeup(p_ctx);
+ }
+ break;
+ case ELE_VUP_SHUTDOWN:
+ if(strcmp(name,"vup_shutdown") == 0) {
+ exitVupShutdown(p_ctx);
+ }
+ break;
+ case ELE_NORMAL_D_GSTEP:
+ case ELE_NORMAL_W_GSTEP:
+ case ELE_VUP_D_GSTEP:
+ case ELE_VUP_W_GSTEP:
+ if(strcmp(name,"global_step") == 0) {
+ exitGstep(p_ctx);
+ }
+ break;
+ case ELE_NORMAL_W_EXEC:
+ case ELE_VUP_W_EXEC:
+ if(strcmp(name,"exec_list") == 0) {
+ exitExec(p_ctx);
+ }
+ break;
+ case ELE_NORMAL_D_REQ:
+ case ELE_NORMAL_W_REQ:
+ case ELE_VUP_D_REQ:
+ case ELE_VUP_W_REQ:
+ if(strcmp(name,"request_list") == 0) {
+ exitReq(p_ctx);
+ }
+ break;
+ }
+}
+/***************************************
+ * parseXmlFile
+ **************************************/
+int
+parseXmlFile(const char* file,XML_Parser parser) {
+ int ret = -1;
+ FILE* fp = fopen(file, "r");
+ if (fp == NULL) {
+ goto ERROR;
+ }
+
+ while(1) {
+ char *buf = (char*) XML_GetBuffer(parser, BUFSIZE);
+ if (!buf) {
+ goto ERROR;
+ }
+
+ size_t nread = fread(buf, sizeof(char), BUFSIZE, fp);
+ if (ferror(fp)) {
+ goto ERROR;
+ }
+
+ if (!XML_ParseBuffer(parser, nread, feof(fp))) {
+ goto ERROR;
+ }
+
+ if (feof(fp)) {
+ break;
+ }
+ }
+ ret = 0;
+ERROR:
+ if(fp) {
+ fclose(fp);
+ }
+ return ret;
+}
+
+/***************************************
+ * externalHandler
+ **************************************/
+int
+externalHandler(XML_Parser parser,
+ const XML_Char* content, const XML_Char* base,
+ const XML_Char* systemId, const XML_Char* publicId) {
+ printf("parse %s \n",systemId);
+
+ int ret = XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+ XML_Parser extparser = NULL;
+
+ extparser = XML_ExternalEntityParserCreate(parser, content, NULL);
+ if(extparser ==NULL) {
+ goto ERROR;
+ }
+
+ if(parseXmlFile(systemId,extparser) != 0) {
+ goto ERROR;
+ }
+ ret = XML_STATUS_OK;
+ERROR:
+ if(extparser) {
+ XML_ParserFree(extparser);
+ }
+ return ret;
+}
+
+/***************************************
+ * usage
+ **************************************/
+void
+usage(const char* cmd) {
+ printf("usage:%s xmlfile\n",cmd);
+}
+
+/***************************************
+ * main
+ **************************************/
+int
+main (int argc, char *argv[]) {
+ struct stat statinfo;
+ int ret=-1;
+ int xmlRet;
+ const char* inpath;
+ char tmpstr1[255];
+ char tmpstr2[255];
+ const char* workdir;
+ const char* infile;
+ XML_Parser parser;
+ PARSE_CTX_t ctx;
+
+ if(argc < 2) {
+ usage(argv[0]);
+ goto ERROR;
+ }
+
+ inpath = argv[1];
+ if(0 != stat(inpath,&statinfo)) {
+ fprintf(stderr, "%s:%s",strerror(errno),inpath);
+ goto ERROR;
+ }
+ memset(&ctx,0,sizeof(ctx));
+
+ strcpy(tmpstr1,inpath);
+ strcpy(tmpstr2,inpath);
+ workdir=dirname(tmpstr1);
+ infile=basename(tmpstr2);
+
+ if(0 != chdir(workdir)) {
+ fprintf(stderr, "%s:%s",strerror(errno),workdir);
+ goto ERROR;
+ }
+
+ ctx.fp = fopen(OUTFILE, "w");
+ if (ctx.fp == NULL) {
+ goto ERROR;
+ }
+ fprintf(ctx.fp,"//This file is created automatically from %s.\n",inpath);
+ fprintf(ctx.fp,"//So you shall not modify this file immediately.\n");
+
+ /* create XML parser */
+ if ((parser = XML_ParserCreate(NULL)) == NULL) {
+ fprintf(stderr, "parser creation error\n");
+ goto ERROR;
+ }
+ XML_SetUserData(parser,&ctx);
+ XML_SetParamEntityParsing(parser,XML_PARAM_ENTITY_PARSING_ALWAYS); // Allow External Entities
+ XML_SetExternalEntityRefHandler(parser,externalHandler);
+ XML_SetElementHandler(parser, elementStart, elementEnd);
+
+ if(parseXmlFile(infile,parser) != 0) {
+ goto ERROR;
+ }
+ ret = 0;
+
+ERROR:
+ if(parser) {
+ XML_ParserFree(parser);
+ }
+ if(ctx.fp) {
+ fclose(ctx.fp);
+ }
+ char buf[255];
+ sprintf(buf,"cat %s >> %s",TMPFILE,OUTFILE);
+ printf("%s\n",buf);
+ system(buf);
+ unlink(TMPFILE);
+ return ret;
+}
+
diff --git a/systemservice/task_manager/client/libtskmcfg/src/tskm_xml_data.cpp b/systemservice/task_manager/client/libtskmcfg/src/tskm_xml_data.cpp
new file mode 100755
index 0000000..531b701
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/src/tskm_xml_data.cpp
@@ -0,0 +1,138 @@
+/*
+ * @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.
+ */
+
+#include "system_service/tskm_xml_data.h"
+
+#include <boost/algorithm/string.hpp>
+#include <fstream>
+#include <iostream>
+#include <string>
+#include <list>
+
+#include "system_service/tskm_svc.h"
+
+#include "system_service/tskm_svcid.h"
+#include "tskm_debug.h"
+#include "tskm_comm.h"
+#include "tskm_auto_build.h" // Generated data from XML
+
+// This size depends on the size of the TM area of CL_Monitor
+#define TSKM_SVC_ID_MAX_SIZE 1024
+
+/***********************************************************************
+ * tskm_initServiceList
+ ***********************************************************************/
+int tskm_initServiceList(TSKM_SVCS_CTX_t* p_svcs, int iFd) {
+ uint32_t ii;
+
+ p_svcs->svcNum = sizeof(serviceList) / sizeof(TSKM_SVC_CTX_t);
+ p_svcs->svcList = serviceList;
+
+ // It is initialized with the Inotify floppy disk.
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ serviceList[ii].attr = &serviceAttr[ii];
+ serviceList[ii].iFd = iFd;
+ if (serviceList[ii].attr->svcId >= TSKM_SVC_ID_MAX_SIZE) {
+ TSKM_ASSERT(0);
+ return -1;
+ }
+ }
+
+ const char* nfsenv = getenv("AGL_NFS");
+ bool isNfs = (nfsenv && strcmp(nfsenv, "y") == 0) ? true : false;
+
+ // For NFS environments, replace the PATH with CAP with /tmp
+ if (isNfs) {
+ std::list<std::string> capFiles;
+ const std::string capPath("/usr/debug/share/target/cap.lst");
+ std::ifstream fin(capPath.c_str());
+ std::string line;
+ while (fin && std::getline(fin, line)) {
+ std::list<std::string> strList;
+ try { // throw exception by boost::split
+ boost::split(strList, line, boost::is_any_of("|"));
+ if (!strList.empty()) {
+ if (strList.front()[0] == '/') { // Only character strings beginning with '/' are considered PATH
+ capFiles.push_back(strList.front().c_str());
+ }
+ }
+ } catch (...) {
+ TSKM_ASSERT(0);
+ }
+ }
+
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ std::string binPath(serviceList[ii].attr->path);
+
+ for (std::list<std::string>::iterator ite = capFiles.begin();
+ ite != capFiles.end(); ite++) {
+ if (binPath == *ite) {
+ std::list<std::string> nodes;
+ try { // throw exception by boost::split
+ boost::split(nodes, binPath, boost::is_any_of("/"));
+ std::string *p_newPath = new std::string("/tmp/"); // Intent not to free up memory
+ *p_newPath += nodes.back();
+ TSKM_PRINTF(TSKM_LOG_STATE, "EXCHG %s", p_newPath->c_str());
+ serviceList[ii].attr->path = p_newPath->c_str();
+ break;
+ } catch (...) {
+ TSKM_ASSERT(0);
+ }
+ }
+ }
+ }
+ }
+
+ // If there is no socket resource equal to the number of services + 1 (internal control connection), a compilation error occurs
+ TSKM_STATIC_ASSERT(TSKM_COMM_CONNECT_MAX >= (TSKM_SVC_NUM+1));
+
+ return 0;
+}
+
+/***********************************************************************
+ * tskm_initWakeupCtx
+ ***********************************************************************/
+void tskm_initWakeupCtx(TSKM_GSTEP_CTX_t* p_wakeup, BOOL isVupMode) {
+ memset(p_wakeup, 0, sizeof(*p_wakeup));
+
+ if (isVupMode) {
+ p_wakeup->gstepNum = sizeof(wakeupGstepVup) / sizeof(TSKM_GSTEP_t);
+ p_wakeup->gstep = wakeupGstepVup;
+ } else {
+ p_wakeup->gstepNum = sizeof(wakeupGstep) / sizeof(TSKM_GSTEP_t);
+ p_wakeup->gstep = wakeupGstep;
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "gstep(wakeup):%d", p_wakeup->gstepNum);
+}
+
+/***********************************************************************
+ * tskm_initDownCtx
+ ***********************************************************************/
+void tskm_initDownCtx(TSKM_GSTEP_CTX_t* p_down, BOOL isVupMode) {
+ memset(p_down, 0, sizeof(*p_down));
+
+ if (isVupMode) {
+ p_down->gstepNum = sizeof(downGstepVup) / sizeof(TSKM_GSTEP_t);
+ p_down->gstep = downGstepVup;
+ } else {
+ p_down->gstepNum = sizeof(downGstep) / sizeof(TSKM_GSTEP_t);
+ p_down->gstep = downGstep;
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "gstep(down):%d", p_down->gstepNum);
+}
+
diff --git a/systemservice/task_manager/client/libtskmcfg/tskm_cfg.xml b/systemservice/task_manager/client/libtskmcfg/tskm_cfg.xml
new file mode 100755
index 0000000..2898f44
--- /dev/null
+++ b/systemservice/task_manager/client/libtskmcfg/tskm_cfg.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" ?>
+
+<!DOCTYPE tskm_cfg [
+ <!ELEMENT tskm_cfg (service_list,normal_wakeup,normal_shutdown,vup_wakeup,vup_shutdown) >
+
+ <!-- service list -->
+ <!ELEMENT service_list (service+) >
+ <!ELEMENT service (subgid_list*) >
+ <!ATTLIST service
+ svcid ID #REQUIRED
+ name CDATA #REQUIRED
+ path CDATA #REQUIRED
+ type (native|unknown) "native"
+ prio CDATA #REQUIRED
+ policy (fifo|tss|rr) #REQUIRED
+ life_cycle (always|always_recoverable|dynamic) "dynamic"
+ retry_cnt CDATA "1"
+ cpu_assign (cpu0|cpu1|auto) "auto"
+ user CDATA #REQUIRED
+ runtime_limit CDATA #IMPLIED
+ cpu_limit CDATA #IMPLIED
+ mem_limit CDATA #IMPLIED
+ args CDATA #IMPLIED
+ shutdown_wait (yes|no) #REQUIRED
+ >
+
+ <!ELEMENT subgid_list (subgid+) >
+ <!ELEMENT subgid EMPTY >
+ <!ATTLIST subgid
+ gid CDATA #REQUIRED
+ >
+
+
+ <!-- Starting/terminating of services -->
+ <!ELEMENT normal_wakeup (global_step+) >
+ <!ELEMENT normal_shutdown (global_step+) >
+ <!ELEMENT vup_wakeup (global_step+) >
+ <!ELEMENT vup_shutdown (global_step+) >
+
+ <!ELEMENT global_step (exec_list?,request_list?,next_trans_condition?) >
+ <!ATTLIST global_step
+ stepid ID #IMPLIED
+ >
+
+ <!ELEMENT exec_list (exec_svc+) >
+ <!ELEMENT exec_svc EMPTY >
+
+ <!ATTLIST exec_svc
+ svcid IDREF #REQUIRED
+ >
+
+ <!ELEMENT request_list (request+) >
+ <!ELEMENT request EMPTY >
+ <!ATTLIST request
+ svcid IDREF #REQUIRED
+ local_step (shm|bupchk|1|2|3|4|5|6|7|8|9|last|all) #REQUIRED
+ >
+
+ <!ELEMENT next_trans_condition EMPTY>
+ <!ATTLIST next_trans_condition
+ cond CDATA #REQUIRED
+ >
+
+ <!ENTITY service_list_xml SYSTEM "tskm_launch.xml">
+ <!ENTITY normal_wakeup_xml SYSTEM "tskm_wakeup.xml">
+ <!ENTITY normal_shutdown_xml SYSTEM "tskm_shutdown.xml">
+ <!ENTITY vup_wakeup_xml SYSTEM "tskm_wakeup_vup.xml">
+ <!ENTITY vup_shutdown_xml SYSTEM "tskm_shutdown_vup.xml">
+]>
+
+
+<tskm_cfg>
+ &service_list_xml;
+
+ &normal_wakeup_xml;
+
+ &normal_shutdown_xml;
+
+ &vup_wakeup_xml;
+
+ &vup_shutdown_xml;
+
+</tskm_cfg>
diff --git a/systemservice/task_manager/client/ss_data_init/Makefile b/systemservice/task_manager/client/ss_data_init/Makefile
new file mode 100755
index 0000000..920fbea
--- /dev/null
+++ b/systemservice/task_manager/client/ss_data_init/Makefile
@@ -0,0 +1,43 @@
+#
+# @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.
+#
+
+#######################################
+#######################################
+INST_SHLIBS := libss_data_init
+
+MKDATAINIT=mkdatainit.sh
+
+INST_HEADERS = tskm_data_init.h task_manager_libss_data_init.h
+
+VPATH = ./include/$(COMPONENT_NAME)
+CPPFLAGS += -I./include/ -I./../../server/include -I./../libtskmcfg/include
+
+libss_data_init_SRCS := tskm_data_init.cpp
+libss_data_init_PCOS := $(shell ls ./obj/*.os)
+
+$(libss_data_init_SRCS): $(libss_data_init_PCOS)
+ set -e ; \
+ sh $(MKDATAINIT)
+
+######## add compile option ########
+LDFLAGS += -Wl,--no-as-needed
+CPPFLAGS += -fno-exceptions
+
+CLEAN_FILES=$(libss_data_init_SRCS)
+
+LDLIBS = -Wl,-Bdynamic -lNS_FrameworkUnified
+
+include ../../../system_service.mk
diff --git a/systemservice/task_manager/client/ss_data_init/include/libss_data_init_taskmanagerlog.h b/systemservice/task_manager/client/ss_data_init/include/libss_data_init_taskmanagerlog.h
new file mode 100755
index 0000000..39422e9
--- /dev/null
+++ b/systemservice/task_manager/client/ss_data_init/include/libss_data_init_taskmanagerlog.h
@@ -0,0 +1,78 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_LIBSS_DATA_INIT_TASKMANAGERLOG_H_
+#define TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_LIBSS_DATA_INIT_TASKMANAGERLOG_H_
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10) // library common def
+#define ZONE_FUNC ZONEMASK(11) // library common def
+#define ZONE_MEM ZONEMASK(12) // library common def
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29) // library common def
+#define ZONE_WARN ZONEMASK(30) // library common def
+#define ZONE_ERR ZONEMASK(31) // library common def
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT) // LPRINT
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_INFO
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams;
+
+#endif // TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_LIBSS_DATA_INIT_TASKMANAGERLOG_H_
diff --git a/systemservice/task_manager/client/ss_data_init/include/system_service/task_manager_libss_data_init.h b/systemservice/task_manager/client/ss_data_init/include/system_service/task_manager_libss_data_init.h
new file mode 100755
index 0000000..e3bdfc5
--- /dev/null
+++ b/systemservice/task_manager/client/ss_data_init/include/system_service/task_manager_libss_data_init.h
@@ -0,0 +1,39 @@
+/*
+ * @copyright Copyright (c) 2017-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.
+ */
+/**
+ * @file
+ * @brief \~english This file include tskm_data_init.h
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef SYSTEMSERVICE_TASKMNAGERLIBSSDATAINIT_H_ // NOLINT(build/header_guard)
+#define SYSTEMSERVICE_TASKMNAGERLIBSSDATAINIT_H_
+
+#include "system_service/tskm_data_init.h"
+
+#endif // SYSTEMSERVICE_TASKMNAGERLIBSSDATAINIT_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/client/ss_data_init/include/system_service/tskm_data_init.h b/systemservice/task_manager/client/ss_data_init/include/system_service/tskm_data_init.h
new file mode 100755
index 0000000..8cb49d6
--- /dev/null
+++ b/systemservice/task_manager/client/ss_data_init/include/system_service/tskm_data_init.h
@@ -0,0 +1,121 @@
+/*
+ * @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.
+ */
+
+
+/**
+ * @file tskm_data_init.h
+ * @brief \~english This file contains API of initial task manager data
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_SYSTEM_SERVICE_TSKM_DATA_INIT_H_
+#define TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_SYSTEM_SERVICE_TSKM_DATA_INIT_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_system_manager_if.h>
+#include "system_service/tskm_type.h"
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_GetExtBootInfo
+/// \~english @par Summary
+/// Gets boot extended information.
+/// \~english @param [in] p_info
+/// T_SS_SM_START_ExtDataStructType * - Boot extended information
+/// \~english @code
+/// typedef struct {
+/// BOOL isProgUpdated;
+/// EMRelaunchStatus relaunchStatus;
+/// BOOL isMapUpdated;
+/// BOOL isMapDiffUpdated;
+/// uint8_t reserved[];
+/// }T_SS_SM_START_ExtDataStructType;
+/// @endcode
+/// \~english @retval TSKM_E_OK Normal end
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @par Preconditions
+/// - None
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - p_info is NULL. [TSKM_E_PAR]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail
+/// Is available only at the functions defined by using TSKM_DATA_INIT_FUNC.
+/// \~english @see TSKM_DATA_INIT_FUNC
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_GetExtBootInfo(T_SS_SM_START_ExtDataStructType *p_info);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_DATA_INIT_FUNC
+/// \~english @par Summary
+/// Defines callback functions to initialize data.
+/// \~english @param [in] serviceName
+/// const char* - Service name
+/// \~english @param [in] argName
+/// const T_SS_SM_START_DataStructType* - Argument name
+/// \~english @code
+/// typedef struct T_SS_SM_START_DataStruct{
+/// EPWR_WAKEUP_FACTOR_TYPE startupReason;
+/// BOOL isUserModeOn;
+/// ESMDataResetModeInfo dataResetMode;
+/// EPWR_SC_SECURITY_STATUS securityStatus;
+/// EPWR_SC_WAKEUP_TYPE wakeupType;
+/// ESMDramBackupStatus dramBackupStatus;
+/// ESMResetStatus resetStatus;
+/// UI_32 resetCount;
+/// } T_SS_SM_START_DataStructType;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Normal
+/// \~english @retval eFrameworkunifiedStatusFail Check error
+/// \~english @par Preconditions
+/// - None
+/// \~english @par Change of the internal state
+/// - The internal state is not changed.
+/// \~english @par Causes of failures
+/// - Return values depend on the mount of callback functions. [eFrameworkunifiedStatusFail]
+/// \~english @par Classification
+/// Public
+/// \~english @par Detail
+/// Defines the callback functions to initialize data. \n
+/// The callback functions defined by this macro are executed at a timing
+/// when boot factor is fixed after booting the system. \n
+/// (Task_Manager executes Callback prior to the boot of ActivityManager.)\n
+/// If each service mounts and installs initialization functions, Task_Manager boots it
+/// at a timing when data initialization is necessary. \n
+/// Each service can install the object file of initialization functions by setting them
+/// to MAKE variables INST_DATAINITOBJ of Makefile.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+#define TSKM_DATA_INIT_FUNC(ServiceName, ArgName) \
+ EFrameworkunifiedStatus tskm_ ## ServiceName ## _data_init(T_SS_SM_START_DataStructType* ArgName)
+
+#endif // TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_SYSTEM_SERVICE_TSKM_DATA_INIT_H_
+/** @}*/ // end of Task_Manager
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/task_manager/client/ss_data_init/include/tskm_data_init_local.h b/systemservice/task_manager/client/ss_data_init/include/tskm_data_init_local.h
new file mode 100755
index 0000000..9d77d19
--- /dev/null
+++ b/systemservice/task_manager/client/ss_data_init/include/tskm_data_init_local.h
@@ -0,0 +1,25 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_TSKM_DATA_INIT_LOCAL_H_
+#define TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_TSKM_DATA_INIT_LOCAL_H_
+
+#include "system_service/tskm_data_init.h"
+
+extern void tskm_dataInitAll(T_SS_SM_START_DataStructType *arg,
+ T_SS_SM_START_ExtDataStructType *extArg);
+
+#endif // TASK_MANAGER_CLIENT_SS_DATA_INIT_INCLUDE_TSKM_DATA_INIT_LOCAL_H_
diff --git a/systemservice/task_manager/client/ss_data_init/mkdatainit.sh b/systemservice/task_manager/client/ss_data_init/mkdatainit.sh
new file mode 100755
index 0000000..802fbd9
--- /dev/null
+++ b/systemservice/task_manager/client/ss_data_init/mkdatainit.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+#
+# Copyright (c) 2019-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.
+#
+
+cp tskm_data_init.cpp.in tskm_data_init.cpp.tmp
+
+LF=$(printf '\\\012_')
+LF=${LF%_}
+
+for files in `ls obj/*.os`
+do
+ serviceName=`nm -C $files | grep " T " | grep -o "tskm_[0-9a-zA-Z_]\+_data_init" | sed -e "s/^tskm_//" | sed -e "s/_data_init\$//"`
+
+ funcname="tskm_"$serviceName"_data_init"
+
+ echo $serviceName $funcname
+ sed -i "s/@DATA_INIT_PROT@/EFrameworkunifiedStatus $funcname(T_SS_SM_START_DataStructType* );$LF@DATA_INIT_PROT@/g" tskm_data_init.cpp.tmp
+ sed -i "s/@DATA_INIT_TABLE@/{\"$serviceName\", $funcname},$LF @DATA_INIT_TABLE@/g" tskm_data_init.cpp.tmp
+
+done
+
+sed -i "s/@DATA_INIT_PROT@//g" tskm_data_init.cpp.tmp
+sed "s/@DATA_INIT_TABLE@/{NULL , NULL},/g" tskm_data_init.cpp.tmp > tskm_data_init.cpp
+
+rm tskm_data_init.cpp.tmp
+
+
+
+
+
+
diff --git a/systemservice/task_manager/client/ss_data_init/tskm_data_init.cpp.in b/systemservice/task_manager/client/ss_data_init/tskm_data_init.cpp.in
new file mode 100755
index 0000000..072a486
--- /dev/null
+++ b/systemservice/task_manager/client/ss_data_init/tskm_data_init.cpp.in
@@ -0,0 +1,66 @@
+/*
+ * @copyright Copyright (c) 2019-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.
+ */
+
+#include <system_service/tskm_data_init.h>
+#include "stdio.h"
+#include "libss_data_init_taskmanagerlog.h"
+
+
+#define ZONE_INFO ZONEMASK(29)
+
+typedef struct{
+ const char *serviceName;
+ EFrameworkunifiedStatus (*dataInitFunc)(T_SS_SM_START_DataStructType *arg);
+} FUNC_INFO_t;
+
+@DATA_INIT_PROT@
+
+const FUNC_INFO_t g_funcTbl[] = {
+ @DATA_INIT_TABLE@
+};
+
+static T_SS_SM_START_ExtDataStructType extBootInfo;
+
+TSKM_ERR_t TSKM_GetExtBootInfo(T_SS_SM_START_ExtDataStructType *p_info){
+ TSKM_ERR_t ret = TSKM_E_OK;
+
+ if(NULL == p_info){
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__,"p_info = NULL");
+ ret = TSKM_E_PAR;
+ }else{
+ memcpy(p_info, &extBootInfo, sizeof(*p_info));
+ }
+
+ return ret;
+}
+
+void tskm_dataInitAll(T_SS_SM_START_DataStructType *arg, T_SS_SM_START_ExtDataStructType *extArg){
+ int i;
+ int itemNum = sizeof(g_funcTbl)/sizeof(FUNC_INFO_t) - 1;
+
+ memcpy(&extBootInfo, extArg, sizeof(extBootInfo));
+
+ // LCOV_EXCL_START 10: Depends on reference information when building software
+ for(i=0;i<itemNum;i++){
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO,__FUNCTION__,"call datainit for %s",g_funcTbl[i].serviceName);
+ g_funcTbl[i].dataInitFunc(arg);
+ }
+ // LCOV_EXCL_STOP
+
+ return;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
+
diff --git a/systemservice/task_manager/include-share/tskm_gstep.h b/systemservice/task_manager/include-share/tskm_gstep.h
new file mode 100755
index 0000000..e2af96d
--- /dev/null
+++ b/systemservice/task_manager/include-share/tskm_gstep.h
@@ -0,0 +1,54 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_INCLUDE_SHARE_TSKM_GSTEP_H_
+#define TASK_MANAGER_INCLUDE_SHARE_TSKM_GSTEP_H_
+
+#include "system_service/tskm_local_type.h"
+#include "tskm_debug.h"
+
+/*********************************************************
+ * Get gradual startup current info
+ *********************************************************/
+inline TSKM_STATIC TSKM_BOOL_t gstepIsLast(TSKM_GSTEP_CTX_t* p_gstep) {
+ if (p_gstep->gstepNum == p_gstep->gstepIdx + 1) {
+ return TSKM_TRUE;
+ }
+ return TSKM_FALSE;
+}
+
+/*********************************************************
+ * Get gradual startup current info
+ *********************************************************/
+inline TSKM_STATIC TSKM_GSTEP_t*
+gstepGetCurrent(TSKM_GSTEP_CTX_t* p_gstep) {
+ if (p_gstep->gstepNum > p_gstep->gstepIdx) {
+ return &p_gstep->gstep[p_gstep->gstepIdx];
+ }
+ return NULL;
+}
+
+/*********************************************************
+ * Issue requests waiting for exec completion
+ *********************************************************/
+inline TSKM_STATIC TSKM_GSTEP_t*
+changeNextStep(TSKM_GSTEP_CTX_t* p_gstep) {
+ p_gstep->gstepIdx++;
+ return gstepGetCurrent(p_gstep);
+}
+
+#endif // TASK_MANAGER_INCLUDE_SHARE_TSKM_GSTEP_H_
+
diff --git a/systemservice/task_manager/include-share/tskm_type_local.h b/systemservice/task_manager/include-share/tskm_type_local.h
new file mode 100755
index 0000000..8ead34e
--- /dev/null
+++ b/systemservice/task_manager/include-share/tskm_type_local.h
@@ -0,0 +1,52 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_INCLUDE_SHARE_TSKM_TYPE_LOCAL_H_
+#define TASK_MANAGER_INCLUDE_SHARE_TSKM_TYPE_LOCAL_H_
+
+#define NTFY_SS_TaskManager_Availability SS_TASK_MANAGER"/Availability"
+
+//*******************************************************
+// Legacy types:
+// Definition is retained because it is referenced by another module
+//******************************************************
+
+// Shared LOG with version upgrade
+#define STATEMGR__CWORD69_LOG_SIZE 176 /* STATEMGR__CWORD69_LOG */
+typedef struct {
+ uint8_t old_Ver[8];
+ uint8_t new_Ver[8];
+} STATEMGR__CWORD69_LOG_VERSION_T;
+
+typedef struct {
+ STATEMGR__CWORD69_LOG_VERSION_T ver;
+ uint8_t status;
+ uint8_t dummy[3];
+} STATEMGR__CWORD69_LOG_VUPINFO_T;
+
+typedef struct {
+ uint32_t seqnum; /* Set value (for chequence check) */
+ uint32_t normalnum; /* Set value (for route check) */
+ uint32_t errornum; /* Set value (for NG check) */
+} STATEMGR__CWORD69_LOG_PROC;
+
+typedef struct {
+ STATEMGR__CWORD69_LOG_VUPINFO_T VerInfo[7]; /* Store version info */
+ STATEMGR__CWORD69_LOG_PROC proc[3]; /* Store logs for analysis */
+} STATEMGR__CWORD69_LOG;
+
+#endif // TASK_MANAGER_INCLUDE_SHARE_TSKM_TYPE_LOCAL_H_
+
diff --git a/systemservice/task_manager/include-share/tskm_util.h b/systemservice/task_manager/include-share/tskm_util.h
new file mode 100755
index 0000000..83665aa
--- /dev/null
+++ b/systemservice/task_manager/include-share/tskm_util.h
@@ -0,0 +1,32 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_INCLUDE_SHARE_TSKM_UTIL_H_
+#define TASK_MANAGER_INCLUDE_SHARE_TSKM_UTIL_H_
+
+#include "system_service/tskm_local_type.h"
+#include "tskm_main.h"
+
+// inline MACRO
+#define TSKM_ERR_CHK(ret, expect, lavel) \
+ if (ret != expect) {TSKM_ASSERT(0); goto lavel;}
+
+#define TSKM_ERR_CHK_DFT TSKM_ERR_CHK(tskmRet, TSKM_E_OK, ERROR)
+
+#define TSKM_MAX(a, b) ((a) > (b) ? (a) : (b))
+
+#endif // TASK_MANAGER_INCLUDE_SHARE_TSKM_UTIL_H_
+
diff --git a/systemservice/task_manager/server/Makefile b/systemservice/task_manager/server/Makefile
new file mode 100755
index 0000000..7e7bfbd
--- /dev/null
+++ b/systemservice/task_manager/server/Makefile
@@ -0,0 +1,67 @@
+#
+# @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.
+#
+
+
+#######################################
+INST_PROGS = tskmgr
+
+######### add source path #############
+######### add local value #############
+VPATH = ./src ./../client/libtskm ./../client/libtskmcfg/include/$(COMPONENT_NAME)
+
+tskmgr_SRCS += tskm_main.cpp
+
+######### compiled sources #############
+tskmgr_SRCS += tskm_api.cpp \
+ tskm_state.cpp \
+ tskm_wakeup.cpp \
+ tskm_shutdown.cpp \
+ tskm_svc.cpp \
+ tskm_watch.cpp \
+ tskm_debug.cpp \
+ tskm_comm.cpp \
+ tskm_port_pf.cpp \
+ tskm_port_subsys.cpp \
+ tskm_srvr_stub.cpp
+
+
+
+######### add include path #############
+CPPFLAGS = -I./include/ -I./../include-share/ -I./../client/ss_data_init/include/ -I./../client/libtskmcfg/include/ -I./../client/libtskm/
+######### add compile option ###########
+CPPFLAGS += -fno-exceptions
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+######### add library path #############
+LDFLAGS += -L./../client/ss_data_init -L./../client/libtskmcfg
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lrt # for mq_xxx
+LDLIBS += -Wl,-Bdynamic -lss_data_init
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lresm
+LDLIBS += -Wl,-Bdynamic -lcommon
+LDLIBS += -Wl,-Bdynamic -lvp
+LDLIBS += -Wl,-Bdynamic -lrpc -lev
+
+#LDLIBS += -Wl,-Bdynamic -lDiagCodeAPI
+LDLIBS += -Wl,-Bdynamic -ltskmcfg
+
+
+LINK_CXX=Y
+
+include ../../system_service.mk
diff --git a/systemservice/task_manager/server/include/system_service/INI_API.h b/systemservice/task_manager/server/include/system_service/INI_API.h
new file mode 100755
index 0000000..871be5e
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/INI_API.h
@@ -0,0 +1,25 @@
+/*
+ * @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.
+ */
+/**
+ * @file INI_API.h
+ * @brief \~english This file include INI_API.hpp
+ */
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_INI_API_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_INI_API_H_
+
+#include "system_service/INI_API.hpp"
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_INI_API_H_
diff --git a/systemservice/task_manager/server/include/system_service/INI_API.hpp b/systemservice/task_manager/server/include/system_service/INI_API.hpp
new file mode 100755
index 0000000..00fe733
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/INI_API.hpp
@@ -0,0 +1,738 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file INI_API.hpp
+ * @brief \~english This file provide api to operating INI
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef _INI_API_HPP_
+#define _INI_API_HPP_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_system_manager_if.h>
+#include "system_service/Primary_common.h"
+
+#define INI_SUCCESS 0 /* Normal */
+#define INI_FALSE -1 /* Failed */
+
+#define INI_FD_MAX 3
+
+// Only the information required for event completion notification is left
+// Gradual startup
+#define INI_INITCOMP_NONE 0x0000000000000000LLU
+#define INI_INITCOMP_ON_START 0x0000000000000001LLU /* ON_START */
+#define INI_INITCOMP_NVM_ACCESS 0x0000000000000002LLU /* NVM ACCESS */
+
+#define INI_INITCOMP_TEST0 0x1000000000000000LLU /* for test */
+#define INI_INITCOMP_TEST1 0x2000000000000000LLU /* for test */
+#define INI_INITCOMP_TEST2 0x4000000000000000LLU /* for test */
+#define INI_INITCOMP_TEST3 0x8000000000000000LLU /* for test */
+
+// Gradual termination
+#define INI_TERMCOMP_NONE 0x0000000000000000LLU
+#define INI_TERMCOMP_ACTIVITYMGR 0x0000000000000001LLU /* Terminate ActivityManager */
+#define INI_TERMCOMP_RESIDENT 0x0000000000000002LLU /* Terminate regident SVC */
+#define INI_TERMCOMP_TRANSIENT 0x0000000000000004LLU /* Terminate non-regident SVC */
+
+#define INI_TERMCOMP_TEST0 0x1000000000000000LLU /* for test */
+#define INI_TERMCOMP_TEST1 0x2000000000000000LLU /* for test */
+#define INI_TERMCOMP_TEST2 0x4000000000000000LLU /* for test */
+#define INI_TERMCOMP_TEST3 0x8000000000000000LLU /* for test */
+
+
+
+typedef struct _T_PRIM_PRM{
+ PCSTR name;
+ const PRIM_SHAREDATA_TBL* shmTbl;
+ const PRIM_EXFUNC_TBL* wakeupExFuncTbl;
+ const PRIM_EXFUNC_TBL* downExFuncTbl;
+ EFrameworkunifiedStatus (*onInit)(HANDLE hApp);
+ EFrameworkunifiedStatus (*onDestory)(HANDLE hApp);
+ EFrameworkunifiedStatus (*onDebugDump)(HANDLE hApp);
+ EFrameworkunifiedStatus (*onTouch)(HANDLE hApp);
+ EFrameworkunifiedStatus (*onLowMem)(HANDLE hApp);
+ void* priv;
+ _T_PRIM_PRM(){
+ name = NULL;
+ shmTbl = NULL;
+ wakeupExFuncTbl = NULL;
+ downExFuncTbl = NULL;
+ onInit = NULL;
+ onDestory = NULL;
+ onDebugDump = NULL;
+ onTouch = NULL;
+ onLowMem = NULL;
+ priv = NULL;
+ }
+}T_PRIM_PRM;
+
+
+typedef struct {
+ BOOL bIsRun;
+ uint32_t timeout;
+}T_PRIM_MONITOR_PRM;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_Main
+/// \~english @par Summary:
+/// Runs the main thread of primary library.
+/// \~english @param [in] p_prm
+/// T_PRIM_PRM - The pointer to the parameter table of primary library
+/// \~english @param [in] argc
+/// int - The number of command parameters (The parameters passed to main functions must be set without processing.)
+/// \~english @param [in] argv
+/// char* - Command parameters (The parameters passed to main functions must be set without processing.)
+/// \~english @par
+/// - Shared memory creation table \n
+/// In process running, register the shared memory to create.\n
+/// This creates the shared memory to be registered in process running and releases it in process end.\n
+/// This must terminate by adding {"\0"} into member shmName of table termination.\n
+/// It is able to access to the shared memory to have been created by shm_open.\n
+/// \~english @code
+/// typedef struct {
+/// char shmName[32]; /* Shared memory name */
+/// uint32_t size; /* Shared memory size (BYTE) */
+/// }PRIM_SHAREDATA_TBL;
+/// @endcode
+/// \~english @par
+/// - Running extended function table / End extended function table \n
+/// Registers callback functions to be called in process start and exit.\n
+/// This must terminate by adding NULL into member func of table termination.\n
+/// Parameters prm of callback functions are User private information and the pointer designated by prm is passed as input parameters [in].\n
+/// Local phase numbers callback func by the designated phase numbers.\n
+/// \~english @code
+/// typedef struct {
+/// void (* func)( void* prm); /* Callback functions for function extension */
+/// void* prm; /* The pointer to the parameters of Callback function func */
+/// uint8_t localStep; /* Local phase numbers */
+/// uint8_t rsv[3]; /* Reserve for alignment */
+/// }PRIM_EXFUNC_TBL;
+/// @endcode
+/// \~english @par
+/// - %Parameter table of primary library\n
+/// For FrameworkunifiedOnInitialization/FrameworkunifiedOnDestroy/FrameworkunifiedOnDebugDump/TaskmanagerOnTouch/FrameworkunifiedOnLowMemory, check the corresponding API specification.\n
+/// It is able to get User private data by INI_GetPrivate().\n
+/// \~english @code
+/// typedef struct _T_PRIM_PRM{
+/// PCSTR name; /* Application name */
+/// const PRIM_SHAREDATA_TBL* shmTbl; /* The pointer to shared memory creation table */
+/// const PRIM_EXFUNC_TBL* wakeupExFuncTbl; /* The pointer to running extended function table */
+/// const PRIM_EXFUNC_TBL* downExFuncTbl; /* The pointer to end extended function table */
+/// EFrameworkunifiedStatus (*onInit)(HANDLE hApp); /* FrameworkunifiedOnInitialization callback function setting */
+/// EFrameworkunifiedStatus (*onDestory)(HANDLE hApp); /* FrameworkunifiedOnDestroy callback function setting */
+/// EFrameworkunifiedStatus (*onDebugDump)(HANDLE hApp); /* FrameworkunifiedOnDebugDump Callback function setting */
+/// EFrameworkunifiedStatus (*onTouch)(HANDLE hApp); /* TaskmanagerOnTouch callback function setting */
+/// EFrameworkunifiedStatus (*onLowMem)(HANDLE hApp); /* FrameworkunifiedOnLowMemory callback function setting */
+/// void* priv; /* User private data */
+/// }T_PRIM_PRM;
+/// @endcode
+/// \~english @retval INI_SUCCESS Normal end
+/// \~english @retval INI_FALSE Abnormal end
+/// \~english @par Preconditions:
+/// - None
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - The pointer to the parameter table of primary library is NULL [INI_FALSE]
+/// - The pointer to the shared memory creation table inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The pointer to the running extended function table inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The pointer to the end extended function table inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of FrameworkunifiedOnInitialization callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of FrameworkunifiedOnDestroy callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of FrameworkunifiedOnDebugDump callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of TaskmanagerOnTouch callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Method only
+/// \~english @par Detail:
+/// This executes the main processing of primary library. Functions do not return until all of end processing of process is completed. \n
+/// Normal end returns INI_SUCCESS and abnormal end does INI_FALSE. \n
+/// User process must return this function's returned values as the returned values of main function and end main function. \n
+/// \~english @see INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+int INI_Main(T_PRIM_PRM* p_prm,int argc,char* argv[]);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_ExitStart
+/// \~english @par Summary:
+/// Starts the end processing of process.
+/// \~english @param [in] rsv
+/// void* - The pointer to reservation parameters (NULL must be appointed)
+/// \~english @retval None
+/// \~english @par Preconditions:
+/// - None
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Collects the resource which primary library got, does the end processing equal to local_step=all and end process. \n
+/// (At the end processing in abnormality, process must be ended by not this function but exit(),_exit() function immediately) \n
+/// When this API is called after this API is already called, do nothing to process.
+/// \~english @par Supplemtent:
+/// local_step is the information defined in default_wakeup.xml/default_shutdown.xml as the definition of running order / end order. \n
+/// local_step defined in default_shutdown.xml has the following types.
+/// - 1-9 : Designates local phase numbers (the phase numbers of end processing)
+/// - last : This designates local phase numbers to be last. When there is the local phase processing not to be executed, this executes all.
+/// - all : The same as last.
+/// \~english @see INI_Main, INI_Init, INI_ExitDone
+////////////////////////////////////////////////////////////////////////////////////
+void INI_ExitStart(void* rsv); // Termination process start
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_ExitDone
+/// \~english @par Summary:
+/// Notifies the completion of process end processing.
+/// \~english @param [in] status
+/// int - Unused (This is for future extension. 0 must be designated.)
+/// \~english @retval None
+/// \~english @par Preconditions:
+/// - None
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Notifies the completion of service end processing to TaskManager. \n
+/// TaskManager ends the corresponding service by this notification. At the time, this callbacks FrameworkunifiedOnDestroy(). \n
+/// \~english @see INI_Main, INI_Init, INI_ExitStart
+////////////////////////////////////////////////////////////////////////////////////
+void INI_ExitDone(int status); // Termination process completed
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_GetPrivate
+/// \~english @par Summary:
+/// Gets private data.
+/// \~english @param None
+/// \~english @retval void* The pointer to user private data
+/// \~english @par Preconditions:
+/// - INI_Main or INI_Init must be called and user private data must be set.
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Gets the private data designated at INI_Main/INI_Init from the inside of the context management information of the process inside primary library and returns it.
+/// \~english @see INI_Main, INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+void* INI_GetPrivate();
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_GetHandle
+/// \~english @par Summary:
+/// Gets the application handle of NSFW.
+/// \~english @param None
+/// \~english @retval void*(HANDLE) The application handle of NSFW
+/// \~english @par Preconditions:
+/// - INI_Main or INI_Init must be called and the application handle of NSFW must be generated.
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Gets the application handle of NSFW from the inside of the context management information of the process inside primary library and returns it.
+/// \~english @see INI_Main, INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+void* INI_GetHandle();
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_SetMonitorTimeout
+/// \~english @par Summary:
+/// Requests the change for abnormality monitoring timeout time to Task Manager. \n
+/// (This is used when main thread is not implemented at service side)
+/// \~english @param [in] timeout
+/// uint32_t - Abnormality monitoring timeout time (sec)(When 0 is designated, the service must be out of abnormality monitoring object.)
+/// \~english @retval INI_SUCCESS Succeeded
+/// \~english @par Preconditions:
+/// - Main thread must be run at INI_Main()
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Sets the abnormality monitoring timeout time designated by parameters inside the context management information of the process inside primary library and returns returned values and INI_SUCCESS. \n
+/// Set timeout time becomes valid after the event waiting at the loop of main thread and this requests the change for service abnormality monitoring timeout time to TaskManager. In other words, this API can be used after running extended function Callback. \n
+/// When process does not return to main thread past the timeout time designated by this function, TaskManager ends the service forcibly. When this function is not called, TaskManager treats the timeout of monitoring time as 50 seconds.
+/// \~english @see INI_Main
+////////////////////////////////////////////////////////////////////////////////////
+int32_t INI_SetMonitorTimeout(uint32_t timeout);
+
+// Event completion notification
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_StepForkComp
+/// \~english @par Summary:
+/// Notifies the completion of running event to TaskManager.
+/// \~english @param [in] compId
+/// uint64_t - The comparison ID for phase running (Designates INI_INITCOMP_[a-zA-Z_]+ to define at INI_API.hpp)
+/// \~english @par
+/// The ID descripted at INI_API.hpp
+/// \~english @code
+/// - INI_INITCOMP_NONE: None
+/// - INI_INITCOMP_ON_START: For ON Start
+/// - INI_INITCOMP_NVM_ACCESS: For NVM access
+/// @endcode
+/// \~english @retval INI_SUCCESS Succeeded
+/// \~english @retval INI_FALSE Failed
+/// \~english @par Preconditions:
+/// - INI_Main or INI_Init must be called.
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - The sending of the completion notification of running event to TaskManager failed [INI_FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Sends the comparison ID for phase running as the completion notification of running event to TaskManager. If it succeeded, returns INI_SUCCESS and if it failed, does INI_FALSE. \n
+/// TaskManager holds which completion notification of running event is notified and can add it to the transition conditions to next phase at phase running. \n
+/// The way to add at TaskManager side depends on the definition of next_trans_condition element described in default_wakeup.xml as the definition of running order.
+/// \~english @par Supplement:
+/// next_trans_condition is the element to designate transition conditions to next phase. The transition to next phase is done when the following two conditions are met. \n
+/// When the description of next_trans_condition element is omitted, transition is done only by condition 1. \n
+/// 1. All of the phase running request processing set by request element is completed. (The phase running request processing is executed by primary library asynchronously) \n
+/// 2. The completion notification of the event designated by next_trans_condition element is completed. \n
+/// Waiting conditions for event completion notification INI_INITCOMP_[A-Z]+ stipulated at INI_API.hpp is set in cond property designated at next_trans_condition element. \n
+/// AND condition can be set by being INI_INITCOMP_AAAA| INI_INITCOMP_BBBB when conditions are some. \n
+/// Event completion notification can be issued by using INI_StepForkComp.
+/// \~english @see INI_Main, INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+int32_t INI_StepForkComp(uint64_t compId);
+
+// Event completion notification
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_AccOffComp
+/// \~english @par Summary:
+/// Notifies end event completion notification to TaskManager.
+/// \~english @param [in] compId
+/// uint64_t - The comparison ID for phase running (Designates INI_TERMCOMP_[a-zA-Z_]+ defined at INI_API.hpp)
+/// \~english @par
+/// The ID described at INI_API.hpp
+/// \~english @code
+/// - INI_TERMCOMP_NONE : None
+/// - INI_TERMCOMP_ACTIVITYMGR : For ActivityManager end
+/// - INI_TERMCOMP_RESIDENT : For resident service end
+/// - INI_TERMCOMP_TRANSIENT : For non-resident service end
+/// @endcode
+/// \~english @retval INI_SUCCESS Succeeded
+/// \~english @retval INI_FALSE Failed
+/// \~english @par Preconditions:
+/// - INI_Main or INI_Init must be called
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - The sending of the completion notification of end event to TaskManager failed [INI_FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Sends the comparison ID for phase running as the completion notification of end event to TaskManager. If it succeeded, returns INI_SUCCESS and if it failed, return INI_FALSE. \n
+/// TaskManager holds which completion notification of end event is notified and can add it to the transition conditions to next phase at phase end. \n
+/// The way to add at TaskManager side depends on the definition of next_trans_condition element described in default_shutdown.xml as the definition of end order.
+/// \~english @par Supplement:
+/// next_trans_condition is the element to designate transition conditions to next phase. The transition to next phase is done when the following two conditions are met. \n
+/// When the description of next_trans_condition element is omitted, transition is done only by condition 1. \n
+/// 1. All of the phase end request processing set by request element is completed. (The phase end request processing is executed by primary library asynchronously) \n
+/// 2. The completion notification of the event designated by next_trans_condition element is completed. Waiting conditions for event completion notification INI_INITCOMP_[A-Z]+ stipulated at INI_API.hpp is set in cond property designated at next_trans_condition element. \n
+/// AND condition can be set by being INI_INITCOMP_AAAA| INI_INITCOMP_BBBB when conditions are some. \n
+/// Event completion notification can be issued by using INI_ AccOffComp.
+/// \~english @see INI_Main, INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+int32_t INI_AccOffComp(uint64_t compId);
+
+// Get boot info
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_GetBootInfo
+// \~english @par Summary:
+/// Gets boot information.
+/// \~english @param [in] info
+/// T_SS_SM_START_DataStructType * - The pointer to boot information structure
+/// \~english @par
+/// T_SS_SM_START_DataStructType structure
+/// \~english @code
+/// typedef struct T_SS_SM_START_DataStruct{
+/// EPWR_WAKEUP_FACTOR_TYPE startupReason; /* Startup reason */
+/// BOOL isUserModeOn; /* User mode ON/OFF */
+/// ESMDataResetModeInfo dataResetMode; /* Data reset mode */
+/// EPWR_SC_SECURITY_STATUS securityStatus; /* Security state */
+/// EPWR_SC_WAKEUP_TYPE wakeupType; /* Battery disconnection state */
+/// ESMDramBackupStatus dramBackupStatus; /* Backup memory area state */
+/// ESMResetStatus resetStatus; /* Reset state */
+/// UI_32 resetCount; /* Abnormal reboot number */
+/// } T_SS_SM_START_DataStructType;
+///
+/// Startup reason type:
+/// - epswfIGN_ACC : Ignition ACC (Currently, Fixed)
+/// User mode ON/OFF:
+/// - TRUE : User mode ON (Currently, Fixed)
+/// Data reset mode:
+/// - e_SS_SM_DATA_RESET_NONE: Not-initialized
+/// - e_SS_SM_DATA_RESET_USER: User data initialization
+/// - e_SS_SM_DATA_RESET_FACTORY: Factory initialization
+/// Security state:
+/// - epsssUNLOCK : Unlock state
+/// - epsssLOCK : Lock state
+/// Battery disconnection state:
+/// - epsstWARMSTART : Battery disconnection does not occur
+/// - epsstCOLDSTART : Battery disconnection occurs
+/// Backup memory area state:
+/// - e_SS_SM_DRAM_BACKUP_OK: Backup OK of Backup memory area
+/// - e_SS_SM_DRAM_BACKUP_NG: Backup NG of Backup memory area
+/// Reset state:
+/// - e_SS_SM_RESET_STATUS_UNSET: Information unsetting(Not decided yet)
+/// - e_SS_SM_RESET_STATUS_NONE : Normal
+/// - e_SS_SM_RESET_STATUS_NG : Abnormality occurred (Abnormal RESET or booting after service abnormal end)
+/// - e_SS_SM_RESET_STATUS_IMMEDIATE : Immediate RESET occurred
+/// @endcode
+/// \~english @retval INI_SUCCESS Succeeded
+/// \~english @retval INI_FALSE Failed
+/// \~english @par Preconditions:
+/// - INI_Main or INI_Init must be called. (%Process running must be completed)
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - The pointer to boot information structure designated at parameters is NULL [INI_FALSE]
+/// - Startup reason type inside the context management information of the process inside primary library is wrong (%Process running is not completed) [INI_FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Gets boot information which is managed inside the context management information of the process inside primary library.
+/// If it succeeded, returns INI_SUCCESS and if it failed, does INI_FALSE. \n
+/// This sets valid values as info values in FrameworkunifiedOnStart of TaskManager. In other words, this sets valid values after running ActivityManager.
+/// \~english @see INI_Main, INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+int32_t INI_GetBootInfo(T_SS_SM_START_DataStructType *info);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_GetExtBootInfo
+/// \~english @par Summary:
+/// Gets boot extended information.
+/// \~english @param [in] info
+/// T_SS_SM_START_ExtDataStructType * - The pointer to boot extended information structure
+/// \~english @par
+/// T_SS_SM_START_ExtDataStructType structure
+/// \~english @code
+/// #define SS_SM_START_EXT_INFO_SIZE 64
+/// #define SS_SM_START_EXT_BODY_SIZE ( sizeof(BOOL)
+/// + sizeof(EMRelaunchStatus)
+/// + sizeof(BOOL)
+/// + sizeof(BOOL)
+/// )
+/// define SS_SM_START_EXT_RSV_SIZE SS_SM_START_EXT_INFO_SIZE
+/// - SS_SM_START_EXT_BODY_SIZE
+/// typedef struct {
+/// BOOL isProgUpdated; /* Program update information */
+/// EMRelaunchStatus relaunchStatus; /* Own-service Relaunch state */
+/// BOOL isMapUpdated; /* Map update information */
+/// BOOL isMapDiffUpdated; /* Map difference update information */
+/// uint8_t reserved[SS_SM_START_EXT_RSV_SIZE]; /* Reserve area */
+/// } T_SS_SM_START_ExtDataStructType;
+///
+/// Program update information
+/// - TRUE : Program update
+/// - FALSE : No Program update
+/// Own-service Relaunch state:
+/// - e_SS_SM_RELAUNCH_STATUS_NONE : Relaunch does not occur (Initial boot)
+/// - e_SS_SM_RELAUNCH_STATUS_SAFE : Normal Relaunch
+/// - e_SS_SM_RELAUNCH_STATUS_ERR : Abnormal Relaunch
+/// Map update information:
+/// - TRUE : Map update
+/// - FALSE : No Map update
+/// Map difference update information
+/// - TRUE : Map difference update
+/// - FALSE : No Map difference update
+/// @endcode
+/// \~english @retval INI_SUCCESS Succeeded
+/// \~english @retval INI_FALSE Failed
+/// \~english @par Preconditions:
+/// - INI_Main or INI_Init must be called. (%Process running must be completed.)
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - The pointer to boot information structure designated at parameters is NULL [INI_FALSE]
+/// - Startup reason type inside the context management information of the process inside primary library is wrong (%Process running is not completed) [INI_FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Gets boot extended information which is managed inside the context management information of the process inside primary library.
+/// If it succeeded, returns INI_SUCCESS and if it failed, does INI_FALSE \n
+/// This sets valid values as info values in FrameworkunifiedOnStart of TaskManager. In other words, this sets valid values after running ActivityManager.
+/// Because TaskManager does not have Relaunch function, always sets e_SS_SM_RELAUNCH_STATUS_NONE in relaunchStatus.
+/// \~english @see INI_Main, INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+int32_t INI_GetExtBootInfo(T_SS_SM_START_ExtDataStructType *info);
+
+//withoutMainLoop
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_Init
+/// \~english @par Summary:
+/// Initializes primary library. \n
+/// (This is used when implementing main thread at service side)
+/// \~english @param [in] p_prm
+/// T_PRIM_PRM - The pointer to parameter table of primary library
+/// \~english @param [in] argc
+/// int - The number of command parameters (The parameters passed to main functions must be set without processing)
+/// \~english @param [in] argv
+/// char* - Command parameters (The parameters passed to main functions must be set without processing)
+/// \~english @param [out] fdNum
+/// int * - The number of element stored in fdlist (INI_FD_MAX:3)
+/// \~english @param [out] fdlist[INI_FD_MAX]
+/// int - The array of FD (File Descriptor) for event reception which primary library waits
+/// \~english @par
+/// - Shared memory creation table \n
+/// In process running, register the shared memory to create. \n
+/// This creates the shared memory to be registered in process running and releases it in process end. \n
+/// This must terminate by adding {"\0"} into member shmName of table termination. \n
+/// It is able to access to the shared memory to have been created by shm_open. \n
+/// \~english @code
+/// typedef struct {
+/// char shmName[32]; /* Shared memory name */
+/// uint32_t size; /* Shared memory size (BYTE) */
+/// }PRIM_SHAREDATA_TBL;
+/// @endcode
+/// \~english @par
+/// - Running extended function table / End extended function table \n
+/// Registers callback functions to be called in process start and exit. \n
+/// This must terminate by adding NULL into member func of table termination. \n
+/// Parameters prm of callback functions are User private information and the pointer designated by prm is passed as input parameters [in]. \n
+/// Local phase numbers callback func by the designated phase numbers. \n
+/// \~english @code
+/// typedef struct {
+/// void (* func)( void* prm); /* Callback functions for function extension */
+/// void* prm; /* The pointer to the parameters of Callback function func */
+/// uint8_t localStep; /* Local phase numbers */
+/// uint8_t rsv[3]; /* Reserve for alignment */
+/// }PRIM_EXFUNC_TBL;
+/// @endcode
+/// \~english @par
+/// - %Parameter table of primary library \n
+/// For FrameworkunifiedOnInitialization/FrameworkunifiedOnDestroy/FrameworkunifiedOnDebugDump/TaskmanagerOnTouch/FrameworkunifiedOnLowMemory, check the corresponding API specification. \n
+/// It is able to get User private data by INI_GetPrivate(). \n
+/// \~english @code
+/// typedef struct _T_PRIM_PRM{
+/// PCSTR name; /* Application name */
+/// const PRIM_SHAREDATA_TBL* shmTbl; /* The pointer to shared memory creation table */
+/// const PRIM_EXFUNC_TBL* wakeupExFuncTbl; /* The pointer to running extended function table */
+/// const PRIM_EXFUNC_TBL* downExFuncTbl; /* The pointer to end extended function table */
+/// EFrameworkunifiedStatus (*onInit)(HANDLE hApp); /* FrameworkunifiedOnInitialization callback function setting */
+/// EFrameworkunifiedStatus (*onDestory)(HANDLE hApp); /* FrameworkunifiedOnDestroy callback function setting */
+/// EFrameworkunifiedStatus (*onDebugDump)(HANDLE hApp); /* FrameworkunifiedOnDebugDump Callback function setting */
+/// EFrameworkunifiedStatus (*onTouch)(HANDLE hApp); /* TaskmanagerOnTouch callback function setting */
+/// EFrameworkunifiedStatus (*onLowMem)(HANDLE hApp); /* FrameworkunifiedOnLowMemory callback function setting */
+/// void* priv; /* User private data */
+/// }T_PRIM_PRM;
+/// @endcode
+/// \~english @retval INI_SUCCESS Succeeded
+/// \~english @retval INI_FALSE Failed
+/// \~english @par Preconditions:
+/// - None
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - The pointer to the parameter table of primary library is NULL [INI_FALSE]
+/// - The pointer to the shared memory creation table inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The pointer to the running extended function table inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The pointer to the end extended function table inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of FrameworkunifiedOnInitialization callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of FrameworkunifiedOnDestroy callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of FrameworkunifiedOnDebugDump callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// - The setting of TaskmanagerOnTouch callback function inside the parameter table of primary library is NULL [INI_FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Initializes primary thread. If it succeeded, returns INI_SUCCESS and if it failed, does INI_FALSE. \n
+/// When implementing main thread at service, this function must be called in running main thread. \n
+/// Waits fd of fdlist gotten by functions by select and when there is change in fd, service must execute event handler of primary by calling INI_Handler().
+/// \~english @see INI_Main
+////////////////////////////////////////////////////////////////////////////////////
+int32_t INI_Init(T_PRIM_PRM* p_prm,int argc ,char* argv[],int *fdNum,int fdlist[INI_FD_MAX]);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_Handler
+/// \~english @par Summary:
+/// Processes the reception event of primary library. \n
+/// (This is used when implementing main thread at service side)
+/// \~english @param [in] p_fds
+/// fd_set* - fd set varied and detected by select()
+/// \~english @retval TRUE Service running (Continuing)
+/// \~english @retval FALSE The process end processing of primary library is completed
+/// \~english @par Preconditions:
+/// - Main thread must be run at INI_Init()
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Access is not from main thread context [FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// When FD which primary library should process in fd set designated by p_fds is included, processes event processing of primary library. \n
+/// When implementing main thread by service, it is necessary to execute the event reception processing of primary library by this function. \n
+/// Returns TRUE during service running and does FALSE when the process end processing of primary library was completed. When FALSE is returned, service must call
+/// INI_Term() and end itself.
+/// \~english @see INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+BOOL INI_Handler(fd_set* p_fds);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_Term
+/// \~english @par Summary:
+/// Releases the resource of primary library. \n
+/// (This is used when implementing main thread at service side)
+/// \~english @param None
+/// \~english @retval None
+/// \~english @par Preconditions:
+/// - Main thread must be run at INI_Init()
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Releases the resource of primary library. \n
+/// When implementing main thread at service, this function must release the resource of primary library in service end.
+/// \~english @see INI_Init, INI_Handler
+////////////////////////////////////////////////////////////////////////////////////
+void INI_Term(void);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup INI_SetMonitorState
+/// \~english @par Summary:
+/// Sets abnormality monitoring state. \n
+/// (This is used when implementing main thread at service side)
+/// \~english @param [in] p_prm
+/// T_PRIM_MONITOR_PRM - The pointer to the parameters structure for monitoring
+/// \~english @par
+/// T_PRIM_MONITOR_PRM structure
+/// \~english @code
+/// typedef struct {
+/// BOOL bIsRun; /* Monitoring state (TRUE:RUN FALSE:SLEEP) */
+/// uint32_t timeout; /* Monitoring timeout time (sec) */
+/// }PRIM_SHAREDATA_TBL;
+/// @endcode
+/// \~english @retval INI_SUCCESS Succeeded
+/// \~english @retval INI_FALSE Failed
+/// \~english @par Preconditions:
+/// - Main thread must be run at INI_ Init ()
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - The pointer(p_prm) to the parameters structure for monitoring designated by parameters is NULL [INI_FALSE]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Sets abnormality monitoring for TaskManager. If it succeeded, returns INI_SUCCESS and if it failed, does INI_FALSE \n
+/// When bIsRun=FALSE is not set until time designated by timeout passes after setting bIsRun=TRUE, TaskManager decides that the service falls into abnormal state and ends forcibly. \n
+/// When 0 is designated at monitoring timeout time(timeout), the service must be out of abnormality monitoring object.
+/// When monitoring state (bIsRun) is FALSE, monitoring state becomes invalid. \n
+/// This API can be used after running extended function CALLBACK.
+/// \~english @see INI_Init
+////////////////////////////////////////////////////////////////////////////////////
+int32_t INI_SetMonitorState(T_PRIM_MONITOR_PRM *p_prm);
+
+
+void _INI_DEBUGDUMP(BOOL bIsNeedSvcName, PCSTR f_cFormat, ...);
+
+#define INI_DEBUGDUMP(args...) _INI_DEBUGDUMP(TRUE, ## args)
+#define INI_DEBUGDUMP_RAW(args...) _INI_DEBUGDUMP(FALSE, ## args)
+
+// Callback functions
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TaskmanagerOnTouch
+/// \~english @par Summary:
+/// Callback to notify process use
+/// \~english @param [in] hApp
+/// HANDLE - Application handle
+/// \~english @retval eFrameworkunifiedStatusOK Succeeded
+/// \~english @retval Other-than-eFrameworkunifiedStatusOK Failed (Error type depends on the implementation at user side)
+/// \~english @par Preconditions:
+/// - Must set inside running information structure in calling INI_Main or INI_Init
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Implementation specification of callback depends on the implementation (design) of an application. For this, error type on failure conditions must be considered at an application side.
+/// \~english @par Detail:
+/// Service is call backed just before using. \n
+/// INI_ExitStart must not be issued for 30 seconds after service called this function. \n
+/// Timeout must be implemented such as counting up by using interval timer so that INI_ExitStart is not issued by timeout after this API was called. \n
+/// This function cannot call the API (TSKM_Xxxx) of TaskManager. (If this calls, deadlock occurs)
+/// \~english @par Classification:
+/// Public
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus TaskmanagerOnTouch(HANDLE hApp);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif //_INI_API_HPP_
+
+/** @}*/ // end of TaskManager
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/systemservice/task_manager/server/include/system_service/Primary_common.h b/systemservice/task_manager/server/include/system_service/Primary_common.h
new file mode 100755
index 0000000..e0624bb
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/Primary_common.h
@@ -0,0 +1,148 @@
+/*
+ * @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.
+ */
+/**
+ * @file Primary_common.h
+ * @brief \~english This file contains declaration of common enum and structures
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_PRIMARY_COMMON_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_PRIMARY_COMMON_H_
+
+#include <stdint.h>
+#include <pthread.h>
+
+typedef unsigned int PRI_DWORD; // To eliminate the DWORD
+
+/* SRAM process type */
+#define SRAM_INIT (int)0 /* Initialization processing specification */
+#define SRAM_CHK (int)1 /* Range check processing specification */
+#define SRAM_MAPVER (int)2 /* Map Version change support designation */
+#define SRAM_MAPVER_CHK (int)3 /* Map Version change support + range checking specification */
+#define SRAM_SYSTEM_INIT (int)4 /* System initialization processing specification */
+#define SRAM_CONFIG_INIT (int)5 /* Reset setting */
+
+/* Processing result */
+#define SRAM_CHK_OK (int)0 /* SRAM checking completed normally (no change) */
+#define SRAM_CHK_CHG (int)1 /* SRAM checking Successful completion value is changed (Including during initialization) */
+#define SRAM_CHK_NG (int)-1 /* SRAM checking error */
+
+/*
+ Constant definition
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#define PRIM_SHM_NAME_MAX 32 /* Maximum name size */
+
+// Local stage number of the stage start request/end request from the TSKM
+// In XML, it is set with a direct value of 1-9, but it is left because the legacy service refers to this definition
+enum _PRIM_FORK_STEP {
+ PRIM_STEPFORK_FIRST = 1, /* First startup step */
+ PRIM_STEPFORK_SECOND, /* 2nd startup step */
+ PRIM_STEPFORK_THIRD, /* 3rd startup step */
+ PRIM_STEPFORK_FOURTH, /* 4th startup step */
+ PRIM_STEPFORK_FIFTH, /* 5th startup step */
+ PRIM_STEPFORK_SIXTH, /* 6th startup step */
+ PRIM_STEPFORK_SEVENTH, /* 7th startup step */
+ PRIM_STEPFORK_EIGHTH, /* 8th startup step */ /* #GPF_10_018 */
+ PRIM_STEPFORK_NINTH, /* 9th startup step */ /* #GPF_10_018 */
+ PRIM_STEPFORK_TENTH, /* 10th startup step */ /* #GPF_10_018 */
+ PRIM_STEPFORK_MAX /* Maximum number of Gradual startup steps */ /* Used for judgment when receiving gradual startup */
+};
+
+enum _PRIM_ACCOFF_STEP {
+ PRIM_ACCOFF_FIRST = 1, /* First step */
+ PRIM_ACCOFF_SECOND, /* 2nd step */
+ PRIM_ACCOFF_THIRD, /* 3rd step */
+ PRIM_ACCOFF_FOURTH, /* 4th step */
+ PRIM_ACCOFF_FIFTH, /* 5th step */
+ PRIM_ACCOFF_MAX /* Total number of ACC-OFF steps */ /* Used for judgment when receiving ACC-OFF instruction */
+};
+
+/******************************************************************************
+ * TAG : PRIM_SHAREDATA_TBL
+ * ABSTRACT : Shared data table
+ * NOTE :
+ ******************************************************************************/
+/* Structure of shared data table */
+typedef struct {
+ char shmName[PRIM_SHM_NAME_MAX]; /* Shared data name */
+ int32_t size; /* Shared data size */
+} PRIM_SHAREDATA_TBL;
+
+/******************************************************************************
+ * TAG : PRIM_FORK_TBL
+ * ABSTRACT : Startup process table
+ * NOTE :
+ ******************************************************************************/
+typedef struct {
+ PRI_DWORD (*threadFunc)(void* prm); /* Thread function */
+ void* prm; /* Thread startup parameters */
+ uint32_t priority; /* Thread priority */
+ uint16_t pno; /* Thuread number */
+ uint8_t rsv; /* Reserved field */
+ uint8_t wakeLocalStep; /* Startup step */
+ // The following is valid only when useLegacy = FALSE
+ char threadName[16]; /* Thread name */
+ char downLocalStep; /* When the termination step is 0, termination notification is not issued */
+ void* primaryLocal; /* Local area for libPrimary (cannot be changed) */
+} PRIM_FORK_TBL;
+
+/******************************************************************************
+ * TAG : PRIM_EXFUNC_TBL
+ * ABSTRACT : Feature extension table
+ ******************************************************************************/
+typedef struct {
+ void (*func)(void* prm); /* Feature extension function */
+ void* prm; /* parameters */
+ uint8_t localStep; /* Startup step */
+ uint8_t rsv[3]; /* Reserved */
+} PRIM_EXFUNC_TBL;
+
+/******************************************************************************
+ * TAG : PRIM_BACKUPCHK_TBL
+ * ABSTRACT : Function table for check backup data
+ ******************************************************************************/
+typedef struct {
+ int32_t (*func)(int32_t kind); /* Feature Extension Functions */
+} PRIM_BACKUPCHK_TBL;
+
+/******************************************************************************
+ * TAG : PRIM_ACCOFF_TBL
+ * ABSTRACT : ACC-OFF process table
+ ******************************************************************************/
+typedef struct {
+ uint32_t localStep; /* ACC-OFF process step */
+ uint16_t pno; /* PNO of Notification destination */
+ uint8_t rsv[2];
+} PRIM_ACCOFF_TBL;
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_PRIMARY_COMMON_H_
+/*
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ End of File : Primary_common.h
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ */
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/server/include/system_service/sysup.h b/systemservice/task_manager/server/include/system_service/sysup.h
new file mode 100755
index 0000000..ef930a4
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/sysup.h
@@ -0,0 +1,41 @@
+/*
+ * @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.
+ */
+/**
+ * @file sysup.h
+ * @brief \~english This file contains declaration of system status(SYS_RESET, SYS_ONLY_RESET)
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_SYSUP_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_SYSUP_H_
+
+#define SYS_RESET (int32)1 /* Resetting */
+#define SYS_ONLY_RESET (int)2 /* Reset only */
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_SYSUP_H_
+/** @}*/
+/** @}*/
+/** @}*/
+
diff --git a/systemservice/task_manager/server/include/system_service/sysup_from.h b/systemservice/task_manager/server/include/system_service/sysup_from.h
new file mode 100755
index 0000000..be7e0fe
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/sysup_from.h
@@ -0,0 +1,41 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_SYSUP_FROM_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_SYSUP_FROM_H_
+
+/**
+ * @file sysup_from.h
+ * @brief \~english empty file
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+// Deleted the definitions in the file because they are not used.
+// Left them for legacy sources that you include.
+/** @}*/
+/** @}*/
+/** @}*/
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_SYSUP_FROM_H_
diff --git a/systemservice/task_manager/server/include/system_service/task_manager.h b/systemservice/task_manager/server/include/system_service/task_manager.h
new file mode 100755
index 0000000..82d23fb
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/task_manager.h
@@ -0,0 +1,54 @@
+/*
+ * @copyright Copyright (c) 2017-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.
+ */
+/**
+ * @file task_manager.h
+ * @brief \~english include all task_manager_library head files
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TASK_MANAGER_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TASK_MANAGER_H_
+
+#include "system_service/INI_API.h"
+#include "system_service/INI_API.hpp"
+#include "system_service/Primary_common.h"
+#include "system_service/sysup_from.h"
+#include "system_service/sysup.h"
+#include "system_service/tskm_svc.h"
+#include "system_service/tskm_type.h"
+#include "system_service/tskm.h"
+#include "system_service/tskm_local_type.h"
+#include "system_service/tskm_xml_data.h"
+#include "system_service/tskm_svcid.h"
+#include "system_service/task_manager_libtskmcfg.h"
+#include "system_service/tskm_data_init.h"
+#include "system_service/task_manager_libss_data_init.h"
+
+
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TASK_MANAGER_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/server/include/system_service/tskm.h b/systemservice/task_manager/server/include/system_service/tskm.h
new file mode 100755
index 0000000..1a2f962
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/tskm.h
@@ -0,0 +1,413 @@
+/*
+ * @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.
+ */
+
+/**
+ * @file tskm.h
+ * @brief \~english This file contains primary API of task manager
+ */
+
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_H_
+
+
+#include <other_service/rpc.h>
+#include "system_service/tskm_type.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TSKM_ID RPC_ID
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_Init
+/// \~english @par Summary:
+/// Creates the resource to communicate with Task_Manager.
+/// \~english @param [out] *pID
+/// UINT32 - Unique ID of the automatically allocated program
+/// \~english @retval None
+/// \~english @par Preconditions:
+/// - None
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Creates the resource to communicate with Task_Manager. \n
+/// It is necessary to call this before using the APIs of TSKM_xxxx defined after this. \n
+/// It is necessary to call this by the thread. \n
+/// \~english @see TSKM_End
+////////////////////////////////////////////////////////////////////////////////////
+#define TSKM_Init(p_tskmId) RPC_START_CLIENT(p_tskmId)
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_End
+/// \~english @par Summary:
+/// Releases the resource created at TSKM_Init.
+/// \~english @param [in] ID
+/// UINT32 - ID gotten at TSKM_Init()
+/// \~english @retval None
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal stat:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// None
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Releases the resource created at TSKM_Init.
+/// \~english @see TSKM_Init
+////////////////////////////////////////////////////////////////////////////////////
+#define TSKM_End(tskmId) RPC_end(tskmId)
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_SvcCtl
+// \~english @par Summary:
+/// Run the control for service.
+/// \~english @param [in] svcid
+/// TSKM_SVCID_t - Service ID
+/// \~english @param [in] ctl
+/// TSKM_SVC_CTL_t* - Command
+/// \~english @code
+/// typedef struct{
+/// TSKM_SVC_CMD_t cmd;
+/// } TSKM_SVC_CTL_t;
+/// @endcode
+/// \~english @retval TSKM_E_OK Succeeded
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @retval TSKM_E_STATE State error
+/// \~english @retval TSKM_E_NG Error
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Parameters ctl is NULL [TSKM_E_PAR]
+/// - Service context is not found [TSKM_E_PAR]
+/// - Before FrameworkunifiedOnStart of Task_Manager is called [TSKM_E_STATE]
+/// - It is prohibited to run designated service [TSKM_E_STATE]
+/// - Message sending failed [TSKM_E_RETRY]
+/// - When the specified service executes the start prohibition except during
+/// the stop or start prohibition status. [TSKM_E_STATE]
+/// - Maximum numbers to register running reservation service are exceeded [TSKM_E_STATE]
+/// - Anything except for the commands specified as parameters is designated [TSKM_E_PAR]
+/// - Writing in files of running reservation information failed [TSKM_E_NG]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// - TSKM_SVC_CMD_EXEC\n
+/// Designated service runs. \n
+/// When designated service already runs, this returns TSKM_E_OK without processing service running. \n
+/// Running equal to local_step=all of request element is done. \n
+/// When designated service designates the service that running is prohibited by
+/// TSKM_SVC_CMD_DISABLE, this returns TSKM_E_STATE. \n
+/// This guarantees that service running finished in API succeeding. \n
+/// - TSKM_SVC_CMD_DISABLE\n
+/// This prohibits to run the designated service. \n
+/// At the prohibited service to run already, this returns TSKM_E_OK without doing anything. \n
+/// When this API uses the service to be run already, this returns TSKM_E_STATE. \n
+/// By this, at resident service, it is necessary to call this before running corresponding service. \n
+/// About the prohibited service, this doesn't decide the wait condition of event completion notice
+/// which service running, phase startup, phase end request, corresponding service control. \n
+/// This command is prepared in consideration of changing the service to run in response to
+/// with or without extended BOX and device configuration. \n
+/// Initial values are running permission. \n
+/// - TSKM_SVC_CMD_ENABLE\n
+/// This permits to run the service to be set as running prohibition. \n
+/// At running permission service, this returns TSKM_E_OK without doing anything. \n
+/// - TSKM_SVC_RESERVE\n
+/// This does the running reservation of non-resident service. \n
+/// In next running, designated service runs automatically after finishing in running resident service. \n
+/// Once this runs automatically, this forgets reservation information. \n
+/// Maximum numbers of service able to do running reservation is the values of TSKM_SVC_RESERVE_MAX. \n
+/// When this reserves over maximum numbers, this returns TSKM_E_STATE. \n
+/// When backup RAM is invalid in running, this does not run automatically and
+/// discards reservation information. \n
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_SvcCtl(TSKM_SVCID_t svcId, const TSKM_SVC_CTL_t* ctl);
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_SvcGetInfo
+// \~english @par Summary:
+/// Gets the information of designated service.
+/// \~english @param [in] svcid
+/// TSKM_SVCID_t - Service ID
+/// \~english @param [out] svcInfo
+/// TSKM_SVC_INFO_t* - Service information
+/// \~english @code
+/// typedef struct {
+/// TSKM_SVCID_t svcId;
+/// TSKM_BOOL_t isExecDisable;
+/// } TSKM_SVC_INFO_t;
+/// svcId : Service ID
+/// isExecDisable : Service running prohibition state
+/// TSKM_TRUE : Running prohibition
+/// TSKM_FALSE : Running permission
+/// @endcode
+/// \~english @retval TSKM_E_OK Succeeded
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Service context is not found [TSKM_E_PAR]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Gets the information of designated service.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_SvcGetInfo(TSKM_SVCID_t svcId, TSKM_SVC_INFO_t* svcInfo);
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_ErrorReboot
+/// \~english @par Summary:
+/// Let system do abnormal reboot.
+/// \~english @param [in] p_info
+/// TSKM_ERROR_REBOOT_t* - REBOOT information
+/// \~english @code
+/// typedef struct {
+/// TSKM_ERROR_REBOOT_TYPE_t type;
+/// TSKM_LOGGING_ INFO_t log;
+/// } TSKM_ERROR_REBOOT_t;
+/// type
+/// TSKM_ERROR_REBOOT_NORMAL : Abnormal detection
+/// log : Log saving information
+/// typedef struct {
+/// char messageStr[TSKM_LOGGING_MSG_STR_SIZE];
+/// } TSKM_LOGGING_INFO_ t;
+/// messageStr : Abnormal message character string
+/// @endcode
+/// \~english @retval TSKM_E_OK Succeeded
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Parameters p_info is NULL [TSKM_E_PAR]
+/// - Reboot factors are except for TSKM_ERROR_REBOOT_NORMAL [TSKM_E_PAR]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Does REBOOT. \n
+/// It is assumed to issue when system is damaged if processing continues any more
+/// such as device trouble and non-volatile data trouble. \n
+/// Access limitation is done to this API by gid and uid. \n
+/// When an application with no authorization calls this, this force-quits the application to have called API. \n
+/// This stores the string designated to messageStr as factors in system information LOG. \n
+/// To link with PSMShadow about trouble factors, this designates abnormal message character string defined
+/// inside ss_error_message.h to messageStr.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_ErrorReboot(const TSKM_ERROR_REBOOT_t* p_info);
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_Reboot
+/// \~english @par Summary:
+/// Let system do reboot.
+/// \~english @param [in] rsv
+/// TSKM_RSV_t* - Reservation ( This must designate NULL)
+/// \~english @retval TSKM_E_OK Succeeded
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Parameters p_rsv is except for NULL [TSKM_E_PAR]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync x Method
+/// \~english @par Detail:
+/// Let system do normal reboot.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_Reboot(const TSKM_RSV_t * p_rsv);
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_Logging
+/// \~english @par Summary:
+/// Stores LOG in internal non-volatile area.
+/// \~english @param [in] p_info
+/// TSKM_LOGGING_INFO_t * - Log storing information
+/// \~english @code
+/// typedef struct{
+/// TSKM_LOGGING_TYPE_NORMAL_t type;
+/// char messageStr[TSKM_LOGGING_MSG_STR_SIZE];
+/// }TSKM_LOGGING_INFO_t;
+/// type : Log storing type
+/// TSKM_LOGGING_TYPE_MODULE_LOGS: General LOG storing request from service
+/// TSKM_LOGGING_TYPE_GRP_RELAUNCH: Log collection by Group Relaunch
+/// messageStr : Trouble factors
+/// @endcode
+/// \~english @retval TSKM_E_OK Succeeded
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Parameters p_info is NULL [TSKM_E_PAR]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @par Detail:
+/// Collects LOG information and stores it in internal non-volatile area \n
+/// This stores the string designated to messageStr as factors in system information LOG.
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_Logging(const TSKM_LOGGING_INFO_t* p_info);
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_DataInit
+/// \~english @par Summary:
+/// Does the initialization process of service data.
+/// \~english @param [in] hApp
+/// HANDLE - Application handle
+/// \~english @param [in] p_info
+/// TSKM_DATAINIT_t * - Data initialization information
+/// \~english @code
+/// typedef struct {
+/// TSKM_DATAINIT_TYPE_t type;
+/// EFrameworkunifiedStatus (*onCompInit)(HANDLE hApp);
+/// } TSKM_DATAINIT_t;
+/// type : Data initialization type
+/// TSKM_DATAINIT_TYPE_USER : User data initialization
+/// onCompInit : Initialization complete Callback
+/// @endcode
+/// \~english @retval TSKM_E_OK Succeeded
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @retval TSKM_E_NG Error
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Parameters hAPP is NULL [TSKM_E_PAR]
+/// - Parameters p_info is NULL [TSKM_E_PAR]
+/// - Member type of parameters p_info is except for TSKM_DATAINIT_TYPE_USER [TSKM_E_PAR]
+/// - Member onCompInit of parameters p_info is NULL [TSKM_E_PAR]
+/// - The process of FrameworkunifiedAttachCallbackToDispatcher failed [TSKM_E_NG]
+/// - The process of FrameworkunifiedOpenService failed [TSKM_E_STATE]
+/// - The process of FrameworkunifiedSendMsg failed [TSKM_E_NG]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Method only
+/// \~english @par Detail:
+/// - How to report \n
+/// Reports by Callback of onCompInit. \n
+/// This can get message data by calling GetMsgData inside onCompInit. \n
+/// - Structure of message data \n
+/// TSKM_ERR_t:Processing result \n
+/// TSKM_E_OK :Normal end \n
+/// TSKM_E_STATE :State error \n
+/// TSKM_E_NG :Error
+/// - Summary of action \n
+/// Calls initialization functions which each service implemented. \n
+/// When this API was called before Availability of Task_Manager becomes TRUE, this
+/// does not call initialization functions and returns TSKM_E_STATE by onCompInit. \n
+/// It is permitted for same application to call this API several times, at this case,
+/// it is necessary to designate the pointer to same functions to onCompInit. \n
+/// When this API was called by designating TSKM_DATAINIT_TYPE_USER to type, this calls
+/// the initialization functions of each service by designating the following parameters. \n
+/// <table>
+/// <tr><th>Member</th><th>Values</th></tr>
+/// <tr><td>startupReason</td><td>epswfIGN_ACC</td></tr>
+/// <tr><td>isUserModeOn</td><td>TRUE</td></tr>
+/// <tr><td>dataResetMode</td><td>e_SS_SM_DATA_RESET_MODE_USER</td></tr>
+/// <tr><td>wakeupType</td><td>epsstWARMSTART</td></tr>
+/// <tr><td>dramBackupStatus</td><td>e_SS_SM_DRAM_BACKUP_OK</td></tr>
+/// <tr><td>resetStatus</td><td>e_SS_SM_RESET_STATUS_NONE</td></tr>
+/// <tr><td>resetCount</td><td>0</td></tr>
+/// </table>
+/// Because Task_Manager calls the initialization functions of each service and implements
+/// the recovery processing according to running factors at the timing of fixing running factor,
+/// this designates the above parameters not to do duplicate recover processing.
+/// \~english @see TSKM_DATA_INIT_FUNC
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_DataInit(HANDLE hApp, const TSKM_DATAINIT_t *p_info);
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup TSKM_SetWakeupOrder
+/// \~english @par Summary:
+/// Holds running order.
+/// \~english @param [in] p_order
+/// TSKM_WAKEUP_ORDER_t * - Running order information
+/// \~english @code
+/// typedef struct {
+/// char orderName[TSKM_ORDER_NAME_MAX];
+/// } TSKM_WAKEUP_ORDER_t;
+/// orderName: Order name (MAX:31 characters)
+/// @endcode
+/// \~english @retval TSKM_E_OK Succeeded
+/// \~english @retval TSKM_E_PAR %Parameter error
+/// \~english @retval TSKM_E_NG Error
+/// \~english @par Preconditions:
+/// - TSKM_Init must be used and initialized
+/// \~english @par Changes of the internal state:
+/// - The internal state is not changed
+/// \~english @par Causes of failures:
+/// - Parameters p_order is NULL [TSKM_E_PAR]
+/// - The string length of the member orderName of Parameters p_order exceeds 32 [TSKM_E_PAR]
+/// - The process of SetWakeupOrderToSystemManager failed [TSKM_E_NG]
+/// \~english @par Classification:
+/// Public
+/// \~english @par Type
+/// Sync x Sync
+/// \~english @par Detail:
+/// This function is Wrapper function to provide SetWakeupOrderToSystemManager
+/// by sessionless which SystemManger provides.
+/// This designates NULL to p_order and returns TSKM_E_PAR.
+/// For the detail of action, refer to SystemManager (SetWakeupOrderToSystemManager).
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t TSKM_SetWakeupOrder(const TSKM_WAKEUP_ORDER_t* p_order);
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_H_
+
+/** @}*/ // end of Task_Manager
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
+
+
diff --git a/systemservice/task_manager/server/include/system_service/tskm_local_type.h b/systemservice/task_manager/server/include/system_service/tskm_local_type.h
new file mode 100755
index 0000000..79831aa
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/tskm_local_type.h
@@ -0,0 +1,287 @@
+/*
+ * @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.
+ */
+/**
+ * @file tskm_local_type.h
+ * @brief \~english localtype of tskm
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_LOCAL_TYPE_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_LOCAL_TYPE_H_
+
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <native_service/frameworkunified_types.h>
+#include "system_service/INI_API.hpp"
+#include "system_service/tskm_type.h"
+
+//==================================================
+// Configuration
+//==================================================
+
+#if 1
+#define TSKM_CFG_WAIT_SHUTDOWN 10000
+#else
+#define TSKM_CFG_WAIT_SHUTDOWN 1 // Handy for test
+#warning TSKM_CFG_WAIT_SHUTDOWN is temorary
+#endif
+
+#define TSKM_CFG_TOUCH_TIMEOUT 2 // TOUCH time-out
+
+//==================================================
+// Task manager internal
+//==================================================
+// State
+#define TSKM_ST_ACCOFF 0x01000000U // ACC-OFF (Default) No transition here
+#define TSKM_ST_ACCON 0x02000000U // ACC-ON
+#define TSKM_ST_WAKEUP 0x02010000U // Gradual startup
+#define TSKM_ST_RUNNING 0x02020000U // Running (Startup completed)
+#define TSKM_ST_DOWN 0x02040000U // Gradual Terminating
+
+typedef uint32_t TSKM_STATE_t;
+#define TSKM_STATE_MASK0 0xFF000000U
+#define TSKM_STATE_MASK1 0xFFFF0000U
+#define TSKM_STATE_MASK2 0xFFFFFF00U
+#define TSKM_STATE_MASK3 0xFFFFFFFFU
+
+// Global step IDs for gradual starting
+typedef uint32_t TSKM_GLOBAL_STEP_t;
+#define TSKM_GSTEP_NONE 0x00000000U //
+#define TSKM_GSTEP_BUPCHK 0x00000001U
+
+// Local step
+typedef uint32_t TSKM_LOCAL_STEP_t;
+#define TSKM_LSTEP_LAST 0xFFFFFFF0U // Executing to end of local steps
+#define TSKM_LSTEP_SHM 0xFFFFFFF1U // Creating shared memory
+#define TSKM_LSTEP_BUPCHK 0xFFFFFFF2U // Checking backup memory
+#define TSKM_LSTEP_ALL 0xFFFFFFF3U // Executing all user definitions
+
+/************************************************************
+ * Structure of gradual startup/termination structure
+ (When this structure is modified, structure of parsexml is also changed)
+ *************************************************************/
+// Structure of request for services
+typedef struct {
+ TSKM_SVCID_t svcId; // Service ID
+ TSKM_LOCAL_STEP_t localStep; // Local step number
+} TSKM_GSTEP_REQ_INFO_t;
+
+// Structure of gradual startup/termination
+typedef struct {
+ uint32_t gstepId;
+
+ // List of executing services
+ uint32_t execSvcNum;
+ TSKM_SVCID_t* execSvcIdList;
+
+ // List of request
+ uint32_t reqNum;
+ TSKM_GSTEP_REQ_INFO_t* reqList;
+
+ // Event completion wait conditions
+ uint64_t nextTransCond;
+} TSKM_GSTEP_t;
+
+typedef struct {
+ uint32_t gstepIdx; // Step index
+ uint32_t gstepNum; // Step number
+ TSKM_GSTEP_t* gstep; // Gradual startup/termination info
+ uint64_t compState; // Status of receiving for Event completion notification
+} TSKM_GSTEP_CTX_t;
+
+//********* Non-volatile management information ****************
+
+#define TSKM_NV_STRUCT_VERSION "v000" // Compatible version of non-volatile management structure
+#define TSKM_SVC_RESERVE_MAX (8) // Maximum number of reserved services to startup
+
+#define TSKM_NV_SIZE_ALL (512)
+#define TSKM_NV_SIZE_HEADER (32)
+#define TSKM_NV_SIZE_FOOTER (32)
+#define TSKM_NV_SIZE_BODY (TSKM_NV_SIZE_ALL - TSKM_NV_SIZE_HEADER - TSKM_NV_SIZE_FOOTER)
+
+// Header
+typedef struct {
+ char version[5];
+} TSKM_NV_HEADER_t;
+
+// Footer
+typedef struct {
+ uint32_t checkSum;
+} TSKM_NV_FOOTER_t;
+
+// Body
+typedef struct {
+ uint8_t rsvSvcNum; // Number of reserved services
+ TSKM_SVCID_t rsvSvcs[TSKM_SVC_RESERVE_MAX]; // List of services
+} TSKM_NV_BODY_t;
+
+// Non-volatile storage info
+typedef struct {
+ TSKM_NV_HEADER_t header;
+ uint8_t rsvHeader[TSKM_NV_SIZE_HEADER - sizeof(TSKM_NV_HEADER_t)];
+ TSKM_NV_BODY_t body;
+ uint8_t rsvBody[TSKM_NV_SIZE_BODY - sizeof(TSKM_NV_BODY_t)];
+ uint8_t rsvFooter[TSKM_NV_SIZE_FOOTER - sizeof(TSKM_NV_FOOTER_t)];
+ TSKM_NV_FOOTER_t footer;
+} TSKM_NV_INFO_t;
+
+// Internal event
+typedef enum {
+ TSKM_EV_NOP, // Do nothing
+ // TSKM->PRI
+ TSKM_EV_PRI_REQ_WAKEUP, // Startup request
+ TSKM_EV_PRI_REQ_DOWN, // Termination request
+ TSKM_EV_PRI_REQ_TOUCH,
+ TSKM_EV_PRI_REQ_DEBUGDUMP, // DebugDump request
+ TSKM_EV_PRI_REP_LOWMEM, // LowMemory detection request
+
+ // PRI->TSKM(SVC)
+ TSKM_EV_PRI_REP_WAKEUP_COMP, // Notification of event completion at startup
+ TSKM_EV_PRI_REP_DOWN_COMP, // Notification of event completion at termination
+ TSKM_EV_PRI_REP_CONNECT, // Connecting
+ TSKM_EV_PRI_REP_DISCONNECT, // Disconnecting
+ TSKM_EV_PRI_RES_WAKEUP, // Response to startup request
+ TSKM_EV_PRI_RES_DOWN, // Response to termination request
+ TSKM_EV_PRI_RES_DEBUGDUMP, // Response to DebugDump request
+ TSKM_EV_PRI_REQ_EXIT, // Response to terminating request
+
+ // SVC->TSKM
+ TSKM_EV_SVC_REP_TERM, // Termination of service
+
+ // APL->TSKM
+ TSKM_EV_API_REQ_REBOOT, // Reboot system
+ TSKM_EV_API_REQ_SVC_CTL, // Startup service
+ TSKM_EV_API_REQ_SVC_DISABLE, // Prohibit starting service
+
+ // Internal message
+ TSKM_EV_LCL_REQ_STOP, // Termination request
+ TSKM_EV_LCL_CHG_SVC_STATE, // State Change of service
+ TSKM_EV_LCL_REQ_SDUMP, // Dump of service list
+ TSKM_EV_LCL_REP_TIMEOUT, // Occured Timeout
+ TSKM_EV_LCL_REP_POLLING, // Polling request
+ TSKM_EV_LCL_REP_LOWMEM, // Notification of LowMemory detection
+ TSKM_EV_LCL_REQ_TRANS_STEP, // Gradual transitioning request
+} TSKM_EVENT_t;
+
+#define TSKM_EV_BOOTINFO_SIZE sizeof(T_SS_SM_START_DataStructType)
+#define TSKM_EV_EXTBOOTINFO_SIZE sizeof(T_SS_SM_START_ExtDataStructType)
+
+typedef struct {
+ TSKM_SVCID_t svcId;
+ TSKM_LOCAL_STEP_t localStep;
+ char bootInfo[TSKM_EV_BOOTINFO_SIZE];
+ char extBootInfo[TSKM_EV_EXTBOOTINFO_SIZE];
+ TSKM_BOOL_t isDynamic; // Nonresident task?
+} TSKM_EV_PRI_REQ_WAKEUP_PRM_t;
+
+typedef struct {
+ TSKM_LOCAL_STEP_t localStep;
+} TSKM_EV_PRI_REQ_DOWN_PRM_t;
+
+// PRI->TSKM
+typedef struct {
+ uint64_t compId;
+} TSKM_EV_PRI_REP_WAKEUP_COMP_PRM_t;
+
+typedef struct {
+ uint64_t compId;
+} TSKM_EV_PRI_REP_DOWN_COMP_PRM_t;
+
+typedef struct {
+ int connFd;
+} TSKM_EV_PRI_REP_CONNECT_PRM_t;
+
+typedef struct {
+ TSKM_BOOL_t isLast;
+ TSKM_BOOL_t isShmDone;
+ TSKM_BOOL_t isStepDone;
+} TSKM_EV_PRI_RES_WAKEUP_PRM_t;
+
+typedef struct {
+ TSKM_BOOL_t isLast;
+} TSKM_EV_PRI_RES_DOWN_PRM_t;
+
+#define TSKM_EV_DEBUGDUMP_SIZE 4096
+
+typedef struct {
+ char dumpMsg[TSKM_EV_DEBUGDUMP_SIZE];
+} TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t;
+
+// APL->TSKM
+
+// Internal message
+typedef struct {
+ TSKM_SVCID_t svcId;
+} TSKM_EV_LCL_CHG_SVC_STATE_PRM_t;
+
+// The structure must be on a stack
+typedef struct _TSKM_EVENT_INFO_t {
+ TSKM_EVENT_t event;
+ TSKM_ERR_t errCode;
+ pid_t fromPid;
+ TSKM_BOOL_t hasExtend;
+ uint32_t extendSize;
+ void *extendPrm;
+ union {
+ // TSKM->PRI
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t reqWakeup;
+ TSKM_EV_PRI_REQ_DOWN_PRM_t reqDown;
+
+ // PRI->TSKM
+ TSKM_EV_PRI_REP_WAKEUP_COMP_PRM_t repWakeupComp;
+ TSKM_EV_PRI_REP_DOWN_COMP_PRM_t repDownComp;
+ TSKM_EV_PRI_REP_CONNECT_PRM_t repConnect;
+ TSKM_EV_PRI_RES_WAKEUP_PRM_t resWakeup;
+ TSKM_EV_PRI_RES_DOWN_PRM_t resDown;
+
+ // Internal message
+ TSKM_EV_LCL_CHG_SVC_STATE_PRM_t chgSvc;
+ } prm;
+ _TSKM_EVENT_INFO_t() {
+ event = TSKM_EV_NOP;
+ errCode = TSKM_E_OK;
+ fromPid = 0;
+ hasExtend = TSKM_FALSE;
+ extendSize = 0;
+ extendPrm = NULL;
+ }
+ ~_TSKM_EVENT_INFO_t() {
+ if (hasExtend && !extendPrm) {
+ free(extendPrm);
+ }
+ }
+} TSKM_EVENT_INFO_t;
+
+typedef enum {
+ TSKM_DATAINIT_REQ = 800,
+ TSKM_DATAINIT_RESP,
+ TSKM_TRANS_STEP_REQ
+} TSKM_PROTCOL_t;
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_LOCAL_TYPE_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/server/include/system_service/tskm_svc.h b/systemservice/task_manager/server/include/system_service/tskm_svc.h
new file mode 100755
index 0000000..8b25581
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/tskm_svc.h
@@ -0,0 +1,904 @@
+/*
+ * @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.
+ */
+/**
+ * @file tskm_svc.h
+ * @brief \~english define of tskm
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_SVC_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_SVC_H_
+
+
+#include <unistd.h>
+#include <sys/types.h>
+#include "system_service/tskm_local_type.h"
+
+
+#define TSKM_SVC_WAIT_REQ_MAX (8) // Number of queued requests
+
+// Service type
+typedef enum {
+ TSKM_SVC_TYPE_NATIVE, //
+ TSKM_SVC_TYPE_UNKNONW, //
+} TSKM_SVC_TYPE_t;
+
+// Scheduling policy
+typedef enum {
+ TSKM_SVC_POLICY_TSS, //
+ TSKM_SVC_POLICY_RR, //
+ TSKM_SVC_POLICY_FIFO, //
+} TSKM_SVC_POLICY_t;
+
+// Life cycle
+typedef enum {
+ TSKM_SVC_LC_ALWAYS, // Resident
+ TSKM_SVC_LC_ALWAYS_RECOVERABLE, // Resident(Recoverable)
+ TSKM_SVC_LC_DYNAMIC // Non-resident
+} TSKM_SVC_LC_t;
+
+// CPU allocation: This defined value should match the specification of the second argument of CL_ProcessCreateAttrSetCpuAssign
+
+typedef enum {
+ TSKM_SVC_ASSIGN_CPU_AUTO = 0, // Automatic allocation
+ TSKM_SVC_ASSIGN_CPU_0 = 1, // Fixed to CPU0
+ TSKM_SVC_ASSIGN_CPU_1 = 2, // Fixed to CPU1
+} TSKM_SVC_ASSIGN_CPU_t;
+
+// Service attributes (given by XML)
+typedef struct {
+ TSKM_SVCID_t svcId; //
+ const char* name; //
+ const char* path; //
+ char** args; //
+ TSKM_SVC_TYPE_t type; //
+ uint32_t prio; //
+ TSKM_SVC_POLICY_t policy; //
+ TSKM_SVC_LC_t lifeCycle; //
+ uint32_t retryCnt; //
+ TSKM_SVC_ASSIGN_CPU_t cpuAssign; //
+ const char* user; //
+ uint32_t runtimeLimit; //
+ uint32_t cpuLimit; //
+ uint32_t memLimit; //
+ TSKM_BOOL_t shotdownWait; //
+ uint32_t subgidNum; //
+ gid_t *subgidList; //
+} TSKM_SVC_ATTR_t;
+
+// Service status
+typedef enum {
+ TSKM_SVC_DORMANT, // During dormant (Not exec)
+ TSKM_SVC_WAITCONNECT, // Wait for connection
+ TSKM_SVC_WAKEUP, // Start in progress
+ TSKM_SVC_RUNNING, // Running (Startup completed)
+ TSKM_SVC_DOWN, // Termination in progress
+ TSKM_SVC_FINDOWN, // Termination completed
+ TSKM_SVC_DISABLE, // Prohibitting startup (exec prohibited)
+} TSKM_SVC_STATE_t;
+
+// Service
+typedef struct { // Life cycle
+ TSKM_SVC_ATTR_t *attr; // Service Attributes ALL
+ TSKM_SVC_STATE_t state; // Service State ALL
+ int iFd; // inotifyFd for touch ALL
+ pid_t pid; // PID of service REQ_WAKEUP - FIN_DOWN
+ int connFd; // service communication socket DO_WAKEUP - FIN_DOWN
+ T_SS_SM_START_DataStructType bootInfo; // Boot info REQ_WAKEUP - FIN_DOWN
+ T_SS_SM_START_ExtDataStructType extBootInfo; // Extended boot info REQ_WAKEUP - FIN_DOWN
+
+ TSKM_BOOL_t isShmDone; // Shared memory initialization completed
+ TSKM_BOOL_t isStepDone; // Gradual startup completed
+ TSKM_BOOL_t isAvailable; // Availability reception completed
+
+ uint32_t watchCnt; // Service monitoring counter
+ uint32_t waitResCnt; // Wait for response to request DO_WAKEUP - WAIT_WAKEUP
+ uint32_t waitReqCnt; // Wait for request issuance REQ_WAKEUP - DO_WAKEUP
+ TSKM_GSTEP_REQ_INFO_t request[TSKM_SVC_WAIT_REQ_MAX]; // REQ_WAKEUP - DO_WAKEUP
+
+ uint32_t errTermCnt; // Number of abnormal terminations ALL
+} TSKM_SVC_CTX_t;
+
+// Service list
+typedef struct {
+ uint32_t svcNum;
+ TSKM_SVC_CTX_t *svcList;
+} TSKM_SVCS_CTX_t;
+
+// State of waiting for service termination
+typedef enum {
+ TSKM_SVC_WAIT_NONE, // No wait
+ TSKM_SVC_WAIT_TRANSIENT, // Waiting for termination of nonresident service
+ TSKM_SVC_WAIT_BOTH, // Waiting for termination of resident/nonresident service
+} TSKM_SVC_WAIT_STATE_t;
+
+// Service list
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsEventHandle
+ /// \~english @par Summary
+ ///
+ /// \~english @param
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @param [in] p_inEv
+ /// p_inEv - pointer of input event info
+ /// \~english @par
+ /// p_inEv TSKM_EVENT_INFO_t*
+ /// \~english @code
+ /// typedef struct _TSKM_EVENT_INFO_t {
+ /// TSKM_EVENT_t event;
+ /// TSKM_ERR_t errCode;
+ /// pid_t fromPid;
+ /// TSKM_BOOL_t hasExtend;
+ /// uint32_t extendSize;
+ /// void *extendPrm;
+ /// union {
+ /// // TSKM->PRI
+ /// TSKM_EV_PRI_REQ_WAKEUP_PRM_t reqWakeup;
+ /// TSKM_EV_PRI_REQ_DOWN_PRM_t reqDown;
+ /// // PRI->TSKM
+ /// TSKM_EV_PRI_REP_WAKEUP_COMP_PRM_t repWakeupComp;
+ /// TSKM_EV_PRI_REP_DOWN_COMP_PRM_t repDownComp;
+ /// TSKM_EV_PRI_REP_CONNECT_PRM_t repConnect;
+ /// TSKM_EV_PRI_RES_WAKEUP_PRM_t resWakeup;
+ /// TSKM_EV_PRI_RES_DOWN_PRM_t resDown;
+ /// TSKM_EV_LCL_CHG_SVC_STATE_PRM_t chgSvc;
+ /// } prm;
+ /// } TSKM_EVENT_INFO_t;
+ /// @endcode
+ /// \~english @param [out] p_outEv
+ /// p_outEv - pointer of output event info
+ /// \~english @par
+ /// p_outEv TSKM_EVENT_INFO_t*
+ /// \~english @retval
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// -
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ ///
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcsEventHandle(TSKM_SVCS_CTX_t* p_svcs,
+ const TSKM_EVENT_INFO_t* p_inEv,
+ TSKM_EVENT_INFO_t* p_outEv);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsGetSvcBySvcId
+ /// \~english @par Summary
+ /// find service in inputed service list by service id.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services object
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @param [in] svcId
+ /// svcId - service Id
+ /// \~english @par
+ /// svcId uint32_t
+ /// \~english @retval TSKM_SVC_CTX_t* service pointer
+ /// \~english @retval TSKM_SVC_CTX_t* NULL
+ /// \~english @par Preconditions
+ /// - none
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - If not find svcId in services list. [NULL]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// find service in inputed service list by service id.. If do not find then return NULL pointer.
+ /// \~english @see getSvcCtxBySvcId
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_SVC_CTX_t* tskm_svcsGetSvcBySvcId(TSKM_SVCS_CTX_t* p_svcs,
+ TSKM_SVCID_t svcId);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsGetSvcByPid
+ /// \~english @par Summary
+ /// find service in inputed service list by process id.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @param [in] pid
+ /// pid - process id
+ /// \~english @par
+ /// pid pid_t
+ /// \~english @retval TSKM_SVC_CTX_t* service pointer
+ /// \~english @retval TSKM_SVC_CTX_t* NULL
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - If not find process id in services list. [NULL]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// find service in inputed service list by process id. If do not find then return NULL pointer.
+ /// \~english @see getSvcCtxByPid
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_SVC_CTX_t* tskm_svcsGetSvcByPid(TSKM_SVCS_CTX_t* p_svcs, pid_t pid);
+
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsIsWaiting
+ /// \~english @par Summary
+ /// Is the service state waiting.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_BOOL_t
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - If service state is TSKM_SVC_WAITCONNECT and wait response num is 0. [TSKM_FALSE]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// Is the service state waiting. \n
+ /// There are not service's state equal TSKM_SVC_WAITCONNECT or wait respose number > 0 return TSKM_TRUE.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_BOOL_t tskm_svcsIsWaiting(TSKM_SVCS_CTX_t* p_svcs);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsGetSvcTermWaitState
+ /// \~english @par Summary
+ /// Get the service which state equanl not equal terminal.
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_SVC_WAIT_STATE_t
+ /// \~english @par
+ /// TSKM_SVC_WAIT_STATE_t enum
+ /// \~english @code
+ /// typedef enum {
+ /// TSKM_SVC_WAIT_NONE, // not waiting state
+ /// TSKM_SVC_WAIT_TRANSIENT, // dynamic service terminal waiting state
+ /// TSKM_SVC_WAIT_BOTH, // no dynamic/ dyanmic service terminal waiting state
+ /// } TSKM_SVC_WAIT_STATE_t;
+ /// @endcode
+ /// \~english @par Preconditions
+ /// - none
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// If all services state equal TSKM_SVC_DORMANT. [TSKM_SVC_WAIT_NONE]
+ /// If dynamic service. [TSKM_SVC_WAIT_TRANSIENT]
+ /// If not dynamic service and state not TSKM_SVC_FINDOWN. [TSKM_SVC_WAIT_BOTH]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// Get the service which state equanl not equal terminal. \n
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_SVC_WAIT_STATE_t tskm_svcsGetSvcTermWaitState(TSKM_SVCS_CTX_t* p_svcs);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsSetBootInfo
+ /// \~english @par Summary
+ /// initialize all services boot info.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @param [in] p_info
+ /// p_info - SS_SM_START 'FrameworkunifiedOnStart'/'evStart' message pointer
+ /// \~english @par
+ /// p_info T_SS_SM_START_DataStructType*
+ /// \~english @code
+ /// Data passed as part of SS_SM_START 'FrameworkunifiedOnStart'/'evStart' message
+ /// typedef struct T_SS_SM_START_DataStruct {
+ /// EPWR_WAKEUP_FACTOR_TYPE startupReason;
+ /// BOOL isUserModeOn;
+ /// ESMDataResetModeInfo dataResetMode;
+ /// EPWR_SC_SECURITY_STATUS securityStatus;
+ /// EPWR_SC_WAKEUP_TYPE wakeupType;
+ /// ESMDramBackupStatus dramBackupStatus;
+ /// ESMResetStatus resetStatus;
+ /// UI_32 errResetCount;
+ /// T_SS_SM_START_DataStruct
+ /// } T_SS_SM_START_DataStructType;
+ /// @endcode
+ /// \~english @param [in] p_exInfo
+ /// p_exInfo - FrameworkunifiedOnStart extend info pointer
+ /// \~english @par
+ /// p_exInfo T_SS_SM_START_ExtDataStructType*
+ /// \~english @code
+ /// /// Extended Parameter for FrameworkunifiedOnStart
+ /// typedef struct {
+ /// BOOL isProgUpdated;
+ /// EMRelaunchStatus relaunchStatus;
+ /// BOOL isMapUpdated;
+ /// BOOL isMapDiffUpdated;
+ /// uint8_t reserved[SS_SM_START_EXT_RSV_SIZE];
+ /// } T_SS_SM_START_ExtDataStructType;
+ /// @endcode
+ /// \~english @retval TSKM_E_OK
+ /// \~english @par
+ /// TSKM_SVC_WAIT_STATE_t enum
+ /// \~english @par Preconditions
+ /// - call tskm_dataInitAll() to get boot info
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - none
+ /// \~english @par Classification
+ /// - pulbic
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// - initialize all services boot info.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcsSetBootInfo(TSKM_SVCS_CTX_t* p_svcs,
+ T_SS_SM_START_DataStructType* p_info,
+ T_SS_SM_START_ExtDataStructType *p_exInfo);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsAvtiveSvcTerm
+ /// \~english @par Summary
+ /// Terminal the dynamic services.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// TSKM_E_NG
+ /// \~english @par Preconditions
+ /// - none
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - tskm_svcDownRequest return failed [TSKM_E_NG]
+ /// \~english @par Classification
+ /// - pulbic
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// Terminal all the dynamic services which state equal TSKM_SVC_RUNNING and response num equal 0. \n
+ /// \~english @see tskm_svcDownRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcsAvtiveSvcTerm(TSKM_SVCS_CTX_t* p_svcs);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsCallDebugDump
+ /// \~english @par Summary
+ /// Send DebugDump message to services.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// TSKM_E_NG
+ /// \~english @par Preconditions
+ /// - none
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - tskm_sockSend send DebugDump message failed [TSKM_E_NG]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// Send DebugDump message to services which state equal TSKM_SVC_RUNNING. \n
+ /// \~english @see tskm_sockSend
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcsCallDebugDump(TSKM_SVCS_CTX_t* p_svcs);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcsCallLowMem
+ /// \~english @par Summary
+ /// Send checking low memory message to services.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// TSKM_E_NG
+ /// \~english @par Preconditions
+ /// - none
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - tskm_sockSend send LowMemory message failed [TSKM_E_NG]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method only
+ /// \~english @par Detail
+ /// Send checking LowMemory message to services which state equal TSKM_SVC_RUNNING. \n
+ /// \~english @see tskm_sockSend
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcsCallLowMem(TSKM_SVCS_CTX_t* p_svcs);
+
+// Service
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcEventHandle
+ /// \~english @par Summary
+ /// process event.
+ /// \~english @param [in] p_svcs
+ /// p_svcs - pointer of services
+ /// \~english @par
+ /// p_svcs TSKM_SVCS_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// uint32_t svcNum; // service num
+ /// TSKM_SVC_CTX_t *svcList; // services list pointer
+ /// } TSKM_SVCS_CTX_t;
+ /// @endcode
+ /// \~english @param [in][out] p_ev
+ /// p_ev - event info pointer
+ /// \~english @par
+ /// p_ev TSKM_EVENT_INFO_t*
+ /// \~english @code
+ /// typedef struct _TSKM_EVENT_INFO_t {
+ /// TSKM_EVENT_t event;
+ /// TSKM_ERR_t errCode;
+ /// pid_t fromPid;
+ /// TSKM_BOOL_t hasExtend;
+ /// uint32_t extendSize;
+ /// void *extendPrm;
+ /// union {
+ /// // TSKM->PRI
+ /// TSKM_EV_PRI_REQ_WAKEUP_PRM_t reqWakeup;
+ /// TSKM_EV_PRI_REQ_DOWN_PRM_t reqDown;
+ ///
+ /// // PRI->TSKM
+ /// TSKM_EV_PRI_REP_WAKEUP_COMP_PRM_t repWakeupComp;
+ /// TSKM_EV_PRI_REP_DOWN_COMP_PRM_t repDownComp;
+ /// TSKM_EV_PRI_REP_CONNECT_PRM_t repConnect;
+ /// TSKM_EV_PRI_RES_WAKEUP_PRM_t resWakeup;
+ /// TSKM_EV_PRI_RES_DOWN_PRM_t resDown;
+ /// TSKM_EV_LCL_CHG_SVC_STATE_PRM_t chgSvc;
+ /// } prm;
+ /// } TSKM_EVENT_INFO_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// \~english @par Preconditions
+ /// - none
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - none
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ /// process event.\n
+ /// process connect response.\n
+ /// process disconnect response. \n
+ /// process service wakeup request. \n
+ /// process service down request. \n
+ /// process service debugdump request. \n
+ /// process service exit request. \n
+ /// process service terminal response. \n
+ /// \~english @see isSvcEvent,connectHandle,disConnectHandle,resWakeupHandle, \n
+ /// resDownHandle,resDebugDumpHandle,reqExit,repTermHandle \n
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcEventHandle(TSKM_SVC_CTX_t* p_svc, TSKM_EVENT_INFO_t* p_ev); // p_ev: [IN/OUT]
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcExec
+ /// \~english @par Summary
+ /// start service.
+ /// \~english @param [in][out] p_svc
+ /// p_svc - pointer of services
+ /// \~english @par
+ /// p_svc TSKM_SVC_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVC_ATTR_t *attr; // attribute of service
+ /// TSKM_SVC_STATE_t state; // state of service
+ /// int iFd; // inotifyFd used by touch
+ /// pid_t pid; // PID of service
+ /// int connFd; // service communicate fd
+ /// T_SS_SM_START_DataStructType bootInfo; // BOOT info
+ /// T_SS_SM_START_ExtDataStructType extBootInfo; // extend BOOT info
+ /// TSKM_BOOL_t isShmDone; // shared memory init done
+ /// TSKM_BOOL_t isStepDone; // step done
+ /// TSKM_BOOL_t isAvailable; // Availability flag
+ /// uint32_t watchCnt; // service monitor count
+ /// uint32_t waitResCnt; // wait response num
+ /// uint32_t waitReqCnt; // wait request num
+ /// TSKM_GSTEP_REQ_INFO_t request[TSKM_SVC_WAIT_REQ_MAX];
+ /// uint32_t errTermCnt; // exception terminal count
+ /// } TSKM_SVC_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// TSKM_E_NG
+ /// TSKM_E_STATE
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - input parameter p_svc is NULL. [TSKM_E_NG]
+ /// - service state is TSKM_SVC_DISABLE [TSKM_E_STATE]
+ /// - reqTouch return failed [TSKM_E_NG]
+ /// - tskm_pf_createProc return failed [TSKM_E_NG]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ /// start service which state is TSKM_SVC_DORMANT.\n
+ /// \~english @see svcExec, reqTouch, tskm_pf_createProc
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcExec(TSKM_SVC_CTX_t* p_svc);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcWakeupRequest
+ /// \~english @par Summary
+ /// Send started request to service.
+ /// \~english @param [in][out] p_svc
+ /// p_svc - pointer of service
+ /// \~english @par
+ /// p_svc TSKM_SVC_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVC_ATTR_t *attr; // attribute of service
+ /// TSKM_SVC_STATE_t state; // state of service
+ /// int iFd; // inotifyFd used by touch
+ /// pid_t pid; // PID of service
+ /// int connFd; // service communicate fd
+ /// T_SS_SM_START_DataStructType bootInfo; // BOOT info
+ /// T_SS_SM_START_ExtDataStructType extBootInfo; // extend BOOT info
+ /// TSKM_BOOL_t isShmDone; // shared memory init done
+ /// TSKM_BOOL_t isStepDone; // step done
+ /// TSKM_BOOL_t isAvailable; // Availability flag
+ /// uint32_t watchCnt; // service monitor count
+ /// uint32_t waitResCnt; // wait response num
+ /// uint32_t waitReqCnt; // wait request num
+ /// TSKM_GSTEP_REQ_INFO_t request[TSKM_SVC_WAIT_REQ_MAX];
+ /// uint32_t errTermCnt; // exception terminal count
+ /// } TSKM_SVC_CTX_t;
+ /// @endcode
+ /// \~english @param [in] p_req
+ /// p_req - pointer of request
+ /// \~english @par
+ /// p_req TSKM_GSTEP_REQ_INFO_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVCID_t svcId; // service ID
+ /// TSKM_LOCAL_STEP_t localStep; // local step id
+ /// } TSKM_GSTEP_REQ_INFO_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// TSKM_E_NG
+ /// TSKM_E_STATE
+ /// \~english @par Preconditions
+ /// - none
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Input parameter p_svc is NULL. [TSKM_E_STATE]
+ /// - Service state is TSKM_SVC_DISABLE [TSKM_E_STATE]
+ /// - wakeupRequest return failed [TSKM_E_NG]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ /// Send started request to service. If service do not connect, save the request.\n
+ /// Send request again when service connect. \n
+ /// \~english @see svcWakeupRequest
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcWakeupRequest(TSKM_SVC_CTX_t* p_svc,
+ TSKM_GSTEP_REQ_INFO_t* p_req);
+
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcDownRequest
+ /// \~english @par Summary
+ /// Send service down request to service.
+ /// \~english @param [in][out] p_svc
+ /// p_svc - pointer service
+ /// \~english @par
+ /// p_svc TSKM_SVC_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVC_ATTR_t *attr; // attribute of service
+ /// TSKM_SVC_STATE_t state; // state of service
+ /// int iFd; // inotifyFd used by touch
+ /// pid_t pid; // PID of service
+ /// int connFd; // service communicate fd
+ /// T_SS_SM_START_DataStructType bootInfo; // BOOT info
+ /// T_SS_SM_START_ExtDataStructType extBootInfo; // extend BOOT info
+ /// TSKM_BOOL_t isShmDone; // shared memory init done
+ /// TSKM_BOOL_t isStepDone; // step done
+ /// TSKM_BOOL_t isAvailable; // Availability flag
+ /// uint32_t watchCnt; // service monitor count
+ /// uint32_t waitResCnt; // wait response num
+ /// uint32_t waitReqCnt; // wait request num
+ /// TSKM_GSTEP_REQ_INFO_t request[TSKM_SVC_WAIT_REQ_MAX];
+ /// uint32_t errTermCnt; // exception terminal count
+ /// } TSKM_SVC_CTX_t;
+ /// @endcode
+ /// \~english @param [in] p_req
+ /// p_req - request pointer
+ /// \~english @par
+ /// p_req TSKM_GSTEP_REQ_INFO_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVCID_t svcId; // service ID
+ /// TSKM_LOCAL_STEP_t localStep; // local step id
+ /// } TSKM_GSTEP_REQ_INFO_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// TSKM_E_NG
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Send service down request failed [TSKM_E_NG]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ /// If service state is commounicated(TSKM_SVC_WAKEUP, TSKM_SVC_RUNNING), \n
+ /// send service down request and set state as TSKM_SVC_DOWN.\n
+ /// \~english @see tskm_svcIsCommunicatable,tskm_sockSend
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcDownRequest(TSKM_SVC_CTX_t* p_svc,
+ TSKM_GSTEP_REQ_INFO_t* p_req);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcDisableRequest
+ /// \~english @par Summary
+ ///
+ /// \~english @param [in][out] p_svc
+ /// p_svc - pointer of service
+ /// \~english @par
+ /// p_svc TSKM_SVC_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVC_ATTR_t *attr; // attribute of service
+ /// TSKM_SVC_STATE_t state; // state of service
+ /// int iFd; // inotifyFd used by touch
+ /// pid_t pid; // PID of service
+ /// int connFd; // service communicate fd
+ /// T_SS_SM_START_DataStructType bootInfo; // BOOT info
+ /// T_SS_SM_START_ExtDataStructType extBootInfo; // extend BOOT info
+ /// TSKM_BOOL_t isShmDone; // shared memory init done
+ /// TSKM_BOOL_t isStepDone; // step done
+ /// TSKM_BOOL_t isAvailable; // Availability flag
+ /// uint32_t watchCnt; // service monitor count
+ /// uint32_t waitResCnt; // wait response num
+ /// uint32_t waitReqCnt; // wait request num
+ /// TSKM_GSTEP_REQ_INFO_t request[TSKM_SVC_WAIT_REQ_MAX];
+ /// uint32_t errTermCnt; // exception terminal count
+ /// } TSKM_SVC_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// TSKM_E_STATE
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - If service state is not TSKM_SVC_DORMANT and TSKM_SVC_DISABLE. [TSKM_E_STATE]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ /// Set service state as TSKM_SVC_DISABLE if state is TSKM_SVC_DORMANT.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcDisableRequest(TSKM_SVC_CTX_t* p_svc);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcDisableRequest
+ /// \~english @par Summary
+ /// Set service state as start available.
+ /// \~english @param [in][out] p_svc
+ /// p_svc - Pointer to service
+ /// \~english @par
+ /// p_svc TSKM_SVC_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVC_ATTR_t *attr; // attribute of service
+ /// TSKM_SVC_STATE_t state; // state of service
+ /// int iFd; // inotifyFd used by touch
+ /// pid_t pid; // PID of service
+ /// int connFd; // service communicate fd
+ /// T_SS_SM_START_DataStructType bootInfo; // BOOT info
+ /// T_SS_SM_START_ExtDataStructType extBootInfo; // extend BOOT info
+ /// TSKM_BOOL_t isShmDone; // shared memory init done
+ /// TSKM_BOOL_t isStepDone; // step done
+ /// TSKM_BOOL_t isAvailable; // Availability flag
+ /// uint32_t watchCnt; // service monitor count
+ /// uint32_t waitResCnt; // wait response num
+ /// uint32_t waitReqCnt; // wait request num
+ /// TSKM_GSTEP_REQ_INFO_t request[TSKM_SVC_WAIT_REQ_MAX];
+ /// uint32_t errTermCnt; // exception terminal count
+ /// } TSKM_SVC_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_ERR_t
+ /// \~english @par
+ /// TSKM_E_OK
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - none
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ /// Set service state as start available which state is disable(TSKM_SVC_DISABLE).
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_ERR_t tskm_svcEnableRequest(TSKM_SVC_CTX_t* p_svc);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tskm_svcIsCommunicatable
+ /// \~english @par Summary
+ /// Whether service is Communicatable.
+ /// \~english @param [in] p_svc
+ /// p_svc - pointer of service
+ /// \~english @par
+ /// p_svc TSKM_SVC_CTX_t*
+ /// \~english @code
+ /// typedef struct {
+ /// TSKM_SVC_ATTR_t *attr; // attribute of service
+ /// TSKM_SVC_STATE_t state; // state of service
+ /// int iFd; // inotifyFd used by touch
+ /// pid_t pid; // PID of service
+ /// int connFd; // service communicate fd
+ /// T_SS_SM_START_DataStructType bootInfo; // BOOT info
+ /// T_SS_SM_START_ExtDataStructType extBootInfo; // extend BOOT info
+ /// TSKM_BOOL_t isShmDone; // shared memory init done
+ /// TSKM_BOOL_t isStepDone; // step done
+ /// TSKM_BOOL_t isAvailable; // Availability flag
+ /// uint32_t watchCnt; // service monitor count
+ /// uint32_t waitResCnt; // wait response num
+ /// uint32_t waitReqCnt; // wait request num
+ /// TSKM_GSTEP_REQ_INFO_t request[TSKM_SVC_WAIT_REQ_MAX];
+ /// uint32_t errTermCnt; // exception terminal count
+ /// } TSKM_SVC_CTX_t;
+ /// @endcode
+ /// \~english @retval TSKM_BOOL_t
+ /// \~english @par
+ /// TSKM_FALSE
+ /// TSKM_TRUE
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - If input parameter p_svc is NULL. [TSKM_FALSE]
+ /// - If input parameter p_svc->attr->type is TSKM_SVC_TYPE_UNKNONW. [TSKM_FALSE]
+ /// - If service state is TSKM_SVC_DORMANT or TSKM_SVC_WAITCONNECT or
+ /// TSKM_SVC_FINDOWN orTSKM_SVC_DISABLE. [TSKM_FALSE]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - method
+ /// \~english @par Detail
+ /// Whether service is Communicatable. \n
+ /// If service state is TSKM_SVC_WAKEUP or TSKM_SVC_RUNNING or TSKM_SVC_DOWN, return TSKM_TRUE. \n
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+TSKM_BOOL_t tskm_svcIsCommunicatable(TSKM_SVC_CTX_t* p_svc);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_SVC_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/server/include/system_service/tskm_type.h b/systemservice/task_manager/server/include/system_service/tskm_type.h
new file mode 100755
index 0000000..7d1f818
--- /dev/null
+++ b/systemservice/task_manager/server/include/system_service/tskm_type.h
@@ -0,0 +1,123 @@
+/*
+ * @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.
+ */
+/**
+ * @file tskm_type.h
+ * @brief \~english type of tskm
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup task_manager
+ * @ingroup system_service
+ * @{
+ */
+#ifndef TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_TYPE_H_
+#define TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_TYPE_H_
+
+
+
+#include <stdint.h>
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_services.h>
+#include "system_service/tskm_svcid.h"
+
+
+#define TSKM_ERR_t int32_t
+#define TSKM_E_OK 0
+#define TSKM_E_PAR 1
+#define TSKM_E_STATE 2
+#define TSKM_E_PERMIT 3
+#define TSKM_E_ALREADY 4
+#define TSKM_E_RETRY 5
+#define TSKM_E_NG 6
+
+#define TSKM_BOOL_t int32_t
+#define TSKM_TRUE 1
+#define TSKM_FALSE 0
+
+#define TSKM_RSV_t int
+
+typedef uint32_t TSKM_SVCID_t;
+// Values are defined in tskm_svcid.h
+
+typedef enum {
+ TSKM_SVC_CMD_NOP, // Do nothing
+ TSKM_SVC_CMD_EXEC, // Startup service
+ TSKM_SVC_CMD_ENABLE, // Allow service startup
+ TSKM_SVC_CMD_DISABLE, // Prohibit service startup
+ TSKM_SVC_CMD_RESERVE, // Reserve service startup
+} TSKM_SVC_CMD_t;
+
+typedef struct {
+ TSKM_SVC_CMD_t cmd;
+} TSKM_SVC_CTL_t;
+
+typedef struct {
+ TSKM_SVCID_t svcId;
+ TSKM_BOOL_t isExecDisable;
+} TSKM_SVC_INFO_t;
+
+typedef enum {
+ TSKM_BOOT_NORMAL, // Normal start
+ TSKM_BOOT_FACTRESET, // start with factory default start
+ TSKM_BOOT_USERRESET, // start with resetting user info
+ TSKM_BOOT_VERSIONUP, // start with version up
+} TSKM_BOOT_t;
+
+typedef enum {
+ TSKM_LOGGING_TYPE_MODULE_LOGS, // logging request from the service
+ TSKM_LOGGING_TYPE_GRP_RELAUNCH, // logging by Group Relaunch
+} TSKM_LOGGING_TYPE_NORMAL_t;
+
+typedef enum {
+ TSKM_ERROR_REBOOT_NORMAL, // Anomaly detection
+} TSKM_ERROR_REBOOT_TYPE_t;
+
+#define TSKM_LOGGING_MSG_STR_SIZE 64
+
+typedef struct {
+ TSKM_LOGGING_TYPE_NORMAL_t type; // Log type
+ char messageStr[TSKM_LOGGING_MSG_STR_SIZE]; // Error message
+} TSKM_LOGGING_INFO_t;
+
+typedef struct {
+ TSKM_ERROR_REBOOT_TYPE_t type; // Reboot type
+ TSKM_LOGGING_INFO_t log; // Log info
+} TSKM_ERROR_REBOOT_t;
+
+typedef enum {
+ TSKM_DATAINIT_TYPE_USER, // Reset user info
+} TSKM_DATAINIT_TYPE_t;
+
+typedef struct {
+ TSKM_DATAINIT_TYPE_t type;
+ EFrameworkunifiedStatus (*onCompInit)(HANDLE hApp);
+} TSKM_DATAINIT_t;
+
+#define TSKM_ORDER_NAME_MAX 32
+
+typedef struct {
+ char orderName[TSKM_ORDER_NAME_MAX];
+} TSKM_WAKEUP_ORDER_t;
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_SYSTEM_SERVICE_TSKM_TYPE_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/task_manager/server/include/tskm_comm.h b/systemservice/task_manager/server/include/tskm_comm.h
new file mode 100755
index 0000000..c884be9
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_comm.h
@@ -0,0 +1,59 @@
+/*
+ * @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.
+ */
+
+// Communication module header file
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_
+
+#include <sys/types.h>
+#include "system_service/tskm_local_type.h"
+
+#define TSKM_SOCKET_NAME "/tmp/tskm_sock" // Sockets for Primary Library
+
+#define TSKM_COMM_CONNECT_MAX (32)
+
+typedef struct {
+ pid_t pid;
+ int connFd;
+} TSKM_SRV_CONNENT_t;
+
+typedef struct {
+ uint32_t num;
+ TSKM_SRV_CONNENT_t conn[TSKM_COMM_CONNECT_MAX];
+} TSKM_SRV_CONNENT_LIST_t;
+
+typedef struct {
+ int sockFd;
+ const char *sockName;
+ TSKM_SRV_CONNENT_LIST_t connList;
+} TSKM_SRV_SOCK_CTX_t;
+
+TSKM_ERR_t tskm_srvSockCreate(const char* sockName,
+ TSKM_SRV_SOCK_CTX_t* p_sock);
+TSKM_SRV_CONNENT_t* tskm_srvSockConnect(TSKM_SRV_SOCK_CTX_t* p_sock);
+void tskm_srvSockDisconnect(TSKM_SRV_SOCK_CTX_t* p_sock,
+ TSKM_SRV_CONNENT_t *p_conn);
+void tskm_srvSockDestory(TSKM_SRV_SOCK_CTX_t* p_sock);
+int tskm_cliSockConnect(const char* sockName);
+int tskm_sockRcv(int fd, TSKM_EVENT_INFO_t* p_ev);
+int tskm_sockSend(int fd, TSKM_EVENT_INFO_t* p_ev);
+void tskm_sockDestory(int fd);
+
+int tskm_comm_procInit(void);
+int tskm_comm_setSvcWatchState(uint32_t id, BOOL bIsRun, uint32_t timeout);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_
+
diff --git a/systemservice/task_manager/server/include/tskm_debug.h b/systemservice/task_manager/server/include/tskm_debug.h
new file mode 100755
index 0000000..ae963a8
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_debug.h
@@ -0,0 +1,208 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_DEBUG_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_DEBUG_H_
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <native_service/ns_logger_if.h>
+#include "system_service/tskm_svc.h"
+
+#include "system_service/tskm_local_type.h"
+
+#define TSKM_STATIC static
+
+// for frameworkunifiedlog
+#define ZONE_INIT ZONEMASK(10) // Reserved for lib
+#define ZONE_FUNC ZONEMASK(11) // Reserved for lib
+#define ZONE_MEM ZONEMASK(12) // Reserved for lib
+#define ZONE_OUT ZONEMASK(13)
+#define ZONE_STATE ZONEMASK(14) // Basic state change
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29) // Reserved for lib
+#define ZONE_WARN ZONEMASK(30) // Reserved for lib
+#define ZONE_ERR ZONEMASK(31) // Reserved for lib
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT|LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_OUT, ZONE_WARN, ZONE_ERR, ZONE_STATE, ZONE_PERFORMANCE, ZONE_SYSTEMDATA
+/*
+ ZONE_NS_FUNC,\
+ ZONE_NS_DIS,\
+ ZONE_NS__CWORD77_,\
+ ZONE_NS_IMP_INFO,\
+ ZONE_NS_SM_DEV_INFO,\
+ ZONE_NS_SM_USR_INFO,\
+ ZONE_NS_INFO,\
+ ZONE_NS_DEBUG_DUMP,\
+ ZONE_NS_WAR ,\
+ ZONE_NS_ERR ,\
+ ZONE_DEBUG_DUMP
+ */
+#endif
+
+#define TSKM_LOG_ERROR 0x00000001U
+#define TSKM_LOG_STATE 0x00000002U
+#define TSKM_LOG_DEBUG 0x00000004U
+#define TSKM_LOG_API 0x00000008U
+#define TSKM_LOG_PORTPF 0x00000010U
+#define TSKM_LOG_FUNC 0x00000020U
+#define TSKM_LOG_MSG 0x00000040U
+#define TSKM_LOG_WARN 0x00000080U
+#define TSKM_LOG_SVCSTATE 0x00000100U
+#define TSKM_LOG_SYSTEMDATA 0x00000200U
+
+// For debugging
+#define TSKM_LOG_CUSTUM (0 \
+ )
+/*
+ |TSKM_LOG_MSG \
+ |TSKM_LOG_DEBUG \
+ |TSKM_LOG_FUNC \
+ |TSKM_LOG_PORTPF \
+ */
+
+typedef enum {
+ TSKM_LOG_TYPE_TEXT,
+ TSKM_LOG_TYPE_PLACE,
+} TSKM_LOG_TYPE_t;
+
+#define TSKM_DEFAULT_PRINTF(flag, fmt, ...) { \
+ switch (flag) { \
+ case TSKM_LOG_SYSTEMDATA: \
+ FRAMEWORKUNIFIEDLOG(ZONE_SYSTEMDATA, __FUNCTION__, fmt, ##__VA_ARGS__); \
+ break; \
+ case TSKM_LOG_API: \
+ case TSKM_LOG_STATE: \
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, fmt, ##__VA_ARGS__); \
+ break; \
+ case TSKM_LOG_ERROR: \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, fmt, ##__VA_ARGS__); \
+ break; \
+ case TSKM_LOG_WARN: \
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, fmt, ##__VA_ARGS__); \
+ break; \
+ case TSKM_LOG_DEBUG: \
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, fmt, ##__VA_ARGS__); \
+ break; \
+ case TSKM_LOG_MSG: \
+ case TSKM_LOG_FUNC: \
+ case TSKM_LOG_PORTPF: \
+ default: \
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, fmt, ##__VA_ARGS__); \
+ break; \
+ } \
+ }
+
+#define TSKM_PRINTF(flag, fmt, ...) { \
+ if (TSKM_LOG_SVCSTATE == flag) { \
+ /* Logs at startup and termination */ \
+ FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, fmt, ## __VA_ARGS__); \
+ } else if (TSKM_LOG_CUSTUM & flag) { \
+ /* Logging by STATE when CUSTUM is specified */ \
+ FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, fmt, ## __VA_ARGS__); \
+ } else { \
+ TSKM_DEFAULT_PRINTF(flag, fmt, ## __VA_ARGS__); \
+ } \
+ }
+
+#define TSKM_ASSERT(x) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "TSKM_ASSERT"); \
+ }
+
+#define TSKM_ASSERT_ERRNO(x) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "TSKM_ASSERT %d:%s", errno, strerror(errno)); \
+ }
+
+#define TSKM_ASSERT_PRINT(x, fmt, ...) \
+ if (!(x)) { \
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "TSKM_ASSERT:" fmt, ## __VA_ARGS__); \
+ }
+
+#define TSKM_STATIC_ASSERT(expr) \
+ { \
+ char STATIC_ASSERTION_FAILED[(expr) ? 1 : -1]; \
+ (void)STATIC_ASSERTION_FAILED; \
+ }
+
+#define TSKM_DUMP(addr, size) { \
+ char* buf = (char*)addr; /* NOLINT (readability/casting) */ \
+ int ii; \
+ printf("[DUMP] %s:%d addr:%p size:%d", __FUNCTION__, __LINE__, addr, size); \
+ for (ii=0 ; ii < size ; ii++) { \
+ if (ii%16 == 0) printf(" "); \
+ if (ii%32 == 0) printf("\n"); \
+ printf("%02x", buf[ii]); \
+ } \
+ printf("\n"); \
+ }
+
+#define TSKM_FUNC_IN() TSKM_PRINTF(TSKM_LOG_FUNC, "%s:IN", __FUNCTION__)
+
+#define TSKM_FUNC_OUT() TSKM_PRINTF(TSKM_LOG_FUNC, "%s:OUT", __FUNCTION__)
+
+const char* tskm_convState2Str(TSKM_STATE_t state);
+const char* tskm_convLocalStep2Str(TSKM_LOCAL_STEP_t localStep);
+const char* tskm_convEvent2Str(TSKM_EVENT_t event);
+const char* tskm_convInitCompId2Str(uint64_t compId);
+const char* tskm_convTermCompId2Str(uint64_t compId);
+const char* tskm_convSvcState2Str(TSKM_SVC_STATE_t state);
+void tskm_svcsDump(TSKM_SVCS_CTX_t* p_svcs);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_DEBUG_H_
diff --git a/systemservice/task_manager/server/include/tskm_main.h b/systemservice/task_manager/server/include/tskm_main.h
new file mode 100755
index 0000000..24ba5f1
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_main.h
@@ -0,0 +1,71 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_MAIN_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_MAIN_H_
+
+#include <system_service/ss_boot_map.h>
+
+#include "system_service/tskm_svc.h"
+#include "system_service/tskm_local_type.h"
+#include "tskm_comm.h"
+#include "tskm_type_local.h"
+
+typedef struct {
+ // State
+ TSKM_BOOL_t isExec; // Executing flag
+ TSKM_STATE_t state; // TSKM state
+
+ // API
+ TSKM_BOOL_t inApi; // API running
+ TSKM_ERR_t apiRet; // API return
+ TSKM_BOOL_t isReboot; // REBOOT request
+
+ TSKM_BOOL_t isOnStartDone; // System start process completion flag
+ TSKM_BOOL_t isOnStopDone; // System stop process completion flag
+
+ // Communication
+ TSKM_SRV_SOCK_CTX_t sock; // priLib socket
+ int sigFd; // signalFd(process-termination-detection)
+ HANDLE hApp; // DispatcherHandle
+ int nsFd; // For receiving from the NSFW
+ int iFd; // inotify FDs
+ int resmFd; // EV FDs of RESM
+
+ // Non-volatile info
+ TSKM_NV_INFO_t nvInfo; // Non-volatile information
+
+ // Startup info
+ T_SS_SM_START_DataStructType bootInfo; // for Pri notification
+ T_SS_SM_START_ExtDataStructType extBootInfo; // for Pri notification
+
+ // Analysis support
+ STATEMGR__CWORD69_LOG* p__CWORD69_Log; // BUGBUG: Required or not
+
+ // Services management
+ TSKM_SVCS_CTX_t svcs;
+
+ // Gradual starting state management
+ TSKM_GSTEP_CTX_t wakeup;
+
+ // Gradual terminating state management
+ TSKM_GSTEP_CTX_t down;
+} TSKM_MAIN_CTX_t;
+
+EFrameworkunifiedStatus OnStart(const HANDLE hApp); // System start process
+TSKM_MAIN_CTX_t* tskm_getMainCtx(void);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_MAIN_H_
diff --git a/systemservice/task_manager/server/include/tskm_port_pf.h b/systemservice/task_manager/server/include/tskm_port_pf.h
new file mode 100755
index 0000000..31da5ab
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_port_pf.h
@@ -0,0 +1,46 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_PORT_PF_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_PORT_PF_H_
+
+#include <native_service/cl_process.h>
+
+#include "system_service/tskm_svc.h"
+#include "system_service/tskm_local_type.h"
+#include "tskm_main.h"
+
+int tskm_pf_sysInit();
+int tskm_pf_procInit();
+pid_t tskm_pf_createProc(TSKM_SVC_ATTR_t* p_svcAttr);
+int tskm_pf_cleanupProc(int sigFd, pid_t* p_pid, TSKM_ERR_t* p_err);
+int tskm_pf_terminateProcGroup(uint16_t pid);
+int tskm_pf_shmCreate(const char* name, int32_t size, void** p_addr);
+int tskm_pf_shmDelete(const char* name);
+int tskm_pf_createThread(void* (*threadFunc)(void*), void* prm,
+ uint32_t priority, const char* threadName,
+ pthread_t* p_thId);
+int tskm_pf_sendStopCompResp();
+int tskm_pf_abort();
+int tskm_pf_exit(int status);
+int tskm_pf_touch(char* path);
+int tskm_pf_mkTouchFileName(pid_t pid, char name[32]);
+int tskm_pf_nvFileInit(HANDLE hApp);
+int tskm_pf_nvFileRead(HANDLE hApp, TSKM_NV_INFO_t* p_nvInfo);
+int tskm_pf_nvFileWrite(const TSKM_NV_INFO_t* p_nvInfo);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_PORT_PF_H_
+
diff --git a/systemservice/task_manager/server/include/tskm_port_subsys.h b/systemservice/task_manager/server/include/tskm_port_subsys.h
new file mode 100755
index 0000000..3dc3565
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_port_subsys.h
@@ -0,0 +1,42 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_PORT_SUBSYS_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_PORT_SUBSYS_H_
+
+#include "system_service/tskm_local_type.h"
+#include "tskm_main.h"
+
+typedef struct {
+ pid_t pid;
+ uint8_t type; // CL_MonitorType_t
+} TSKM_HUNG_INFO_t;
+
+int tskm_sub_init(void);
+int tskm_sub_term(void);
+void tskm_sub_reboot(const TSKM_ERROR_REBOOT_t* p_info);
+void tskm_sub_reboot_normal(void);
+void tskm_sub_logging(const TSKM_LOGGING_INFO_t* p_info);
+void tskm_sub_debugDumpRes(BOOL bIsNeedSvcName, const char *p_dumpMsg);
+int tskm_sub_getExtBootInfo(T_SS_SM_START_ExtDataStructType *p_info);
+
+TSKM_HUNG_INFO_t *tskm_sub_searchHungSvcs();
+int tskm_sub_resmInit();
+int tskm_sub_resmRcv(TSKM_EVENT_INFO_t* p_ev);
+int tskm_sub_setWakeupOrder(const char* p_order);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_PORT_SUBSYS_H_
+
diff --git a/systemservice/task_manager/server/include/tskm_shutdown.h b/systemservice/task_manager/server/include/tskm_shutdown.h
new file mode 100755
index 0000000..bb76d3c
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_shutdown.h
@@ -0,0 +1,27 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_SHUTDOWN_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_SHUTDOWN_H_
+
+#include "tskm_main.h"
+
+TSKM_ERR_t tskm_entryDown(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_exitDown(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_handleDown(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_SHUTDOWN_H_
+
diff --git a/systemservice/task_manager/server/include/tskm_state.h b/systemservice/task_manager/server/include/tskm_state.h
new file mode 100755
index 0000000..748d25e
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_state.h
@@ -0,0 +1,36 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_STATE_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_STATE_H_
+
+#include "system_service/tskm_local_type.h"
+#include "system_service/tskm_type.h"
+#include "tskm_main.h"
+
+#define TSKM_SUB_STATE_IS(p_main, subState) \
+ (((p_main)->state & subState) == subState) // NOLINT (runtime/references)
+
+// Public functions
+TSKM_ERR_t tskm_entryState(TSKM_MAIN_CTX_t* p_rec, TSKM_STATE_t state);
+TSKM_ERR_t tskm_exitState(TSKM_MAIN_CTX_t* p_rec, TSKM_STATE_t state);
+TSKM_ERR_t tskm_stateTransit(TSKM_MAIN_CTX_t* p_main, TSKM_STATE_t srcState,
+ TSKM_STATE_t dstState);
+void tskm_handleEvent(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev);
+
+TSKM_ERR_t tskm_handleAccon(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_STATE_H_
diff --git a/systemservice/task_manager/server/include/tskm_wakeup.h b/systemservice/task_manager/server/include/tskm_wakeup.h
new file mode 100755
index 0000000..d4a1193
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_wakeup.h
@@ -0,0 +1,26 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_WAKEUP_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_WAKEUP_H_
+
+#include "tskm_main.h"
+
+TSKM_ERR_t tskm_entryWakeup(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_exitWakeup(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_handleWakeup(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev);
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_WAKEUP_H_
diff --git a/systemservice/task_manager/server/include/tskm_watch.h b/systemservice/task_manager/server/include/tskm_watch.h
new file mode 100755
index 0000000..d1aced5
--- /dev/null
+++ b/systemservice/task_manager/server/include/tskm_watch.h
@@ -0,0 +1,25 @@
+/*
+ * @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.
+ */
+
+#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_WATCH_H_
+#define TASK_MANAGER_SERVER_INCLUDE_TSKM_WATCH_H_
+
+#include "tskm_main.h"
+
+int tskm_watch_startTimer();
+
+#endif // TASK_MANAGER_SERVER_INCLUDE_TSKM_WATCH_H_
+
diff --git a/systemservice/task_manager/server/src/pri_main.cpp b/systemservice/task_manager/server/src/pri_main.cpp
new file mode 100755
index 0000000..2c87623
--- /dev/null
+++ b/systemservice/task_manager/server/src/pri_main.cpp
@@ -0,0 +1,840 @@
+/*
+ * @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.
+ */
+
+#include "pri_main.h"
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/eventfd.h>
+#include <stdlib.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <system_service/ss_system_if.h>
+
+#include "tskm_debug.h"
+#include "tskm_comm.h"
+#include "tskm_port_pf.h"
+#include "tskm_port_subsys.h"
+#include "tskm_util.h"
+
+
+
+#define PRI_PROC_NAME_MAX 32
+
+// Context
+typedef struct {
+ T_PRIM_PRM prm;
+
+ TSKM_SVCID_t svcId; // Set valid value by REQ_WAKEUP
+ char procName[PRI_PROC_NAME_MAX];
+ // State
+ TSKM_BOOL_t isExec;
+ T_SS_SM_START_DataStructType bootInfo;
+ T_SS_SM_START_ExtDataStructType extBootInfo; TSKM_BOOL_t isDynamic;
+ uint32_t wakeupStepDone; // Executed local step
+ TSKM_BOOL_t shmDone;
+ uint32_t downStepDone; // Executed local step
+ TSKM_BOOL_t isExitStart;
+
+#define PRI_MONITOR_DEFAULT_TIMEOUT 50
+ uint32_t timeout; // Service monitoring timeout period (valid only for the INI_Main type service)
+
+ // Resources
+ int connFd; // TSKM communication socket
+ int nsFd; // NSFW socket
+ int pipeFd[2]; // for exitDone
+ HANDLE hApp; // appHandle
+} PRI_CTX_t;
+
+static PRI_CTX_t g_pri;
+
+/*********************************************
+ * Create shared memory
+ *********************************************/
+TSKM_STATIC void shmMake(PRI_CTX_t* p_ctx) {
+ const PRIM_SHAREDATA_TBL* shmEntry;
+ for (shmEntry = p_ctx->prm.shmTbl; shmEntry->shmName[0] != '\0'; shmEntry++) {
+ int ret;
+ ret = tskm_pf_shmCreate(shmEntry->shmName, shmEntry->size, NULL);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+ }
+ p_ctx->shmDone = TSKM_TRUE;
+ return;
+
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************
+ * Call backup check CB
+ *********************************************/
+TSKM_STATIC uint32_t wakeupExFuncCallback(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ const PRIM_EXFUNC_TBL* funcEntry;
+ uint32_t maxStep = 0;
+
+ for (funcEntry = p_ctx->prm.wakeupExFuncTbl; funcEntry->localStep != 0;
+ funcEntry++) {
+ if (funcEntry->localStep == p_prm->localStep) {
+ funcEntry->func(funcEntry->prm);
+ }
+ maxStep = TSKM_MAX(maxStep, funcEntry->localStep);
+ }
+ return maxStep;
+}
+
+/*********************************************
+ * Gradual startup request
+ *********************************************/
+TSKM_STATIC void wakeupRequest(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t prm = *p_prm;
+ uint32_t max = 0;
+
+ // Execute step by step
+ for (prm.localStep = p_ctx->wakeupStepDone + 1;
+ (prm.localStep <= p_prm->localStep && prm.localStep < PRIM_STEPFORK_MAX);
+ prm.localStep++) {
+ max = wakeupExFuncCallback(p_ctx, &prm);
+ }
+
+ if (max <= p_prm->localStep) {
+ // Completed gradual startup
+ p_ctx->wakeupStepDone = PRIM_STEPFORK_MAX;
+ } else {
+ p_ctx->wakeupStepDone = p_prm->localStep;
+ }
+}
+
+/*********************************************
+ * All startup requests
+ *********************************************/
+TSKM_STATIC void allWakeup(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ if (!p_ctx->shmDone) {
+ shmMake(p_ctx);
+ }
+
+ if (p_ctx->wakeupStepDone < PRIM_STEPFORK_MAX) {
+ wakeupRequest(p_ctx, p_prm);
+ }
+}
+
+/*********************************************
+ * Startup request handles
+ *********************************************/
+TSKM_STATIC void wakeupRequestHandle(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+
+ bzero(&ev, sizeof(ev));
+
+ p_ctx->svcId = p_prm->svcId;
+ memcpy(&p_ctx->bootInfo, &p_prm->bootInfo, sizeof(p_ctx->bootInfo));
+ memcpy(&p_ctx->extBootInfo, &p_prm->extBootInfo, sizeof(p_ctx->extBootInfo));
+ p_ctx->isDynamic = p_prm->isDynamic;
+
+ if (p_prm->localStep == TSKM_LSTEP_ALL) {
+ allWakeup(p_ctx, p_prm);
+ } else if (p_prm->localStep == TSKM_LSTEP_LAST) {
+ wakeupRequest(p_ctx, p_prm);
+ } else if (p_prm->localStep == TSKM_LSTEP_SHM) {
+ shmMake(p_ctx);
+ } else {
+ wakeupRequest(p_ctx, p_prm);
+ }
+
+ ev.prm.resWakeup.isShmDone = p_ctx->shmDone;
+ ev.prm.resWakeup.isStepDone =
+ (p_ctx->wakeupStepDone >= PRIM_STEPFORK_MAX) ?
+ TSKM_TRUE :
+ TSKM_FALSE;
+
+ // LCOV_EXCL_BR_START 6: Because it depends on the test order
+ if (ev.prm.resWakeup.isShmDone && ev.prm.resWakeup.isStepDone) {
+ // LCOV_EXCL_BR_STOP
+ ev.prm.resWakeup.isLast = TSKM_TRUE;
+ }
+
+ ev.event = TSKM_EV_PRI_RES_WAKEUP;
+ ev.errCode = TSKM_E_OK;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+}
+
+/*********************************************
+ * Gradual termination callback
+ *********************************************/
+TSKM_STATIC uint32_t downExFuncCallback(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
+ const PRIM_EXFUNC_TBL* funcEntry;
+ uint32_t maxStep = 0;
+
+ for (funcEntry = p_ctx->prm.downExFuncTbl; funcEntry->localStep != 0;
+ funcEntry++) {
+ if (funcEntry->localStep == p_prm->localStep) {
+ funcEntry->func(funcEntry->prm);
+ }
+ maxStep = TSKM_MAX(maxStep, funcEntry->localStep);
+ }
+ return maxStep;
+}
+
+/*********************************************
+ * Gradual termination requests
+ *********************************************/
+TSKM_STATIC void downRequest(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
+ TSKM_EV_PRI_REQ_DOWN_PRM_t prm = *p_prm;
+ uint32_t max = 0;
+
+ // Execute step by step
+ for (prm.localStep = p_ctx->downStepDone + 1;
+ (prm.localStep <= p_prm->localStep && prm.localStep < PRIM_ACCOFF_MAX);
+ prm.localStep++) {
+ max = downExFuncCallback(p_ctx, &prm);
+ }
+
+ if (max <= p_prm->localStep) {
+ p_ctx->downStepDone = PRIM_ACCOFF_MAX; // Completed all steps
+ } else {
+ p_ctx->downStepDone = p_prm->localStep;
+ }
+}
+
+TSKM_STATIC void downRequestHandle(PRI_CTX_t* p_ctx,
+ TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+
+ bzero(&ev, sizeof(ev));
+
+ if (p_prm->localStep == TSKM_LSTEP_ALL || p_prm->localStep == TSKM_LSTEP_LAST) {
+ downRequest(p_ctx, p_prm);
+ } else if (p_prm->localStep == TSKM_LSTEP_SHM) {
+ TSKM_ASSERT(0);
+ } else if (p_prm->localStep == TSKM_LSTEP_BUPCHK) {
+ TSKM_ASSERT(0);
+ } else {
+ downRequest(p_ctx, p_prm);
+ }
+
+ if (p_ctx->downStepDone >= PRIM_ACCOFF_MAX) {
+ /* It is not notified when the last function is executed, and it is left to the exitDone.
+ TSKM_PRINTF(TSKM_LOG_DEBUG,"ACCOFF DONE");
+ ev.prm.resDown.isLast = TSKM_TRUE;
+ p_ctx->isExec = TSKM_FALSE;
+ ret = tskm_sockSend(p_ctx->connFd,&ev);
+ if(ret <= 0){
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ }
+ */
+ } else {
+ ev.event = TSKM_EV_PRI_RES_DOWN;
+ ev.errCode = TSKM_E_OK;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+ }
+}
+
+/*********************************************
+ * Termination completion notification to the TSKM
+ *********************************************/
+TSKM_STATIC void sendLastDoneRes(PRI_CTX_t* p_ctx) {
+ int ret;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+
+ ev.event = TSKM_EV_PRI_RES_DOWN;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.resDown.isLast = TSKM_TRUE;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+}
+
+/*********************************************
+ * Call Touch CB
+ *********************************************/
+TSKM_STATIC void touchService(PRI_CTX_t* p_ctx) {
+ char touchName[32];
+
+ if (p_ctx->isExitStart) {
+ // If termination has already begun, the system just processes as timeout for retrying not respond Touch
+ return;
+ }
+
+ p_ctx->prm.onTouch(p_ctx->hApp);
+
+ tskm_pf_mkTouchFileName(getpid(), touchName);
+
+ if ((access(touchName, F_OK) == 0)) {
+ // Synchronize by deleting files.
+ TSKM_PRINTF(TSKM_LOG_STATE, "del:%s", touchName);
+ unlink(touchName);
+ } else {
+ TSKM_ASSERT_PRINT(0, "%s", touchName);
+ }
+}
+
+/*********************************************
+ * Call Debugdump CB
+ *********************************************/
+TSKM_STATIC void callDebugDump(PRI_CTX_t* p_ctx) {
+ if (!p_ctx->prm.onDebugDump) { // LCOV_EXCL_BR_LINE 6: As NULL checked by INI_Init
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: As NULL checked by INI_Init
+ } else {
+ p_ctx->prm.onDebugDump(p_ctx->hApp);
+ }
+}
+
+/*********************************************
+ * Call LowMemory detection
+ *********************************************/
+TSKM_STATIC void callLowMem(PRI_CTX_t* p_ctx) {
+ if (!p_ctx->prm.onLowMem) {
+ TSKM_ASSERT(0);
+ } else if (!p_ctx->isExitStart) {
+ // Notify LowMemory only before starting terminating process
+ p_ctx->prm.onLowMem(p_ctx->hApp);
+ }
+}
+
+/*********************************************
+ * Event handles
+ *********************************************/
+TSKM_STATIC void eventHandle(PRI_CTX_t* p_ctx, TSKM_EVENT_INFO_t* p_ev) {
+ //Processing according to the request
+ switch (p_ev->event) {
+ case TSKM_EV_PRI_REQ_WAKEUP:
+ wakeupRequestHandle(p_ctx, &p_ev->prm.reqWakeup);
+ break;
+ case TSKM_EV_PRI_REQ_DOWN:
+ downRequestHandle(p_ctx, &p_ev->prm.reqDown);
+ break;
+ case TSKM_EV_PRI_REQ_TOUCH:
+ touchService(p_ctx);
+ break;
+ case TSKM_EV_PRI_REQ_DEBUGDUMP:
+ callDebugDump(p_ctx);
+ break;
+ case TSKM_EV_PRI_REP_LOWMEM:
+ callLowMem(p_ctx);
+ break;
+ default:
+ TSKM_ASSERT(0);
+ break;
+ }
+}
+
+/*********************************************
+ * Initialize Context
+ *********************************************/
+TSKM_STATIC void initCtx(T_PRIM_PRM* p_prm, PRI_CTX_t* p_ctx, int argc,
+ char* argv[]) {
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+
+ p_ctx->prm = *p_prm;
+
+ cbFuncs.onInitilization = p_ctx->prm.onInit;
+ cbFuncs.onDestroy = p_ctx->prm.onDestory;
+ cbFuncs.onDebugDump = p_ctx->prm.onDebugDump;
+ cbFuncs.onStart = FrameworkunifiedOnStart;
+ cbFuncs.onStop = FrameworkunifiedOnStop;
+ cbFuncs.createStateMachine = FrameworkunifiedCreateStateMachine;
+ cbFuncs.ssFrameworkInterface = FrameworkunifiedSSFrameworkInterface;
+
+ EFrameworkunifiedStatus taskmanagerRet;
+ taskmanagerRet = FrameworkunifiedCreateDispatcherWithoutLoop(p_ctx->prm.name, p_ctx->hApp, argc,
+ argv, &cbFuncs, FALSE);
+ if (eFrameworkunifiedStatusOK != taskmanagerRet) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+
+ taskmanagerRet = FrameworkunifiedGetDispatcherFD(p_ctx->hApp, &p_ctx->nsFd);
+ if (taskmanagerRet != eFrameworkunifiedStatusOK) {
+ TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
+ exit(EXIT_FAILURE);
+ }
+ p_ctx->connFd = tskm_cliSockConnect(TSKM_SOCKET_NAME);
+ if (p_ctx->connFd < 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+ if (pipe(p_ctx->pipeFd) != 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+
+ return;
+
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************
+ * Destroy context
+ *********************************************/
+TSKM_STATIC void termCtx(PRI_CTX_t* p_ctx) {
+ if (p_ctx->shmDone) { // LCOV_EXCL_BR_LINE 6: Since it has been set to True by INI_Handler and cannot be changed
+ const PRIM_SHAREDATA_TBL* shmEntry = p_ctx->prm.shmTbl;
+ for (shmEntry = p_ctx->prm.shmTbl; shmEntry->shmName[0] != '\0';
+ shmEntry++) {
+ TSKM_ASSERT(0 == tskm_pf_shmDelete(shmEntry->shmName)); // LCOV_EXCL_BR_LINE 8: For processing in which only return value 0 is set
+ }
+ }
+
+ if (p_ctx->connFd > 0) { // LCOV_EXCL_BR_LINE 6: For processing in which only return value 0 is set
+ tskm_sockDestory(p_ctx->connFd);
+ }
+
+ EFrameworkunifiedStatus taskmanagerRet;
+ taskmanagerRet = FrameworkunifiedDestroyDispatcherWithoutLoop(p_ctx->hApp);
+ TSKM_ASSERT(taskmanagerRet == eFrameworkunifiedStatusOK);
+
+ if (p_ctx->isDynamic) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "EXIT %s", p_ctx->procName);
+ } else {
+ // Hung up running services to prevent adversely affecting to system termination processing during process termination processing
+ sleep(TSKM_CFG_WAIT_SHUTDOWN);
+ }
+}
+
+/*******************************************************************
+ * Initialize PRI context
+ *******************************************************************/
+void pri_init(T_PRIM_PRM* p_prm, int argc, char* argv[], int *fdNum,
+ int fdlist[INI_FD_MAX]) {
+ int ret = 0;
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ strncpy(p_ctx->procName, basename(argv[0]), sizeof(p_ctx->procName) - 1);
+
+ ret = tskm_pf_procInit();
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 6: Return value of 0 only
+ // LCOV_EXCL_START 6: Return value of 0 only
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 6: Return value of 0 only
+ }
+
+ ret = tskm_comm_procInit();
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ }
+
+ initCtx(p_prm, p_ctx, argc, argv);
+
+ *fdNum = 3;
+ fdlist[0] = p_ctx->connFd;
+ fdlist[1] = p_ctx->pipeFd[0];
+ fdlist[2] = p_ctx->nsFd;
+
+ p_ctx->svcId = TSKM_SVCID_NONE;
+ p_ctx->isExec = TSKM_TRUE;
+
+ p_ctx->bootInfo.startupReason = epswfINVALID;
+ p_ctx->bootInfo.isUserModeOn = FALSE;
+ p_ctx->bootInfo.dataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
+ p_ctx->bootInfo.securityStatus = epsssINVALID;
+ p_ctx->bootInfo.wakeupType = epsstINVALID;
+ p_ctx->bootInfo.dramBackupStatus = e_SS_SM_DRAM_BACKUP_UNSET;
+ p_ctx->bootInfo.resetStatus = e_SS_SM_RESET_STATUS_UNSET;
+
+ memset(&p_ctx->extBootInfo, 0, sizeof(p_ctx->extBootInfo));
+
+ p_ctx->timeout = PRI_MONITOR_DEFAULT_TIMEOUT;
+
+ return;
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort(); // ABORT
+// LCOV_EXCL_STOP
+}
+
+/*******************************************************************
+ * Primary library handler
+ *******************************************************************/
+BOOL pri_handler(fd_set* p_fds) {
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ if (FD_ISSET(p_ctx->connFd, p_fds)) {
+ int ret;
+ TSKM_EVENT_INFO_t ev;
+ ret = tskm_sockRcv(p_ctx->connFd, &ev);
+ // LCOV_EXCL_BR_START 5: True condition is checked in Death tests, but not reflected in coverage and excluded
+ if (ret > 0) {
+ // LCOV_EXCL_BR_STOP
+ eventHandle(p_ctx, &ev);
+ } else { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (FD_ISSET(p_ctx->pipeFd[0], p_fds)) {
+ // only use exitDone
+ uint32_t tmp;
+ TSKM_ASSERT(sizeof(tmp) == read(p_ctx->pipeFd[0], &tmp, sizeof(tmp)));
+ TSKM_ASSERT(p_ctx->downStepDone == PRIM_ACCOFF_MAX); // Check if all exit functions are complete
+ if (p_ctx->isDynamic) {
+ // A nonresident service completes its termination processing by terminating the process (because the SIGNAL will overtake the sockets)
+ } else {
+ // The resident service completes termination processing with a termination notice (Do not terminate processes to reduce the impact on system termination)
+ sendLastDoneRes(p_ctx);
+ }
+ p_ctx->isExec = TSKM_FALSE;
+ }
+
+ if (FD_ISSET(p_ctx->nsFd, p_fds)) {
+ FrameworkunifiedDispatchProcessWithoutLoop(p_ctx->hApp);
+ }
+ return p_ctx->isExec;
+
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort(); // ABORT
+ return 0;
+// LCOV_EXCL_STOP
+}
+
+/*******************************************************************
+ * Process termination
+ *******************************************************************/
+void pri_term(void) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ termCtx(p_ctx);
+}
+
+/*******************************************************************
+ * Service Monitoring Status Setting
+ *******************************************************************/
+int pri_setMonitorState(BOOL bIsRun, uint32_t timeout) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ int ret = INI_SUCCESS;
+
+ if (TSKM_SVCID_NONE == p_ctx->svcId) {
+ // Ignore requests until svcId is acquired
+ } else if ((TRUE == bIsRun) && (0 == timeout)) {
+ // When RUN is specified with timeout = 0, monitoring is disabled
+ } else {
+ ret = tskm_comm_setSvcWatchState(p_ctx->svcId, bIsRun, timeout);
+ if (INI_SUCCESS != ret) {
+ TSKM_ASSERT(0);
+ }
+ }
+
+ return ret;
+}
+
+/*******************************************************************
+ * MAIN function
+ *******************************************************************/
+int pri_main(T_PRIM_PRM* p_prm, int argc, char* argv[]) {
+ int mainRet = -1;
+ int fdlist[INI_FD_MAX];
+ int fdNum;
+ int ii;
+ BOOL isExec = TRUE;
+
+ pri_init(p_prm, argc, argv, &fdNum, fdlist);
+
+ while (isExec) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ int maxFd = 0;
+ fd_set fds;
+ int ret;
+
+ FD_ZERO(&fds);
+
+ for (ii = 0; ii < fdNum; ii++) {
+ FD_SET(fdlist[ii], &fds);
+ maxFd = TSKM_MAX(fdlist[ii], maxFd);
+ }
+
+ TSKM_ASSERT(INI_SUCCESS == pri_setMonitorState(FALSE, 0));
+ ret = select(maxFd + 1, &fds, NULL, NULL, NULL);
+ TSKM_ASSERT(INI_SUCCESS == pri_setMonitorState(TRUE, p_ctx->timeout));
+ if (ret < 1) {
+ if (errno != EINTR) {
+ TSKM_ASSERT(0);
+ }
+ continue;
+ }
+
+ isExec = pri_handler(&fds);
+ }
+
+ mainRet = 0;
+
+ pri_term();
+ return mainRet;
+}
+
+/*******************************************************************
+ * Termination request
+ *******************************************************************/
+void pri_exitStart(void *rsv) {
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+ p_ctx->isExitStart = TRUE;
+ ev.event = TSKM_EV_PRI_REQ_EXIT;
+ ev.errCode = TSKM_E_OK;
+
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ return;
+ // LCOV_EXCL_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_abort();
+ // LCOV_EXCL_STOP
+}
+
+void pri_exitDone(int status) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ uint32_t l_status = (uint32_t) status;
+
+ // LCOV_EXCL_BR_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
+ if (p_ctx->pipeFd[1] > 0) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(
+ write(p_ctx->pipeFd[1], &l_status, sizeof(l_status))
+ == sizeof(l_status));
+ // LCOV_EXCL_STOP
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
+ }
+}
+
+/*******************************************************************
+ * Event completion notification at startup
+ *******************************************************************/
+int32_t pri_stepForkComp(uint64_t id) {
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+ ev.event = TSKM_EV_PRI_REP_WAKEUP_COMP;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.repWakeupComp.compId = id;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ return INI_SUCCESS;
+ ERROR: return INI_FALSE;
+}
+
+/*******************************************************************
+ * Event completion notification at termination
+ *******************************************************************/
+int32_t pri_accOffComp(uint64_t id) {
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+
+ ev.event = TSKM_EV_PRI_REP_DOWN_COMP;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.repDownComp.compId = id;
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ return INI_SUCCESS;
+ ERROR: return INI_FALSE;
+}
+
+/*******************************************************************
+ * Get private info
+ *******************************************************************/
+void*
+pri_getPrivate() {
+ PRI_CTX_t* p_ctx = &g_pri;
+ return p_ctx->prm.priv;
+}
+
+/*******************************************************************
+ * Get app-handle
+ *******************************************************************/
+HANDLE pri_getHandle() {
+ PRI_CTX_t* p_ctx = &g_pri;
+ return p_ctx->hApp;
+}
+
+/*******************************************************************
+ * Service monitoring status setting timeout setting
+ *******************************************************************/
+int32_t pri_setMonitorTimeout(uint32_t timeout) {
+ PRI_CTX_t* p_ctx = &g_pri;
+ p_ctx->timeout = timeout;
+ return INI_SUCCESS;
+}
+
+/*******************************************************************
+ * Get boot info
+ *******************************************************************/
+int32_t pri_getBootInfo(T_SS_SM_START_DataStructType *info) {
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ if (p_ctx->bootInfo.startupReason == epswfINVALID) {
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+
+ *info = p_ctx->bootInfo;
+
+ return INI_SUCCESS;
+}
+
+/*******************************************************************
+ * Get extended boot info
+ *******************************************************************/
+int32_t pri_getExtBootInfo(T_SS_SM_START_ExtDataStructType *info) {
+ PRI_CTX_t* p_ctx = &g_pri;
+
+ if (p_ctx->bootInfo.startupReason == epswfINVALID) {
+ TSKM_ASSERT(0);
+ return INI_FALSE;
+ }
+
+ *info = p_ctx->extBootInfo;
+
+ return INI_SUCCESS;
+}
+
+/*******************************************************************
+ * DebugDump response
+ *******************************************************************/
+void pri_sendDebugDumpRes(const char *buf) { // LCOV_EXCL_START 7: Debugging code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ int ret;
+ PRI_CTX_t* p_ctx = &g_pri;
+ TSKM_EVENT_INFO_t ev;
+ TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *p_prm;
+
+ ev.event = TSKM_EV_PRI_RES_DEBUGDUMP;
+ ev.errCode = TSKM_E_OK;
+ ev.hasExtend = TSKM_TRUE;
+
+ ev.extendPrm = malloc(sizeof(TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t));
+ if (!ev.extendPrm) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ ev.extendSize = sizeof(TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t);
+
+ p_prm = (TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *) ev.extendPrm; // NOLINT (readability/casting)
+ snprintf(p_prm->dumpMsg, TSKM_EV_DEBUGDUMP_SIZE, "%s", buf);
+
+ ret = tskm_sockSend(p_ctx->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ }
+
+ ERROR: return;
+}
+// LCOV_EXCL_STOP
+/*************************************************
+ * Empty functions implemented for building software
+ **************************************************/
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
diff --git a/systemservice/task_manager/server/src/tskm_api.cpp b/systemservice/task_manager/server/src/tskm_api.cpp
new file mode 100755
index 0000000..94c8226
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_api.cpp
@@ -0,0 +1,268 @@
+/*
+ * @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.
+ */
+
+#include "tskm_debug.h"
+#include "tskm_main.h"
+#include "tskm_state.h"
+#include "tskm_util.h"
+
+#include "tskm_srvr.h"
+#include "tskm_port_pf.h"
+#include "tskm_port_subsys.h"
+
+/**
+ * _TSKM_SvcCtl Sub-func Task-startup-process
+ * @param svcId service id
+ * @param p_main TSKM_MAIN_CTX_t*
+ * @param p_svc TSKM_SVC_CTX_t*
+ * @return TSKM_E_OK Succeeded
+ * @return other Failed
+ */
+
+TSKM_ERR_t tskm_svcExecRequest(TSKM_SVCID_t svcId, TSKM_MAIN_CTX_t* p_main, TSKM_SVC_CTX_t* p_svc) {
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+
+ // Startup tasks
+ TSKM_GSTEP_REQ_INFO_t req = { 0 };
+
+ if (p_main->isOnStartDone == TSKM_FALSE) {
+ TSKM_PRINTF(TSKM_LOG_WARN, "Transient SVC cannot exec before get BootInfo");
+ return TSKM_E_STATE;
+ } else if (p_main->isOnStopDone == TSKM_TRUE) {
+ TSKM_PRINTF(TSKM_LOG_WARN, "Transient SVC cannot exec after FrameworkunifiedOnStop");
+ return TSKM_E_STATE;
+ }
+
+ tskmRet = tskm_svcExec(p_svc);
+ TSKM_ERR_CHK_DFT;
+ if (p_svc->state == TSKM_SVC_WAITCONNECT) {
+ // In the state of waiting to execute
+ req.svcId = svcId;
+ req.localStep = TSKM_LSTEP_ALL;
+ tskmRet = tskm_svcWakeupRequest(p_svc, &req);
+ TSKM_ERR_CHK_DFT; // LCOV_EXCL_BR_LINE 6: Because TSKM_ERR_CHK_DFT does not specify a condition for goto to ERROR
+ }
+ ERROR: return tskmRet;
+}
+
+/**
+ * _TSKM_SvcCtl Sub-func Task-startup-process
+ * @param p_main TSKM_MAIN_CTX_t*
+ * @param svcId TSKM_SVCID_t
+ * @return TSKM_E_OK Succeeded
+ * @return other Failed
+ */
+
+TSKM_ERR_t tskm_svcReserveRequest(TSKM_MAIN_CTX_t* p_main, TSKM_SVCID_t svcId) {
+ uint8_t rsvSvcNum = p_main->nvInfo.body.rsvSvcNum;
+ TSKM_SVCID_t* p_rsvSvcs = p_main->nvInfo.body.rsvSvcs;
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+
+ if (rsvSvcNum >= TSKM_SVC_RESERVE_MAX) {
+ tskmRet = TSKM_E_STATE;
+ } else {
+ int ii;
+ int ret;
+
+ for (ii = 0; ii < rsvSvcNum; ii++) {
+ if (p_rsvSvcs[ii] == svcId) {
+ TSKM_ASSERT_PRINT(0, "Rsv Req already registered(%d)", svcId);
+ // Return OK as continuable
+ return tskmRet;
+ }
+ }
+
+ p_rsvSvcs[rsvSvcNum] = svcId;
+ p_main->nvInfo.body.rsvSvcNum++;
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "Rsv Svc registered(%#x)", svcId);
+
+ ret = tskm_pf_nvFileWrite(&p_main->nvInfo); // LCOV_EXCL_BR_LINE 6: Return value of 0 only
+ if (ret == -1) {
+ TSKM_ASSERT(0);
+ tskmRet = TSKM_E_NG;
+ return tskmRet;
+ }
+ }
+ return tskmRet;
+}
+
+/**
+ * Service control
+ * @param svcId service id
+ * @param ctl control command
+ * @return TSKM_E_OK Succeeded
+ * @return other Failed
+ */
+TSKM_ERR_t _TSKM_SvcCtl(TSKM_SVCID_t svcId, const TSKM_SVC_CTL_t* ctl) {
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+ TSKM_MAIN_CTX_t* p_main = tskm_getMainCtx();
+
+ TSKM_SVC_CTX_t* p_svc;
+
+ if (ctl == NULL) {
+ TSKM_ASSERT(0);
+ return TSKM_E_PAR;
+ }
+
+ p_svc = tskm_svcsGetSvcBySvcId(&p_main->svcs, svcId);
+ if (p_svc == NULL) {
+ TSKM_ASSERT(0);
+ TSKM_PRINTF(TSKM_LOG_ERROR, "unknown svcId:%#x", svcId);
+ return TSKM_E_PAR;
+ }
+
+ TSKM_PRINTF(TSKM_LOG_API, "%s(%#x,%d)", __FUNCTION__, svcId, ctl->cmd);
+
+ if (ctl->cmd == TSKM_SVC_CMD_EXEC) {
+ tskmRet = tskm_svcExecRequest(svcId, p_main, p_svc);
+ } else if (ctl->cmd == TSKM_SVC_CMD_ENABLE) {
+ tskmRet = tskm_svcEnableRequest(p_svc);
+ TSKM_ERR_CHK_DFT; // LCOV_EXCL_BR_LINE 8: Because TSKM_ERR_CHK_DFT does not specify a condition for goto to ERROR
+
+ } else if (ctl->cmd == TSKM_SVC_CMD_DISABLE) {
+ tskmRet = tskm_svcDisableRequest(p_svc);
+ TSKM_ERR_CHK_DFT;
+
+ } else if (ctl->cmd == TSKM_SVC_CMD_RESERVE) {
+ tskmRet = tskm_svcReserveRequest(p_main, svcId);
+
+ } else {
+ return TSKM_E_PAR;
+ }
+
+ ERROR: return tskmRet;
+}
+
+/**
+ * Get service info
+ * @param svcId service id
+ * @param svcInfo[O] service info
+ * @return TSKM_E_OK Succeeded
+ * @return other Failed
+ */
+TSKM_ERR_t TSKM_SvcGetInfo(TSKM_SVCID_t svcId, TSKM_SVC_INFO_t* svcInfo) {
+// Do not LOG acquisition APIs TSKM_PRINTF(TSKM_LOG_API,"%s()",__FUNCTION__)
+
+ TSKM_MAIN_CTX_t* p_main = tskm_getMainCtx();
+ TSKM_SVC_CTX_t* p_svc = tskm_svcsGetSvcBySvcId(&p_main->svcs, svcId);
+
+ if (p_svc == NULL || svcInfo == NULL) {
+ return TSKM_E_PAR;
+ }
+
+ svcInfo->svcId = p_svc->attr->svcId;
+ svcInfo->isExecDisable =
+ (p_svc->state == TSKM_SVC_DISABLE) ? TSKM_TRUE : TSKM_FALSE;
+
+ return TSKM_E_OK;
+}
+
+RPC_Result _TSKM_ErrorReboot(const TSKM_ERROR_REBOOT_t* p_info) {
+ RPC_Result rpcRet = RPC_OK;
+ TSKM_ERROR_REBOOT_t rebootInfo;
+
+ if (!p_info || (p_info->type != TSKM_ERROR_REBOOT_NORMAL)) {
+ TSKM_ASSERT(0);
+ return RPC_ERR_Fatal;
+ }
+
+ memset(&rebootInfo, 0, sizeof(TSKM_ERROR_REBOOT_t));
+ rebootInfo.type = p_info->type;
+ snprintf(rebootInfo.log.messageStr, TSKM_LOGGING_MSG_STR_SIZE, "%s",
+ p_info->log.messageStr);
+
+ TSKM_PRINTF(TSKM_LOG_API, "%s(%d)", __FUNCTION__, p_info->type);
+
+ tskm_sub_reboot(&rebootInfo);
+
+ return rpcRet;
+}
+
+/**
+ * Reboot service
+ * @param p_rsv Reserved
+ * @return TSKM_E_OK Succeeded
+ * @return other Failed
+ */
+TSKM_ERR_t TSKM_Reboot(const TSKM_RSV_t * p_rsv) {
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+
+ TSKM_PRINTF(TSKM_LOG_API, "%s()", __FUNCTION__)
+ if (p_rsv != NULL) {
+ TSKM_ASSERT(0);
+ return TSKM_E_PAR;
+ }
+
+ tskm_sub_reboot_normal();
+
+ return tskmRet;
+}
+
+/**
+ * Save LOGs
+ * @param p_info LOG storage info
+ * @return TSKM_E_OK Succeeded
+ * @return other Failed
+ */
+TSKM_ERR_t TSKM_Logging(const TSKM_LOGGING_INFO_t* p_info) {
+ TSKM_LOGGING_INFO_t logInfo;
+ TSKM_PRINTF(TSKM_LOG_API, "%s()", __FUNCTION__)
+
+ if (!p_info) {
+ TSKM_ASSERT(0);
+ return TSKM_E_PAR;
+ } else {
+ switch (p_info->type) {
+ case TSKM_LOGGING_TYPE_MODULE_LOGS:
+ case TSKM_LOGGING_TYPE_GRP_RELAUNCH:
+ break;
+ default:
+ TSKM_ASSERT(0);
+ return TSKM_E_PAR;
+ }
+ }
+
+ logInfo.type = p_info->type;
+ snprintf(logInfo.messageStr, TSKM_LOGGING_MSG_STR_SIZE, "%s",
+ p_info->messageStr);
+
+ tskm_sub_logging(&logInfo);
+
+ return TSKM_E_OK;
+}
+
+TSKM_ERR_t TSKM_SetWakeupOrder(const TSKM_WAKEUP_ORDER_t* p_order) {
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+
+ TSKM_PRINTF(TSKM_LOG_API, "%s()", __FUNCTION__)
+
+ if (p_order == NULL) {
+ return TSKM_E_PAR;
+ }
+
+ if (strnlen(p_order->orderName, TSKM_ORDER_NAME_MAX) >= TSKM_ORDER_NAME_MAX) {
+ return TSKM_E_PAR;
+ }
+
+ if (tskm_sub_setWakeupOrder(p_order->orderName) != 0) {
+ TSKM_ASSERT(0);
+ tskmRet = TSKM_E_NG;
+ }
+
+ return tskmRet;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/server/src/tskm_comm.cpp b/systemservice/task_manager/server/src/tskm_comm.cpp
new file mode 100755
index 0000000..b177b9b
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_comm.cpp
@@ -0,0 +1,402 @@
+/*
+ * @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.
+ */
+
+#ifndef _GNU_SOURCE
+#warning "_GNU_SOURCE not defined, so define here"
+#define _GNU_SOURCE
+#endif
+#include "tskm_comm.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <native_service/cl_monitor.h>
+
+#include "tskm_debug.h"
+#include "tskm_util.h"
+
+
+/**********************************************************
+ * Internal functions
+ **********************************************************/
+TSKM_STATIC TSKM_SRV_CONNENT_t*
+addConnFd(TSKM_SRV_CONNENT_LIST_t* list, TSKM_SRV_CONNENT_t* conn) {
+ TSKM_SRV_CONNENT_t* retConn;
+ if (list->num >= TSKM_COMM_CONNECT_MAX) {
+ TSKM_ASSERT(0)
+ return NULL;
+ }
+
+ retConn = &list->conn[list->num];
+ list->conn[list->num] = *conn;
+ list->num++;
+ return retConn;
+}
+
+TSKM_STATIC void delConnFd(TSKM_SRV_CONNENT_LIST_t* list,
+ TSKM_SRV_CONNENT_t* conn) {
+ uint32_t ii;
+ TSKM_BOOL_t isFind = TSKM_FALSE;
+ for (ii = 0; ii < list->num; ii++) {
+ if (!isFind && list->conn[ii].connFd == conn->connFd) {
+ isFind = TSKM_TRUE;
+ list->num--;
+ }
+
+ if (isFind && (ii < list->num)) {
+ list->conn[ii] = list->conn[ii + 1];
+ }
+ }
+ TSKM_ASSERT(isFind);
+}
+
+/**********************************************************
+ * Public functions
+ **********************************************************/
+TSKM_ERR_t tskm_srvSockCreate(const char *sockName,
+ TSKM_SRV_SOCK_CTX_t* p_sock) {
+ int fd = -1;
+ int ret;
+ int sockRet;
+ int enable = 1;
+ int listenNum = TSKM_COMM_CONNECT_MAX;
+
+ struct sockaddr_un unix_addr = { };
+
+ fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
+ if (fd < 0) { // LCOV_EXCL_BR_LINE 5: For processing initializing process
+ // LCOV_EXCL_START 5: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if (0 == access(sockName, F_OK)) { // LCOV_EXCL_BR_LINE 5: For processing initializing process
+ TSKM_ASSERT(0);
+ unlink(sockName);
+ }
+
+ unix_addr.sun_family = AF_UNIX;
+ strncpy(unix_addr.sun_path, sockName, sizeof(unix_addr.sun_path) - 1);
+
+ sockRet = bind(fd, (struct sockaddr *) &unix_addr, sizeof(unix_addr));
+ if (sockRet != 0) { // LCOV_EXCL_BR_LINE 5: For processing initializing process
+ // LCOV_EXCL_START 5: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ ret = chmod(sockName, S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: For processing initializing process
+ // LCOV_EXCL_START 5: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ sockRet = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable));
+ if (sockRet != 0) { // LCOV_EXCL_BR_LINE 5:For processing initializing process
+ // LCOV_EXCL_START 5: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ sockRet = listen(fd, listenNum);
+ if (sockRet != 0) { // LCOV_EXCL_BR_LINE 5: For process initialization processing
+ // LCOV_EXCL_START 5: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ memset(p_sock, 0, sizeof(*p_sock));
+ p_sock->sockFd = fd;
+ p_sock->sockName = sockName;
+
+ return TSKM_E_OK;
+ // LCOV_EXCL_START 5: For process initialization processing
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (fd != -1) {
+ close(fd);
+ }
+ return TSKM_E_NG;
+ // LCOV_EXCL_STOP
+}
+
+TSKM_SRV_CONNENT_t*
+tskm_srvSockConnect(TSKM_SRV_SOCK_CTX_t* p_sock) {
+ int fd = -1;
+ socklen_t len;
+ int sockRet;
+ TSKM_SRV_CONNENT_t conn;
+ TSKM_SRV_CONNENT_t *retConn;
+ struct ucred credent;
+ struct sockaddr_un unix_addr;
+
+ memset(&conn, 0, sizeof(conn));
+ conn.connFd = -1;
+
+ len = sizeof(unix_addr);
+ fd = accept(p_sock->sockFd, (struct sockaddr*) &unix_addr,
+ (socklen_t *) &len); // NOLINT (readability/casting)
+ if (fd < 0) { // LCOV_EXCL_BR_LINE 5: Accept's Error-Handling Process
+ // LCOV_EXCL_START 5: Accept's Error-Handling Process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ conn.connFd = fd;
+
+ len = sizeof(credent);
+ sockRet = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &credent, &len);
+ if (sockRet != 0) { // LCOV_EXCL_BR_LINE 5: Getsockopt's Error-Handling Process
+ // LCOV_EXCL_START 5: Getsockopt's Error-Handling Process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ conn.pid = credent.pid;
+
+ retConn = addConnFd(&p_sock->connList, &conn);
+ if (retConn == NULL) { // LCOV_EXCL_BR_LINE 5: Connect's Error-Handling Process
+ // LCOV_EXCL_START 5: Connect's Error-Handling Process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ return retConn;
+ // LCOV_EXCL_START 5: Error-Handling Process
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (conn.connFd != -1) {
+ tskm_sockDestory(conn.connFd);
+ }
+ return NULL;
+ // LCOV_EXCL_STOP
+}
+
+void tskm_srvSockDisconnect(TSKM_SRV_SOCK_CTX_t* p_sock,
+ TSKM_SRV_CONNENT_t *p_conn) {
+ int fd = p_conn->connFd;
+ delConnFd(&p_sock->connList, p_conn);
+ tskm_sockDestory(fd);
+}
+
+void tskm_srvSockDestory(TSKM_SRV_SOCK_CTX_t* p_sock) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (p_sock->sockFd) {
+ tskm_sockDestory(p_sock->sockFd);
+ p_sock->sockFd = 0;
+
+ TSKM_ASSERT_ERRNO(0 == unlink(p_sock->sockName));
+ }
+}
+// LCOV_EXCL_STOP
+int tskm_cliSockConnect(const char* sockName) {
+ int fd = -1;
+ int sockRet;
+ struct sockaddr_un unix_addr = { };
+
+ /* Create socket */
+ fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
+ if (fd < 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ unix_addr.sun_family = AF_UNIX;
+ strncpy(unix_addr.sun_path, sockName, sizeof(unix_addr.sun_path) - 1);
+ sockRet = connect(fd, (struct sockaddr*) &unix_addr, sizeof(unix_addr));
+ if (sockRet < 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ return fd;
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (fd != -1) {
+ TSKM_ASSERT_ERRNO(0 == close(fd));
+ }
+ return -1;
+ // LCOV_EXCL_STOP
+}
+
+int tskm_sockRcv(int fd, TSKM_EVENT_INFO_t* p_ev) {
+ int ret;
+ TSKM_EVENT_INFO_t ev;
+ ret = static_cast<int>(recv(fd, &ev, sizeof(ev), 0));
+
+ // LCOV_EXCL_BR_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ if (ret > (int) sizeof(ev)) { // NOLINT (readability/casting)
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ if (ret > 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ TSKM_PRINTF(TSKM_LOG_MSG, "recv:%s from:%d ret:%d",
+ tskm_convEvent2Str(ev.event), ev.fromPid, ret);
+ }
+
+ *p_ev = ev;
+
+ if (p_ev->hasExtend && (0 != p_ev->extendSize)) {
+ TSKM_PRINTF(TSKM_LOG_MSG, "rcv:ex(%d) ", p_ev->extendSize);
+
+ p_ev->extendPrm = malloc(p_ev->extendSize);
+ if (!p_ev->extendPrm) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ ret = static_cast<int>(recv(fd, p_ev->extendPrm, p_ev->extendSize, 0));
+
+ // LCOV_EXCL_BR_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ if (ret > (int) p_ev->extendSize) { // NOLINT (readability/casting)
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ return ret;
+
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1;
+ // LCOV_EXCL_STOP
+}
+
+int tskm_sockSend(int fd, TSKM_EVENT_INFO_t* p_ev) {
+ int ret;
+ p_ev->fromPid = getpid();
+ TSKM_PRINTF(TSKM_LOG_MSG, "send:%s ", tskm_convEvent2Str(p_ev->event));
+ ret = static_cast<int>(send(fd, p_ev, sizeof(*p_ev), MSG_NOSIGNAL));
+ if (ret != sizeof(*p_ev)) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+ // Because it is entered only when called from a debugging function (pri_sendDebugDumpRes)
+ if (p_ev->hasExtend && p_ev->extendPrm && (0 != p_ev->extendSize)) {
+ TSKM_PRINTF(TSKM_LOG_MSG, "send:ex(%d) ", p_ev->extendSize);
+
+ ret = static_cast<int>(send(fd, p_ev->extendPrm, p_ev->extendSize, MSG_NOSIGNAL));
+ if (ret != (int)p_ev->extendSize) { // NOLINT (readability/casting)
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+ }
+
+ return ret;
+
+ ERROR: return -1;
+}
+
+void tskm_sockDestory(int fd) {
+ TSKM_ASSERT_ERRNO(0 == shutdown(fd, SHUT_RDWR));
+ TSKM_ASSERT_ERRNO(0 == close(fd));
+}
+
+/******************************************************************
+ * Initializing (Process)
+ ******************************************************************/
+int tskm_comm_procInit(void) {
+ int ret;
+
+ ret = CL_MonitorInit(CL_MONITOR_INIT_USER);
+
+ if (ret != 0) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ return 0;
+
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1;
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************************
+ * Service Error Monitoring Status Setting
+ *********************************************************/
+int tskm_comm_setSvcWatchState(uint32_t id, BOOL bIsRun, uint32_t timeout) {
+ int ret = 0;
+
+ CL_MonitorState_t state = CL_MONITOR_STATE_SLEEP;
+
+ if (bIsRun) {
+ state = CL_MONITOR_STATE_RUN;
+ }
+
+ ret = CL_MonitorSetEntry(CL_MONITOR_TYPE_GENERIC, id, state, timeout, 0);
+ if (0 != ret) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ return 0;
+ ERROR: return -1;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/server/src/tskm_debug.cpp b/systemservice/task_manager/server/src/tskm_debug.cpp
new file mode 100755
index 0000000..5881f9a
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_debug.cpp
@@ -0,0 +1,286 @@
+/*
+ * @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.
+ */
+
+#include "tskm_debug.h"
+
+const char*
+tskm_convState2Str(TSKM_STATE_t state) {
+ const char* ret = "UNKNONW";
+ switch (state) { // LCOV_EXCL_BR_LINE 7:debug code
+ case TSKM_ST_ACCOFF:
+ ret = "ACCOFF";
+ break;
+ case TSKM_ST_ACCON:
+ ret = "ACCON";
+ break;
+ case TSKM_ST_WAKEUP:
+ ret = "WAKEUP";
+ break;
+ case TSKM_ST_RUNNING:
+ ret = "RUNNING";
+ break;
+ case TSKM_ST_DOWN:
+ ret = "DOWN";
+ break;
+ }
+ return ret;
+}
+
+const char*
+tskm_convEvent2Str(TSKM_EVENT_t event) {
+ switch (event) { // LCOV_EXCL_BR_LINE 7:debug code
+ case TSKM_EV_NOP:
+ return "NOP";
+ case TSKM_EV_PRI_REQ_WAKEUP:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REQ_WAKEUP";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REQ_DOWN:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REQ_DOWN";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REQ_TOUCH:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REQ_TOUCH";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REQ_DEBUGDUMP:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REQ_DEBUGDUMP";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REP_LOWMEM:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REP_LOWMEM";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REP_WAKEUP_COMP:
+ return "PRI_REP_WAKEUP_COMP";
+ case TSKM_EV_PRI_REP_DOWN_COMP:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REP_DOWN_COMP";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REP_CONNECT:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REP_CONNECT";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REP_DISCONNECT:
+ return "PRI_REP_DISCONNECT";
+ case TSKM_EV_PRI_RES_WAKEUP:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_RES_WAKEUP";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_RES_DOWN:
+ return "PRI_RES_DOWN";
+ case TSKM_EV_PRI_RES_DEBUGDUMP:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_RES_DEBUGDUMP";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_PRI_REQ_EXIT:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "PRI_REQ_EXIT";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_SVC_REP_TERM:
+ return "SVC_REP_TERM";
+ case TSKM_EV_API_REQ_REBOOT:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "API_REQ_REBOOT";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_API_REQ_SVC_CTL:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "API_REQ_SVC_CTL";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_API_REQ_SVC_DISABLE:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "API_REQ_SVC_DISABLE";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_LCL_REQ_STOP:
+ return "API_REQ_STOP";
+ case TSKM_EV_LCL_CHG_SVC_STATE:
+ return "LCL_CHG_SVC_STATE";
+ case TSKM_EV_LCL_REQ_SDUMP:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "LCL_REQ_SDUMP";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_LCL_REP_TIMEOUT:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "LCL_REP_TIMEOUT";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_LCL_REP_POLLING:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "LCL_REP_POLLING";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_LCL_REP_LOWMEM:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "LCL_REP_LOWMEM";
+ // LCOV_EXCL_STOP
+ case TSKM_EV_LCL_REQ_TRANS_STEP:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "LCL_REQ_TRANS_STEP";
+ // LCOV_EXCL_STOP
+ default:
+ break;
+ }
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "UNKNOWN";
+ // LCOV_EXCL_STOP
+}
+
+const char*
+tskm_convInitCompId2Str(uint64_t compId) {
+ switch (compId) { // LCOV_EXCL_BR_LINE 7:debug code
+ case INI_INITCOMP_NONE:
+ return "NONE";
+ case INI_INITCOMP_ON_START:
+ return "ONSTART";
+ case INI_INITCOMP_NVM_ACCESS:
+ return "NVM_ACCESS";
+ case INI_INITCOMP_TEST0:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST0";
+ // LCOV_EXCL_STOP
+ case INI_INITCOMP_TEST1:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST1";
+ // LCOV_EXCL_STOP
+ case INI_INITCOMP_TEST2:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST2";
+ // LCOV_EXCL_STOP
+ case INI_INITCOMP_TEST3:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST3";
+ // LCOV_EXCL_STOP
+ }
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "UNKNONW";
+ // LCOV_EXCL_STOP
+}
+
+const char*
+tskm_convTermCompId2Str(uint64_t compId) {
+ switch (compId) { // LCOV_EXCL_BR_LINE 7:debug code
+ case INI_TERMCOMP_NONE:
+ return "NONE";
+ case INI_TERMCOMP_ACTIVITYMGR:
+ return "ACTIVITYMGR";
+ case INI_TERMCOMP_RESIDENT:
+ return "RESIDENT";
+ case INI_TERMCOMP_TRANSIENT:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TRANSIENT";
+ // LCOV_EXCL_STOP
+ case INI_TERMCOMP_TEST0:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST0";
+ // LCOV_EXCL_STOP
+ case INI_TERMCOMP_TEST1:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST1";
+ // LCOV_EXCL_STOP
+ case INI_TERMCOMP_TEST2:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST2";
+ // LCOV_EXCL_STOP
+ case INI_TERMCOMP_TEST3:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "TEST3";
+ // LCOV_EXCL_STOP
+ }
+ return "UNKNONW";
+}
+
+const char*
+tskm_convSvcState2Str(TSKM_SVC_STATE_t state) {
+ switch (state) { // LCOV_EXCL_BR_LINE 7:debug code
+ case TSKM_SVC_DORMANT:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "DORMANT";
+ // LCOV_EXCL_STOP
+ case TSKM_SVC_WAITCONNECT:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "WAITCONNECT";
+ // LCOV_EXCL_STOP
+ case TSKM_SVC_WAKEUP:
+ return "WAKEUP";
+ case TSKM_SVC_RUNNING:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "RUNNING";
+ // LCOV_EXCL_STOP
+ case TSKM_SVC_DOWN:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "DOWN";
+ // LCOV_EXCL_STOP
+ case TSKM_SVC_FINDOWN:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "FINDOWN";
+ // LCOV_EXCL_STOP
+ case TSKM_SVC_DISABLE:
+ // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return "DISABLE";
+ // LCOV_EXCL_STOP
+ default:
+ break;
+ }
+ return "UNKNONW";
+}
+
+TSKM_STATIC void svcDump(TSKM_SVC_CTX_t* p_svc) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "<%s>", p_svc->attr->name);
+ TSKM_PRINTF(TSKM_LOG_STATE, " pid:%d svcId:%#x state:%s waitResCnt:%d",
+ p_svc->pid, p_svc->attr->svcId,
+ tskm_convSvcState2Str(p_svc->state), p_svc->waitResCnt);
+}
+
+void tskm_svcsDump(TSKM_SVCS_CTX_t* p_svcs) {
+ uint32_t ii;
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ svcDump(&p_svcs->svcList[ii]);
+ }
+}
+
diff --git a/systemservice/task_manager/server/src/tskm_main.cpp b/systemservice/task_manager/server/src/tskm_main.cpp
new file mode 100755
index 0000000..33c10fa
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_main.cpp
@@ -0,0 +1,727 @@
+/*
+ * @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.
+ */
+
+#include "tskm_main.h"
+#include <stdio.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/inotify.h>
+#include <getopt.h>
+#include <system_service/ss_services.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <system_service/ss_system_if.h>
+#include <system_service/ss_version.h>
+#include <system_service/ss_templates.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <other_service/rpc.h>
+#include <system_service/resm.h>
+
+#include "tskm_data_init_local.h"
+#include "tskm_port_pf.h"
+#include "tskm_port_subsys.h"
+#include "tskm_debug.h"
+#include "tskm_util.h"
+#include "tskm_srvr.h"
+#include "tskm_comm.h"
+#include "tskm_watch.h"
+#include "system_service/tskm_local_type.h"
+#include "system_service/tskm_xml_data.h"
+#include "tskm_state.h"
+
+#define TSKM_DATA_KEY "TSKM_KEY"
+
+TSKM_STATIC TSKM_MAIN_CTX_t g_mainCtx; // Main context
+
+TSKM_STATIC BOOL s_isVupMode = FALSE;
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
+
+// For NsLog
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
+FRAMEWORKUNIFIEDLOGOPTIONS, {
+ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ZONE_TEXT_31 }, FRAMEWORKUNIFIEDLOGZONES };
+
+EFrameworkunifiedStatus OnFinishLoadFile(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ int ret;
+ TSKM_MAIN_CTX_t* p_main = &g_mainCtx;
+ TSKM_EVENT_INFO_t ev;
+
+ ret = tskm_pf_nvFileRead(hApp, &p_main->nvInfo);
+ if (ret != 0) {
+ TSKM_ASSERT(0);
+ }
+
+ // issure INI_INITCOMP_NVM_ACCESS
+ bzero(&ev, sizeof(ev));
+ ev.event = TSKM_EV_PRI_REP_WAKEUP_COMP;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.repWakeupComp.compId = INI_INITCOMP_NVM_ACCESS;
+ tskm_handleEvent(p_main, &ev);
+
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus onDataInitRequest(HANDLE hApp) {
+ TSKM_ERR_t l_tskmRet = TSKM_E_OK;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSKM_MAIN_CTX_t* p_main = tskm_getMainCtx();
+
+ TSKM_PRINTF(TSKM_LOG_API, "%s()", __FUNCTION__)
+
+ if (p_main->bootInfo.startupReason == epswfINVALID) {
+ // Before issuing FrameworkunifiedOnStart = Requests before TaskManager became Availabile are not accepted
+ TSKM_ASSERT(0);
+ l_tskmRet = TSKM_E_STATE;
+ } else {
+ T_SS_SM_START_DataStructType bootInfo(epswfIGN_ACC, TRUE,
+ e_SS_SM_DATA_RESET_MODE_USER,
+ epsssUNLOCK, epsstWARMSTART,
+ e_SS_SM_DRAM_BACKUP_OK,
+ e_SS_SM_RESET_STATUS_NONE, 0);
+
+ T_SS_SM_START_ExtDataStructType extBootInfo;
+
+ memcpy(&extBootInfo, &p_main->extBootInfo, sizeof(extBootInfo));
+
+ // After updating the program,
+ // FALSE is notified here because it is notified when data initialization I/F is called at startup
+ extBootInfo.isProgUpdated = FALSE;
+
+ tskm_dataInitAll(&bootInfo, &extBootInfo);
+ }
+
+ PCSTR l_senderName = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_senderName) {
+ HANDLE hSession = FrameworkunifiedMcOpenSender(hApp, l_senderName);
+ if (hSession == NULL) {
+ TSKM_ASSERT(0);
+ } else {
+ TSKM_ASSERT(
+ eFrameworkunifiedStatusOK
+ == FrameworkunifiedSendMsg(hSession, TSKM_DATAINIT_RESP, sizeof(l_tskmRet),
+ &l_tskmRet));
+ TSKM_ASSERT(eFrameworkunifiedStatusOK == FrameworkunifiedMcClose(hSession));
+ }
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus onTransStepRequest(HANDLE hApp) { // LCOV_EXCL_START 6:Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_MAIN_CTX_t* p_main = &g_mainCtx;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TSKM_EVENT_INFO_t ev;
+ bzero(&ev, sizeof(ev));
+
+ ev.event = TSKM_EV_LCL_REQ_TRANS_STEP;
+ ev.errCode = TSKM_E_OK;
+ tskm_handleEvent(p_main, &ev);
+
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus OnResmAvailability(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_MAIN_CTX_t* p_main = &g_mainCtx;
+
+ if (0 != strcmp(NTFY_ResourceMgr_Availability, FrameworkunifiedGetLastNotification(hApp))) {
+ TSKM_ASSERT(0);
+ } else if (FrameworkunifiedIsServiceAvailable(hApp)) {
+ // Availability = TRUE
+
+ p_main->resmFd = tskm_sub_resmInit();
+ if (-1 == p_main->resmFd) {
+ TSKM_ASSERT(0);
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+//************ NS Framework Callback : must implemet ******************
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSKM_PRINTF(TSKM_LOG_STATE, "+");
+
+ l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hApp, NTFY_SS_TaskManager_Availability);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, FRAMEWORKUNIFIED_NS_NPSERVICE,
+ NPS_GET_PERS_FILE_ACK,
+ OnFinishLoadFile);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, FRAMEWORKUNIFIED_ANY_SOURCE,
+ TSKM_DATAINIT_REQ,
+ onDataInitRequest);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, FrameworkunifiedGetAppName(hApp),
+ TSKM_TRANS_STEP_REQ,
+ onTransStepRequest);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_ResourceMgr_Availability, OnResmAvailability);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "-");
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSKM_PRINTF(TSKM_LOG_STATE, "+");
+ l_eStatus = OnStart(hApp);
+ TSKM_PRINTF(TSKM_LOG_STATE, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSKM_PRINTF(TSKM_LOG_STATE, "+");
+ l_eStatus = OnStart(hApp);
+ TSKM_PRINTF(TSKM_LOG_STATE, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSKM_PRINTF(TSKM_LOG_STATE, "+");
+ l_eStatus = OnStart(hApp);
+ TSKM_PRINTF(TSKM_LOG_STATE, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ TSKM_MAIN_CTX_t* p_main = &g_mainCtx;
+ // Returns Fail to send asynchronous STOP reply to SM
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ TSKM_EVENT_INFO_t ev;
+ bzero(&ev, sizeof(ev));
+
+ ev.event = TSKM_EV_LCL_REQ_STOP;
+ ev.errCode = TSKM_E_OK;
+ tskm_handleEvent(p_main, &ev);
+
+ p_main->isOnStopDone = TSKM_TRUE;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ TSKM_MAIN_CTX_t* p_main = &g_mainCtx;
+ TSKM_ERR_t l_tskmRet;
+
+ // Call DebugDump of all running SVCs
+ l_tskmRet = tskm_svcsCallDebugDump(&p_main->svcs);
+ if (TSKM_E_OK != l_tskmRet) {
+ TSKM_ASSERT(0);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+/*********************************************************
+ * System start process
+ *********************************************************/
+EFrameworkunifiedStatus OnStart(const HANDLE hApp) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "+");
+ TSKM_MAIN_CTX_t* const p_main = &g_mainCtx;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (p_main->isOnStartDone == TSKM_FALSE) {
+ T_SS_SM_START_DataStructType startupInfo;
+ TSKM_EVENT_INFO_t ev;
+ l_eStatus = ReadMsg<T_SS_SM_START_DataStructType>(hApp, startupInfo);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ TSKM_ASSERT(0);
+ } else {
+ memcpy(&p_main->bootInfo, &startupInfo, sizeof(T_SS_SM_START_DataStructType));
+ }
+
+ if (0 != tskm_sub_getExtBootInfo(&p_main->extBootInfo)) {
+ TSKM_ASSERT(0);
+ }
+
+ tskm_dataInitAll(&p_main->bootInfo, &p_main->extBootInfo);
+
+ tskm_svcsSetBootInfo(&p_main->svcs, &p_main->bootInfo, &p_main->extBootInfo);
+ p_main->isOnStartDone = TSKM_TRUE;
+
+ l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ TSKM_ASSERT(0);
+ } else {
+ TSKM_PRINTF(TSKM_LOG_STATE, "Availability TRUE");
+ }
+
+ // Issure INI_INITCOMP_ON_START
+ bzero(&ev, sizeof(ev));
+ ev.event = TSKM_EV_PRI_REP_WAKEUP_COMP;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.repWakeupComp.compId = INI_INITCOMP_ON_START;
+ tskm_handleEvent(p_main, &ev);
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "-");
+ return l_eStatus;
+}
+
+/*********************************************************
+ * Argument analysis process
+ *********************************************************/
+TSKM_STATIC EFrameworkunifiedStatus argParser(SI_32 argument, PCHAR argumentValue) { // LCOV_EXCL_START 6: for process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if ('v' == argument) {
+ s_isVupMode = TRUE;
+ }
+
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+/*********************************************************
+ * Creating process for TSKM internal context
+ *********************************************************/
+TSKM_STATIC void ctxCreate(TSKM_MAIN_CTX_t* p_main, int argc, char* argv[]) {
+ int ret;
+ EFrameworkunifiedStatus taskmanagerRet;
+ TSKM_ERR_t tskmRet;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cbFuncs);
+ CustomCommandLineOptions cmdLineOpt = { "v", NULL, argParser };
+
+ p_main->state = TSKM_ST_ACCOFF;
+ p_main->isOnStartDone = TSKM_FALSE;
+
+ // Create dispatcher
+ taskmanagerRet = FrameworkunifiedCreateDispatcherWithoutLoop(SS_TASK_MANAGER, p_main->hApp, argc,
+ argv, &cbFuncs, TRUE, &cmdLineOpt);
+ if (eFrameworkunifiedStatusOK != taskmanagerRet) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_START 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "s_isVupMode :%s", s_isVupMode ? "TRUE" : "FALSE");
+
+ taskmanagerRet = FrameworkunifiedGetDispatcherFD(p_main->hApp, &p_main->nsFd);
+ if (taskmanagerRet != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_START 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP
+ }
+
+ p_main->sigFd = tskm_pf_sysInit(); // Platform initialization
+ if (p_main->sigFd == -1) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_LINE 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ p_main->iFd = inotify_init1(IN_CLOEXEC);
+ if (p_main->sigFd == -1) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_LINE 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ // Obtain RESM FDs after waiting for Availability
+ p_main->resmFd = -1;
+
+ tskmRet = tskm_srvSockCreate(TSKM_SOCKET_NAME, &p_main->sock);
+ TSKM_ERR_CHK(tskmRet, TSKM_E_OK, ERROR); // LCOV_EXCL_BR_LINE 6: For process initialization processing
+
+ ret = tskm_pf_nvFileInit(p_main->hApp);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_START 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ ret = tskm_initServiceList(&p_main->svcs, p_main->iFd); // Service to be started
+ if (0 != ret) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_START 6: For For process initialization process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ tskm_initWakeupCtx(&p_main->wakeup, s_isVupMode); // Gradual startup info
+ tskm_initDownCtx(&p_main->down, s_isVupMode); // Gradual termination info
+ return;
+
+ // LCOV_EXCL_START 6: For process initialization processing
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_exit(EXIT_FAILURE);
+ return;
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************************
+ * Get main context
+ *********************************************************/
+TSKM_MAIN_CTX_t*
+tskm_getMainCtx(void) {
+ return &g_mainCtx;
+}
+
+/*********************************************************
+ * Process initialization process (MAIN function sub)
+ *********************************************************/
+int Init_Process(int* rpcFd, int* sockFd, int* maxFd, fd_set* fds, TSKM_MAIN_CTX_t* p_main) {
+ int ret;
+ uint32_t ii;
+
+ TSKM_SRV_CONNENT_LIST_t* p_connList = &p_main->sock.connList;
+
+ FD_ZERO(fds);
+
+ FD_SET(*rpcFd, fds);
+ *maxFd = TSKM_MAX(*rpcFd, *maxFd); // LCOV_EXCL_BR_LINE 6: For process initialization processing
+
+ FD_SET(*sockFd, fds);
+ *maxFd = TSKM_MAX(*sockFd, *maxFd); // LCOV_EXCL_BR_LINE 6: For process initialization processing
+
+ FD_SET(p_main->nsFd, fds);
+ *maxFd = TSKM_MAX(p_main->nsFd, *maxFd); // LCOV_EXCL_BR_LINE 6: For process initialization processing
+
+ FD_SET(p_main->sigFd, fds);
+ *maxFd = TSKM_MAX(p_main->sigFd, *maxFd); // LCOV_EXCL_BR_LINE 6: For process initialization processing
+
+ if (-1 != p_main->resmFd) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_START 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FD_SET(p_main->resmFd, fds);
+ *maxFd = TSKM_MAX(p_main->resmFd, *maxFd);
+ // LCOV_EXCL_STOP
+ }
+
+ for (ii = 0; ii < p_connList->num; ii++) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ // LCOV_EXCL_START 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_SRV_CONNENT_t* p_conn = &p_connList->conn[ii];
+ FD_SET(p_conn->connFd, fds);
+ *maxFd = TSKM_MAX(p_conn->connFd, *maxFd);
+ // LCOV_EXCL_STOP
+ }
+
+ TSKM_PRINTF(TSKM_LOG_FUNC, "SELECT IN");
+ ret = select(*maxFd + 1, fds, NULL, NULL, NULL);
+ if (ret < 1) {
+ if (errno != EINTR) {
+ TSKM_ASSERT(0);
+ }
+ return ret;
+ }
+ TSKM_PRINTF(TSKM_LOG_FUNC, "SELECT OUT");
+ return 0;
+}
+
+/*********************************************************
+ * Receiving Messages from CONNECT Clients (MAIN Functions Sub)
+ *********************************************************/
+void Recv_Msg_FromConnectClient(fd_set* fds, TSKM_MAIN_CTX_t* p_main) {
+ uint32_t ii;
+ TSKM_SRV_CONNENT_LIST_t* p_connList = &p_main->sock.connList;
+
+ // Messages from CONNECT clients
+ for (ii = 0; ii < p_connList->num; ii++) {
+ TSKM_SRV_CONNENT_t* p_conn = &p_connList->conn[ii];
+ if (FD_ISSET(p_conn->connFd, fds)) {
+ TSKM_PRINTF(TSKM_LOG_FUNC, "connFd IN");
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+ ret = tskm_sockRcv(p_conn->connFd, &ev);
+
+ if (ret < 0) {
+ TSKM_ASSERT(0);
+ } else {
+ TSKM_SVC_CTX_t* p_svc;
+
+ if (ret == 0) {
+ // Closed Connection
+ TSKM_PRINTF(TSKM_LOG_STATE, "DISSCON pid:%d", p_conn->pid);
+ ev.event = TSKM_EV_PRI_REP_DISCONNECT;
+ ev.errCode = TSKM_E_OK;
+ ev.fromPid = p_conn->pid;
+ tskm_srvSockDisconnect(&p_main->sock, p_conn);
+ p_conn = NULL; // If the connection is lost, it cannot be referenced.
+ }
+
+ p_svc = tskm_svcsGetSvcByPid(&p_main->svcs, ev.fromPid);
+ if (p_svc) { // Events from service
+ TSKM_ERR_t tskmRet;
+ tskmRet = tskm_svcEventHandle(p_svc, &ev); // Service handler
+ if (tskmRet != TSKM_E_OK) {
+ TSKM_ASSERT(0);
+ }
+ }
+ if (ev.event != TSKM_EV_NOP) {
+ tskm_handleEvent(p_main, &ev); // Main handler
+ }
+ }
+ TSKM_PRINTF(TSKM_LOG_FUNC, "connFd OUT");
+ }
+ }
+}
+
+/*********************************************************
+ * CONNECT Requests (MAIN Functions Sub)
+ *********************************************************/
+void Recv_Req_Connect(fd_set* fds, TSKM_MAIN_CTX_t* p_main, int sockFd) {
+ // CONNECT requests
+ if (FD_ISSET(sockFd, fds)) {
+ TSKM_PRINTF(TSKM_LOG_FUNC, "sockFd IN");
+
+ TSKM_SRV_CONNENT_t* conn;
+ conn = tskm_srvSockConnect(&p_main->sock);
+ if (conn == NULL) {
+ TSKM_ASSERT(0);
+ } else {
+ TSKM_SVC_CTX_t* p_svc;
+ TSKM_PRINTF(TSKM_LOG_STATE, "CONNECT pid:%d", conn->pid);
+
+ p_svc = tskm_svcsGetSvcByPid(&p_main->svcs, conn->pid);
+ if (p_svc) {
+ TSKM_ERR_t tskmRet;
+ TSKM_EVENT_INFO_t ev;
+
+ ev.event = TSKM_EV_PRI_REP_CONNECT;
+ ev.errCode = TSKM_E_OK;
+ ev.fromPid = conn->pid;
+ ev.prm.repConnect.connFd = conn->connFd;
+
+ tskmRet = tskm_svcEventHandle(p_svc, &ev); // Service handler
+ if (tskmRet != TSKM_E_OK) {
+ TSKM_ASSERT(0);
+ } else if (ev.event != TSKM_EV_NOP) {
+ tskm_handleEvent(p_main, &ev); // Main hander
+ }
+ }
+ }
+ TSKM_PRINTF(TSKM_LOG_FUNC, "sockFd OUT");
+ }
+}
+
+/*********************************************************
+ * MAIN Function
+ *********************************************************/
+int main(int argc, char* argv[]) {
+ RPC_ID rpcId = TSKM_RPC_ID;
+ int rpcFd = 0;
+ int maxFd = 0;
+ int ret;
+ fd_set fds;
+ TSKM_MAIN_CTX_t* p_main = &g_mainCtx;
+
+ // Logging setting
+ FRAMEWORKUNIFIED_SET_ZONES();
+
+ ctxCreate(p_main, argc, argv); // Initialize context
+
+ tskm_sub_init(); // Initialize sub systems
+
+ RPC_START_SECURE_SERVER(rpcId);
+ RPC_get_fd(rpcId, &rpcFd);
+
+ uid_t uid[2];
+ gid_t gid[2];
+
+ uid[0] = 0;
+ gid[0] = 0;
+ uid[1] = getuid();
+ gid[1] = getgid();
+
+ if (RPC_OK != RPC_regist_credential(2, uid, 2, gid)) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: For process initialization processing
+ }
+
+ // Start periodic timer thread
+ ret = tskm_watch_startTimer();
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: For process initialization processing
+ }
+
+ tskm_stateTransit(p_main, TSKM_ST_ACCOFF, TSKM_ST_ACCON);
+
+ p_main->isExec = TSKM_TRUE;
+ while (p_main->isExec) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ int sockFd = p_main->sock.sockFd;
+
+ // Initialization processing
+ if (Init_Process(&rpcFd, &sockFd, &maxFd, &fds, p_main) != 0) { // LCOV_EXCL_BR_LINE 6: For process initialization processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ continue; // LCOV_EXCL_LINE 6: For process initialization processing
+ }
+
+ // RPC API
+ if (FD_ISSET(rpcFd, &fds)) {
+ RPC_process_API_request(rpcId);
+ }
+
+ // Process termination signal
+ if (FD_ISSET(p_main->sigFd, &fds)) {
+ int count = 0;
+
+ do {
+ TSKM_EVENT_INFO_t ev;
+ ev.event = TSKM_EV_SVC_REP_TERM;
+
+ count++;
+
+ ret = tskm_pf_cleanupProc(p_main->sigFd, &ev.fromPid, &ev.errCode);
+ if (ret == -1) {
+ TSKM_ASSERT(0);
+ break;
+ }
+
+ TSKM_SVC_CTX_t* p_svc;
+
+ p_svc = tskm_svcsGetSvcByPid(&p_main->svcs, ev.fromPid);
+ if (p_svc) {
+ TSKM_ERR_t tskmRet;
+
+ tskmRet = tskm_svcEventHandle(p_svc, &ev); // Service handler
+ if (tskmRet != TSKM_E_OK) {
+ TSKM_ASSERT(0);
+ }
+ if (ev.event != TSKM_EV_NOP) {
+ tskm_handleEvent(p_main, &ev); // Main handler
+ }
+ }
+ } while (ret == 1 && count < 50);
+ }
+
+ if (FD_ISSET(p_main->nsFd, &fds)) {
+ FrameworkunifiedDispatchProcessWithoutLoop(p_main->hApp);
+ }
+
+ // EV from RESM
+ if (-1 != p_main->resmFd) {
+ if (FD_ISSET(p_main->resmFd, &fds)) {
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+ ret = tskm_sub_resmRcv(&ev);
+
+ if (-1 == ret) {
+ TSKM_ASSERT(0);
+ } else {
+ tskm_handleEvent(p_main, &ev);
+ }
+ }
+ }
+
+ // Messages from connected clients
+ Recv_Msg_FromConnectClient(&fds, p_main);
+
+ // CONNECT request
+ Recv_Req_Connect(&fds, p_main, sockFd);
+ }
+
+ tskm_srvSockDestory(&p_main->sock);
+
+ RPC_end(rpcId);
+
+ FrameworkunifiedDestroyDispatcherWithoutLoop(p_main->hApp);
+ TSKM_PRINTF(TSKM_LOG_STATE, "tskm end");
+
+ sleep(TSKM_CFG_WAIT_SHUTDOWN);
+ return 0;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/server/src/tskm_port_pf.cpp b/systemservice/task_manager/server/src/tskm_port_pf.cpp
new file mode 100755
index 0000000..f427255
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_port_pf.cpp
@@ -0,0 +1,884 @@
+/*
+ * @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.
+ */
+
+#include "tskm_port_pf.h"
+#include <pthread.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <pwd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <native_service/cl_process.h>
+#include <native_service/cl_monitor.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_sm_client_if.h>
+
+#include "system_service/tskm_svc.h"
+#include "tskm_debug.h"
+
+#define TSKM_PORTPF_IN() TSKM_PRINTF(TSKM_LOG_PORTPF, "%s:IN", __FUNCTION__)
+#define TSKM_PORTPF_IN_ARG(format, ...) TSKM_PRINTF(TSKM_LOG_PORTPF, "%s:IN:" format, __FUNCTION__, __VA_ARGS__)
+#define TSKM_PORTPF_OUT() TSKM_PRINTF(TSKM_LOG_PORTPF, "%s:OUT", __FUNCTION__)
+
+#define TSKM_PRIO_MIN 1
+#define TSKM_PRIO_MAX 99
+#define TSKM_PRIO_MIN_TSS -20
+#define TSKM_PRIO_MAX_TSS 19
+
+#define TSKM_TMP_DIRECTORY "/tmp"
+#define TSKM_TMP_TSKM_DIRECTORY TSKM_TMP_DIRECTORY "/tskm"
+#define TSKM_TMP_NV_INFO_FILEPATH TSKM_TMP_TSKM_DIRECTORY "/nvInfo"
+
+#define TSKM_NPP_NV_FILE_TAG SS_TASK_MANAGER "/nvInfo"
+
+/*********************************************************
+ * user->uid/gid conversion
+ *********************************************************/
+TSKM_STATIC int cnvUserName2UidGid(const char *user, uid_t *uid, gid_t *gid) {
+ int ret = -1;
+
+ if (0 == strcmp(user, "")) {
+ *uid = geteuid();
+ *gid = getegid();
+ } else {
+ static __thread size_t bufSize = 0;
+ static __thread char *buf = NULL;
+ struct passwd pwd;
+ struct passwd *result;
+
+ if (0 == bufSize) {
+ struct stat statInfo;
+
+ bufSize = -1;
+
+ if (0 != stat("/etc/passwd", &statInfo) || 0 >= statInfo.st_size) { // LCOV_EXCL_START 8: Because buf is a static variable and cannot be passed test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+ // LCOV_EXCL_STOP
+
+ bufSize = statInfo.st_size * 2;
+
+ // Since TaskManager is a resident service, the area allocated here is expected to be released at process termination and is not explicitly released by free()
+ buf = (char *) malloc(sizeof(char) * bufSize); // NOLINT (runtime/printf)
+ if (NULL == buf) { // LCOV_EXCL_BR_LINE 5: Error branching of the standard-function malloc
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0); // LCOV_EXCL_LINE 5: Error branching of the standard-function malloc
+ goto ERROR; // LCOV_EXCL_LINE 5: Error branching of the standard-function malloc
+ }
+ }
+
+ if (NULL == buf) { // LCOV_EXCL_BR_LINE 8: Because buf is a static variable and cannot be passed test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 8: Because buf is a static variable and cannot be passed test
+ goto ERROR; // LCOV_EXCL_LINE 8: Because buf is a static variable and cannot be passed test
+ }
+
+ ret = getpwnam_r(user, &pwd, buf, bufSize, &result);
+ if (ret != 0 || result == NULL) {
+ TSKM_ASSERT_PRINT(0, "ret = %d[%s]", ret, user);
+ goto ERROR;
+ }
+
+ *uid = pwd.pw_uid;
+ *gid = pwd.pw_gid;
+ }
+
+ ret = 0;
+
+ ERROR:
+
+ return ret;
+}
+
+/*********************************************************
+ * Convert Scheduling Policy Definitions Values (TSKM -> CL)
+ *********************************************************/
+TSKM_STATIC CL_ProcessSchedPolicy_t cnvTskmPolicy2ClPolicy(
+ TSKM_SVC_POLICY_t policy) {
+ switch (policy) {
+ case TSKM_SVC_POLICY_FIFO:
+ return CL_PROCESS_SCHED_POLICY_FIFO;
+ case TSKM_SVC_POLICY_TSS:
+ return CL_PROCESS_SCHED_POLICY_OTHER;
+ case TSKM_SVC_POLICY_RR:
+ return CL_PROCESS_SCHED_POLICY_RR;
+ default:
+ TSKM_ASSERT(0);
+ break;
+ }
+ return CL_PROCESS_SCHED_POLICY_OTHER;
+}
+
+/*********************************************************
+ * Process priority valid value determination
+ *********************************************************/
+TSKM_STATIC int chkPrioValue(TSKM_SVC_POLICY_t policy, int prio) {
+ switch (policy) {
+ case TSKM_SVC_POLICY_FIFO:
+ case TSKM_SVC_POLICY_RR:
+ if ((TSKM_PRIO_MIN > prio) || (prio > TSKM_PRIO_MAX)) {
+ TSKM_ASSERT(0);
+ }
+ break;
+ case TSKM_SVC_POLICY_TSS:
+ default:
+ if ((TSKM_PRIO_MIN_TSS > prio) || (prio > TSKM_PRIO_MAX_TSS)) {
+ TSKM_ASSERT(0);
+ }
+ break;
+ }
+
+ return prio;
+}
+
+/*********************************************************
+ * COMMONLIB initialization (at system startup)
+ *********************************************************/
+int tskm_pf_sysInit() {
+ int fd = 0;
+ int ret = 0;
+
+ TSKM_PORTPF_IN();
+
+ fd = CL_ProcessInit();
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 6: Error branching during process initialization
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0); // LCOV_EXCL_LINE 6: Error branching during process initialization
+ goto ERROR; // LCOV_EXCL_LINE 6: Error branching during process initialization
+ }
+
+ ret = CL_MonitorInit(CL_MONITOR_INIT_USER);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ TSKM_ASSERT_ERRNO(0);
+ }
+
+ TSKM_PORTPF_OUT();
+ return fd;
+ // LCOV_EXCL_START 6: Error branching during process initialization
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1;
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************************
+ * COMMONLIB initialization (at process startup)
+ *********************************************************/
+int tskm_pf_procInit() {
+ TSKM_PORTPF_IN();
+ // Originally called the _sys_Setup_CWORD64_API (NULL), but changed to empty function along to derete "_sys"
+
+ TSKM_PORTPF_OUT();
+ return 0;
+}
+
+/*********************************************************
+ * Process startup
+ *********************************************************/
+pid_t tskm_pf_createProc(TSKM_SVC_ATTR_t* p_svcAttr) {
+ TSKM_PORTPF_IN();
+ pid_t retPid = -1;
+ pid_t pid = -1;
+
+ CL_ProcessAttr_t attr;
+ char procPath[255];
+ char* procName;
+ uid_t setUid = 0;
+ gid_t setGid = 0;
+
+ if (0 != CL_ProcessCreateAttrInit(&attr)) { // LCOV_EXCL_BR_LINE 6: Error branching during process initialization
+ // LCOV_EXCL_START 6: Error branching during process initialization
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ // Process name setting(from basename)
+ if (strlen(p_svcAttr->path) < sizeof(procPath)) {
+ strcpy(procPath, p_svcAttr->path); // NOLINT (runtime/printf)
+ } else {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ procName = basename(procPath);
+ if (strlen(procName) >= 16) {
+ TSKM_ASSERT(0);
+ procName[16] = '\0';
+ }
+
+ if (0 != CL_ProcessCreateAttrSetName(&attr, procName)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if (0 != cnvUserName2UidGid(p_svcAttr->user, &setUid, &setGid)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ setUid = geteuid();
+ setGid = getegid();
+ // LCOV_EXCL_STOP
+ }
+
+ if (0 != CL_ProcessCreateAttrSetUid(&attr, setUid)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if (0 != CL_ProcessCreateAttrSetGid(&attr, setGid)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ // All are group leaders in order to recover to the child processes of the service
+ if (0 != CL_ProcessCreateAttrSetGroup(&attr, 1)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ if (0 != CL_ProcessCreateAttrSetCpuAssign(&attr, p_svcAttr->cpuAssign)) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ if (0
+ != CL_ProcessCreateAttrSetSchedule(
+ &attr, cnvTskmPolicy2ClPolicy(p_svcAttr->policy),
+ chkPrioValue(p_svcAttr->policy, p_svcAttr->prio))) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ pid = CL_ProcessCreate(p_svcAttr->path, p_svcAttr->args, NULL, &attr);
+ if (pid == -1) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ retPid = pid;
+ ERROR:
+
+ TSKM_PORTPF_OUT();
+ return retPid;
+}
+
+/*********************************************************
+ * Recover termination processes
+ *********************************************************/
+int tskm_pf_cleanupProc(int sigFd, pid_t* p_pid, TSKM_ERR_t* p_err) {
+ int ret;
+ CL_ProcessCleanupInfo_t info;
+
+ ret = CL_ProcessCleanup(sigFd, &info);
+ if (ret != 0 && ret != 1) {
+ TSKM_ASSERT_PRINT(0, "ret = %d", ret);
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "SVC TERM:pid:%d code:%d status:%d", info.pid,
+ info.code, info.status);
+
+ switch (info.code) {
+ case CLD_STOPPED:
+ // Not comes here usually
+ TSKM_PRINTF(TSKM_LOG_STATE, "svc stoped\n");
+ goto ERROR;
+ case CLD_TRAPPED:
+ // Comes here only during debugging
+ TSKM_PRINTF(TSKM_LOG_STATE, "svc traped\n");
+ goto ERROR;
+ case CLD_CONTINUED:
+ // Not comes here usually
+ TSKM_PRINTF(TSKM_LOG_STATE, "svc continue\n");
+ goto ERROR;
+ default:
+ break;
+ }
+
+ *p_pid = info.pid;
+ *p_err =
+ (info.code != CLD_EXITED) ? TSKM_E_NG :
+ (info.code == CLD_EXITED && info.status != EXIT_SUCCESS) ?
+ TSKM_E_NG : TSKM_E_OK;
+
+ if (TSKM_E_OK != *p_err) {
+ TSKM_PRINTF(TSKM_LOG_SYSTEMDATA, "SVC ERR TERM:pid:%d code:%d status:%d",
+ info.pid, info.code, info.status);
+ }
+
+ return ret;
+ ERROR: return -1;
+}
+
+/*********************************************************
+ * Force Terminating a Process Group
+ *********************************************************/
+int tskm_pf_terminateProcGroup(uint16_t pid) {
+ int ret;
+ pid_t pgid;
+
+ pgid = getpgid(pid);
+ if (pgid < 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "TERM SVC GROUP:pid:%dpgid:%d", pid, pgid);
+
+ ret = CL_ProcessEuthanizeGroup(pgid);
+ if (ret != 0) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ return 0;
+ ERROR: return -1;
+}
+
+/*********************************************************
+ * Opening shared memory and trancating
+ *********************************************************/
+int tskm_pf_shmCreate_Open_Ftrn(const char* name, int32_t size, void** p_addr) {
+ int ret = 0;
+ int fd = 0;
+
+ fd = shm_open(name, O_CREAT | O_RDWR | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0); // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ ret = -1; // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ if (fd > 0) { // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ TSKM_ASSERT_ERRNO(close(fd) == 0); // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ } // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ return ret; // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ }
+
+ ret = ftruncate(fd, size);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0); // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ if (fd > 0) { // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ TSKM_ASSERT_ERRNO(close(fd) == 0); // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ } // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ return ret; // LCOV_EXCL_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded.
+ }
+
+ if (p_addr) { // LCOV_EXCL_BR_LINE 8: Because p_addr is set to NULL only
+ // LCOV_EXCL_START 8: Because p_addr is set to NULL only
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // Not supported
+ TSKM_ASSERT_ERRNO(0);
+ ret = -1;
+ if (fd > 0) {
+ TSKM_ASSERT_ERRNO(close(fd) == 0);
+ }
+ return ret;
+ // LCOV_EXCL_STOP
+ }
+
+ ret = 0;
+ if (fd > 0) {
+ TSKM_ASSERT_ERRNO(close(fd) == 0);
+ }
+ return ret;
+}
+
+/*********************************************************
+ * Creating shared memory
+ *********************************************************/
+int tskm_pf_shmCreate(const char* name, int32_t size, void** p_addr) {
+ TSKM_PORTPF_IN_ARG("%s,%d", name, size);
+ struct stat statInfo;
+ int ret = -1;
+
+ if (stat(name, &statInfo) == 0) {
+ TSKM_ASSERT_PRINT(0, "Already Exist %s", name);
+ ret = 0; // To be Succeeded
+ TSKM_PORTPF_OUT();
+ return ret;
+ }
+
+ ret = tskm_pf_shmCreate_Open_Ftrn(name, size, p_addr);
+
+ TSKM_PORTPF_OUT();
+ return ret;
+}
+
+/*********************************************************
+ * Deleting shared memory
+ *********************************************************/
+int tskm_pf_shmDelete(const char* name) {
+ TSKM_PORTPF_IN_ARG("%s", name);
+ int ret = 0;
+
+ if (0 != shm_unlink(name)) {
+ TSKM_ASSERT_ERRNO(0);
+ }
+
+ TSKM_PORTPF_OUT();
+ return ret;
+}
+
+/*********************************************************
+ * Starting thread
+ *********************************************************/
+int tskm_pf_createThread(void* (*threadFunc)(void*), void* prm,
+ uint32_t priority, const char* threadName,
+ pthread_t* p_thId) {
+ TSKM_PORTPF_IN();
+
+ int ret;
+ CL_ThreadAttr_t cl_attr;
+
+ ret = CL_ThreadCreateAttrInit(&cl_attr);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 6: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0); // LCOV_EXCL_LINE 6: For processing initializing process
+ goto ERROR; // LCOV_EXCL_LINE 6: For processing initializing process
+ }
+
+ if (threadName) {
+ ret = CL_ThreadCreateAttrSetName(&cl_attr, threadName);
+ TSKM_ASSERT_ERRNO(ret == 0);
+ }
+
+ ret = CL_ThreadCreate(p_thId, NULL, &cl_attr, threadFunc, prm);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 6: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0); // LCOV_EXCL_LINE 6: For processing initializing process
+ goto ERROR; // LCOV_EXCL_LINE 6: For processing initializing process
+ }
+ int sched_policy;
+ struct sched_param sparam;
+
+ pthread_getschedparam(*p_thId, &sched_policy, &sparam);
+
+ sparam.sched_priority = priority;
+ if ((priority != 0) && (sched_policy == SCHED_OTHER)) {
+ sched_policy = SCHED_FIFO;
+ } else if ((priority == 0) && (sched_policy != SCHED_OTHER)) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ sched_policy = SCHED_OTHER; // LCOV_EXCL_LINE 6: For processing initializing process
+ }
+
+ ret = pthread_setschedparam(*p_thId, sched_policy, &sparam);
+ TSKM_ASSERT(ret == 0);
+ TSKM_PORTPF_OUT();
+ return 0;
+ ERROR: return -1;
+}
+/*********************************************************
+ * Send Stop Complete Response
+ *********************************************************/
+int tskm_pf_sendStopCompResp() {
+ EFrameworkunifiedStatus l_eStatus;
+ TSKM_PORTPF_IN();
+
+ l_eStatus = SendInterfaceunifiedOnStopResponseToSystemManager(eFrameworkunifiedStatusOK);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ TSKM_ASSERT(0);
+ }
+
+ TSKM_PORTPF_OUT();
+ return 0;
+}
+
+/*********************************************************
+ * ABORT
+ *********************************************************/
+int tskm_pf_abort() {
+ TSKM_PORTPF_IN();
+
+ TSKM_ASSERT(0);
+ sleep(1); // Sleep a little so that the logging at the time of abnormality may be interrupted
+
+ // Issure SIGSEG
+ printf("%d\n", *(int *) 0); // NOLINT (readability/casting)
+
+ TSKM_PORTPF_OUT();
+ return 0;
+}
+
+/*********************************************************
+ * EXIT
+ *********************************************************/
+int tskm_pf_exit(int status) { //LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_PORTPF_IN();
+
+ exit(status);
+
+ TSKM_PORTPF_OUT();
+ return 0;
+}
+// LCOV_EXCL_STOP
+
+/*********************************************************
+ * TOUCH
+ *********************************************************/
+int tskm_pf_touch(char* path) {
+ TSKM_PORTPF_IN();
+ int fd;
+ fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ if (fd < 0) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ TSKM_ASSERT_ERRNO(close(fd) == 0);
+ TSKM_PORTPF_OUT();
+ return 0;
+ ERROR:
+ return -1;
+}
+
+/*********************************************************
+ * Touch
+ *********************************************************/
+int tskm_pf_mkTouchFileName(pid_t pid, char name[32]) {
+ TSKM_PORTPF_IN();
+
+ sprintf(name, "/tmp/tskm_touch%d", pid); // NOLINT (runtime/printf)
+
+ TSKM_PORTPF_OUT();
+ return 0;
+}
+
+/*********************************************************
+ * Read file
+ *********************************************************/
+static ssize_t readFile(const char* filePath, void* l_buf, ssize_t bufSize) {
+ int fd = -1;
+ ssize_t readSize, totalReadSize = 0;
+ char *p_buf = (char*) l_buf; // NOLINT (readability/casting)
+ fd = open(filePath, O_RDONLY);
+ if (fd == -1) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ do {
+ readSize = read(fd, p_buf, bufSize);
+ if (readSize == -1) {
+ if (errno == EINTR) {
+ continue;
+ } else {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+ } else if (readSize == 0) {
+ break;
+ }
+
+ p_buf += readSize;
+ bufSize -= readSize;
+ totalReadSize += readSize;
+ } while (bufSize > 0);
+
+ ERROR: if (fd != -1) {
+ close(fd);
+ }
+
+ return totalReadSize;
+}
+
+/*********************************************************
+ * Write to file
+ *********************************************************/
+static ssize_t writeFile(const char *filePath, const void* l_buf,
+ ssize_t bufSize) {
+ int ret = -1;
+ int fd = -1;
+
+ const char *p_buf = (const char*) l_buf;
+
+ ssize_t writeSize, totalWriteSize = 0;
+
+ fd = open(filePath, O_RDWR | O_TRUNC | O_CREAT, S_IRWXU);
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: Error branching of the standard-function open()
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0); // LCOV_EXCL_LINE 5: Error branching of the standard-function open()
+ goto ERROR; // LCOV_EXCL_LINE 5: Error branching of the standard-function open()
+ }
+
+ do {
+ writeSize = write(fd, p_buf, bufSize);
+ if (writeSize == -1) { // LCOV_EXCL_BR_LINE 5: Error branching of the standard-function write()
+ // LCOV_EXCL_START 5: Error branching of the standard-function write()
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno == EINTR) {
+ continue;
+ } else {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+ // LCOV_EXCL_STOP
+ } else if (writeSize == 0) { // LCOV_EXCL_BR_LINE 5: Error branching of the standard-function write()
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ break; // LCOV_EXCL_LINE 5: Error branching of the standard-function write()
+ }
+ p_buf += writeSize;
+ bufSize -= writeSize;
+ totalWriteSize += writeSize;
+ } while (bufSize > 0); // LCOV_EXCL_BR_LINE 5: Error branching of the standard-function write()
+
+ ret = fsync(fd);
+ if (ret == -1) { // LCOV_EXCL_BR_LINE 5: Error branching of the standard-function fsync()
+ // LCOV_EXCL_START 5: Error branching of the standard-function fsync()
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ ERROR: if (fd != -1) { // LCOV_EXCL_BR_LINE 5: Error branching of the standard-function open()
+ close(fd);
+ }
+
+ return totalWriteSize;
+}
+
+/*********************************************************
+ * Checksum calculation
+ *********************************************************/
+static uint32_t calcCheckSum(const void* p_buf, size_t bufSize) {
+ int ii;
+ int blockNum;
+ uint32_t sum = 0;
+ uint32_t *p_calcBuf = (uint32_t*) p_buf; // NOLINT (readability/casting)
+
+ blockNum = static_cast<int>(bufSize) / static_cast<int>(sizeof(uint32_t));
+
+ for (ii = 0; ii < blockNum; ii++) {
+ sum += p_calcBuf[ii];
+ }
+
+ return sum;
+}
+
+/*********************************************************
+ * Checking files
+ *********************************************************/
+static TSKM_BOOL_t checkFile(const char *filePath) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ uint32_t checkSum;
+ struct stat st;
+ ssize_t readSize;
+ TSKM_NV_INFO_t nvInfo;
+ TSKM_BOOL_t isFileOk = TSKM_FALSE;
+
+ if (stat(filePath, &st) != 0) {
+ goto ERROR;
+ }
+
+ readSize = readFile(filePath, &nvInfo, sizeof(TSKM_NV_INFO_t));
+ if (readSize != sizeof(TSKM_NV_INFO_t)) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ checkSum = calcCheckSum(&nvInfo, offsetof(TSKM_NV_INFO_t, footer.checkSum));
+
+ if (checkSum != nvInfo.footer.checkSum) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ if (strncmp(nvInfo.header.version, TSKM_NV_STRUCT_VERSION,
+ sizeof(TSKM_NV_STRUCT_VERSION)) != 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ isFileOk = TSKM_TRUE;
+ ERROR: return isFileOk;
+}
+// LCOV_EXCL_STOP
+/*********************************************************
+ * Non-volatile file initialization (Including checksum write)
+ *********************************************************/
+static int initNvFile() {
+ int ii;
+ ssize_t writeSize;
+ TSKM_NV_INFO_t nvInfo;
+
+ TSKM_STATIC_ASSERT(sizeof(TSKM_NV_INFO_t) == TSKM_NV_SIZE_ALL);
+ TSKM_STATIC_ASSERT(
+ offsetof(TSKM_NV_INFO_t, footer.checkSum) % sizeof(uint32_t) == 0);
+
+ memset(&nvInfo, 0, sizeof(TSKM_NV_INFO_t));
+ sprintf(nvInfo.header.version, TSKM_NV_STRUCT_VERSION); // NOLINT (readability/casting)
+ nvInfo.body.rsvSvcNum = 0;
+ for (ii = 0; ii < TSKM_SVC_RESERVE_MAX; ii++) {
+ nvInfo.body.rsvSvcs[ii] = TSKM_SVCID_NONE;
+ }
+ nvInfo.footer.checkSum = calcCheckSum(
+ &nvInfo, offsetof(TSKM_NV_INFO_t, footer.checkSum));
+
+ writeSize = writeFile(TSKM_TMP_NV_INFO_FILEPATH, &nvInfo,
+ sizeof(TSKM_NV_INFO_t));
+ if (writeSize != sizeof(TSKM_NV_INFO_t)) { // LCOV_EXCL_BR_LINE 6: writeSize must be the size of TSKM_NV_INFO_t
+ // LCOV_EXCL_START 6: writeSize must be the size of TSKM_NV_INFO_t
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ return 0;
+ ERROR: return -1;
+}
+
+/*********************************************************
+ * Non-volatile file initialization
+ *********************************************************/
+int tskm_pf_nvFileInit(HANDLE hApp) {
+ int ret = -1;
+ struct stat st;
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (stat(TSKM_TMP_TSKM_DIRECTORY, &st) != 0) { // LCOV_EXCL_BR_LINE 5:Standard C function return value
+ // LCOV_EXCL_START 5:Standard C function return value
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = mkdir(TSKM_TMP_TSKM_DIRECTORY, S_IRWXU);
+ if (ret == -1) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = FrameworkunifiedNPRegisterPersistentFile(hApp, TSKM_NPP_NV_FILE_TAG);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: For processing initializing process
+ goto ERROR; // LCOV_EXCL_LINE 6: For processing initializing process
+ }
+
+ l_eStatus = FrameworkunifiedNPLoadPersistentFile(hApp, TSKM_TMP_NV_INFO_FILEPATH, TSKM_NPP_NV_FILE_TAG);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: For processing initializing process
+ goto ERROR; // LCOV_EXCL_LINE 6: For processing initializing process
+ }
+
+ return 0;
+ ERROR: return -1;
+}
+
+/*********************************************************
+ * Non-volatile file read
+ *********************************************************/
+int tskm_pf_nvFileRead(HANDLE hApp, TSKM_NV_INFO_t* p_nvInfo) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ NC_LoadPersistedAck l_tMsgAck;
+ ssize_t readSize;
+ TSKM_BOOL_t isTmpFileOk = TSKM_FALSE;
+
+ if (sizeof(l_tMsgAck) != FrameworkunifiedGetMsgLength(hApp)) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_tMsgAck, sizeof(l_tMsgAck)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if ((strncmp(l_tMsgAck.cTag, TSKM_NPP_NV_FILE_TAG, sizeof(TSKM_NPP_NV_FILE_TAG)) == 0)
+ && (eFrameworkunifiedStatusOK == l_tMsgAck.eStatus)) {
+ if (checkFile(TSKM_TMP_NV_INFO_FILEPATH) == TSKM_TRUE) {
+ isTmpFileOk = TSKM_TRUE;
+ }
+ }
+
+ if (isTmpFileOk == TSKM_FALSE) {
+ int ret;
+
+ ret = initNvFile();
+ if (ret == -1) { // LCOV_EXCL_BR_LINE 6: must return ok
+ // LCOV_EXCL_START 6: must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ readSize = readFile(TSKM_TMP_NV_INFO_FILEPATH, p_nvInfo,
+ sizeof(TSKM_NV_INFO_t));
+ if (readSize != sizeof(TSKM_NV_INFO_t)) { // LCOV_EXCL_BR_LINE 6: readSize must be the size of TSKM_NV_INFO_t
+ // LCOV_EXCL_START 6: readSize must be the size of TSKM_NV_INFO_t
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = FrameworkunifiedNPReleasePersistentFile(hApp, eFrameworkunifiedPersistOnShutdown, TSKM_NPP_NV_FILE_TAG, TSKM_TMP_NV_INFO_FILEPATH);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ return 0;
+ ERROR: return -1;
+}
+
+/*********************************************************
+ * Write non-volatile file (Including checksum)
+ *********************************************************/
+int tskm_pf_nvFileWrite(const TSKM_NV_INFO_t* p_nvInfo) {
+ ssize_t writeSize;
+ TSKM_NV_INFO_t nvInfo;
+
+ memcpy(&nvInfo, p_nvInfo, sizeof(TSKM_NV_INFO_t));
+
+ nvInfo.footer.checkSum = calcCheckSum(
+ &nvInfo, offsetof(TSKM_NV_INFO_t, footer.checkSum));
+
+ writeSize = writeFile(TSKM_TMP_NV_INFO_FILEPATH, &nvInfo,
+ sizeof(TSKM_NV_INFO_t));
+ if (writeSize != sizeof(TSKM_NV_INFO_t)) { // LCOV_EXCL_BR_LINE 6: writeSize must be the size of TSKM_NV_INFO_t
+ // LCOV_EXCL_START 6: writeSize must be the size of TSKM_NV_INFO_t
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+ return 0;
+} // LCOV_EXCL_BR_LINE 10: Final line
diff --git a/systemservice/task_manager/server/src/tskm_port_subsys.cpp b/systemservice/task_manager/server/src/tskm_port_subsys.cpp
new file mode 100755
index 0000000..cfdec49
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_port_subsys.cpp
@@ -0,0 +1,297 @@
+/*
+ * @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.
+ */
+
+#include "tskm_port_subsys.h"
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <native_service/cl_monitor.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/resm.h>
+//#include <stub/ss_diag.h>
+#include <string>
+
+#include "agl_thread.h"
+
+#include "tskm_main.h"
+#include "tskm_debug.h"
+#include "tskm_util.h"
+#include "tskm_port_pf.h"
+
+
+#ifndef oops_name2pid
+ #define oops_name2pid(processname) syscall(OOPSTRACE_SYSCALL, 17, processname)
+#endif
+
+
+typedef struct {
+ CL_MonitorSearch_t clMonSearch;
+ uint32_t resmId; // Session ID of RESM
+} SUB_SYS_CTX_t;
+
+static SUB_SYS_CTX_t g_sub;
+
+/******************************************************************
+ * Subsystem initialization
+ ******************************************************************/
+int tskm_sub_init(void) {
+ int clRet;
+ SUB_SYS_CTX_t* p_ctx = &g_sub;
+
+ clRet = CL_MonitorSearchInit(&p_ctx->clMonSearch);
+ if (clRet != 0) { // LCOV_EXCL_BR_LINE 6: For processing intializing process
+ // LCOV_EXCL_START 6:For processing initializing process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 6: For processing initializing process
+ }
+
+ return 0;
+ // LCOV_EXCL_START 6:For processing initializing process
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return 1;
+ // LCOV_EXCL_STOP
+}
+
+/******************************************************************
+ * Subsystem termination
+ ******************************************************************/
+int tskm_sub_term(void) {
+ int ret;
+ SUB_SYS_CTX_t* p_ctx = &g_sub;
+
+ ret = CL_MonitorSearchDestroy(&p_ctx->clMonSearch);
+ if (ret != 0) {
+ TSKM_ASSERT_ERRNO(0);
+ }
+
+ return 0;
+}
+/*********************************************************
+ * REBOOT
+ *********************************************************/
+void tskm_sub_reboot(const TSKM_ERROR_REBOOT_t* p_info) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TSKM_ASSERT(0);
+
+ l_eStatus = SendCpuResetRequestToSystemManager(
+ e_SS_SM_CPU_RESET_REASON_GENERIC_ERR, p_info->log.messageStr);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+}
+
+/*********************************************************
+ * REBOOT NORMAL
+ *********************************************************/
+void tskm_sub_reboot_normal(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = SendCpuResetRequestToSystemManager(
+ e_SS_SM_CPU_RESET_REASON_NORMAL);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ TSKM_ASSERT(0);
+ }
+}
+
+/*********************************************************
+ * LOGGING
+ *********************************************************/
+void tskm_sub_logging(const TSKM_LOGGING_INFO_t* p_info) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ eSMUserLogType l_eType;
+
+ switch (p_info->type) {
+ case TSKM_LOGGING_TYPE_GRP_RELAUNCH:
+ l_eType = e_SS_SM_CAPTURE_GROUP_RELAUNCH;
+ break;
+ case TSKM_LOGGING_TYPE_MODULE_LOGS:
+ default:
+ l_eType = e_SS_SM_CAPTURE_MODULE_LOGS;
+ break;
+ }
+
+ l_eStatus = SendUserInvokedLoggingRequestToSystemManager(l_eType,
+ p_info->messageStr);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ TSKM_ASSERT(0);
+ }
+}
+
+/*********************************************************
+ * DEBUG DUMP
+ *********************************************************/
+void tskm_sub_debugDumpRes(BOOL bIsNeedSvcName, const char *p_dumpMsg) {
+ if (bIsNeedSvcName) { // LCOV_EXCL_BR_LINE 8: As the bIsNeedSvcName is set to FALSE only
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ SSDEBUGDUMP("%s", p_dumpMsg); // LCOV_EXCL_LINE 8: As the bIsNeedSvcName is set to FALSE only
+ } else {
+ SSDEBUGDUMP_RAW("%s", p_dumpMsg);
+ }
+}
+
+/*********************************************************
+ * EXT BOOT INFO
+ *********************************************************/
+int tskm_sub_getExtBootInfo(T_SS_SM_START_ExtDataStructType *p_info) {
+ EFrameworkunifiedStatus l_eStatus;
+ T_SS_SM_START_ExtDataStructType extStartupInfo;
+
+ l_eStatus = GetInterfaceunifiedOnStartExtInfo(extStartupInfo);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ memcpy(p_info, &extStartupInfo, sizeof(extStartupInfo));
+
+ return 0;
+ ERROR: return -1;
+}
+
+/*********************************************************
+ * Service Error Monitoring Check
+ *********************************************************/
+TSKM_HUNG_INFO_t*
+tskm_sub_searchHungSvcs() {
+ int ret;
+ TSKM_HUNG_INFO_t *p_hungList = NULL;
+ SUB_SYS_CTX_t* p_ctx = &g_sub;
+
+ ret = CL_MonitorSearchTimeout(&p_ctx->clMonSearch);
+ if (ret == -1) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ if (0 < p_ctx->clMonSearch.entry_num) {
+ int ii;
+
+ TSKM_PRINTF(TSKM_LOG_DEBUG, "TimeoutSvcNum = %d",
+ p_ctx->clMonSearch.entry_num);
+
+ if (NULL == p_ctx->clMonSearch.entry_list) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ p_hungList = (TSKM_HUNG_INFO_t *) malloc( // NOLINT (readability/casting)
+ sizeof(TSKM_HUNG_INFO_t) * (p_ctx->clMonSearch.entry_num + 1));
+ if (p_hungList == NULL) { // LCOV_EXCL_BR_LINE 5: malloc's error case.
+ // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ for (ii = 0; ii < p_ctx->clMonSearch.entry_num; ii++) {
+ p_hungList[ii].pid = p_ctx->clMonSearch.entry_list[ii].pid;
+ p_hungList[ii].type = p_ctx->clMonSearch.entry_list[ii].type;
+ }
+ // set "-1" to pid at the end of list.
+ p_hungList[p_ctx->clMonSearch.entry_num].pid = -1;
+ }
+
+ ERROR: return p_hungList;
+}
+
+/*********************************************************
+ * RESM Initialization
+ *********************************************************/
+int tskm_sub_resmInit(void) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ int redmFd;
+ SUB_SYS_CTX_t* p_ctx = &g_sub;
+ RESM_ERR_t resmRet = RESM_E_OK;
+ RESM_REQ_EVENT_t ev;
+
+ int pid;
+
+ resmRet = RESM_Open(NULL, &(p_ctx->resmId));
+ if (RESM_E_OK != resmRet) {
+ TSKM_ASSERT(0);
+
+#warning RESM backtrace disabled, because 'print_backtrace_pid' not support.
+#if 0
+ // Backtrace outoutput of the RESM
+ pid = oops_name2pid(MN_SS_RESOURCEMGR);
+ if(pid > 0){
+ TSKM_ASSERT(-1 != print_backtrace_pid(pid));
+ }else{
+ TSKM_PRINTF(TSKM_LOG_ERROR, "ERR : oops_name2pid %d , err:%d, msg:%s",
+ pid, errno, strerror(errno));
+ }
+#endif
+
+ goto ERROR;
+ }
+
+ resmRet = RESM_GetEventFd(p_ctx->resmId, &redmFd);
+ if (RESM_E_OK != resmRet) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ ev.reqEvent = RESM_EV_MEM;
+ ev.prm.restMemThresh = 512; // Threshold(BYTE)
+
+ resmRet = RESM_ReqEvent(p_ctx->resmId, &ev);
+ if (RESM_E_OK != resmRet) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ return redmFd;
+ ERROR: return -1;
+}
+// LCOV_EXCL_STOP
+/*********************************************************
+ * Get EV of RESM
+ *********************************************************/
+int tskm_sub_resmRcv(TSKM_EVENT_INFO_t* p_ev) {
+ SUB_SYS_CTX_t* p_ctx = &g_sub;
+ RESM_ERR_t resmRet = RESM_E_OK;
+ RESM_EV_t evFlag;
+
+ resmRet = RESM_GetEvent(p_ctx->resmId, &evFlag);
+ if (RESM_E_OK != resmRet) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ if (RESM_EV_MEM != evFlag) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ TSKM_PRINTF(TSKM_LOG_ERROR, "Detect LowMem");
+
+ p_ev->event = TSKM_EV_LCL_REP_LOWMEM;
+
+ return 0;
+ ERROR: return -1;
+}
+
+int tskm_sub_setWakeupOrder(const char* p_order) {
+ // Under consideration
+ return 0;
+} // LCOV_EXCL_BR_LINE 10: Gcov constraints (last row)
diff --git a/systemservice/task_manager/server/src/tskm_shutdown.cpp b/systemservice/task_manager/server/src/tskm_shutdown.cpp
new file mode 100755
index 0000000..1699f90
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_shutdown.cpp
@@ -0,0 +1,242 @@
+/*
+ * @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.
+ */
+
+#include "tskm_shutdown.h"
+#include "tskm_util.h"
+#include "tskm_debug.h"
+#include "tskm_state.h"
+
+#include "tskm_port_pf.h"
+#include "tskm_port_subsys.h"
+#include "tskm_gstep.h"
+
+
+/*********************************************************
+ * Get context of gradual startup
+ *********************************************************/
+TSKM_STATIC TSKM_GSTEP_CTX_t*
+gstepGetDownCtx(TSKM_MAIN_CTX_t* p_main) {
+ return &p_main->down;
+}
+
+/*********************************************************
+ * System shutdown completed
+ *********************************************************/
+TSKM_STATIC void downFinish(TSKM_MAIN_CTX_t* p_main) {
+ int ret;
+
+ // Send FrameworkunifiedOnStop response
+ ret = tskm_pf_sendStopCompResp();
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 8: As ret never becomes non-zero
+ // LCOV_EXCL_START 8: As ret never becomes non-zero
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ // LCOV_EXCL_STOP
+ }
+
+ // Terminate subsystems
+ tskm_sub_term();
+}
+/*********************************************************
+ * Challenge for a transition to the next state
+ *********************************************************/
+TSKM_STATIC void tryTransNextState(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_GSTEP_CTX_t* p_down;
+ TSKM_GSTEP_t* p_current;
+
+ p_down = gstepGetDownCtx(p_main);
+ p_current = gstepGetCurrent(p_down);
+
+ if (gstepIsLast(p_down)) {
+ TSKM_SVC_WAIT_STATE_t waitState;
+
+ // Checking the ShutdownWaitSVC termination status
+ waitState = tskm_svcsGetSvcTermWaitState(&p_main->svcs);
+ switch (waitState) {
+ case TSKM_SVC_WAIT_BOTH:
+ break;
+ case TSKM_SVC_WAIT_TRANSIENT:
+ if ((p_down->compState & INI_TERMCOMP_RESIDENT) != INI_TERMCOMP_RESIDENT) {
+ // Nonresident service termination processing
+ if (TSKM_E_OK != tskm_svcsAvtiveSvcTerm(&p_main->svcs)) { // LCOV_EXCL_BR_LINE 5: tskm_svcsAvtiveSvcTerm is always return TSKM_E_OK
+ // LCOV_EXCL_START 5: tskm_svcsAvtiveSvcTerm is always return TSKM_E_OK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ // LCOV_EXCL_STOP
+ }
+ // Nonresident SVC terminated and started
+ p_down->compState |= INI_TERMCOMP_RESIDENT;
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "TERM COMP :%s(%#llx)",
+ tskm_convTermCompId2Str(INI_TERMCOMP_RESIDENT),
+ INI_TERMCOMP_RESIDENT);
+ }
+ break;
+ case TSKM_SVC_WAIT_NONE:
+ // Complete ShutdownWaitSVC
+ // Nonresident SVC terminated and started
+ p_down->compState |= INI_TERMCOMP_TRANSIENT;
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "TERM COMP :%s(%#llx)",
+ tskm_convTermCompId2Str(INI_TERMCOMP_TRANSIENT),
+ INI_TERMCOMP_TRANSIENT);
+ break;
+ default:
+ // LCOV_EXCL_START 8: As it does not meet the default requirements
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ break;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (tskm_svcsIsWaiting(&p_main->svcs) == TSKM_FALSE && // No waiting services
+ ((p_down->compState & p_current->nextTransCond)
+ == p_current->nextTransCond)) { // Event completion condition
+ if (gstepIsLast(p_down)) {
+ tskm_stateTransit(p_main, TSKM_ST_ACCON, TSKM_ST_ACCOFF);
+ } else {
+ tskm_stateTransit(p_main, TSKM_ST_DOWN, TSKM_ST_DOWN);
+ }
+ }
+}
+
+/*********************************************************
+ * Check and process gradual termination request
+ *********************************************************/
+TSKM_ERR_t tskm_entryDown_Check_Req(TSKM_MAIN_CTX_t* p_main,
+ TSKM_GSTEP_t* p_current) {
+ uint32_t ii;
+
+ if (0 == p_current->reqNum) {
+ EFrameworkunifiedStatus l_eStatus;
+
+ // If there is no gradual termination request, check the transition to the next step.
+ l_eStatus = FrameworkunifiedSendSelf(p_main->hApp, TSKM_TRANS_STEP_REQ, 0, NULL);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 5: Checked in death testing, but it is not reflected in the coverage and excluded
+ // LCOV_EXCL_START 5: Checked in death testing, but it is not reflected in the coverage and excluded
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ return TSKM_E_NG;
+ // LCOV_EXCL_STOP
+ }
+
+ } else {
+ // Gradual termination request
+ for (ii = 0; ii < p_current->reqNum; ii++) {
+ TSKM_ERR_t tskmRet;
+ TSKM_GSTEP_REQ_INFO_t* p_req = &p_current->reqList[ii];
+ TSKM_SVC_CTX_t* p_svc = tskm_svcsGetSvcBySvcId(&p_main->svcs,
+ p_req->svcId);
+
+ tskmRet = tskm_svcDownRequest(p_svc, p_req);
+ if (tskmRet != TSKM_E_OK) {
+ TSKM_ASSERT(0);
+ }
+ }
+ }
+ return TSKM_E_OK;
+}
+
+/*********************************************************
+ * Gradual termination entry process
+ *********************************************************/
+TSKM_ERR_t tskm_entryDown(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_FUNC_IN();
+
+ TSKM_GSTEP_CTX_t* p_down;
+ TSKM_GSTEP_t* p_current;
+
+ p_main->state = TSKM_ST_DOWN;
+ p_down = gstepGetDownCtx(p_main);
+ p_current = gstepGetCurrent(p_down);
+ if (p_current == NULL) { // LCOV_EXCL_BR_LINE 200:p_current can not be null
+ // LCOV_EXCL_START 200:p_current can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "DOWN GSTEP:%d", p_down->gstepIdx);
+
+ if (tskm_entryDown_Check_Req(p_main, p_current) == TSKM_E_NG) { // LCOV_EXCL_BR_LINE 200:the function of tskm_entryDown_Check_Req can not be TSKM_E_NG at this case // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 200:tskm_entryDown_Check_Req can not be TSKM_E_NG at this case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if (p_current->nextTransCond) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "WAIT COMP:%s(%llx)",
+ tskm_convTermCompId2Str(p_current->nextTransCond),
+ p_current->nextTransCond);
+ }
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+
+ ERROR: tskm_pf_abort();
+ return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Gradual termination exit process
+ *********************************************************/
+TSKM_ERR_t tskm_exitDown(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_FUNC_IN();
+ TSKM_GSTEP_CTX_t* p_down;
+
+ p_down = gstepGetDownCtx(p_main);
+
+ if (gstepIsLast(p_down)) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "DOWN FINISH");
+ downFinish(p_main); // Final process of termination
+ }
+
+ changeNextStep(p_down); // Proceed to the next step
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+/*********************************************************
+ * Hander during gradual termination
+ *********************************************************/
+TSKM_ERR_t tskm_handleDown(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev) {
+ TSKM_FUNC_IN();
+
+ switch (p_ev->event) {
+ case TSKM_EV_PRI_REP_DOWN_COMP: // Notificaton for event completion in termination
+ {
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "TERM COMP :%s(%#llx) from:%d",
+ tskm_convTermCompId2Str(p_ev->prm.repDownComp.compId),
+ p_ev->prm.repDownComp.compId, p_ev->fromPid);
+ TSKM_GSTEP_CTX_t* p_down = gstepGetDownCtx(p_main);
+ p_down->compState |= p_ev->prm.repDownComp.compId;
+ tryTransNextState(p_main);
+ }
+ break;
+ case TSKM_EV_LCL_CHG_SVC_STATE: // Service state change
+ tryTransNextState(p_main);
+ break;
+ case TSKM_EV_LCL_REQ_TRANS_STEP: //Step transition request
+ tryTransNextState(p_main);
+ break;
+ default:
+ tskm_handleAccon(p_main, p_ev);
+ break;
+ }
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/server/src/tskm_state.cpp b/systemservice/task_manager/server/src/tskm_state.cpp
new file mode 100755
index 0000000..b777090
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_state.cpp
@@ -0,0 +1,452 @@
+/*
+ * @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.
+ */
+
+#include "tskm_state.h"
+#include <stdlib.h>
+#include "tskm_util.h"
+#include "tskm_debug.h"
+#include "tskm_wakeup.h"
+#include "tskm_shutdown.h"
+#include "tskm_port_subsys.h"
+#include "tskm_port_pf.h"
+
+
+
+// Prototype declarations
+TSKM_ERR_t tskm_entryAccoff(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_exitAccoff(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_handleAccoff(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev);
+
+TSKM_ERR_t tskm_entryAccon(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_exitAccon(TSKM_MAIN_CTX_t* p_main);
+
+TSKM_ERR_t tskm_entryRunning(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_exitRunning(TSKM_MAIN_CTX_t* p_main);
+TSKM_ERR_t tskm_handleRunning(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev);
+
+// Structures of state transitioning callback functions
+typedef TSKM_ERR_t (*entry_state_t)(TSKM_MAIN_CTX_t* p_main);
+typedef TSKM_ERR_t (*exit_state_t)(TSKM_MAIN_CTX_t* p_main);
+typedef TSKM_ERR_t (*event_handler_t)(TSKM_MAIN_CTX_t* p_main,
+ TSKM_EVENT_INFO_t* p_ev);
+
+typedef struct {
+ TSKM_STATE_t state;
+ entry_state_t entry_func;
+ exit_state_t exit_func;
+ event_handler_t event_handler;
+} state_func_table_t;
+
+// State specific function table
+static const state_func_table_t state_func_table[] = { { TSKM_ST_ACCOFF,
+ tskm_entryAccoff, tskm_exitAccoff, tskm_handleAccoff }, { TSKM_ST_ACCON,
+ tskm_entryAccon, tskm_exitAccon, tskm_handleAccon }, { TSKM_ST_WAKEUP,
+ tskm_entryWakeup, tskm_exitWakeup, tskm_handleWakeup }, { TSKM_ST_RUNNING,
+ tskm_entryRunning, tskm_exitRunning, tskm_handleRunning }, { TSKM_ST_DOWN,
+ tskm_entryDown, tskm_exitDown, tskm_handleDown }, { 0, 0, 0, 0 } };
+
+/****************************************************
+ * ACC OFF ENTRY
+ ****************************************************/
+TSKM_ERR_t tskm_entryAccoff(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_FUNC_IN();
+ p_main->state = TSKM_ST_ACCOFF;
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * ACC OFF EXIT
+ *************************************************************************/
+TSKM_ERR_t tskm_exitAccoff(TSKM_MAIN_CTX_t* p_main) {
+ // Do nothing
+ // Called only once at startup
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * ACC OFF HANDLE
+ *************************************************************************/
+TSKM_ERR_t tskm_handleAccoff(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev) {
+ TSKM_ASSERT(0); // Do nothing
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * ACC ON ENTRY
+ *************************************************************************/
+TSKM_ERR_t tskm_entryAccon(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_FUNC_IN();
+ p_main->state = TSKM_ST_ACCON;
+
+ tskm_entryState(p_main, TSKM_ST_WAKEUP);
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * ACC ON HANDLE
+ *************************************************************************/
+TSKM_ERR_t tskm_exitAccon(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_FUNC_IN();
+
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+
+ if (TSKM_SUB_STATE_IS(p_main, TSKM_ST_WAKEUP)) { // LCOV_EXCL_BR_LINE 8:Because the condition is never true
+ // LCOV_EXCL_START 8: Because the condition is never true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskmRet = tskm_exitState(p_main, TSKM_ST_WAKEUP);
+ // LCOV_EXCL_STOP
+ } else if (TSKM_SUB_STATE_IS(p_main, TSKM_ST_RUNNING)) { // LCOV_EXCL_BR_LINE 8: Because the condition is never true
+ // LCOV_EXCL_START 8: Because the condition is never true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskmRet = tskm_exitState(p_main, TSKM_ST_RUNNING);
+ // LCOV_EXCL_STOP
+ } else if (TSKM_SUB_STATE_IS(p_main, TSKM_ST_DOWN)) { // LCOV_EXCL_BR_LINE 8:Because the condition is never false
+ tskmRet = tskm_exitState(p_main, TSKM_ST_DOWN);
+ }
+
+ TSKM_ERR_CHK(tskmRet, TSKM_E_OK, ERROR); // LCOV_EXCL_BR_LINE 8: Because the tskmRet does not change to NG
+ p_main->isExec = TSKM_FALSE;
+ ERROR:
+ TSKM_FUNC_OUT();
+ return tskmRet;
+}
+
+/*************************************************************************
+ * POLL EVENT HANDLE
+ *************************************************************************/
+TSKM_STATIC void checkHungSvcs(TSKM_MAIN_CTX_t* p_main) {
+ int ret;
+ TSKM_HUNG_INFO_t *p_hungSvcList = NULL;
+
+ p_hungSvcList = tskm_sub_searchHungSvcs();
+ if (p_hungSvcList != NULL) {
+ int hungSvcNum = 0;
+
+ while (p_hungSvcList[hungSvcNum].pid != -1) {
+ pid_t pid = p_hungSvcList[hungSvcNum].pid;
+
+ TSKM_SVC_CTX_t* p_svc = tskm_svcsGetSvcByPid(&p_main->svcs, pid);
+
+ if (p_svc) {
+ TSKM_PRINTF(TSKM_LOG_SYSTEMDATA, "HUNG SVC(%s:%d), TYPE(%d)",
+ p_svc->attr->name, pid, p_hungSvcList[hungSvcNum].type);
+
+ ret = tskm_pf_terminateProcGroup(static_cast<uint16_t>(pid));
+ if (ret != 0) {
+ TSKM_ASSERT(0);
+ }
+
+ } else {
+ TSKM_PRINTF(TSKM_LOG_WARN, "UNKNOWN HUNG SVC(%d), TYPE(%d)", pid,
+ p_hungSvcList[hungSvcNum].type);
+ }
+
+ hungSvcNum++;
+ }
+
+ free(p_hungSvcList);
+ }
+
+ return;
+}
+
+#define AVAILABILITY_CHECK_RETRY_COUNT 24
+
+/*************************************************************************
+ * CHECK SVC AVAILABILITY
+ *************************************************************************/
+TSKM_STATIC void checkSvcAvailability(TSKM_MAIN_CTX_t* p_main) {
+ for (uint32_t ii = 0; ii < p_main->svcs.svcNum; ii++) {
+ if (p_main->svcs.svcList[ii].state == TSKM_SVC_RUNNING
+ && !p_main->svcs.svcList[ii].isAvailable) {
+ p_main->svcs.svcList[ii].watchCnt++;
+ TSKM_ASSERT_PRINT(0, "WAIT AVAILABILITY FOR %s(%d) (%d/%d)",
+ p_main->svcs.svcList[ii].attr->name,
+ p_main->svcs.svcList[ii].pid,
+ p_main->svcs.svcList[ii].watchCnt,
+ AVAILABILITY_CHECK_RETRY_COUNT);
+
+ if (p_main->svcs.svcList[ii].watchCnt > AVAILABILITY_CHECK_RETRY_COUNT) {
+ int ret;
+
+ ret = tskm_pf_terminateProcGroup(static_cast<uint16_t>(p_main->svcs.svcList[ii].pid));
+ if (ret != 0) {
+ TSKM_ASSERT(0);
+ }
+ }
+ }
+ }
+
+ return;
+}
+
+/*************************************************************************
+ * POLL EVENT HANDLE
+ *************************************************************************/
+TSKM_STATIC void handlePolling(TSKM_MAIN_CTX_t* p_main) {
+ checkHungSvcs(p_main);
+
+ checkSvcAvailability(p_main);
+
+ return;
+}
+
+/*************************************************************************
+ * LOW MEMORY EVENT HANDLE
+ *************************************************************************/
+TSKM_STATIC void handleLowMem(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+
+ tskmRet = tskm_svcsCallLowMem(&p_main->svcs);
+ if (TSKM_E_OK != tskmRet) {
+ TSKM_ASSERT(0);
+ }
+
+ return;
+}
+/*************************************************************************
+ * ACC ON HANDLE
+ *************************************************************************/
+TSKM_ERR_t tskm_handleAccon(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev) {
+ TSKM_FUNC_IN();
+
+ switch (p_ev->event) {
+ case TSKM_EV_LCL_REQ_SDUMP:
+ tskm_svcsDump(&p_main->svcs);
+ break;
+ // LCOV_EXCL_STOP
+ case TSKM_EV_LCL_REP_POLLING:
+ TSKM_PRINTF(TSKM_LOG_DEBUG, "watch timer polling event.");
+ handlePolling(p_main);
+ break;
+ default:
+ TSKM_PRINTF(TSKM_LOG_STATE, "IGNORE:%s(%d)",
+ tskm_convEvent2Str(p_ev->event), p_ev->event);
+ break;
+ }
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * BOOT RESERVED SERVICES
+ *************************************************************************/
+static int bootRsvSvcs(TSKM_MAIN_CTX_t* p_main) {
+ uint32_t ii;
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+ uint8_t rsvSvcNum = p_main->nvInfo.body.rsvSvcNum;
+ TSKM_SVCID_t* p_rsvSvcs = p_main->nvInfo.body.rsvSvcs;
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "RSV SVC NUM = %d", rsvSvcNum);
+
+ for (ii = 0; ii < rsvSvcNum; ii++) {
+ TSKM_GSTEP_REQ_INFO_t req = { 0 };
+ TSKM_SVC_CTX_t* p_svc;
+
+ p_svc = tskm_svcsGetSvcBySvcId(&p_main->svcs, p_rsvSvcs[ii]);
+ if (p_svc == NULL) {
+ TSKM_ASSERT(0);
+ continue;
+ }
+
+ tskmRet = tskm_svcExec(p_svc);
+ if (TSKM_E_OK != tskmRet) {
+ TSKM_ASSERT(0);
+ continue;
+ }
+ if (p_svc->state == TSKM_SVC_WAITCONNECT) {
+ // In the state waiting for execution
+ req.svcId = p_rsvSvcs[ii];
+ req.localStep = TSKM_LSTEP_ALL;
+ tskmRet = tskm_svcWakeupRequest(p_svc, &req);
+ if (TSKM_E_OK != tskmRet) { // LCOV_EXCL_BR_LINE 8: Because the condition is never true
+ // LCOV_EXCL_START 8: Because the condition is never true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT_PRINT(0, "tskmRet = %d", tskmRet);
+ continue;
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+
+ if (rsvSvcNum != 0) {
+ int ret;
+
+ for (ii = 0; ii < TSKM_SVC_RESERVE_MAX; ii++) {
+ p_rsvSvcs[ii] = TSKM_SVCID_NONE;
+ }
+
+ p_main->nvInfo.body.rsvSvcNum = 0;
+
+ ret = tskm_pf_nvFileWrite(&p_main->nvInfo);
+ if (ret == -1) { // LCOV_EXCL_BR_LINE 8: Because the tskm_pf_nvFileWrite() only returns a return value of 0
+ // LCOV_EXCL_START 8:Because the condition is never true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ return 0;
+ // LCOV_EXCL_START 8: Because the tskm_pf_nvFileWrite() only returns a return value of 0
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1;
+ // LCOV_EXCL_STOP
+}
+
+/*************************************************************************
+ * RUN ENTRY
+ *************************************************************************/
+TSKM_ERR_t tskm_entryRunning(TSKM_MAIN_CTX_t* p_main) {
+ int ret;
+
+ TSKM_FUNC_IN();
+ p_main->state = TSKM_ST_RUNNING;
+
+ ret = bootRsvSvcs(p_main);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 8: Because bootRsvSvcs returns only a return value of 0
+ // LCOV_EXCL_START 8: Because bootRsvSvcs returns only a return value of 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ // LCOV_EXCL_STOP
+ }
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * RUN EXIT
+ *************************************************************************/
+TSKM_ERR_t tskm_exitRunning(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_FUNC_IN();
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * RUN HANDLE
+ *************************************************************************/
+TSKM_ERR_t tskm_handleRunning(TSKM_MAIN_CTX_t* p_main,
+ TSKM_EVENT_INFO_t* p_ev) {
+ TSKM_FUNC_IN();
+
+ switch (p_ev->event) {
+ case TSKM_EV_LCL_REQ_STOP:
+ tskm_stateTransit(p_main, TSKM_ST_RUNNING, TSKM_ST_DOWN);
+ break;
+ case TSKM_EV_LCL_REP_LOWMEM:
+ handleLowMem(p_main);
+ break;
+ default:
+ tskm_handleAccon(p_main, p_ev);
+ break;
+ }
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*************************************************************************
+ * Get transition table
+ *************************************************************************/
+static const state_func_table_t*
+tskm_getFuncTable(TSKM_STATE_t state) {
+ int i;
+ for (i = 0; state_func_table[i].state != 0; i++) {
+ if (state == state_func_table[i].state) {
+ return &state_func_table[i];
+ }
+ }
+ TSKM_ASSERT(0);
+ return &state_func_table[0];
+}
+
+/*************************************************************************
+ * State transition instructions
+ *************************************************************************/
+TSKM_ERR_t tskm_stateTransit(TSKM_MAIN_CTX_t* p_main, TSKM_STATE_t srcState,
+ TSKM_STATE_t dstState) {
+ TSKM_ERR_t tskmRet;
+ TSKM_PRINTF(TSKM_LOG_STATE, "STATE:%s(%s) -> %s",
+ tskm_convState2Str(srcState), tskm_convState2Str(p_main->state),
+ tskm_convState2Str(dstState));
+
+ tskmRet = tskm_exitState(p_main, srcState);
+ TSKM_ERR_CHK(tskmRet, TSKM_E_OK, ERROR); // LCOV_EXCL_BR_LINE 8: Because TSKM_ERR_CHK does not specify a goto ERROR condition
+ tskmRet = tskm_entryState(p_main, dstState);
+ TSKM_ERR_CHK(tskmRet, TSKM_E_OK, ERROR); // LCOV_EXCL_BR_LINE 8: Because TSKM_ERR_CHK does not specify a goto ERROR condition
+ return TSKM_E_OK;
+
+ // LCOV_EXCL_START 8: Because TSKM_ERR_CHK does not specify a goto ERROR condition
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return TSKM_E_NG;
+ // LCOV_EXCL_STOP
+}
+
+/*************************************************************************
+ * Event handler
+ *************************************************************************/
+void tskm_handleEvent(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev) {
+ event_handler_t handlerFunc;
+ handlerFunc = tskm_getFuncTable(p_main->state)->event_handler;
+ handlerFunc(p_main, p_ev);
+}
+
+/****************************************************
+ * State transitioning entry process
+ ****************************************************/
+TSKM_ERR_t tskm_entryState(TSKM_MAIN_CTX_t* p_rec, TSKM_STATE_t state) {
+ TSKM_ERR_t ret = TSKM_E_NG;
+ const state_func_table_t* p_table = tskm_getFuncTable(state);
+
+ TSKM_PRINTF(TSKM_LOG_DEBUG, "entry :%s", tskm_convState2Str(state));
+ if (p_table->entry_func) { // LCOV_EXCL_BR_LINE 8: Because p_table->entry_func never becomes 0
+ ret = ((*p_table->entry_func)(p_rec));
+ } else {
+ // LCOV_EXCL_START 8: Because p_table->entry_func never becomes 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ // LCOV_EXCL_STOP
+ }
+ return ret;
+}
+
+/****************************************************
+ * State transitioning exit process
+ ****************************************************/
+TSKM_ERR_t tskm_exitState(TSKM_MAIN_CTX_t* p_rec, TSKM_STATE_t state) {
+ TSKM_ERR_t ret = TSKM_E_NG;
+ const state_func_table_t* p_table = tskm_getFuncTable(state);
+
+ if (p_table->exit_func) { // LCOV_EXCL_BR_LINE 8: Because p_table->exit_func never becomes 0
+ ret = (*p_table->exit_func)(p_rec);
+ } else {
+ // LCOV_EXCL_START 8: Because p_table->exit_func never becomes 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ // LCOV_EXCL_STOP
+ }
+ TSKM_PRINTF(TSKM_LOG_DEBUG, "exit :%s", tskm_convState2Str(state));
+ return ret;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/server/src/tskm_svc.cpp b/systemservice/task_manager/server/src/tskm_svc.cpp
new file mode 100755
index 0000000..2f9abc1
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_svc.cpp
@@ -0,0 +1,970 @@
+/*
+ * @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.
+ */
+
+#include "system_service/tskm_svc.h"
+#include <string.h>
+#include <stdlib.h>
+#include <sys/inotify.h>
+#include <errno.h>
+
+#include <native_service/ns_np_service_if.h>
+#include <string>
+
+#include "tskm_debug.h"
+#include "tskm_util.h"
+#include "tskm_port_pf.h"
+#include "tskm_port_subsys.h"
+#include "tskm_comm.h"
+
+
+/*********************************************************
+ * Is the target event of the service handler?
+
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t isSvcEvent(const TSKM_EVENT_INFO_t* p_ev) {
+ switch (p_ev->event) {
+ case TSKM_EV_PRI_REP_CONNECT:
+ case TSKM_EV_PRI_REP_DISCONNECT:
+ case TSKM_EV_PRI_RES_WAKEUP:
+ case TSKM_EV_PRI_RES_DOWN:
+ case TSKM_EV_PRI_RES_DEBUGDUMP:
+ case TSKM_EV_PRI_REQ_EXIT:
+ case TSKM_EV_SVC_REP_TERM:
+ return TSKM_TRUE;
+ break;
+ default:
+ break;
+ }
+ return TSKM_FALSE;
+}
+
+/*********************************************************
+ * Get service context
+ *********************************************************/
+TSKM_STATIC TSKM_SVC_CTX_t*
+getSvcCtxBySvcId(TSKM_SVCS_CTX_t* p_svcs, TSKM_SVCID_t svcId) {
+ uint32_t ii;
+
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ if (p_svcs->svcList[ii].attr->svcId == svcId) {
+ return &p_svcs->svcList[ii];
+ }
+ }
+ TSKM_ASSERT(0);
+ return NULL;
+}
+
+/*********************************************************
+ * Get service context
+ *********************************************************/
+TSKM_STATIC TSKM_SVC_CTX_t*
+getSvcCtxByPid(TSKM_SVCS_CTX_t* p_svcs, pid_t pid) {
+ uint32_t ii;
+
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ if (p_svcs->svcList[ii].pid == pid) {
+ return &p_svcs->svcList[ii];
+ }
+ }
+ return NULL;
+}
+
+/*********************************************************
+ * Get service context
+ *********************************************************/
+TSKM_STATIC TSKM_SVC_CTX_t*
+getSvcCtxByName(TSKM_SVCS_CTX_t* p_svcs, const char *p_name) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ uint32_t ii;
+
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ if (0
+ == strncmp(p_svcs->svcList[ii].attr->name, p_name,
+ strlen(p_svcs->svcList[ii].attr->name))) {
+ return &p_svcs->svcList[ii];
+ }
+ }
+ return NULL;
+}
+// LCOV_EXCL_STOP
+/*********************************************************
+ * Issuing a start request to the service
+ *********************************************************/
+TSKM_STATIC TSKM_ERR_t wakeupRequest(TSKM_SVC_CTX_t* p_svc,
+ TSKM_GSTEP_REQ_INFO_t* p_req) {
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+ bzero(&ev, sizeof(ev));
+
+ ev.event = TSKM_EV_PRI_REQ_WAKEUP;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.reqWakeup.svcId = p_svc->attr->svcId;
+ ev.prm.reqWakeup.localStep = p_req->localStep;
+ ev.prm.reqWakeup.isDynamic =
+ (p_svc->attr->lifeCycle == TSKM_SVC_LC_DYNAMIC) ? TSKM_TRUE : TSKM_FALSE;
+ // Since there is no startup in the P_CWORD72_ but only communication in the ALL/LAST,
+ // the startup information is optimized including the startup information in the communication of the WakeupRequest.
+ memcpy(&ev.prm.reqWakeup.bootInfo, &p_svc->bootInfo,
+ sizeof(ev.prm.reqWakeup.bootInfo));
+ memcpy(&ev.prm.reqWakeup.extBootInfo, &p_svc->extBootInfo,
+ sizeof(ev.prm.reqWakeup.extBootInfo));
+
+ ret = tskm_sockSend(p_svc->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ p_svc->waitResCnt++;
+ p_svc->state = TSKM_SVC_WAKEUP;
+
+ return TSKM_E_OK;
+ ERROR: return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Touch services and extend EXIT timeouts
+ *********************************************************/
+TSKM_STATIC TSKM_ERR_t reqTouch(TSKM_SVC_CTX_t* p_svc) {
+#define TSKM_BUF_LEN ( 4 * ( sizeof(struct inotify_event) ) ) /* read size */
+ TSKM_ERR_t funcRet = TSKM_E_NG;
+ char touchFileName[32];
+ BOOL isNeedRetry = FALSE;
+
+ int iFd = p_svc->iFd;
+ int wd = 0;
+
+ TSKM_EVENT_INFO_t ev;
+ int ret;
+ bzero(&ev, sizeof(ev));
+
+ // Create monitoring files
+ tskm_pf_mkTouchFileName(p_svc->pid, touchFileName);
+ if (0 != tskm_pf_touch(touchFileName)) {
+ goto ERROR;
+ }
+
+ // Synchronize by iNortify
+ wd = inotify_add_watch(iFd, touchFileName, IN_DELETE_SELF);
+ if (wd == -1) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+
+ // Send Touch request
+ ev.event = TSKM_EV_PRI_REQ_TOUCH;
+ ev.errCode = TSKM_E_OK;
+ ret = tskm_sockSend(p_svc->connFd, &ev);
+ if (ret <= 0) {
+ // Immediately after the nonresident service process terminates, since the TaskManager service status is other than DORMANT
+ // (mainly DOWN), the socket may be discarded and communication may fail, so retry
+ funcRet = TSKM_E_RETRY;
+ TSKM_PRINTF(TSKM_LOG_WARN, "ret = %d", ret);
+ goto ERROR;
+ }
+
+ // Wait for Touch completion
+ while (1) {
+ int maxFd = 0;
+ int ret;
+ fd_set fds;
+ FD_ZERO(&fds);
+ struct timeval timeout = { 0 };
+ timeout.tv_sec = TSKM_CFG_TOUCH_TIMEOUT;
+
+ FD_SET(iFd, &fds);
+ maxFd = iFd;
+
+ ret = select(maxFd + 1, &fds, NULL, NULL, &timeout);
+ if (ret == 0) {
+ TSKM_ASSERT_PRINT(0, "TIMEOUT:%s", touchFileName); // Timeout occurs
+ isNeedRetry = TRUE;
+ break;
+ } else if (ret < 1) {
+ if (errno == EINTR) {
+ continue;
+ } else {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ }
+
+ if (FD_ISSET(iFd, &fds)) {
+ int length;
+ uint8_t buf[TSKM_BUF_LEN];
+
+ length = static_cast<int>(read(iFd, buf, TSKM_BUF_LEN));
+ if (length < 0) {
+ TSKM_ASSERT_ERRNO(0);
+ goto ERROR;
+ }
+ struct inotify_event *event = (struct inotify_event *) buf;
+ if (event->mask & IN_DELETE_SELF) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "TouchOK");
+ wd = 0;
+ // When a file is deleted, the association with the monitoring target is automatically released and inotify_rm_watch is no longer needed.
+ break;
+ } else {
+ TSKM_ASSERT_PRINT(0, "%x", event->mask);
+ }
+ }
+ }
+
+ if (isNeedRetry) {
+ funcRet = TSKM_E_RETRY;
+ } else {
+ funcRet = TSKM_E_OK;
+ }
+
+ ERROR: if (wd > 0) {
+ TSKM_ASSERT_ERRNO(0 == inotify_rm_watch(iFd, wd))
+ }
+
+ if (access(touchFileName, F_OK) == 0) {
+ // Timeout care
+ unlink(touchFileName);
+ }
+
+ return funcRet;
+}
+
+/*********************************************************
+ * Availability Monitoring Callbacks for Services
+ *********************************************************/
+EFrameworkunifiedStatus OnSvcAvailability(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ PCSTR availabilityName;
+ TSKM_MAIN_CTX_t* p_main = tskm_getMainCtx();
+ TSKM_SVC_CTX_t* p_svc;
+
+ availabilityName = FrameworkunifiedGetLastNotification(hApp);
+
+ std::string str = availabilityName;
+
+// unsigned int position;
+// if (std::string::npos != (position = static_cast<unsigned int>(str.find("/Availability", 0)))) {
+ ssize_t position;
+ if (0 <= (position = str.find("/Availability", 0))) {
+ str.erase(position, position + strlen("/Availability"));
+ }
+
+ p_svc = getSvcCtxByName(&p_main->svcs, str.c_str());
+ if (p_svc) {
+ p_svc->isAvailable = FrameworkunifiedIsServiceAvailable(hApp) ? TSKM_TRUE : TSKM_FALSE;
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "%s Availability %s", p_svc->attr->name,
+ (p_svc->isAvailable == TSKM_TRUE) ? "TRUE" : "FALSE");
+ }
+
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+/*********************************************************
+ * Starting Availability Monitoring of Services
+ *********************************************************/
+TSKM_STATIC TSKM_ERR_t startWatchAvailability(TSKM_SVC_CTX_t* p_svc) {
+ TSKM_ERR_t funcRet = TSKM_E_OK;
+
+ // LCOV_EXCL_BR_START 8: Since the condition is checked by the caller, it is not true.
+ if (p_svc->attr->type == TSKM_SVC_TYPE_UNKNONW) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ p_svc->isAvailable = TSKM_TRUE; // LCOV_EXCL_LINE 8: Since the condition is checked by the caller, it is not true.
+ } else {
+ EFrameworkunifiedStatus taskmanagerStatus;
+ TSKM_MAIN_CTX_t* p_main = tskm_getMainCtx();
+ SS_String availabilityName = p_svc->attr->name;
+
+ availabilityName.append("/Availability");
+
+ taskmanagerStatus = FrameworkunifiedSubscribeNotificationWithCallback(p_main->hApp,
+ availabilityName.c_str(),
+ OnSvcAvailability);
+ if (eFrameworkunifiedStatusOK != taskmanagerStatus) {
+ TSKM_ASSERT(0);
+ funcRet = TSKM_E_NG;
+ }
+ }
+
+ return funcRet;
+}
+
+/*********************************************************
+ * Service startup sub
+ *********************************************************/
+void svcExec_Process(TSKM_SVC_CTX_t* p_svc) {
+ TSKM_ERR_t funcRet;
+
+ if (p_svc->attr->type == TSKM_SVC_TYPE_NATIVE) {
+ p_svc->state = TSKM_SVC_WAITCONNECT;
+ TSKM_PRINTF(TSKM_LOG_DEBUG, "[ST:%d] WAIT_EXEC", p_svc->pid);
+ funcRet = startWatchAvailability(p_svc);
+ if (TSKM_E_OK != funcRet) {
+ TSKM_ASSERT(0);
+ p_svc->isAvailable = TSKM_TRUE;
+ }
+ } else {
+ p_svc->state = TSKM_SVC_RUNNING;
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "[ST:%d] RUN", p_svc->pid);
+ p_svc->isAvailable = TSKM_TRUE;
+ }
+ return;
+}
+
+/*********************************************************
+ * Service startup main
+ *********************************************************/
+TSKM_STATIC TSKM_ERR_t svcExec(TSKM_SVC_CTX_t* p_svc) {
+ TSKM_ERR_t funcRet = TSKM_E_NG;
+ pid_t pid;
+
+ if (p_svc == NULL) { // LCOV_EXCL_BR_LINE 6:double check
+ // LCOV_EXCL_START 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP
+ }
+
+ if (p_svc->state == TSKM_SVC_DISABLE) {
+ // Prohibited startup
+ TSKM_ASSERT(0);
+ return TSKM_E_STATE;
+ } else if (p_svc->state == TSKM_SVC_WAITCONNECT) {
+ return TSKM_E_OK;
+ } else if (p_svc->state != TSKM_SVC_DORMANT) {
+ // Already started
+ funcRet = reqTouch(p_svc);
+ if (TSKM_E_OK != funcRet) {
+ TSKM_PRINTF(TSKM_LOG_WARN, "funcRet = %d", funcRet);
+ goto ERROR;
+ }
+ return TSKM_E_OK;
+ }
+
+ pid = tskm_pf_createProc(p_svc->attr);
+ if (pid <= 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ TSKM_PRINTF(TSKM_LOG_STATE, "EXEC %s:%d", p_svc->attr->name, pid);
+
+ p_svc->pid = pid;
+ p_svc->waitReqCnt = 0;
+
+ // Startup service
+ svcExec_Process(p_svc);
+
+ funcRet = TSKM_E_OK;
+ ERROR: return funcRet;
+}
+
+/*********************************************************
+ * Issuing a start request to the service
+ *********************************************************/
+TSKM_STATIC TSKM_ERR_t svcWakeupRequest(TSKM_SVC_CTX_t* p_svc,
+ TSKM_GSTEP_REQ_INFO_t* p_req) {
+ if (p_svc == NULL || p_svc->state == TSKM_SVC_DISABLE) { // LCOV_EXCL_BR_LINE 6: Since this function has always been called after checking // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return TSKM_E_STATE; // LCOV_EXCL_LINE 6: Since this function has always been called after checking
+ } else if (p_svc->state == TSKM_SVC_WAITCONNECT) {
+ // Remember it once and issue a request when the CONNECT completes.
+ p_svc->request[p_svc->waitReqCnt] = *p_req;
+ p_svc->waitReqCnt++;
+ } else {
+ TSKM_ERR_t tskmRet;
+ tskmRet = wakeupRequest(p_svc, p_req);
+ TSKM_ERR_CHK_DFT;
+ }
+
+ return TSKM_E_OK;
+ ERROR: return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Service reboot processing
+ *********************************************************/
+TSKM_STATIC TSKM_ERR_t svcErrTermPost(TSKM_SVC_CTX_t* p_svc) {
+ TSKM_MAIN_CTX_t* p_main = tskm_getMainCtx();
+
+ TSKM_PRINTF(TSKM_LOG_SYSTEMDATA, "ERR TERM SVC(%s:%d)", p_svc->attr->name,
+ p_svc->pid);
+
+ if (p_svc->attr->lifeCycle == TSKM_SVC_LC_ALWAYS || (p_svc->errTermCnt > p_svc->attr->retryCnt && (uint32_t) -1 != p_svc->attr->retryCnt)) { // NOLINT(whitespace/line_length)
+ TSKM_ERROR_REBOOT_t rebootInfo;
+
+ TSKM_ASSERT(0);
+ memset(&rebootInfo, 0, sizeof(TSKM_ERROR_REBOOT_t));
+ rebootInfo.type = TSKM_ERROR_REBOOT_NORMAL;
+ snprintf(rebootInfo.log.messageStr, TSKM_LOGGING_MSG_STR_SIZE,
+ "TaskManager:SVC ErrTerm");
+ tskm_sub_reboot(&rebootInfo);
+ } else {
+ TSKM_LOGGING_INFO_t logInfo;
+ logInfo.type = TSKM_LOGGING_TYPE_MODULE_LOGS;
+
+ snprintf(logInfo.messageStr, TSKM_LOGGING_MSG_STR_SIZE,
+ "TaskManager:SVC ErrTerm");
+ tskm_sub_logging(&logInfo);
+
+ if (p_svc->attr->lifeCycle == TSKM_SVC_LC_ALWAYS_RECOVERABLE) {
+ TSKM_ERR_t ret;
+ TSKM_GSTEP_REQ_INFO_t req = { 0 };
+
+ ret = svcExec(p_svc);
+
+ if (TSKM_E_OK != ret) {
+ TSKM_ASSERT_PRINT(0, "ret = %d", ret);
+ goto ERROR;
+ } else if (p_svc->state == TSKM_SVC_WAITCONNECT) {
+ // In the state waiting for execution
+ req.svcId = p_svc->attr->svcId;
+ req.localStep = TSKM_LSTEP_ALL;
+ ret = svcWakeupRequest(p_svc, &req);
+ if (TSKM_E_OK != ret) {
+ TSKM_ASSERT_PRINT(0, "ret = %d", ret);
+ goto ERROR;
+ }
+ }
+ }
+ }
+
+ return TSKM_E_OK;
+ ERROR: return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Connection handler
+ * ret:TRUE SVC status changed
+ * ret:FALSE SVC status not changed
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t connectHandle(TSKM_SVC_CTX_t* p_svc,
+ const TSKM_EVENT_INFO_t* p_inEv) {
+ uint32_t ii;
+
+ TSKM_ASSERT(p_svc->state == TSKM_SVC_WAITCONNECT);
+
+ p_svc->connFd = p_inEv->prm.repConnect.connFd;
+ p_svc->state = TSKM_SVC_WAKEUP;
+ TSKM_PRINTF(TSKM_LOG_DEBUG, "[ST:%d] WAKEUP", p_svc->pid);
+
+ p_svc->waitResCnt = 0;
+
+ if (p_svc->waitReqCnt) {
+ for (ii = 0; ii < p_svc->waitReqCnt; ii++) {
+ TSKM_ASSERT(TSKM_E_OK == wakeupRequest(p_svc, &p_svc->request[ii]));
+ }
+ p_svc->waitReqCnt = 0;
+ }
+
+ return TSKM_TRUE;
+}
+
+/*********************************************************
+ * Disconnection handler
+ * ret:TRUE SVC status changed
+ * ret:FALSE SVC status not changed
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t disConnectHandle(TSKM_SVC_CTX_t* p_svc,
+ const TSKM_EVENT_INFO_t* p_inEv) {
+ // No status change
+
+ return TSKM_TRUE;
+}
+
+/*********************************************************
+ * Response handler for the activation request
+ * ret:TRUE SVC status changed
+ * ret:FALSE SVC status not changed
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t resWakeupHandle(TSKM_SVC_CTX_t* p_svc,
+ const TSKM_EVENT_INFO_t* p_inEv) {
+ TSKM_ASSERT(p_svc->state == TSKM_SVC_WAKEUP);
+ TSKM_ASSERT(p_svc->waitResCnt > 0);
+ TSKM_BOOL_t isStateChg = TSKM_FALSE;
+
+ if (p_svc->isShmDone == TSKM_FALSE && p_inEv->prm.resWakeup.isShmDone) {
+ p_svc->isShmDone = TSKM_TRUE;
+ isStateChg = TSKM_TRUE;
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "%s:SHM DONE", p_svc->attr->name);
+ }
+ if (p_svc->isStepDone == TSKM_FALSE && p_inEv->prm.resWakeup.isStepDone) {
+ p_svc->isStepDone = TSKM_TRUE;
+ isStateChg = TSKM_TRUE;
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "%s:STEP DONE", p_svc->attr->name);
+ }
+
+ if (p_svc->waitResCnt > 0) {
+ p_svc->waitResCnt--;
+ if (p_svc->waitResCnt == 0) { // Transition when the wait runs out
+ if (p_inEv->prm.resWakeup.isLast) {
+ p_svc->state = TSKM_SVC_RUNNING; // Startup completed
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "[ST:%d] RUN", p_svc->pid);
+ }
+ isStateChg = TSKM_TRUE;
+ }
+ }
+ return isStateChg;
+}
+
+/*********************************************************
+ * Response handler for the termination request
+ * ret:TRUE SVC state changed
+ * ret:FALSE SVC state not changed
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t resDownHandle(TSKM_SVC_CTX_t* p_svc,
+ const TSKM_EVENT_INFO_t* p_inEv) {
+ TSKM_ASSERT(p_svc->state == TSKM_SVC_DOWN);
+ TSKM_ASSERT(p_svc->waitResCnt > 0);
+ TSKM_BOOL_t isStateChg = TSKM_FALSE;
+
+ TSKM_PRINTF(TSKM_LOG_DEBUG, "pid:%d waitCnt:%d", p_svc->pid,
+ p_svc->waitResCnt);
+ if (p_svc->waitResCnt > 0) {
+ p_svc->waitResCnt--;
+ if (p_svc->waitResCnt == 0) { // Transition when the wait runs out
+ if (p_inEv->prm.resWakeup.isLast) {
+ p_svc->state = TSKM_SVC_FINDOWN; // Termination complete
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "[ST:%d] FIN_DOWN", p_svc->pid);
+ }
+ isStateChg = TSKM_TRUE;
+ }
+ }
+ return isStateChg;
+}
+
+/*********************************************************
+ * Response Handlers for DebugDump Requests
+ * ret:TRUE SVC state changed
+ * ret:FALSE SVC state not changed
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t resDebugDumpHandle(TSKM_SVC_CTX_t* p_svc,
+ const TSKM_EVENT_INFO_t* p_inEv) {
+ TSKM_BOOL_t isStateChg = TSKM_FALSE;
+ TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *p_prm;
+
+ if (!p_inEv->hasExtend || !p_inEv->extendPrm) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+
+ p_prm = (TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *) p_inEv->extendPrm; // NOLINT (readability/casting)
+
+ // FALSE is specified here because the required service names have been added in the PrimaryLib.
+ tskm_sub_debugDumpRes(FALSE, p_prm->dumpMsg);
+
+ ERROR: return isStateChg;
+}
+
+/*********************************************************
+ * Service termination request
+ * ret:TRUE SVC state changed
+ * ret:FALSE SVC state not changed
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t reqExit(TSKM_SVC_CTX_t* p_svc,
+ const TSKM_EVENT_INFO_t* p_inEv) {
+ int ret;
+ TSKM_ERR_t tskmRet;
+ TSKM_ASSERT(p_svc->state == TSKM_SVC_RUNNING);
+ TSKM_ASSERT(p_svc->waitResCnt == 0);
+ TSKM_GSTEP_REQ_INFO_t req = { 0 };
+
+ req.svcId = p_svc->attr->svcId;
+ req.localStep = TSKM_LSTEP_ALL;
+ tskmRet = tskm_svcDownRequest(p_svc, &req);
+ TSKM_ERR_CHK_DFT;
+
+ return TSKM_TRUE;
+
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ERROR: ret = tskm_pf_terminateProcGroup(static_cast<uint16_t>(p_svc->pid));
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 8: dead code
+ TSKM_PRINTF(TSKM_LOG_WARN, "ret = %d", ret);
+ }
+
+ return TSKM_TRUE;
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************************
+ * Service termination handler
+ * ret:TRUE SVC state changed
+ * ret:FALSE SVC state not changed
+ *********************************************************/
+TSKM_STATIC TSKM_BOOL_t repTermHandle(TSKM_SVC_CTX_t* p_svc,
+ const TSKM_EVENT_INFO_t* p_inEv) {
+ int ret;
+
+ // Check error
+ if (p_svc->attr->lifeCycle == TSKM_SVC_LC_DYNAMIC) {
+ if (p_svc->state != TSKM_SVC_DOWN) {
+ // A STATE other than DOWN does not terminate.
+ TSKM_PRINTF(TSKM_LOG_ERROR, "ERR TERM %s(%d) waitCnt:%d",
+ p_svc->attr->name, p_svc->pid, p_svc->waitResCnt);
+ TSKM_ASSERT(0);
+ }
+ } else {
+ // The resident service terminated.
+ TSKM_PRINTF(TSKM_LOG_ERROR, "ERR TERM %s(%d) waitCnt:%d", p_svc->attr->name,
+ p_svc->pid, p_svc->waitResCnt);
+ TSKM_ASSERT(0);
+ }
+
+ TSKM_PRINTF(TSKM_LOG_STATE, "[ST:%d] DORMANT", p_svc->pid);
+
+ p_svc->state = TSKM_SVC_DORMANT;
+ p_svc->waitResCnt = 0;
+ p_svc->pid = 0;
+
+ if (p_svc->attr->type == TSKM_SVC_TYPE_NATIVE) {
+ EFrameworkunifiedStatus taskmanagerStatus;
+ TSKM_MAIN_CTX_t* p_main = tskm_getMainCtx();
+ SS_String availabilityName = p_svc->attr->name;
+ availabilityName.append("/Availability");
+
+ taskmanagerStatus = FrameworkunifiedUnsubscribeNotificationWithCallback(
+ p_main->hApp, availabilityName.c_str());
+ if (eFrameworkunifiedStatusOK != taskmanagerStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ p_svc->isAvailable = TSKM_FALSE;
+ p_svc->watchCnt = 0;
+
+ HANDLE hMq = McOpenSender(FRAMEWORKUNIFIED_NS_NPSERVICE);
+ if (NULL == hMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 4: NSFW error case.
+ } else {
+ ServiceAvailability availInfo = { };
+
+ snprintf(availInfo.cServiceName, MAX_NAME_SIZE_APP, "%s",
+ p_svc->attr->name);
+ availInfo.eServiceAvailability = eFrameworkunifiedServiceNotAvailable;
+
+ taskmanagerStatus = NPPublishNotification(hMq, p_svc->attr->name,
+ availabilityName.c_str(), &availInfo,
+ sizeof(availInfo));
+ if (eFrameworkunifiedStatusOK != taskmanagerStatus) {
+ TSKM_ASSERT(0);
+ }
+
+ taskmanagerStatus = McClose(hMq);
+ if (eFrameworkunifiedStatusOK != taskmanagerStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0); // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ }
+ }
+
+ if (p_inEv->errCode != TSKM_E_OK) {
+ p_svc->errTermCnt++;
+ // Notify 'NG' at Relaunch after abnormal termination
+ p_svc->bootInfo.resetStatus = e_SS_SM_RESET_STATUS_NG;
+
+ ret = svcErrTermPost(p_svc);
+ if (ret != TSKM_E_OK) {
+ TSKM_ASSERT(0);
+ }
+ } else {
+ // NONE is notified at Relaunch after normal completion.
+ p_svc->bootInfo.resetStatus = e_SS_SM_RESET_STATUS_NONE;
+ }
+
+ return TSKM_TRUE;
+}
+
+/*********************************************************
+ * Get service context
+ *********************************************************/
+TSKM_SVC_CTX_t*
+tskm_svcsGetSvcBySvcId(TSKM_SVCS_CTX_t* p_svcs, TSKM_SVCID_t svcId) {
+ return getSvcCtxBySvcId(p_svcs, svcId);
+}
+
+/*********************************************************
+ * Get service context
+ *********************************************************/
+TSKM_SVC_CTX_t*
+tskm_svcsGetSvcByPid(TSKM_SVCS_CTX_t* p_svcs, pid_t pid) {
+ return getSvcCtxByPid(p_svcs, pid);
+}
+
+/*********************************************************
+ * Check for waiting services
+ *********************************************************/
+TSKM_BOOL_t tskm_svcsIsWaiting(TSKM_SVCS_CTX_t* p_svcs) {
+ uint32_t ii;
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ if (p_svcs->svcList[ii].waitResCnt > 0
+ || p_svcs->svcList[ii].state == TSKM_SVC_WAITCONNECT) {
+ return TSKM_TRUE;
+ }
+ }
+ return TSKM_FALSE;
+}
+
+/*********************************************************
+ * Check if ShutdownWait services are terminated
+ *********************************************************/
+TSKM_SVC_WAIT_STATE_t tskm_svcsGetSvcTermWaitState(TSKM_SVCS_CTX_t* p_svcs) {
+ uint32_t ii;
+ TSKM_SVC_WAIT_STATE_t waitState = TSKM_SVC_WAIT_NONE;
+
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ if (p_svcs->svcList[ii].attr->shotdownWait) {
+ // Check shutdownWait SVC Only
+ if (p_svcs->svcList[ii].state != TSKM_SVC_DORMANT) {
+ // DORMANT is terminated or not started, so no checking is required
+ if (TSKM_SVC_LC_DYNAMIC != p_svcs->svcList[ii].attr->lifeCycle
+ && p_svcs->svcList[ii].state != TSKM_SVC_FINDOWN) { // Check of termination of resident SVCs
+ waitState = TSKM_SVC_WAIT_BOTH;
+ break;
+ } else if (TSKM_SVC_LC_DYNAMIC == p_svcs->svcList[ii].attr->lifeCycle) { // Check of termination of non-resident SVCs
+ waitState = TSKM_SVC_WAIT_TRANSIENT;
+ }
+ }
+ }
+ }
+ return waitState;
+}
+
+/*********************************************************
+ * Update boot info of all services
+ *********************************************************/
+TSKM_ERR_t tskm_svcsSetBootInfo(TSKM_SVCS_CTX_t* p_svcs,
+ T_SS_SM_START_DataStructType* p_info,
+ T_SS_SM_START_ExtDataStructType *p_exInfo) {
+ uint32_t ii = 0;
+
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ p_svcs->svcList[ii].bootInfo = *p_info;
+ p_svcs->svcList[ii].extBootInfo = *p_exInfo;
+ }
+ return TSKM_E_OK;
+}
+
+/*********************************************************
+ * Terminates a running non-resident services
+ *********************************************************/
+TSKM_ERR_t tskm_svcsAvtiveSvcTerm(TSKM_SVCS_CTX_t* p_svcs) {
+ uint32_t ii;
+
+ for (ii = 0; ii < p_svcs->svcNum; ii++) {
+ TSKM_SVC_CTX_t* p_svc = &p_svcs->svcList[ii];
+
+ if (TSKM_SVC_LC_DYNAMIC == p_svc->attr->lifeCycle && // Non-resident SVC
+ TSKM_SVC_RUNNING == p_svc->state && p_svc->waitResCnt == 0) { // Running
+ TSKM_ERR_t tskmRet;
+ TSKM_GSTEP_REQ_INFO_t req = { 0 };
+
+ req.svcId = p_svc->attr->svcId;
+ req.localStep = TSKM_LSTEP_ALL;
+ tskmRet = tskm_svcDownRequest(p_svc, &req);
+ TSKM_ERR_CHK_DFT;
+ }
+ }
+
+ return TSKM_E_OK;
+
+ ERROR:
+ return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Calls back the DebugDump of the running services
+ *********************************************************/
+TSKM_ERR_t tskm_svcsCallDebugDump(TSKM_SVCS_CTX_t* p_svcs) {
+ for (uint32_t ii = 0; ii < p_svcs->svcNum; ii++) {
+ TSKM_SVC_CTX_t* p_svc = &p_svcs->svcList[ii];
+
+ if (TSKM_SVC_RUNNING == p_svc->state) { // Running
+ TSKM_EVENT_INFO_t ev;
+ bzero(&ev, sizeof(ev));
+
+ // Send DebugDump request
+ ev.event = TSKM_EV_PRI_REQ_DEBUGDUMP;
+ ev.errCode = TSKM_E_OK;
+ if (0 >= tskm_sockSend(p_svc->connFd, &ev)) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ }
+ }
+
+ return TSKM_E_OK;
+ ERROR: return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Calls back the LowMemory of the running services
+ *********************************************************/
+TSKM_ERR_t tskm_svcsCallLowMem(TSKM_SVCS_CTX_t* p_svcs) {
+ for (uint32_t ii = 0; ii < p_svcs->svcNum; ii++) {
+ TSKM_SVC_CTX_t* p_svc = &p_svcs->svcList[ii];
+ if (TSKM_SVC_RUNNING == p_svc->state) { // Running
+ TSKM_EVENT_INFO_t ev;
+ bzero(&ev, sizeof(ev));
+
+ // Send LowMemory detection notification
+ ev.event = TSKM_EV_PRI_REP_LOWMEM;
+ ev.errCode = TSKM_E_OK;
+ if (0 >= tskm_sockSend(p_svc->connFd, &ev)) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ }
+ }
+
+ return TSKM_E_OK;
+ ERROR: return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Event handler
+ *********************************************************/
+TSKM_ERR_t tskm_svcEventHandle(TSKM_SVC_CTX_t* p_svc, TSKM_EVENT_INFO_t* p_ev) {
+ TSKM_FUNC_IN();
+ TSKM_BOOL_t isStateChg = TSKM_FALSE;
+
+ if (isSvcEvent(p_ev) == TSKM_FALSE) {
+ // If it is not an event for the service, it will be sent as follows.
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+ }
+
+ switch (p_ev->event) {
+ case TSKM_EV_PRI_REP_CONNECT: // Connection Registration from Service
+ isStateChg = connectHandle(p_svc, p_ev);
+ break;
+ case TSKM_EV_PRI_REP_DISCONNECT: // Disconnection Registration from Service
+ isStateChg = disConnectHandle(p_svc, p_ev);
+ break;
+ case TSKM_EV_PRI_RES_WAKEUP: // Response to a startup request from a service
+ isStateChg = resWakeupHandle(p_svc, p_ev);
+ break;
+ case TSKM_EV_PRI_RES_DOWN:
+ isStateChg = resDownHandle(p_svc, p_ev);
+ break;
+ case TSKM_EV_PRI_RES_DEBUGDUMP:
+ isStateChg = resDebugDumpHandle(p_svc, p_ev);
+ break;
+ case TSKM_EV_PRI_REQ_EXIT:
+ isStateChg = reqExit(p_svc, p_ev);
+ break;
+ case TSKM_EV_SVC_REP_TERM: // Service termination
+ isStateChg = repTermHandle(p_svc, p_ev);
+ break;
+ default:
+ break;
+ }
+
+ // Overwrite service state change
+ if (isStateChg) {
+ p_ev->event = TSKM_EV_LCL_CHG_SVC_STATE;
+ p_ev->prm.chgSvc.svcId = p_svc->attr->svcId;
+ } else {
+ p_ev->event = TSKM_EV_NOP;
+ }
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+/*********************************************************
+ * Startup service
+ *********************************************************/
+TSKM_ERR_t tskm_svcExec(TSKM_SVC_CTX_t* p_svc) {
+ return svcExec(p_svc);
+}
+
+/*********************************************************
+ * Issue a startup request to the service
+ *********************************************************/
+TSKM_ERR_t tskm_svcWakeupRequest(TSKM_SVC_CTX_t* p_svc,
+ TSKM_GSTEP_REQ_INFO_t* p_req) {
+ return svcWakeupRequest(p_svc, p_req);
+}
+
+/*********************************************************
+ * Issue a termination request to the service
+ *********************************************************/
+TSKM_ERR_t tskm_svcDownRequest(TSKM_SVC_CTX_t* p_svc,
+ TSKM_GSTEP_REQ_INFO_t* p_req) {
+ int ret;
+ TSKM_EVENT_INFO_t ev;
+
+ bzero(&ev, sizeof(ev));
+
+ if (tskm_svcIsCommunicatable(p_svc) == TSKM_FALSE) {
+ return TSKM_E_OK;
+ }
+
+ ev.event = TSKM_EV_PRI_REQ_DOWN;
+ ev.errCode = TSKM_E_OK;
+ ev.prm.reqDown.localStep = p_req->localStep;
+
+ ret = tskm_sockSend(p_svc->connFd, &ev);
+ if (ret <= 0) {
+ TSKM_ASSERT(0);
+ goto ERROR;
+ }
+ p_svc->waitResCnt++;
+ p_svc->state = TSKM_SVC_DOWN;
+
+ return TSKM_E_OK;
+ ERROR: return TSKM_E_NG;
+}
+
+/*********************************************************
+ * Prohibit starting service
+ *********************************************************/
+TSKM_ERR_t tskm_svcDisableRequest(TSKM_SVC_CTX_t* p_svc) {
+ if (p_svc->state == TSKM_SVC_DORMANT || p_svc->state == TSKM_SVC_DISABLE) {
+ p_svc->state = TSKM_SVC_DISABLE;
+ return TSKM_E_OK;
+ }
+ return TSKM_E_STATE;
+}
+
+/*********************************************************
+ * Allow starting service
+ *********************************************************/
+TSKM_ERR_t tskm_svcEnableRequest(TSKM_SVC_CTX_t* p_svc) {
+ if (p_svc->state == TSKM_SVC_DISABLE) {
+ p_svc->state = TSKM_SVC_DORMANT;
+ }
+ return TSKM_E_OK;
+}
+
+/*********************************************************
+ * Queriy whether the service is ready for communication
+ *********************************************************/
+TSKM_BOOL_t tskm_svcIsCommunicatable(TSKM_SVC_CTX_t* p_svc) {
+ TSKM_BOOL_t ret = TSKM_FALSE;
+ if (p_svc == NULL || p_svc->attr->type == TSKM_SVC_TYPE_UNKNONW) {
+ } else {
+ switch (p_svc->state) {
+ case TSKM_SVC_WAKEUP:
+ case TSKM_SVC_RUNNING:
+ case TSKM_SVC_DOWN:
+ ret = TSKM_TRUE;
+ break;
+ default:
+ break;
+ }
+ }
+ return ret;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/server/src/tskm_wakeup.cpp b/systemservice/task_manager/server/src/tskm_wakeup.cpp
new file mode 100755
index 0000000..b5c6e89
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_wakeup.cpp
@@ -0,0 +1,201 @@
+/*
+ * @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.
+ */
+
+#include "tskm_wakeup.h"
+#include "tskm_debug.h"
+#include "tskm_util.h"
+#include "tskm_state.h"
+#include "tskm_port_subsys.h"
+#include "tskm_port_pf.h"
+
+#include "tskm_gstep.h"
+
+
+/*********************************************************
+ * Get gradual startup context
+ *********************************************************/
+TSKM_STATIC TSKM_GSTEP_CTX_t*
+gstepGetWakeupCtx(TSKM_MAIN_CTX_t* p_main) {
+ return &p_main->wakeup;
+}
+
+/***********************************************************************
+ * Startup completion process
+ ***********************************************************************/
+TSKM_STATIC void wakeupFinish(TSKM_MAIN_CTX_t* p_main) {
+ return;
+}
+
+/*********************************************************
+ * Challenge for a transition to the next state
+ *********************************************************/
+TSKM_STATIC void tryTransNextState(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_GSTEP_CTX_t* p_wakeup;
+ TSKM_GSTEP_t* p_current;
+
+ p_wakeup = gstepGetWakeupCtx(p_main);
+ p_current = gstepGetCurrent(p_wakeup);
+
+ if (!p_current) {
+ return;
+ }
+
+ // LCOV_EXCL_BR_START 8: Because the second condition in the if statement is never false
+ if (tskm_svcsIsWaiting(&p_main->svcs) == TSKM_FALSE && // No waiting services
+ ((p_wakeup->compState & p_current->nextTransCond)
+ == p_current->nextTransCond)) { // Event completion condition
+ // LCOV_EXCL_BR_STOP
+ if (gstepIsLast(p_wakeup)) {
+ tskm_stateTransit(p_main, TSKM_ST_WAKEUP, TSKM_ST_RUNNING);
+ } else {
+ tskm_stateTransit(p_main, TSKM_ST_WAKEUP, TSKM_ST_WAKEUP);
+ }
+ }
+}
+
+/*********************************************************
+ * Gradual startup request issuance process
+ *********************************************************/
+TSKM_ERR_t tskm_entryWakeup_Req(TSKM_MAIN_CTX_t* p_main,
+ TSKM_GSTEP_t* p_current) {
+ uint32_t ii;
+
+ // Refer to the stepId and perform preprocessing if needed.
+ if (p_current->gstepId == TSKM_GSTEP_BUPCHK) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "BUPCHK EXE");
+ // When TaskManager is used as a system Launcher, system data is initialized here.
+ }
+
+ // Start process
+ for (ii = 0; ii < p_current->execSvcNum; ii++) {
+ TSKM_ERR_t tskmRet;
+ TSKM_SVCID_t svcId = p_current->execSvcIdList[ii];
+ TSKM_SVC_CTX_t* p_svc = tskm_svcsGetSvcBySvcId(&p_main->svcs, svcId);
+
+ tskmRet = tskm_svcExec(p_svc);
+ TSKM_ERR_CHK_DFT;
+ }
+
+ // Issue gradual startup request
+ for (ii = 0; ii < p_current->reqNum; ii++) {
+ TSKM_ERR_t tskmRet;
+ TSKM_GSTEP_REQ_INFO_t* p_req = &p_current->reqList[ii];
+ TSKM_SVC_CTX_t* p_svc = tskm_svcsGetSvcBySvcId(&p_main->svcs, p_req->svcId);
+
+ // Queuing in the SVC layer even for services that are not started.
+ tskmRet = tskm_svcWakeupRequest(p_svc, p_req);
+ TSKM_ERR_CHK_DFT; // LCOV_EXCL_BR_LINE 6: Because TSKM_ERR_CHK_DFT does not specify a condition for goto to ERROR
+ }
+
+ if (p_current->nextTransCond) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "WAIT COMP:%s(%llx)",
+ tskm_convInitCompId2Str(p_current->nextTransCond),
+ p_current->nextTransCond);
+ }
+
+ return TSKM_E_OK;
+
+ // LCOV_EXCL_START 6: Checked in Death testing, but it is not reflected in the coverage and excluded
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return TSKM_E_NG;
+ // LCOV_EXCL_STOP
+}
+
+/*********************************************************
+ * Gradual startup entry process
+ *********************************************************/
+TSKM_ERR_t tskm_entryWakeup(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_FUNC_IN();
+
+ TSKM_GSTEP_CTX_t* p_wakeup;
+ TSKM_GSTEP_t* p_current;
+
+ p_main->state = TSKM_ST_WAKEUP;
+ p_wakeup = gstepGetWakeupCtx(p_main);
+ p_current = gstepGetCurrent(p_wakeup);
+
+ if (p_current == NULL) { // LCOV_EXCL_BR_LINE 8: Because condition false setting is not possible
+ // LCOV_EXCL_START 8: Because condition false setting is not possible
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ tskm_pf_exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP
+ }
+
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "WAKEUP GSTEP:%d", p_wakeup->gstepIdx);
+
+ if (tskm_entryWakeup_Req(p_main, p_current) == TSKM_E_NG) { // LCOV_EXCL_BR_LINE 200:the function of tskm_entryWakeup_Req can not be TSKM_E_NG at this case // NOLINT(whitespace/line_length)
+ // LCOV_EXCL_START 200:the function of tskm_entryWakeup_Req can not be TSKM_E_NG at this case // NOLINT(whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ tskm_pf_exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP
+ }
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*********************************************************
+ * Gradual startup exit process
+ *********************************************************/
+TSKM_ERR_t tskm_exitWakeup(TSKM_MAIN_CTX_t* p_main) {
+ TSKM_GSTEP_CTX_t* p_wakeup;
+
+ TSKM_FUNC_IN();
+ p_wakeup = gstepGetWakeupCtx(p_main);
+
+ // Exit process at the end of the gradual startup
+ if (gstepIsLast(p_wakeup)) {
+ TSKM_PRINTF(TSKM_LOG_STATE, "WAKEUP FIN");
+ wakeupFinish(p_main);
+ }
+
+ changeNextStep(p_wakeup); // Transition to next step
+
+ TSKM_FUNC_OUT();
+ return TSKM_E_OK;
+}
+
+/*********************************************************
+ * Gradual startup handler
+ *********************************************************/
+TSKM_ERR_t tskm_handleWakeup(TSKM_MAIN_CTX_t* p_main, TSKM_EVENT_INFO_t* p_ev) {
+ TSKM_FUNC_IN();
+ TSKM_ERR_t tskmRet = TSKM_E_OK;
+
+ switch (p_ev->event) {
+ case TSKM_EV_PRI_REP_WAKEUP_COMP: // Event completion notification at startup
+ {
+ TSKM_PRINTF(TSKM_LOG_SVCSTATE, "INIT COMP :%s(%#llx) from:%d",
+ tskm_convInitCompId2Str(p_ev->prm.repWakeupComp.compId),
+ p_ev->prm.repWakeupComp.compId, p_ev->fromPid);
+ TSKM_GSTEP_CTX_t* p_wakeup = gstepGetWakeupCtx(p_main);
+ p_wakeup->compState |= p_ev->prm.repWakeupComp.compId;
+ tryTransNextState(p_main);
+ }
+ break;
+ case TSKM_EV_LCL_CHG_SVC_STATE: // Service state change
+ tryTransNextState(p_main);
+ break;
+ default:
+ tskmRet = tskm_handleAccon(p_main, p_ev);
+ break;
+ }
+ TSKM_FUNC_OUT();
+ return tskmRet;
+} // LCOV_EXCL_BR_LINE 10: Final line
+
diff --git a/systemservice/task_manager/server/src/tskm_watch.cpp b/systemservice/task_manager/server/src/tskm_watch.cpp
new file mode 100755
index 0000000..455de0b
--- /dev/null
+++ b/systemservice/task_manager/server/src/tskm_watch.cpp
@@ -0,0 +1,101 @@
+/*
+ * @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.
+ */
+
+#include "tskm_watch.h"
+#include <agl_thread.h>
+
+#include "tskm_debug.h"
+#include "tskm_port_pf.h"
+#include "tskm_comm.h"
+
+
+#define WATCH_CYCLE 5
+
+#define TIMER_THREAD_NAME "SS_TskmTimer"
+
+/*******************************************************************
+ * Periodic Timer-Thread MAIN Function
+ *******************************************************************/
+void *
+watchMain(void *arg) {
+ int connFd = -1;
+
+ connFd = tskm_cliSockConnect(TSKM_SOCKET_NAME);
+ if (connFd < 0) { // LCOV_EXCL_BR_LINE 5: system function(uinx) "socket" fail process
+ // LCOV_EXCL_START 5: system function(uinx) "socket" fail process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5
+ }
+
+ while (1) {
+ int ret;
+ TSKM_EVENT_INFO_t ev;
+
+ sleep(WATCH_CYCLE);
+
+ ev.event = TSKM_EV_LCL_REP_POLLING;
+ ev.errCode = TSKM_E_OK;
+ ret = tskm_sockSend(connFd, &ev);
+ if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: system function(uinx) "send" fail process
+ // LCOV_EXCL_START 5: system function(uinx) "send" fail process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5
+ }
+ }
+
+ // LCOV_EXCL_START 6: system function(uinx) call fail process
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (connFd != -1) {
+ tskm_sockDestory(connFd);
+ }
+
+ return 0;
+ // LCOV_EXCL_STOP
+}
+
+/*******************************************************************
+ * Periodic Timer thread start
+ *******************************************************************/
+int tskm_watch_startTimer() {
+ int ret;
+ pthread_t thId = { 0 };
+
+ ret = tskm_pf_createThread(watchMain, NULL, PR_SS_TSKMTIMER,
+ TIMER_THREAD_NAME, &thId);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 5: system function(uinx) "pthread_*" fail process
+ // LCOV_EXCL_START 5: system function(uinx) "pthread_*" fail process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ TSKM_ASSERT(0);
+ goto ERROR;
+ // LCOV_EXCL_STOP 5
+ } else {
+ TSKM_PRINTF(TSKM_LOG_STATE, "watch thread created.");
+ }
+
+ return 0;
+
+ // LCOV_EXCL_LINE 6: system function(uinx) "pthread_*" fail process
+ ERROR:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1;
+ // LCOV_EXCL_STOP
+}
+
diff --git a/systemservice/version_library/LICENSE b/systemservice/version_library/LICENSE
new file mode 100755
index 0000000..f433b1a
--- /dev/null
+++ b/systemservice/version_library/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/systemservice/version_library/Makefile.client b/systemservice/version_library/Makefile.client
new file mode 100755
index 0000000..38d4f60
--- /dev/null
+++ b/systemservice/version_library/Makefile.client
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-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.
+#
+
+SUBDIRS := library
+
+include ../system_service.mk
diff --git a/systemservice/version_library/library/Makefile b/systemservice/version_library/library/Makefile
new file mode 100755
index 0000000..79654a2
--- /dev/null
+++ b/systemservice/version_library/library/Makefile
@@ -0,0 +1,37 @@
+#
+# @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.
+#
+
+# installed shared library(.so)
+INST_SHLIBS := libssver
+
+# compiled source
+libssver_SRCS := ss_ver.cc
+
+# installed header
+INST_HEADERS := version_library.h ss_ver.h
+
+# additional source path
+VPATH += ./src \
+ ./include/$(COMPONENT_NAME)
+
+# additional include path
+CPPFLAGS += -I./include
+
+# linked library
+LDFLAGS += -Wl,--no-as-needed
+LDLIBS += -Wl,-Bdynamic,--no-as-needed -lNS_FrameworkUnified
+
+include ../../system_service.mk
diff --git a/systemservice/version_library/library/include/system_service/ss_ver.h b/systemservice/version_library/library/include/system_service/ss_ver.h
new file mode 100755
index 0000000..a78c5ff
--- /dev/null
+++ b/systemservice/version_library/library/include/system_service/ss_ver.h
@@ -0,0 +1,338 @@
+/*
+ * @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.
+ */
+
+#ifndef VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_
+#define VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <algorithm>
+#include <map>
+
+/**
+ * @file ss_ver.h
+ * @brief \~english This file supports CSSVer class, This class is a generic CSSVer abstraction
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup version_library
+ * @ingroup system_service
+ * @{
+ */
+
+using namespace std; // NOLINT (readability/nolint)
+
+#define SSVER_VERCHAR_MAX (64)
+#define SSVER_DATE_MAX (16)
+
+/**
+* @struct SSVER_PkgInfo
+* @brief \~english The structure of version package information
+*/
+typedef struct {
+ char version[SSVER_VERCHAR_MAX]; /*!< \~english Version information (String):*/
+ /*!< \~english The termination of string must be "\0"*/
+ char date[SSVER_DATE_MAX]; /*!< \~english Date (String):The termination of string must be "\0" */
+ /*!< \~english Date (String):Store "\0" when date information does not exist.*/
+} SSVER_PkgInfo;
+
+typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList;
+typedef SSVerPkgList::const_iterator SSVerPkgListIter;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// \ingroup SS_SystemManager
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// \brief This class is a generic CSSVer abstraction
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @class CSSVer
+ * \~english @brief Version information set-up/acquisition
+ * \~english @par Brief Introduction
+ * Class to provide the function of the version information set-up/acquisition
+ *
+ */
+class CSSVer {
+ private:
+ SSVerPkgList m_verList;
+ void dump(void) const;
+
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Constructor for CSSVer class
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Changes of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// Creates the instance of CSSVer class. \n
+ /// This API reads the version information registered in VersionDB and creates the package
+ /// lists inside a instance. \n
+ /// This can create some instances at the same time. \n
+ /// Meanwhile, this does not guarantee the action when some threads
+ /// inside same process access to same instances. \n
+ /// It is possible that version information is overwritten from other process but the information overwritten
+ /// at other process is not reflected into the version information held inside self-instance.
+ /// By this, it is necessary to recreate an instance to get the latest information. \n
+ /// \~english @see ~CSSVer
+ ////////////////////////////////////////////////////////////////////////////////////
+ CSSVer();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Destructor for CSSVer class
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Changes of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classfication
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// Releases the instance of CSSVer class.
+ /// \~english @see CSSVer
+ ////////////////////////////////////////////////////////////////////////////////////
+ ~CSSVer();
+
+ // Wrapper
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Returns the first iterator of package list.
+ /// \~english @param None
+ /// \~english @retval SSVerPkgListIter The first iterator of package list
+ /// \~english @par
+ /// The structure of version package information
+ /// \~english @code
+ /// #define SSVER_VERCHAR_MAX (64)
+ /// #define SSVER_DATE_MAX (16)
+ /// typedef struct{
+ /// char version[SSVER_VERCHAR_MAX]; /* Version information (String): The termination of
+ /// string must be "\0" */
+ /// char date[SSVER_DATE_MAX]; /* Date (String): The termination of string must be "\0"*/
+ /// /* Store "\0" when date information does not exist. */
+ /// }SSVER_PkgInfo;
+ ///
+ /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
+ /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
+ /// @endcode
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Changes of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Gets and returns the first iterator of package list from the package list inside an instance.
+ /// \~english @see end
+ ////////////////////////////////////////////////////////////////////////////////////
+ SSVerPkgListIter begin() {
+ return m_verList.begin();
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Returns the end iterator of package list.
+ /// \~english @param None
+ /// \~english @retval SSVerPkgListIter The end iterator of package list
+ /// \~english @par
+ /// The structure of version package information
+ /// \~english @code
+ /// #define SSVER_VERCHAR_MAX (64)
+ /// #define SSVER_DATE_MAX (16)
+ /// typedef struct{
+ /// char version[SSVER_VERCHAR_MAX]; /* Version information (String): The termination of
+ /// string must be "\0" */
+ /// char date[SSVER_DATE_MAX]; /* Date (String): The termination of string must be "\0" */
+ /// /* Store "\0" when date information does not exist. */
+ /// }SSVER_PkgInfo;
+ ///
+ /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
+ /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
+ /// @endcode
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Changes of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Gets and returns the last iterator of package list from the package list inside a instance.
+ /// \~english @see begin
+ ////////////////////////////////////////////////////////////////////////////////////
+ SSVerPkgListIter end() {
+ return m_verList.end();
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Checks whether data exists in package list or not.
+ /// \~english @param None
+ /// \~english @retval bool The possibility of data existence of package list
+ /// \~english @par
+ /// - true : Data does not exist
+ /// - false : Data exists
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Changes of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Returns true when package list is null and return false when data exists.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ bool empty() {
+ return m_verList.empty();
+ }
+
+ // Setter,getter
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Gets the package information of specified package.
+ /// \~english @param [in] name
+ /// std::string & - Package name
+ /// \~english @param [out] p_info
+ /// SSVER_PkgInfo* - Pointer to the storage area of package information
+ /// \~english @par
+ /// The structure of version package information
+ /// \~english @code
+ /// #define SSVER_VERCHAR_MAX (64)
+ /// #define SSVER_DATE_MAX (16)
+ /// typedef struct{
+ /// char version[SSVER_VERCHAR_MAX]; /* Version information (String): The termination of
+ /// string must be "\0" */
+ /// char date[SSVER_DATE_MAX]; /* Date (String): The termination of string must be "\0" */
+ /// /* Store "\0" when date information does not exist. */
+ /// }SSVER_PkgInfo;
+ ///
+ /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
+ /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Succeeded in getting package information
+ /// \~english @retval eFrameworkunifiedStatusFileLoadError Loading error for file
+ /// \~english @retval eFrameworkunifiedStatusFail Failed at some process
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Changes of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Pointer(p_info) to the storage area for package information specified
+ /// by parameters is NULL. [eFrameworkunifiedStatusFail]
+ /// - Package information does not exist. [eFrameworkunifiedStatusFileLoadError]
+ /// - Unexpected error occurs. [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Returns this package information if the package name specified by parameters exists
+ /// in the package information list inside an instance.
+ /// This API reads and returns the package information from package
+ /// information storing files if it does not exist. \n
+ /// This adds the package information read from files to the package information list
+ /// inside an instance. \n
+ /// When other CSSVer instance (B) adds package from setPkgInfo during creating instance (A),
+ /// after that, this API can get the package information added by instance (A).
+ /// \~english @see setPkgInfo
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus getPkgInfo(const std::string &name, SSVER_PkgInfo* p_info);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SS_SystemManager
+ /// \~english @par Summary
+ /// Sets the package information of specified package.
+ /// \~english @param [in] name
+ /// std::string & - Package name
+ /// \~english @param [in] info
+ /// SSVER_PkgInfo* - Package information
+ /// \~english @par
+ /// The structure of version package information
+ /// \~english @code
+ /// #define SSVER_VERCHAR_MAX (64)
+ /// #define SSVER_DATE_MAX (16)
+ /// typedef struct{
+ /// char version[SSVER_VERCHAR_MAX]; /* Version information (String): The termination of
+ /// string must be "\0" */
+ /// char date[SSVER_DATE_MAX]; /* Date (String): The termination of string must be \ */
+ /// /* Store "\0" when date information does not exist. */
+ /// }SSVER_PkgInfo;
+ ///
+ /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
+ /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
+ /// @endcode
+ /// \~english @retval eFrameworkunifiedStatusOK Succeeded in setting package information
+ /// \~english @retval eFrameworkunifiedStatusFail Faild at some process
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Changes of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - Unexpected error occurs [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync only(None communication)
+ /// \~english @par Detail
+ /// Sets the package information specified by parameters and update VersionDB. \n
+ /// When some package information exists in the package information list inside an instance,
+ /// this API adds the package information specified by parameters to the package
+ /// information list inside an instance,
+ /// and writes the package information specified by parameters in package information storing files. \n
+ /// When package information does not exist in the package information list inside an instance,
+ /// this sets the package information specified by parameters to the package information list inside an instance
+ /// and writes the package information specified by parameters in package information storing files.
+ /// \~english @see getPkgInfo
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus setPkgInfo(const std::string &name, SSVER_PkgInfo &info); // NOLINT (readability/nolint)
+};
+
+#endif // VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_
diff --git a/systemservice/version_library/library/include/system_service/version_library.h b/systemservice/version_library/library/include/system_service/version_library.h
new file mode 100755
index 0000000..f56a259
--- /dev/null
+++ b/systemservice/version_library/library/include/system_service/version_library.h
@@ -0,0 +1,40 @@
+//
+// @copyright Copyright (c) 2017-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.
+//
+/**
+ * @file version_library.h
+ * @brief \~english This file include ss_ver.h
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup version_library
+ * @ingroup system_service
+ * @{
+ */
+// Include guard
+#ifndef SYSTEMSERVICE_VERSIONLIBRARY_H_ // NOLINT(build/header_guard)
+#define SYSTEMSERVICE_VERSIONLIBRARY_H_
+
+#include "system_service/ss_ver.h"
+
+#endif // SYSTEMSERVICE_VERSIONLIBRARY_H_
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/systemservice/version_library/library/src/ss_ver.cc b/systemservice/version_library/library/src/ss_ver.cc
new file mode 100755
index 0000000..70f120c
--- /dev/null
+++ b/systemservice/version_library/library/src/ss_ver.cc
@@ -0,0 +1,309 @@
+/*
+ * @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.
+ */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/file.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <native_service/ns_logger_if.h>
+#include <system_service/ss_templates.h>
+
+#include <system_service/ss_ver.h>
+
+// For DEBUG
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#define ZONE_DEFAULT ZONE_FUNC
+
+#define SSVER_TMPDIR "/tmp/ssver"
+
+// FILE IO
+class CPkgInfoIo {
+ private:
+ int m_fd;
+ std::string m_path;
+ static std::map<std::string, int> m_dbgCnt; // Debug information for exclusive leakage check
+
+ void openFD(const int32_t mode) {
+ m_fd = open(m_path.c_str(), mode, 0664); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (m_fd == -1) {
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h
+ throw eFrameworkunifiedStatusFail;
+ }
+
+ // File lock to protect file accesses
+ SS_ASERT_ERRNO(0 == flock(m_fd, LOCK_EX)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h
+ // LCOV_EXCL_BR_START 11:Unexpected branch
+ m_dbgCnt[m_path]++;
+ SS_ASERT_LOG(m_dbgCnt[m_path] == 1, "%s:%d", m_path.c_str(), // LCOV_EXCL_BR_LINE 15: marco define @ss_templates.h
+ m_dbgCnt[m_path]);
+ // LCOV_EXCL_BR_STOP
+ }
+
+public:
+ CPkgInfoIo(const std::string& pkgName)
+ : m_fd(-1),
+ m_path(SSVER_TMPDIR) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT,__FUNCTION__,"+:%s",pkgName.c_str());
+ m_path += "/";
+ m_path += pkgName;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT,__FUNCTION__,"-");
+ }
+
+ ~CPkgInfoIo() {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "+");
+
+ // LCOV_EXCL_BR_START 11:Unexpected branch
+ m_dbgCnt[m_path]--;
+ SS_ASERT_LOG(m_dbgCnt[m_path] == 0, "%s:%d", m_path.c_str(), // LCOV_EXCL_BR_LINE 15: marco define @ss_templates.h
+ m_dbgCnt[m_path]);
+ SS_ASERT_ERRNO(0 == flock(m_fd, LOCK_UN)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h
+
+ if (m_fd != -1) {
+ SS_ASERT_ERRNO(0 == close(m_fd)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h
+ }
+ // LCOV_EXCL_BR_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "-");
+ }
+
+ void putData(SSVER_PkgInfo &info) { // NOLINT (readability/nolint)
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "+");
+ openFD(O_RDWR|O_CREAT|O_CLOEXEC);
+ ssize_t wsz;
+ wsz = write(m_fd, &info, sizeof(info));
+ if (wsz != sizeof(info)) { // LCOV_EXCL_BR_LINE 5:std c lib error process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed write(). wsz=%d size=%d errno=%d", // LCOV_EXCL_LINE 5: glibc fail safe
+ wsz, sizeof(info), errno); // LCOV_EXCL_LINE 5:std c lib error process
+ throw eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 5:std c lib error process
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "-");
+ }
+
+ void getData(SSVER_PkgInfo* p_info) {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "+");
+ openFD(O_RDONLY|O_CLOEXEC);
+
+ ssize_t rsz;
+ rsz = my_read(m_fd, p_info, sizeof(*p_info));
+ if (rsz != sizeof(*p_info)) { // LCOV_EXCL_BR_LINE 5:std c lib error process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed read(). rsz=%d size=%d", rsz, // LCOV_EXCL_LINE 5:std c lib error process
+ sizeof(*p_info)); // LCOV_EXCL_LINE 5:std c lib error process
+ p_info->version[0] = '\0'; // LCOV_EXCL_LINE 5:std c lib error process
+ p_info->date[0] = '\0'; // LCOV_EXCL_LINE 5:std c lib error process
+ throw eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 5:std c lib error process
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "-");
+ }
+
+ int my_read(int fd, void* buf, int size) {
+ int done = 0;
+ char *buffer = reinterpret_cast<char*>(buf);
+ int sz = done;
+
+ while (size > 0) {
+ done = read(fd, buffer + done, size);
+ if (done < 0) { // LCOV_EXCL_BR_LINE 5:std c lib error process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 5:std c lib error process
+ if (errno == EINTR) { // LCOV_EXCL_LINE 5:std c lib error process
+ continue;
+ } else {
+ return done;
+ }
+ } else if (done == 0) { // LCOV_EXCL_BR_LINE 5:std c lib error process
+ return sz;
+ }
+ size -= done;
+ sz += done;
+ }
+ return sz;
+ }
+};
+
+std::map<std::string, int> CPkgInfoIo::m_dbgCnt; // Actual status
+
+//==================================================================
+// private
+//==================================================================
+void CSSVer::dump(void) const { // LCOV_EXCL_START 7:debugging process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ std::string dumpStr;
+ dumpStr = "VERINFO DUMP\n";
+
+ for (SSVerPkgList::const_iterator ite = m_verList.begin();
+ ite != m_verList.end(); ite++) {
+ dumpStr += ite->first;
+ dumpStr += "\n";
+ dumpStr += ite->second.version;
+ dumpStr += "\n";
+ dumpStr += ite->second.date;
+ dumpStr += "\n";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "%s", dumpStr.c_str());
+}
+// LCOV_EXCL_STOP
+
+//==================================================================
+// PUBLIC
+//==================================================================
+CSSVer::CSSVer() {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "+");
+ DIR *dir = NULL;
+ struct dirent dent, *next;
+ struct stat statbuf;
+
+ try {
+ if (stat(SSVER_TMPDIR, &statbuf) != 0) {
+ mkdir(SSVER_TMPDIR, 0775);
+ // Because this process is not locked, if multiple processes process at the same time,
+ // although it may have been created and fail, do not ASSERT it because it is harmless.
+ }
+
+ // Linux dependency codes
+ if ((dir = opendir(SSVER_TMPDIR)) == NULL) { // LCOV_EXCL_BR_LINE 5:std c lib error process
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 5:std c lib error process
+ throw eFrameworkunifiedStatusFail;
+ }
+
+ // LCOV_EXCL_BR_START 11:Unexpected branch
+ while (0 == readdir_r(dir, &dent, &next) && next) {
+ if (DT_REG == dent.d_type) {
+ SSVER_PkgInfo info;
+ std::string name(dent.d_name);
+ std::string verInfo;
+
+ CPkgInfoIo pkgIo(name);
+ pkgIo.getData(&info);
+
+ verInfo += "\nPACKAGE :";
+ verInfo += name;
+ verInfo += "\n";
+ verInfo += " VERSION:";
+ verInfo += info.version;
+ verInfo += "\n";
+ verInfo += " DATE :";
+ verInfo += info.date;
+ verInfo += "\n";
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "%s", verInfo.c_str());
+
+ m_verList.insert(std::make_pair(name, info));
+ }
+ }
+ SS_ASERT_ERRNO(0 == closedir(dir)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h
+ // LCOV_EXCL_BR_STOP
+ } catch (...) { // LCOV_EXCL_START 6:unable to reach
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ if (dir) {
+ SS_ASERT_ERRNO(0 == closedir(dir));
+ }
+ } // LCOV_EXCL_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "-");
+}
+
+CSSVer::~CSSVer() {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus CSSVer::getPkgInfo(const std::string &name, SSVER_PkgInfo* p_info) {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "+");
+ EFrameworkunifiedStatus versionlibraryRet = eFrameworkunifiedStatusOK;
+ try {
+ if (p_info == NULL) {
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h
+ throw eFrameworkunifiedStatusFail;
+ }
+
+ SSVerPkgList::iterator ite = m_verList.find(name);
+
+ if (ite != m_verList.end()) {
+ // cache hit
+ *p_info = ite->second;
+ } else {
+ // cache miss
+ std::string path(SSVER_TMPDIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ path += "/";
+ path += name;
+
+ if (access(path.c_str(), F_OK) == 0) {
+ // cache refresh
+ CPkgInfoIo pkgIo(name); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ pkgIo.getData(p_info); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ m_verList.insert(std::make_pair(name, *p_info)); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ } else {
+ throw eFrameworkunifiedStatusFileLoadError;
+ }
+ }
+ } catch (EFrameworkunifiedStatus ee) {
+ versionlibraryRet = ee;
+ } catch (...) { // LCOV_EXCL_START 6:unable to reach
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ versionlibraryRet = eFrameworkunifiedStatusFail;
+ } // LCOV_EXCL_STOP
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "-");
+ return versionlibraryRet;
+}
+
+EFrameworkunifiedStatus CSSVer::setPkgInfo(const std::string &name, SSVER_PkgInfo &info) {
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "+");
+ EFrameworkunifiedStatus versionlibraryRet = eFrameworkunifiedStatusOK;
+ try {
+ // LCOV_EXCL_BR_START 11:Unexpected branch
+ SSVerPkgList::iterator ite = m_verList.find(name);
+
+ if (ite == m_verList.end()) {
+ m_verList.insert(std::make_pair(name, info));
+ CPkgInfoIo pkgIo(name);
+ pkgIo.putData(info);
+ } else {
+ ite->second = info;
+ CPkgInfoIo pkgIo(name);
+ pkgIo.putData(info);
+ }
+ // LCOV_EXCL_BR_STOP
+ } catch (EFrameworkunifiedStatus ee) {
+ versionlibraryRet = ee;
+ } catch (...) { // LCOV_EXCL_START 6:unable to reach
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h
+ versionlibraryRet = eFrameworkunifiedStatusFail;
+ } // LCOV_EXCL_STOP
+
+ FRAMEWORKUNIFIEDLOG(ZONE_DEFAULT, __FUNCTION__, "-");
+ return versionlibraryRet;
+} // LCOV_EXCL_BR_LINE 10:for the last line
+