From: Hwankyu Jhun Date: Fri, 3 Aug 2018 07:32:07 +0000 (+0900) Subject: Support watchdog timer X-Git-Tag: submit/tizen/20180809.235246~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F185882%2F4;p=platform%2Fcore%2Fappfw%2Fapp-core.git Support watchdog timer To enable/disable the watchdog timer, appcore uses aul watchdog APIs. appcore watchdog APIs are added for application developers. Adds: - appcore_watchdog_enable() - appcore_watchdog_disable() - appcore_watchdog_kick() Requires: - https://review.tizen.org/gerrit/#/c/185276/ [aul-1] - https://review.tizen.org/gerrit/#/c/185882/ [app-core] - https://review.tizen.org/gerrit/#/c/185884/ [amd] - https://review.tizen.org/gerrit/#/c/186247/ [app-common] Change-Id: I1fc869aed8d54ed473f210eb81d95d25d67a0842 Signed-off-by: Hwankyu Jhun --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 450daf7..17f4d5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,18 @@ SET(CMAKE_SKIP_BUILD_RPATH TRUE) # Build appcore-common Library # ------------------------------ SET(APPCORE_COMMON "appcore-common") -SET(SRCS_common src/legacy/appcore.c src/legacy/appcore-measure.c src/legacy/appcore-rotation.c src/legacy/appcore-i18n.c src/base/appcore_base.c) - -SET(HEADERS_common appcore-common.h appcore_base.h) +SET(SRCS_common + src/legacy/appcore.c + src/legacy/appcore-measure.c + src/legacy/appcore-rotation.c + src/legacy/appcore-i18n.c + src/base/appcore_base.c + src/watchdog/appcore_watchdog.c) + +SET(HEADERS_common + appcore-common.h + appcore_base.h + appcore_watchdog.h) INCLUDE(FindPkgConfig) SET(APPCORE_PKG_CHECK_MODULES "gio-2.0 vconf sensor aul dlog capi-system-info") diff --git a/include/appcore_watchdog.h b/include/appcore_watchdog.h new file mode 100644 index 0000000..f1e94cf --- /dev/null +++ b/include/appcore_watchdog.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 __APPCORE_WATCHDOG_H__ +#define __APPCORE_WATCHDOG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enables watchdog timer. + * + * @return @c 0 on success, + * otherwise a negative error value + */ +int appcore_watchdog_enable(void); + +/** + * @brief Disables watchdog timer. + * + * @return @c 0 on success, + * otherwise a negative error value + */ +int appcore_watchdog_disable(void); + +/** + * @brief Kicks watchdog timer. + * + * @return @c 0 on success, + * otherwise a negative error value + */ +int appcore_watchdog_kick(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __APPCORE_WATCHDOG_H__ */ diff --git a/packaging/app-core.spec b/packaging/app-core.spec index b34a52e..78bb922 100644 --- a/packaging/app-core.spec +++ b/packaging/app-core.spec @@ -185,6 +185,7 @@ rm -rf %{buildroot} %{_libdir}/pkgconfig/appcore-common.pc %{_includedir}/appcore/appcore-common.h %{_includedir}/appcore/appcore_base.h +%{_includedir}/appcore/appcore_watchdog.h %files ui %manifest %{name}.manifest diff --git a/src/base/appcore_base.c b/src/base/appcore_base.c index 0ed9bb5..4507e23 100644 --- a/src/base/appcore_base.c +++ b/src/base/appcore_base.c @@ -38,8 +38,10 @@ #include #include #include + #include "appcore_base.h" #include "appcore_base_private.h" +#include "appcore_watchdog.h" #define PATH_LOCALE "locale" #define RESOURCED_FREEZER_PATH "/Org/Tizen/ResourceD/Freezer" @@ -1081,6 +1083,8 @@ EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, vo if (__context.ops.set_i18n) __context.ops.set_i18n(__context.data); + appcore_watchdog_enable(); + if (__context.ops.create) { traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:CREATE"); r = __context.ops.create(__context.data); @@ -1102,6 +1106,7 @@ EXPORT_API void appcore_base_fini(void) int i; aul_status_update(STATUS_DYING); + appcore_watchdog_disable(); if (__context.ops.terminate) { traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:TERMINATE"); __context.ops.terminate(__context.data); diff --git a/src/watchdog/appcore_watchdog.c b/src/watchdog/appcore_watchdog.c new file mode 100644 index 0000000..777c5fb --- /dev/null +++ b/src/watchdog/appcore_watchdog.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +#include "appcore_watchdog.h" +#include "appcore_watchdog_private.h" + +EXPORT_API int appcore_watchdog_enable(void) +{ + _W("[__APPCORE_WATCHDOG__] enable"); + return aul_watchdog_enable(); +} + +EXPORT_API int appcore_watchdog_disable(void) +{ + _W("[__APPCORE_WATCHDOG__] kick"); + return aul_watchdog_disable(); +} + +EXPORT_API int appcore_watchdog_kick(void) +{ + _W("[__APPCORE_WATCHDOG__] kick"); + return aul_watchdog_kick(); +} diff --git a/src/watchdog/appcore_watchdog_private.h b/src/watchdog/appcore_watchdog_private.h new file mode 100644 index 0000000..2b0fb8e --- /dev/null +++ b/src/watchdog/appcore_watchdog_private.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 __APPCORE_WATCHDOG_PRIVATE_H__ +#define __APPCORE_WATCHDOG_PRIVATE_H__ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "APP_CORE_WATCHDOG" + +#ifndef EXPORT_API +#define EXPORT_API __attribute__ ((visibility("default"))) +#endif + +#ifndef _E +#define _E(fmt, arg...) LOGE(fmt, ##arg) +#endif + +#ifndef _W +#define _W(fmt, arg...) LOGW(fmt, ##arg) +#endif + +#ifndef _I +#define _I(fmt, arg...) LOGI(fmt, ##arg) +#endif + +#ifndef _D +#define _D(fmt, arg...) LOGD(fmt, ##arg) +#endif + +#endif /* __APPCORE_WATCHDOG_PRIVATE_H__ */