diff options
author | 2020-11-19 12:45:32 +0900 | |
---|---|---|
committer | 2020-11-19 12:45:32 +0900 | |
commit | 8e0e00d21146a84c18f9cf9409e187b4fb0248aa (patch) | |
tree | ef791689dad216ac61091a1d1bd3b928d563aba6 /systemservice/config/library/system_manager_config | |
parent | 18df6e21c6743a137e2760c52ca89d0789e90417 (diff) |
Init basesystem source codes.
Signed-off-by: Riku Nomoto <riku_nomoto@mail.toyota.co.jp>
Change-Id: I55aa2f1406ce7f751ae14140b613b53b68995528
Diffstat (limited to 'systemservice/config/library/system_manager_config')
22 files changed, 1656 insertions, 0 deletions
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 Binary files differnew file mode 100755 index 0000000..2463eec --- /dev/null +++ b/systemservice/config/library/system_manager_config/last2order/sm_last2order.cfo 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> + |