diff options
Diffstat (limited to 'resource_manager/client')
-rw-r--r-- | resource_manager/client/Makefile | 58 | ||||
-rw-r--r-- | resource_manager/client/RESMGR.api | 12 | ||||
-rw-r--r-- | resource_manager/client/include/resmgr_api_resourcemanagerlog.h | 78 | ||||
-rw-r--r-- | resource_manager/client/libresm.ver | 28 | ||||
-rw-r--r-- | resource_manager/client/src/resmgr_api_lib.c | 142 |
5 files changed, 318 insertions, 0 deletions
diff --git a/resource_manager/client/Makefile b/resource_manager/client/Makefile new file mode 100644 index 00000000..c2148e09 --- /dev/null +++ b/resource_manager/client/Makefile @@ -0,0 +1,58 @@ +# +# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +######### add source path ############# +VPATH += ./ +VPATH += ./src +VPATH += ./include +VPATH += ../server/include +VPATH += ../server/include/system_service + +######### install headers(*.h) ############# +INST_HEADERS += resm.h +INST_HEADERS += resm_type.h +INST_HEADERS += resource_manager.h + +######### installed program ############# + + +######### installed library(*.a) ############# +INST_LIBS = + +######### installed shared library(*.so) ############# +INST_SHLIBS = libresm +RPC_API := RESMGR + +######### compiled sources ############# +libresm_SRCS += resmgr_api_stub.c +libresm_SRCS += resmgr_api_lib.c + +######### add include path ############# +CPPFLAGS += -I./ +CPPFLAGS += -I./include +CPPFLAGS += -I../server/include + +######## add compile option ######## + +######### add library path ############# +LDFLAGS += -Wl,--no-as-needed + +######### linked library (dynamic) ############# +LDLIBS += -lrpc +LDLIBS += -Wl,-Bdynamic -lev +LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified + +include ../../system_service.mk diff --git a/resource_manager/client/RESMGR.api b/resource_manager/client/RESMGR.api new file mode 100644 index 00000000..7bd9734e --- /dev/null +++ b/resource_manager/client/RESMGR.api @@ -0,0 +1,12 @@ +/* + * Resource Manager API + */ + +INCLUDE <system_service/resm.h> + +RPC_Result RESM_ReqEvent(uint32_t ssnld, const RESM_REQ_EVENT_t* p_reqEvent); +RPC_Result RESM_GetStatus(uint32_t ssnld, RESM_STATUS_t* p_status); +RPC_Result RESM_SV_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnld); +RPC_Result RESM_SV_Close(uint32_t ssnld); +RPC_Result RESM_SV_ChkSsnId(uint32_t ssnld); + diff --git a/resource_manager/client/include/resmgr_api_resourcemanagerlog.h b/resource_manager/client/include/resmgr_api_resourcemanagerlog.h new file mode 100644 index 00000000..8e6efb1f --- /dev/null +++ b/resource_manager/client/include/resmgr_api_resourcemanagerlog.h @@ -0,0 +1,78 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _resmgr_api_resourcemanagerlog_h_ // NOLINT +#define _resmgr_api_resourcemanagerlog_h_ + +#include <native_service/ns_logger_if.h> + +#define ZONE_INIT ZONEMASK(10) // LIB common definition +#define ZONE_FUNC ZONEMASK(11) // LIB common definition +#define ZONE_MEM ZONEMASK(12) // LIB common definition +#define ZONE_13 ZONEMASK(13) +#define ZONE_14 ZONEMASK(14) +#define ZONE_15 ZONEMASK(15) +#define ZONE_16 ZONEMASK(16) +#define ZONE_17 ZONEMASK(17) +#define ZONE_18 ZONEMASK(18) +#define ZONE_19 ZONEMASK(19) +#define ZONE_20 ZONEMASK(20) +#define ZONE_21 ZONEMASK(21) +#define ZONE_22 ZONEMASK(22) +#define ZONE_23 ZONEMASK(23) +#define ZONE_24 ZONEMASK(24) +#define ZONE_25 ZONEMASK(25) +#define ZONE_26 ZONEMASK(26) +#define ZONE_27 ZONEMASK(27) +#define ZONE_28 ZONEMASK(28) +#define ZONE_INFO ZONEMASK(29) // LIB common definition +#define ZONE_WARN ZONEMASK(30) // LIB common definition +#define ZONE_ERR ZONEMASK(31) // LIB common definition + +#define ZONE_TEXT_10 "Init" +#define ZONE_TEXT_11 "Function" +#define ZONE_TEXT_12 "Memory" +#define ZONE_TEXT_13 "" +#define ZONE_TEXT_14 "" +#define ZONE_TEXT_15 "" +#define ZONE_TEXT_16 "" +#define ZONE_TEXT_17 "" +#define ZONE_TEXT_18 "" +#define ZONE_TEXT_19 "" +#define ZONE_TEXT_20 "" +#define ZONE_TEXT_21 "" +#define ZONE_TEXT_22 "" +#define ZONE_TEXT_23 "" +#define ZONE_TEXT_24 "" +#define ZONE_TEXT_25 "" +#define ZONE_TEXT_26 "" +#define ZONE_TEXT_27 "" +#define ZONE_TEXT_28 "" +#define ZONE_TEXT_29 "Info" +#define ZONE_TEXT_30 "Warning" +#define ZONE_TEXT_31 "Error" + +#define ALL_ZONES_BUT_IPC_INFO 0xEFFFFFFF + +#ifndef FRAMEWORKUNIFIEDLOGOPTIONS +#define FRAMEWORKUNIFIEDLOGOPTIONS (LSHAREDMEM) // LPRINT, LSHAREDMEM +#endif + +#ifndef FRAMEWORKUNIFIEDLOGAPPZONES +#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN, ZONE_ERR, ZONE_INFO +#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */ + +#endif /* !_resmgr_api_resourcemanagerlog_h_ */ // NOLINT diff --git a/resource_manager/client/libresm.ver b/resource_manager/client/libresm.ver new file mode 100644 index 00000000..dc063f2c --- /dev/null +++ b/resource_manager/client/libresm.ver @@ -0,0 +1,28 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +# +# libresm version script +# +{ + global: + ### .text section ### + RESM_*; + ### .data section ### + local: + *; +}; + diff --git a/resource_manager/client/src/resmgr_api_lib.c b/resource_manager/client/src/resmgr_api_lib.c new file mode 100644 index 00000000..af3a174e --- /dev/null +++ b/resource_manager/client/src/resmgr_api_lib.c @@ -0,0 +1,142 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <other_service/rpc.h> +#include "resm_internal.h" +#include "resmgr_api.h" +#include "resmgr_api_resourcemanagerlog.h" + +/********************************************** + * External variable definitions + **********************************************/ +RPC_ID __thread rpcId; + +/******************************************************************************* + * RPC public API + *******************************************************************************/ +/* Connection */ +RESM_ERR_t +RESM_Open(const RESM_RSV_t* p_prim, uint32_t* p_ssnId) +{ + + RESM_ERR_t resmRet; + EV_ERR evRet; + + // Argument check + if( p_ssnId == NULL ) { + return RESM_E_PAR; + } + + // RPC resources + if( RPC_OK != RPC_START_CLIENT(&rpcId) ) { + FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: RPC_START Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" + return RESM_E_NG; + } + + + // Session connection + resmRet = RESM_SV_Open(p_prim, p_ssnId); + if( resmRet != RESM_E_OK ) { + FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: Open Session Error. ret[%d]", resmRet); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" + return RESM_E_NG; + } + + // Create Event Flag + evRet = EV_create_flag(Resm_Flag_ID_Base + *p_ssnId); + if( evRet != EV_OK ) { + FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr Open: create_flag Error. ret[%d]", evRet); + return RESM_E_NG; + } + + return RESM_E_OK; +} + +/* Disconnection */ +RESM_ERR_t +RESM_Close(uint32_t ssnId) +{ + + RESM_ERR_t resmRet; + + // Disconnect session + resmRet = RESM_SV_Close(ssnId); + if( resmRet != RESM_E_OK ) { + return resmRet; + } + + // Destroy RPC Resources + RPC_end(rpcId); + + return RESM_E_OK; +} + +/* Get event FD */ +RESM_ERR_t +RESM_GetEventFd(uint32_t ssnId, int32_t* p_fd) +{ + + RESM_ERR_t resmRet; + + // Argument check + if( p_fd == NULL ) { + return RESM_E_PAR; + } + // Session ID check + resmRet = RESM_SV_ChkSsnId(ssnId); + if( resmRet != RESM_E_OK ) { + return RESM_E_PAR; + } + + if( EV_OK != EV_get_flag_fd(Resm_Flag_ID_Base + ssnId, p_fd) ) { + FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr GetEventFd Error"); + return RESM_E_NG; + } + + return RESM_E_OK; +} + +/* Get event */ +RESM_ERR_t +RESM_GetEvent(uint32_t ssnId, RESM_EV_t* p_evFlag) +{ + + RESM_ERR_t resmRet; + EV_Flag flag; + + // Argument check + if( p_evFlag == NULL ) { + return RESM_E_PAR; + } + // Session ID Check + resmRet = RESM_SV_ChkSsnId(ssnId); + if( resmRet != RESM_E_OK ) { + return RESM_E_PAR; + } + + if( EV_OK != EV_get_flag(Resm_Flag_ID_Base + ssnId, &flag)) { + FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "[RESM_ERR]ResMgr GetEvent(get_flag) Error"); + return RESM_E_NG; + } + + if( flag.bits == 0 ) { + // No event + return RESM_E_NG; + } + + *p_evFlag = flag.bits; + + return RESM_E_OK; +} |