summaryrefslogtreecommitdiffstats
path: root/nsframework/framework_unified/client/NS_FrameworkCore/include
diff options
context:
space:
mode:
Diffstat (limited to 'nsframework/framework_unified/client/NS_FrameworkCore/include')
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h676
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp43
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h675
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.h41
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.h148
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h97
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h89
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h30
8 files changed, 1799 insertions, 0 deletions
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h
new file mode 100644
index 00000000..cb8bcee7
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h
@@ -0,0 +1,676 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_NSFramework
+/// \brief Application framework's core structures and data types.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_CORE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_CORE_H_
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <other_service/strlcpy.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/ns_logger_if.h>
+
+#include <iostream>
+#include <string>
+#include <map>
+#include <queue>
+#include <cstdio>
+#include <vector>
+#include <utility>
+
+static const UI_32 THREAD_SESSION_ID = 0;
+
+typedef HANDLE SessionHandle;
+typedef int SessionId; // < service protocol command
+typedef int ServiceProtocolCommand; // < service protocol command
+typedef int Fd; // < FD associated with callback
+typedef std::string Notification; // < notification name
+typedef std::string ServiceName; // < service name
+typedef std::string ThreadName;
+typedef std::string DataKey;
+typedef std::string InvokerName;
+typedef int Socket;
+typedef std::string ConnectKey;
+typedef PVOID Data;
+
+typedef std::map<Notification, CallbackFunctionPtr> NotificationTable;
+
+
+typedef std::map<ServiceProtocolCommand, CallbackFunctionPtr> ServiceProtocolTable;
+typedef std::map<SessionId, ServiceProtocolTable> SessionTable;
+typedef std::map<ServiceName, SessionTable> Services;
+typedef std::map<HANDLE, ServiceName> ServiceSendMsgHandle;
+typedef std::map<Fd, CallbackFunctionPtr> FdTable;
+
+typedef int EventId;
+typedef std::map<ServiceProtocolCommand, EventId> ServiceEventProtocolTable;
+typedef std::map<SessionId, ServiceEventProtocolTable> EventSessionTable;
+typedef std::map<ServiceName, EventSessionTable> EventServices;
+typedef std::map<Notification, EventId> NotificationEventTable;
+typedef std::map<SessionId, SessionHandle> SessionHandleTable;
+typedef std::map<ServiceName, SessionHandleTable> ServiceSessionTable;
+typedef std::map<InvokerName, HANDLE> InvokeResponseQTable;
+typedef std::map<Socket, ConnectKey> AcceptMonitorTable;
+typedef std::map<Socket, ConnectKey> ConnectMonitorTable;
+
+typedef std::pair<NotificationTable::iterator, bool> NotificationTableRetStatus;
+typedef std::map<DataKey, Data> AppData;
+
+// private event data structure
+typedef struct _EventData {
+ PVOID pData; /// <message data
+ UI_32 uiLength; /// <message length
+} EventData;
+
+// framework message queue info
+typedef struct _MsgQInfo {
+ CHAR cSrcName[MAX_NAME_SIZE_APP]; /// <source message queue name
+ CHAR cMsgQName[MAX_NAME_SIZE_APP]; /// <name of the handle to the msgq
+ UI_32 checkCode;
+ pthread_t self;
+ HANDLE hMsgQ; /// <handle to message queue
+ UI_32 sessionId; /// <Used only when it is a session handle
+} MsgQInfo;
+
+#define MSGQ_CHECK_CODE (0xACCE55ED)
+
+static inline BOOL frameworkunifiedCheckValidMsgQ(HANDLE hService) {
+ static __thread int detect_once = 0;
+ if (NULL != hService) {
+ MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
+ /**
+ * @todo
+ * If an application handle is specified in place of a session handle,
+ * the element is accessed illegally without type checking,
+ * and a DeathTest occurs because the thread_self check is violated.
+ */
+ if (pMsgQ->self != pthread_self() && detect_once == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __func__, "Invalid thread context detect(hService/hSession):%#lx:%#lx", pMsgQ->self,
+ pthread_self());
+ detect_once = 1;
+ }
+ if (pMsgQ->checkCode == MSGQ_CHECK_CODE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/* data structure for public state events and data associated with it */
+// map of state events and data associated with it
+typedef std::map<UI_32, EventData *> PublicStateEventTable;
+
+/* data structure for private state events and data associated with it */
+// list of session id's of service and event data(private) associated with it
+typedef std::map<UI_32, EventData *> SessionEventData;
+
+// map of service name and list of its session id's and associated event data
+typedef std::map<ServiceName, SessionEventData> ServiceSessionEventData;
+
+// map of private events and the data published on the all sessions of all services subscribed to it
+typedef std::map<UI_32, ServiceSessionEventData> PrivateStateEventTable;
+
+
+// list of session id's for each service registering with event
+typedef std::vector<UI_32> SessionIdList;
+typedef std::vector<UI_32> EventIdList;
+
+// map of service name and and list of its session id
+typedef std::map<ServiceName, SessionIdList> ServiceSessionIdListTable;
+// map of events and its subscribers
+typedef std::map<UI_32, ServiceSessionIdListTable> EventTable;
+
+// structure to hold the session handle and list of event ids for that session
+typedef struct _SessionEventInfo {
+ HANDLE m_hSession; // Msg queue handle for the specific session
+ EventIdList m_vEvents; // List of event ids corresponding to the session
+} SessionEventInfo, *PSessionEventInfo;
+
+// map to hold the session id and structure of session event info
+typedef std::map<SessionId, SessionEventInfo *> SessionToEventInfo;
+
+// map of service name with session id and session handle
+typedef std::map<ServiceName, SessionToEventInfo > ServiceSessionHandleTable;
+
+// Defer'ed queue
+// When a pop is issued this data will be copied to the internal CFrameworkunifiedFrameworkApp struct
+// which will call the FrameworkunifiedDispatchProcess that will process the message as if
+// it was received off the message queue!
+class DeferedMsgInfo {
+ void copy_me(const DeferedMsgInfo &defer) {
+ if (this != &defer) {
+ uiProtocolCmd = defer.uiProtocolCmd;
+ strlcpy(cMsgSrcName, defer.cMsgSrcName, sizeof(cMsgSrcName));
+ std::memcpy(uiMsgRcvBuffer, defer.uiMsgRcvBuffer, MAX_MSGQ_BUFFER);
+ }
+ }
+
+ public:
+ UI_32 uiProtocolCmd; /// <protocol req/ack received
+ CHAR cMsgSrcName[MAX_NAME_SIZE_APP]; /// <name of client/server(application) message queue
+ UI_8 uiMsgRcvBuffer[MAX_MSGQ_BUFFER]; /// <receive buffer for message queue
+
+ DeferedMsgInfo() : uiProtocolCmd(0) {
+ std::memset(uiMsgRcvBuffer, 0, MAX_MSGQ_BUFFER);
+ std::memset(cMsgSrcName, '\0', MAX_NAME_SIZE_APP);
+ }
+
+ DeferedMsgInfo(const DeferedMsgInfo &defer) {
+ copy_me(defer); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ DeferedMsgInfo(UI_32 cmd, PCSTR name, UI_8 buf[MAX_MSGQ_BUFFER]) {
+ DeferedMsgInfo defer;
+
+ defer.uiProtocolCmd = cmd;
+ strlcpy(defer.cMsgSrcName, name, sizeof(defer.cMsgSrcName));
+ std::memcpy(defer.uiMsgRcvBuffer, buf, MAX_MSGQ_BUFFER);
+
+ copy_me(defer);
+ }
+
+ DeferedMsgInfo &operator = (const DeferedMsgInfo &defer) {
+ copy_me(defer);
+
+ return *this;
+ }
+};
+
+typedef struct _ServiceNotificationInfo {
+ CHAR sNotificationName[MAX_SYS_INFO_SIZE];
+ UI_32 uiEventId;
+} ServiceNotificationInfo;
+
+typedef std::vector<ServiceNotificationInfo> NotificationList;
+typedef std::queue<DeferedMsgInfo> DeferedMessageQueue;
+
+typedef struct _LostSessionInfo {
+ std::string sServiceName;
+ SessionId iSessionId;
+} LostSessionInfo;
+
+typedef std::queue<LostSessionInfo> LostSessionQueue;
+
+#ifdef DISPATCHER_PROFILER
+class FrameworkunifiedMsgProfiler;
+#endif
+
+class ResponseData {
+ std::vector<UI_8> rawBuffer;
+
+ public:
+ void set(PVOID src, UI_32 size) {
+ rawBuffer.resize(size);
+ std::memcpy(&rawBuffer[0], src, size);
+ }
+
+ UI_8 *data(void) {
+ return rawBuffer.empty() ? NULL : &rawBuffer[0];
+ }
+
+ void clear(void) {
+ std::vector<UI_8>().swap(rawBuffer);
+ }
+
+ UI_32 size(void) {
+ return static_cast<UI_32>(rawBuffer.size());
+ }
+};
+
+
+// framework container
+typedef struct _CFrameworkunifiedFrameworkApp {
+ CHAR cAppName[MAX_NAME_SIZE_APP]; /// <application(client/service) name
+ UI_32 checkCode; /// <check code
+ pthread_t self;
+
+ // message receive information
+ HANDLE hAppRcvMsgQ; /// <handle to apps receive message queue
+ HANDLE hAppSndMsgQ; /// <handle to apps send message queue
+ UI_32 uiMsgLength; /// <length of data in message queue
+ UI_32 uiProtocolCmd; /// <protocol req/ack received
+ UI_32 uiSessionId;
+ CHAR cSystemInfo[MAX_SYS_INFO_SIZE];
+ CHAR cMsgSrcName[MAX_NAME_SIZE_APP]; /// <name of client/server(application) message queue
+ UI_8 uiMsgRcvBuffer[MAX_MSGQ_BUFFER]; /// <receive buffer for message queue
+ int efd; /// <FD for multiple wait generated by the epoll_create()
+ int defer_evfd; /// <FD for receiving Defer events to Dispatcher
+
+ Services services; /// <services <map>
+ ServiceSendMsgHandle servicesHandle; /// <serviceHandle <map>
+ NotificationTable notifications; /// <notification <map>
+ FdTable fds; /// <fdTable <map>
+
+ InvokeResponseQTable invokeResQTable;
+
+ AcceptMonitorTable acceptMonitorTable;
+ ConnectMonitorTable connectMonitorTable;
+ LostSessionQueue lostSessionQueue;
+ CallbackFunctionPtr lostSessionHandler;
+
+ EventServices eventservices;
+ NotificationEventTable notificationevents;
+
+ AppData appdata;
+
+ // Defer'ed Message Queue
+ DeferedMessageQueue deferedMsgQueue; /// <defer'ed message <queue>
+ BOOL fPopDeferedMsg;
+
+ HANDLE hNPSndMsgQ; /// <send msgq handle to NPService
+
+ // application & framework errors
+ EFrameworkunifiedStatus eLastFrameworkError; /// <Framework internal errors
+ EFrameworkunifiedStatus eLastAppError; /// <application(client/server/child thread) reported errors
+
+ /////////////////////////////////////////
+ void *FrameworkData;
+ HANDLE hParentSndMsgQ;
+ CHAR cParentAppName[MAX_NAME_SIZE_APP]; /// <application(client/service) name
+ /////////////////////////////////////////
+
+ HANDLE hConfigFileHandle;
+
+ class CFrameworkunifiedHSMFramework *m_pFrameworkunifiedStateMachine;
+
+ ServiceSessionTable sessiontable;
+ NotificationList servicenotificationlist;
+ CHAR sServiceAvailabilityNotification[MAX_SYS_INFO_SIZE];
+ BOOL bIsAvailable;
+
+ ServiceSessionHandleTable servicesessionhandletable;
+
+ void *pRsrcMgr;
+
+ // framework state information
+ // TODO(framework_unified): consider this for future
+
+ // Current user
+ HANDLE hUser;
+
+ // table holding list of all the events of service and its subscribers
+ EventTable eventtable;
+
+ // table holding list of all the public events of service and the event data corresponding to it
+ PublicStateEventTable publicstateeventtable;
+
+ // table holding list of all the private events of service and
+ // the event data corresponding to each of the subscribed session of its subscribers
+ PrivateStateEventTable privatestateeventtable;
+
+ ResponseData responsedata;
+
+ UI_64 total_occupy_time;
+ UI_64 total_run_count;
+ UI_32 max_occupy_time;
+
+ SI_32 siMonitorSock;
+
+ BOOL fDeferredSyncResponse;
+
+#ifdef DISPATCHER_PROFILER
+ // Profiler object. This is required per dispatcher
+ FrameworkunifiedMsgProfiler *m_pFrameworkunifiedMsgProfiler;
+#endif
+} CFrameworkunifiedFrameworkApp;
+
+// Structure containing the synchronization data
+struct SFrameworkunifiedSyncDataPacket {
+ PVOID m_pNotificationData; // Data published with the notification
+ UI_32 m_uiDataSize; // Size of the data published with the notification
+ time_t m_tTimeStamp; // Time when the notification was recently published
+};
+
+struct PCData {
+ PCData(pthread_barrier_t *bar, EFrameworkunifiedStatus *status, PCSTR parent, PCSTR child, CbFuncPtr init, CbFuncPtr shdn,
+ EFrameworkunifiedSchedPolicy policy, SI_32 priority, CbFuncPtr CreateHSM = NULL)
+ : barrier(bar),
+ childStatus(status),
+ parentName(parent),
+ childName(child),
+ initFn(init),
+ shdnFn(shdn),
+ schedPolicy(policy),
+ schedPriority(priority),
+ CbCreateStateMachine(CreateHSM) { // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ pthread_barrier_t *barrier;
+ EFrameworkunifiedStatus *childStatus;
+ const ServiceName parentName;
+ const ServiceName childName;
+ CbFuncPtr initFn;
+ CbFuncPtr shdnFn;
+ EFrameworkunifiedSchedPolicy schedPolicy;
+ SI_32 schedPriority;
+ CbFuncPtr CbCreateStateMachine;
+};
+
+#define APP_CHECK_CODE (0xAC1D5EED)
+
+static inline BOOL frameworkunifiedCheckValidAppHandle(HANDLE hApp) {
+ static __thread int detect_once = 0;
+ if (NULL != hApp) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+ /**
+ * @todo
+ * eFrameworkunifiedStatusOK is returned even if a appHandle created in another thread is passed,
+ * and the specifications and operations differ.
+ * @todo
+ * If an application handle is specified in place of a session handle,
+ * the element is accessed illegally without type checking,
+ * and a DeathTest occurs because the thread_self check is violated.
+ * @todo
+ * If you specify an app handle for a child thread,
+ * the NULL's return value is not terminated abnormally at the intended point (frameworkunifiedCheckValidAppHandle).
+ */
+ if (pApp->self != pthread_self() && detect_once == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __func__, "Invalid thread context detect(hApp):%#lx:%#lx", pApp->self, pthread_self());
+ detect_once = 1;
+ }
+ if (pApp->checkCode == APP_CHECK_CODE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSubscribeToNotification
+/// API to send message to Notification Service to add to subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotification(HANDLE hApp, PCSTR pNotification);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSubscribeToNotifications
+/// API to send message to Notification Service to add multiple subscriptions list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationCallbackHandler - Name of Notification
+/// \param [in] uiListLength
+/// UI_32 - number of notification that your subscribing too.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList, UI_32 uiListLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPUnsubscribeFromNotification
+/// API to send message to Notification Service to remove from subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotification(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPUnsubscribeFromNotifications
+/// API to send message to Notification Service to remove multiple notification from subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationCallbackHandler - notifications list
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
+ UI_32 uiListLength);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMSubscribeToNotificationsEvents
+/// API to send message to Notification Service to add multiple subscriptions list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationEvent - list of notification events
+/// \param [in] uiListLength
+/// UI_32 - number of notification that your subscribing too.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
+ UI_32 uiListLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMSubscribeToNotificationEvent
+/// API to send message to Notification Service to add to subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationEvent(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent
+/// API to send message to Notification Service to remove from subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents
+/// API to send message to Notification Service to remove multiple subscriptions list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationEvent - list of notification events
+/// \param [in] uiListLength
+/// UI_32 - number of notification that your subscribing too.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
+ UI_32 uiListLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDispatcher
+///
+/// \param [in] cAppName
+/// PCSTR - Application name
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocol(HANDLE hApp);
+
+EFrameworkunifiedStatus frameworkunifiedAddConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName);
+EFrameworkunifiedStatus frameworkunifiedDelConnectMonitorPre(int efd, PCSTR serverName, PCSTR clientName);
+EFrameworkunifiedStatus frameworkunifiedDelConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDispatcher
+///
+/// \param [in] cAppName
+/// PCSTR - Application name
+/// \param [out] hApp
+/// HANDLE& - Reference of application handle
+/// \param [in] bIsChildThread
+/// BOOL - child thread
+///
+/// \return status
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if success
+/// eFrameworkunifiedStatusFail if invalid app name
+/// eFrameworkunifiedStatusNullPointer if unable to open message Q handle
+/// or possible errors from call FrameworkunifiedAttachSystemCallbacksDispatcher/
+/// FrameworkunifiedAttachLoggerCallbacksDispatcher/
+/// FrameworkunifiedAttachVersionCallbacksDispatcher
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread = FALSE); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RunDispatcher
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RunDispatcher(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RunChildDispatcher
+/// Dispatcher for child thread. Only difference with \ref RunDispatcher is, child dispatcher
+/// exits when non eFrameworkunifiedStatusOK value by callback function is returned.
+/// Whereas, \ref RunDispatcher is not supposed to exit.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RunChildDispatcher(HANDLE hChildApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsValidWaitBarrier
+///
+/// \param [in] wbret
+/// int - barrier
+///
+/// \return bool
+/// valid or invalid
+////////////////////////////////////////////////////////////////////////////////////////////
+bool IsValidWaitBarrier(int wbret);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// setChildThreadSched
+///
+/// \param [in] policy
+/// EFrameworkunifiedSchedPolicy - scheduling policy
+/// \param [in] priority
+/// SI_32 - scheduling priority
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus setChildThreadSched(EFrameworkunifiedSchedPolicy policy, SI_32 priority);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateChildThread
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] childName
+/// PCSTR - Name of child thread to be created
+/// \param [in] CbInitialize
+/// CbFuncPtr - Initialize function.
+/// \param [in] CbShutdown
+/// CbFuncPtr - Shutdown function.
+/// \param [in] attr
+/// const FrameworkunifiedChildThreadAttr * - child thread attribute
+/// \param [in] CbCreateStateMachine
+/// CbFuncPtr - Function pointer to create state machine, in case of SM child thread, else NULL
+///
+/// \return HANDLE
+/// Non-null value if thread is created else NULL
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE CreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr CbShutdown,
+ const FrameworkunifiedChildThreadAttr *attr, CbFuncPtr CbCreateStateMachine);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Child thread attribute initialize
+///
+/// \param [out] attr
+/// FrameworkunifiedChildThreadAttr - Child thread attribute
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Child thread attribute set schedule policy & priority
+///
+/// \param [out] attr
+/// FrameworkunifiedChildThreadAttr - Child thread attribute
+/// \param [int] policy
+/// EFrameworkunifiedSchedPolicy - Child thread scheduling policy
+/// \param [in] priority
+/// SI_32 - Child thread scheduling priority
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// DestroyThread
+// Sends eFrameworkunifiedStatusExit status to exits the dispatcher loop to terminate the thread.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DestroyThread(HANDLE hApp);
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_CORE_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp
new file mode 100644
index 00000000..8599fb22
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp
@@ -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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief This file provides framework's API which are used by system services.
+///////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_INTERNAL_HPP_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_INTERNAL_HPP_
+
+#include <stdexcept>
+#include <native_service/frameworkunified_types.h>
+
+namespace frameworkunified {
+namespace framework {
+namespace error {
+
+class CSystemError : public std::runtime_error {
+ public:
+ explicit CSystemError(EFrameworkunifiedSystemError error, PCSTR errorMsg);
+ const EFrameworkunifiedSystemError m_eSystemError;
+};
+}
+}
+}
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_INTERNAL_HPP_
+//@}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h
new file mode 100644
index 00000000..4d38828a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h
@@ -0,0 +1,675 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_NSFramework
+/// \brief Internal functions of the application framework.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_INTERNAL_H_
+
+#include <native_service/ns_shared_mem_if.h>
+#include <native_service/frameworkunified_types.h>
+#include "frameworkunified_framework_core.h"
+#define PASA_APPCONFIG_FILES "PASA_APPCONFIG_FILES"
+
+#define FRAMEWORKUNIFIEDLOG_CUT(zone, funcname, print_fmt, args...)
+
+//////////////////////////////////////////////////
+// dispatcher internal functions
+//////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachSystemCallbacksDispatcher
+/// All system defined callbacks will be attached to the dispatcher
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework.
+///
+/// \return eStatus
+/// EFrameworkunifiedStatus - success or error
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachSystemCallbacksDispatcher(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendSystemErrMessage
+/// This API is used to send application's critical error message to system manager.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework.
+/// \param [in] eSystemError
+/// EFrameworkunifiedSystemError - System error type
+///
+/// \return EFrameworkunifiedStatus - success or error
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendSystemErrMessage(HANDLE hApp, EFrameworkunifiedSystemError eSystemError);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateDispatcher
+/// Creates and initializes an applications/threads dispatcher.
+///
+/// \param [in] cAppname
+/// PCSTR - Application/ thread name
+/// \param [out] hApp
+/// HANDLE& - Reference of application handle
+/// \param [in] bIsChildThread
+/// BOOL - child thread
+///
+/// \return status
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if Success
+/// possible errors from call CreateDispatcher
+///
+/// \see FrameworkunifiedDispatchBlock,
+/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateHSMDispatcher
+/// Creates and initializes an applications/threads hsm dispatcher.
+///
+/// \param [in] cAppname
+/// PCSTR - Application/ thread name
+/// \param [out] hApp
+/// HANDLE& - Reference of application handle
+/// \param [in] bIsThread
+/// BOOL - child thread
+/// \param [in] f_pFrameworkunifiedHSM
+/// CFrameworkunifiedHSMFramework* - statemachine instances
+///
+/// \return status
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if Success
+/// possible errors from call CreateDispatcher
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcher(PCSTR cAppName,
+ HANDLE &hApp, // NOLINT (readability/nolint)
+ BOOL bIsThread,
+ CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatchBlock
+/// Blocked until the dipatcher receives a notification of a service request or ack.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher,
+/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatchBlock(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// frameworkunifiedFdHandler
+/// FD POLLIN blocked & process.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] efd
+/// int - epoll FD
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchProcess, FrameworkunifiedDispatchBlock,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus frameworkunifiedFdHandler(HANDLE hApp , int efd);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatchProcess
+/// Processes the Service/system request or notification.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedCloseDispatcher,
+///
+/// \details
+/// \code
+/// Pseudo code:
+/// IF message_source != Notification Service
+/// FIND source_name
+/// IF source_name available
+/// FIND protocol_cmd
+/// IF protocol_cmd available
+/// execute callback
+/// ELSE
+/// ignore
+/// END
+/// ELSE
+/// ignore
+/// END
+/// ELSE // notification
+/// FIND notification_callback
+/// IF available
+/// execute callback
+/// END
+/// \endcode
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatchProcess(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCloseDispatcher
+/// Closing the dispatcher
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseDispatcher(HANDLE hApp);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPopedDeferedMessage
+/// Checks the Defer'ed Message Queue should be pop'ed off
+/// the front of the queue!
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// BOOL - TRUE (a message has been pop'ed of the defer'ed msg queue)
+/// FALSE (no msg was pop'ed of the defer'ed msg queue)
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedPopedDeferedMessage(HANDLE hApp);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatcherMain
+/// Main processing loop that is shared between FrameworkunifiedDispacther and FrameworkunifiedDispatcherWithCmdLnArguments.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// BOOL - TRUE (a message has been pop'ed of the defer'ed msg queue)
+/// FALSE (no msg was pop'ed of the defer'ed msg queue)
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatcherMain(HANDLE hApp);
+
+EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatcherMain
+/// Main processing loop that is shared between FrameworkunifiedDispacther and FrameworkunifiedDispatcherWithCmdLnArguments.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// BOOL - TRUE (a message has been pop'ed of the defer'ed msg queue)
+/// FALSE (no msg was pop'ed of the defer'ed msg queue)
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedArgumentParser(HANDLE hApp, int argc, char *argv[], CustomCommandLineOptions *cmdLineOptions);
+
+
+EFrameworkunifiedStatus FrameworkunifiedOnInitializationInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnDestroyInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnStartInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnStopInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnPreStartInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnPreStopInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStartInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStopInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDumpInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachineInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterfaceInternal(HANDLE hApp);
+EFrameworkunifiedStatus RegistDefaultCbHandler(const FrameworkunifiedDefaultCallbackHandler *CbHandler);
+
+
+//////////////////////////////////////////////////
+// message center internal functions
+//////////////////////////////////////////////////
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// frameworkunifiedGetIsTypeOfSync
+/// Gets if message type is sync, return TRUE. or not return FALSE
+///
+/// \param [in] hApp
+/// HANDLE - Handle to a Application Framework
+///
+/// \return status
+/// BOOL - TRUE or FALSE
+///
+/// \see FrameworkunifiedInvokeSync, frameworkunifiedSendSyncResponse
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL frameworkunifiedGetIsTypeOfSync(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendSyncResponse
+/// Send Sync Response to the hApp.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the dispatcher to receive message
+/// \param [in] seq_id
+/// UI_32 - Sync sequence ID
+/// \param [in] retValue
+/// EFrameworkunifiedStatus - Return Status
+/// \param [in] length
+/// UI_32 - Length of the data to be receive response.
+/// \param [in] data
+/// PVOID - Pointer to the response data.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedInvokeSync
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus frameworkunifiedSendSyncResponse(HANDLE hApp, UI_32 iCmd, UI_32 seq_id, EFrameworkunifiedStatus retValue, UI_32 length, PCVOID data);
+
+//////////////////////////////////////////////////
+// logger internal functions
+//////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachLoggerCallbacksDispatcher(HANDLE hApp);
+
+#ifdef DISPATCHER_PROFILER
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachMsgProfilerCallbacksDispatcher
+/// This function attaches callback function for profiler protocol for main thread.
+/// Protocol is attached considering the source as "nsprofilerutil"
+///
+/// \param [in] hApp
+/// HANDLE - Handle to a Application Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachMsgProfilerCallbacksDispatcher(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachMsgProfilerCallbacksDispatcher
+/// This function attaches callback function for profiler protocol for child threads.
+/// Protocol is attached considering the source as parent thread
+///
+/// \param [in] hApp
+/// HANDLE - Handle to a Application Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachChildMsgProfilerCallbacksDispatcher(HANDLE hApp);
+#endif
+
+EFrameworkunifiedStatus FrameworkunifiedSetLogMask(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedGetLogMask(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedSetOutputLogOpts(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedGetOutputLogOpts(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedSetLogSeverity(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedGetLogSeverity(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedDebugDumpRequest(HANDLE hApp);
+
+EFrameworkunifiedStatus NSRcsSetLogSettings(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsGetLogSettings(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsSetLogMask(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsSetOutputLogOpts(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsSetLogSeverity(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetConfigHandle
+/// This Function opens the configuration file from given path and sets the file handle in hApp
+///
+/// \param [in] cAppname
+/// HANDLE - Application handle
+/// \param [in] sFilePath
+/// PCHAR - File path of the config file
+///
+/// \return status of the operation
+///
+/// \see SetDefaultFilePath,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetConfigHandle(HANDLE hApp, PCHAR sFilePath);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetDefaultFilePath
+/// This Function fetches the default config path, opens the configuration file and sets the file
+/// handle in the application
+///
+/// \param [in] cAppname
+/// HANDLE - Application handle
+/// \param [in] sFilePath
+/// PCHAR - File path of the config file
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetDefaultConfigFile(HANDLE hApp);
+
+EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocolHSMEvent(HANDLE hApp, PCSTR pRequester);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ProcessProtocolEvents
+/// This Function registers the events of server with the client.
+/// If the event is published previously and is a state event then send the event data to the client.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus ProcessProtocolEvents(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ProcessPrivateEvents
+/// This Function registers the events of server with the client.
+/// If the event is published previously and is a state event then send the event data to the client.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus ProcessPrivateEvents(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CleanAllEventsOfSession
+/// This Function closes the session handle and removes its entry from the table of
+/// ServiceSessionHandleTable of application framework handle.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Name of a service
+/// \param [in] sessionId
+/// UI_32 - Session id
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CleanAllEventsOfSession(HANDLE hApp, PCSTR serviceName, UI_32 sessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveEntryFromSessionEventInfoTable
+/// This Function removes the entry of event id from the session table based on the service
+/// name and session id.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Name of service
+/// \param [in] sessionId
+/// UI_32 - Session id
+/// \param [in] eventId
+/// UI_32 - Event id which needs to be removed from internal table
+///
+/// \return eFrameworkunifiedStatusOK- Success, or eFrameworkunifiedStatusFail
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RemoveEntryFromSessionEventInfoTable(HANDLE hApp, PCSTR serviceName, UI_32 sessionId, UI_32 eventId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// HandleSessionEventOnCloseSession
+/// This Function does the handling of session events on close session request
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus HandleSessionEventOnCloseSession(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// UnregisterPrivateEvents
+/// This Function unregisters the private event.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus UnregisterPrivateEvents(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetMsgQueueHandle
+/// Gets the message queue handle from servicesessionhandletable map.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Service name of receiver
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return Message queue handle
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE GetMsgQueueHandle(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetNewMsgQueueHandle
+/// This function creates and returns the message queue handle.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Service name of receiver
+/// \param [in] uiSessionId
+/// UI_32 - session id
+/// \param [in] uiEventId
+/// const UI_32 - event id
+///
+/// \return Message queue handle
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE GetNewHandleAndUpdateEventInfoTable(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId,
+ const UI_32 uiEventId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsEventAlreadyRegistered
+/// Searches for the session id in the vector
+///
+/// \param [in] vSessionIdList
+/// SessionIdList - list of sessions id's
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return true or false
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL IsEventAlreadyRegistered(const SessionIdList &vSessionIdList, const UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveEventEntryFromEventTable
+/// This Function removes the entry of event for received service on the active session id
+/// from Event Table.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] serviceName
+/// PCSTR - Service name of receiver
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RemoveEventEntryFromEventTable(HANDLE hApp, UI_32 uiEventId, PCSTR cServiceName, const UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SendEventMessage
+/// This function sends the private event message to all the sessions of service registered
+/// for event.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] vSessionIdList
+/// SessionIdList - session id list
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] cServiceName
+/// PCSTR - Service name of receiver
+/// \param [in] pData
+/// PCVOID - data to send
+/// \param [in] uiLength
+/// UI_32 - length of data
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendEventMessage(HANDLE hApp, const SessionIdList &vSessionIdList, UI_32 uiEventId, PCSTR cServiceName,
+ PCVOID pData, UI_32 uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdatePublicStateEventData
+/// This API updates the event data of public state event for all the session of
+/// all subscribed clients.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] pData
+/// PCVOID - data to send
+/// \param [in] uiLength
+/// UI_32 - length of data
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus UpdatePublicStateEventData(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdatePrivateStateEventData
+/// This API updates the event data of private state event for session with
+/// session id uiSessionId of client pClientName.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] pClientName
+/// PCSTR - Event Subscriber name
+/// \param [in] uiSessionId
+/// UI_32 - session id
+/// \param [in] pData
+/// PCVOID - data to send
+/// \param [in] uiLength
+/// UI_32 - length of data
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus UpdatePrivateStateEventData(HANDLE hApp, UI_32 uiEventId, PCSTR pClientName, UI_32 uiSessionId, PCVOID pData,
+ UI_32 uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// DeleteSessionEventData
+/// This function is called while destroying the session with client.
+/// This method removes the private event data associated with the session.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pClientName
+/// PCSTR - Event Subscriber name
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DeleteSessionEventData(HANDLE hApp, PCSTR pClientName, UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetDataUSID
+/// Gets the shared memory ID
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// UI_32 - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+TMemID FrameworkunifiedGetDataUSID(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedIsAutoPublishServiceAvailableEnabled
+/// This function is used to check whether auto publishing of service availability is
+/// enabled or not.
+///
+/// \param None
+///
+/// \return BOOL
+/// BOOL - true if auto publish is enabled for service else false
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsAutoPublishServiceAvailableEnabled();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedIsWaitInStoppingStateEnabled
+/// Check if wait in stopping state is enabled.
+///
+/// \param [in] none
+///
+/// \return BOOL - TRUE if enabled or FALSE
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsWaitInStoppingStateEnabled();
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.h
new file mode 100644
index 00000000..b78297e3
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.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 FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_UTILITY_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_UTILITY_H_
+
+#include <native_service/ns_utility.hpp>
+#include "frameworkunified_framework_internal.h"
+
+DEFINE_EXCEPTION(happ_error, std::runtime_error);
+
+class HAppTraits {
+ public:
+ typedef HANDLE Type;
+ typedef happ_error Exception;
+ static void Release(Type rsrc) {
+ FrameworkunifiedOnDestroyInternal(rsrc);
+ FrameworkunifiedCloseDispatcher(rsrc);
+ }
+
+ static BOOL BadValue(Type rsrc) {
+ return NULL == rsrc;
+ }
+};
+
+typedef ResourceMgr< HANDLE, HAppTraits > THApp;
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_UTILITY_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.h
new file mode 100644
index 00000000..f512e760
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.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.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief File declares FrameworkunifiedMsgProfiler class which keeps profiler information for message dispatcher
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <vector>
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Profiler class which keeps and manage profiler information for message dispatcher
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class FrameworkunifiedMsgProfiler {
+ public:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedMsgProfiler
+ /// Parameterized constructor
+ /// \param [in] f_cAppName
+ /// const std::string& - Name of the application or dispatcher
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ explicit FrameworkunifiedMsgProfiler(const std::string &f_cAppName);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~FrameworkunifiedMsgProfiler
+ /// Class destructor
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ~FrameworkunifiedMsgProfiler();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// GetAppName
+ /// Returns application name corresponding to profiler
+ ///
+ /// \param [in] none
+ ///
+ /// \return std::string
+ /// std::string - Returns application name corresponding to profiler
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetAppName();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// AddChildName
+ /// Returns application name corresponding to profiler
+ ///
+ /// \param [in] f_cChildName
+ /// const std::string& - Add the name of child dispatcher profiler
+ ///
+ /// \return none
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID AddChildName(const std::string &f_cChildName);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// MsgReceived
+ /// Updates the profiler information once the message is received.
+ /// e.g. increaments msg count, save the time of msg received
+ ///
+ /// \param [in] none
+ ///
+ /// \return none
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID MsgReceived();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// MsgProcessed
+ /// Updates the profiler information once the message is processed.
+ /// e.g. Updates the frequency of execution of message
+ ///
+ /// \param [in] none
+ ///
+ /// \return none
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID MsgProcessed();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintProfileInfo
+ /// All the profiler information which FrameworkunifiedMsgProfiler class has prints it in message
+ /// queue FRAMEWORKUNIFIED_NS_MSGPROFILERUTIL
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Application framework handle
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or failure
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus PrintProfileInfo(HANDLE f_hApp);
+
+ static BOOL m_bMsgProfilerEnabled; /// Flag is enabled when command line argument -q is passed.
+ /// Otherwise no profiler information is maintained.
+
+ private:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// GetClock
+ /// GetClock of milliseconds
+ ///
+ /// \param [in] none
+ ///
+ /// \return UI_64
+ /// UI_64 - returns time in Milliseconds
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ UI_64 GetClock();
+
+ std::vector<std::string> m_vChildNames; /// vector to save list of all child threads dispatcher
+ std::string m_cAppName; /// Dispacther application name
+ UI_32 m_ui32TotalNoOfMsgsReceived; /// Total number of messages received by the dispatcher
+
+ // NOTE: Storing time in ClockCycle. So that it will not add overhead for converting it to miliseconds.
+ // It will get converted only when information is required to print.
+ UI_64 m_ui64MinMsgProcessingTime; // time is in clock cycles
+ UI_64 m_ui64MaxMsgProcessingTime; // time is in clock cycles
+
+ UI_64 m_ui64TotalMsgExecutionTime; /// total time spent in message execution
+ UI_64 m_ui64LastMsgReceivedTime; /// save the time when last message was received
+ UI_64 m_ui64AppInitTime; /// save the time when application got initialized
+ BOOL m_bLastMsgWasPrintProfile; /// TRUE if the last message received
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h
new file mode 100644
index 00000000..20ed3f62
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h
@@ -0,0 +1,97 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedFinalState class definitions. CFrameworkunifiedFinalState is derived from
+/// CFrameworkunifiedState class.This class implements the additional functionality supported by HSM Final
+/// state.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_
+
+
+#include <native_service/frameworkunified_sm_state.h>
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the additional functionality supported by HSM Final state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedFinalState : public CFrameworkunifiedState {
+ public :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedFinalState
+ /// Parameterized constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedFinalState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedFinalState
+ /// Class destructor
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedFinalState();
+
+ virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// UpdateHistory
+ /// This function stores the last active state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UpdateHistory();
+
+ protected :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEntry
+ /// state initialization can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnExit
+ /// state cleanup can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData);
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_
+// @}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h
new file mode 100644
index 00000000..ea564df7
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.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_StateMachine
+/// \brief
+///
+/// This File has public Macro definition that simplifies the statemachine implementation
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
+/// Include files
+#include <native_service/frameworkunified_framework_types.h>
+#include <vector>
+#include <utility>
+
+/// connect child state to parent state and sets it as default state
+#define CONNECT_DEFAULTSTATE(parent, child) \
+ FrameworkunifiedConnect(l_p## parent, l_p## child, TRUE);
+
+/// connect child state to parent state
+#define CONNECT_STATE(parent, child) \
+ FrameworkunifiedConnect(l_p## parent, l_p## child);
+
+/// connect the deferred event and reactions and associate them with the state
+#define CONNECT_DEFERREDEVENT(state, eventid) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, NULL, #eventid, TRUE); \
+
+/// connect the event and reactions and associate them with the state
+#define CONNECT_EVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn## reaction, #eventid);
+
+/// connect the event and reactions and associate them with the state
+#define CONNECT_LOCAL_EVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pLocalTrn## reaction, #eventid);
+
+/// Sets the state as root state in the statemachine
+#define CONNECTROOT(state) \
+ FrameworkunifiedConnect(l_p## state);
+
+/// Creates the state
+#define CREATE_STATE(class_name) \
+ CHKNULL(m_pFrameworkunifiedStateList) \
+ C## class_name *l_p## class_name = new C## class_name(#class_name); \
+ CHKNULL(l_p## class_name) \
+ m_pFrameworkunifiedStateList->insert(std::pair<UI_32, CFrameworkunifiedState*>(e## class_name, l_p## class_name));
+
+// create a new shallow history state and add it in parent state
+#define ADD_SHALLOWHISTORYSTATE(parent) \
+ CFrameworkunifiedShallowHistoryState *l_p##parent##SHALLOWHISTORYSTATE = new CFrameworkunifiedShallowHistoryState(SHALLOWHISTORYSTATE);\
+ FrameworkunifiedConnect(l_p## parent, l_p##parent##SHALLOWHISTORYSTATE);\
+ l_p##parent##SHALLOWHISTORYSTATE->SetDefaultHistory();
+
+// create a new shallow history state and add it in parent state
+#define ADD_DEEPHISTORYSTATE(parent) \
+ CFrameworkunifiedDeepHistoryState *l_p##parent##DEEPHISTORYSTATE = new CFrameworkunifiedDeepHistoryState(DEEPHISTORYSTATE);\
+ FrameworkunifiedConnect(l_p## parent, l_p##parent##DEEPHISTORYSTATE);\
+ l_p##parent##DEEPHISTORYSTATE->SetDefaultHistory();
+
+/// connect deep history event to reaction and add to state
+#define CONNECT_DEEPHISTORYEVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##DEEPHISTORYSTATE, #eventid);
+
+/// connect shallow history event to reaction and add to state
+#define CONNECT_SHALLOWHISTORYEVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##SHALLOWHISTORYSTATE, #eventid);
+
+typedef struct _HSMConfigOptions {
+ EUserChangeOptions eUserChange;
+ BOOL bAutoPublishServiceAvaialble;
+ BOOL bWaitInStoppingState;
+} HSMConfigOptions;
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h
new file mode 100644
index 00000000..ff670295
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.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_NSFramework
+/// \brief Internal functions related to state machine child threads
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_
+
+void *child_hsm_thread_proc(void *args);
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_