pass-hal: tw3: Update pass-hal-tw3 by using hal-api-power interface 80/251380/4
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 13 Jan 2021 05:40:16 +0000 (14:40 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 26 Jan 2021 01:02:27 +0000 (10:02 +0900)
Prior pass-hal-tw3 depends on PASS HAL interface (hal.h) provided by
pass-hal-devel pkg. In order to keep the new HAL API package on Tizen 6.5,
change the pass-hal-tw3 package.

[Mandatory implementation for HAL backend]
- Power HAL backend must define 'hal_backend_power_data' symbol
including the implementation of Power HAL interface.
- Include /hal/lib64/libhal-backend-power.so

Change-Id: I516dc8e8c1064ef0cfb9bb1a0101783059ed27fc
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
14 files changed:
CMakeLists.txt
packaging/pass-hal-tw3.spec
scripts/pass.conf
src/cpu/CMakeLists.txt [deleted file]
src/cpu/cpu.c [deleted file]
src/hal-backend-power.c [new file with mode: 0644]
src/memory/CMakeLists.txt [deleted file]
src/memory/memory.c [deleted file]
src/nonstandard/CMakeLists.txt [deleted file]
src/nonstandard/nonstandard.c [deleted file]
src/shared/sysfs.c [deleted file]
src/shared/sysfs.h [deleted file]
src/sysfs.c [new file with mode: 0644]
src/sysfs.h [new file with mode: 0644]

index 63a158db12766a7148ac074e64c9b2de08673710..447ed6daaa31f0900374cad4300e854153355864 100644 (file)
@@ -1,29 +1,39 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(pass-hal-tw3 C)
 
+SET(LIBRARY_NAME "hal-backend-power")
 SET(CMAKE_VERBOSE_MAKEFILE ON)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(HAL_LIBDIR ${CMAKE_HAL_LIBDIR_PREFIX})
+SET(HAL_LICENSEDIR ${CMAKE_HAL_LICENSEDIR_PREFIX})
 
-SET(PKG_MODULES
-       dlog)
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+pkg_check_modules(pkgs REQUIRED
+       dlog
+       hal-api-common
+       hal-api-power
+)
 
 FOREACH(flag ${pkgs_CFLAGS})
          SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_CFLAGS} ${EXTRA_CFLAGS}")
 
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(DEST_DIR ${LIB_INSTALL_DIR}/pass)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+
+SET(SRCS
+       ${PROJECT_SOURCE_DIR}/src/${LIBRARY_NAME}.c
+       ${PROJECT_SOURCE_DIR}/src/sysfs.c)
 
-ADD_SUBDIRECTORY(src/cpu)
-ADD_SUBDIRECTORY(src/memory)
-ADD_SUBDIRECTORY(src/nonstandard)
+ADD_LIBRARY(${LIBRARY_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${pkgs_LDFLAGS} -ldl)
 
-SET(CONF_DIR /etc/pass)
 SET(CONF_FILES
        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass.conf
        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-resource0.conf
        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-resource1.conf
        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-resource2.conf)
-INSTALL(FILES ${CONF_FILES} DESTINATION ${CONF_DIR})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-hal.conf DESTINATION ${LIB_INSTALL_DIR}/tmpfiles.d)
+INSTALL(FILES ${CONF_FILES} DESTINATION /hal/etc/pass)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-hal.conf DESTINATION /hal/lib/tmpfiles.d)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION ${HAL_LICENSEDIR}/${PROJECT_NAME})
+INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${HAL_LIBDIR} COMPONENT RuntimeLibraries)
index e751a5817e90301243385cdf5f92d2e693138e4a..ded420027312d891d7a12b3ac86dc789c539669d 100644 (file)
@@ -2,7 +2,7 @@
 %define release 1
 
 Name:       pass-hal-tw3
-Summary:    PASS hal for tw3
+Summary:    Power HAL for TW3
 Version:    %{version}
 Release:    %{release}
 Group:      System/Hardware Adaptation
@@ -14,25 +14,24 @@ ExclusiveArch: %{arm}
 
 Requires(post): /sbin/ldconfig
 Requires(post): /bin/systemctl
-Requires(post): security-config
 Requires(postun): /sbin/ldconfig
 Requires(postun): /bin/systemctl
-Requires: pass >= 1.1.0
-Requires: pass-hal-devel >= 1.1.0
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:         pkgconfig(pass-hal-devel)
+BuildRequires:  pkgconfig(hal-api-common)
+BuildRequires:  pkgconfig(hal-api-power)
 
 %description
-PASS hal for tw3
+Power HAL for TW3
 
 %prep
 %setup -q
 cp %{SOURCE1} .
 
 %build
-%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DHAL_VERSION=%{version}.%{release}
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+       -DCMAKE_HAL_LIBDIR_PREFIX=%{_hal_libdir} \
+       -DCMAKE_HAL_LICENSEDIR_PREFIX=%{_hal_licensedir} \
 
 make %{?jobs:-j%jobs}
 
@@ -40,10 +39,9 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 
 %make_install
-
 %post
 /sbin/ldconfig
-systemd-tmpfiles %{_libdir}/tmpfiles.d/pass-hal.conf --create
+systemd-tmpfiles /hal/lib/tmpfiles.d/pass-hal.conf --create
 if [ -f %{_unitdir}/pass.service ]; then
        systemctl try-restart pass.service
 fi
@@ -56,9 +54,10 @@ fi
 
 %files
 %manifest %{name}.manifest
-%{_libdir}/pass/*.so
-%{_libdir}/tmpfiles.d/pass-hal.conf
-%config %{_sysconfdir}/pass/pass.conf
-%config %{_sysconfdir}/pass/pass-resource0.conf
-%config %{_sysconfdir}/pass/pass-resource1.conf
-%config %{_sysconfdir}/pass/pass-resource2.conf
+%{_hal_licensedir}/%{name}/LICENSE
+%{_hal_libdir}/*.so
+/hal/lib/tmpfiles.d/pass-hal.conf
+%config %{_hal_sysconfdir}/pass/pass.conf
+%config %{_hal_sysconfdir}/pass/pass-resource0.conf
+%config %{_hal_sysconfdir}/pass/pass-resource1.conf
+%config %{_hal_sysconfdir}/pass/pass-resource2.conf
index fcd8696c9875d66d63d77f58d73fe7dc2a081801..3397edf0edd4d21284ff9cbe85727e183019f087 100644 (file)
@@ -10,16 +10,16 @@ pass_num_resources=3
 pass_res_type=cpu
 pass_res_name=cpu0
 pass_res_thermal_name=ap_therm
-pass_path_conf_file=/etc/pass/pass-resource0.conf
+pass_path_conf_file=/hal/etc/pass/pass-resource0.conf
 pass_first_cpu=0
 pass_num_cpus=2
 
 [PassResource1]
 pass_res_type=memory
 pass_res_name=memory
-pass_path_conf_file=/etc/pass/pass-resource1.conf
+pass_path_conf_file=/hal/etc/pass/pass-resource1.conf
 
 [PassResource2]
 pass_res_type=nonstandard
 pass_res_name=trm
-pass_path_conf_file=/etc/pass/pass-resource2.conf
+pass_path_conf_file=/hal/etc/pass/pass-resource2.conf
diff --git a/src/cpu/CMakeLists.txt b/src/cpu/CMakeLists.txt
deleted file mode 100644 (file)
index 3cd62b8..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(cpu C)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog glib-2.0)
-
-#HAL version
-string(REPLACE "." ";" HAL_VERSION_LIST ${HAL_VERSION})
-list(GET HAL_VERSION_LIST 0 HAL_VERSION_MAJOR)
-list(GET HAL_VERSION_LIST 1 HAL_VERSION_MINOR)
-list(GET HAL_VERSION_LIST 2 HAL_VERSION_REVISION)
-list(GET HAL_VERSION_LIST 3 HAL_VERSION_RELEASE)
-add_definitions(-DVER_MAJOR=${HAL_VERSION_MAJOR} -DVER_MINOR=${HAL_VERSION_MINOR})
-add_definitions(-DVER_REVISION=${HAL_VERSION_REVISION} -DVER_RELEASE=${HAL_VERSION_RELEASE})
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-SET(SRCS ${PROJECT_NAME}.c
-       ../shared/sysfs.c)
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE ${SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${DEST_DIR} COMPONENT RuntimeLibraries)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
deleted file mode 100644 (file)
index 169ce13..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 <errno.h>
-#include <limits.h>
-#include <pass/hal.h>
-#include <pass/hal-log.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../shared/sysfs.h"
-
-#define CPUFREQ_PATH_PREFIX                    "/sys/devices/system/cpu/"
-#define CPUFREQ_PMQOS_PATH_PREFIX              "/sys/devices/system/cpu/cpufreq/pmqos"
-#define CPUFREQ_PATH_PREFIX                    "/sys/devices/system/cpu/"
-#define TMU_PATH_PREFIX                                "/sys/class/sec/temperature/"
-
-#define CPUFREQ_CPU_ONLINE_MIN_NUM_PATH_SUFFIX "/cpu_online_min"
-#define CPUFREQ_CPU_ONLINE_MAX_NUM_PATH_SUFFIX "/cpu_online_max"
-#define CPUFREQ_MAX_FREQ_PATH_SUFFIX           "/cpufreq/scaling_max_freq"
-#define CPUFREQ_MIN_FREQ_PATH_SUFFIX           "/cpufreq/scaling_min_freq"
-#define CPUFREQ_CURR_FREQ_PATH_SUFFIX          "/cpufreq/cpuinfo_cur_freq"
-
-#define CPUFREQ_DEFAULT_MIN_FREQ               0
-#define CPUFREQ_DEFAULT_MAX_FREQ               1014000
-#define CPUFREQ_DEFAULT_ONLINE_MIN_NUM         0
-#define CPUFREQ_DEFAULT_ONLINE_MAX_NUM         2
-
-#define CPUFREQ_PMQOS_REQUEST_UNLOCK           -1
-
-static int tw3_dvfs_get_curr_freq(char *res_name)
-{
-       char path[PATH_MAX];
-       int freq, ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s%s",
-               CPUFREQ_PATH_PREFIX,
-               res_name,
-               CPUFREQ_CURR_FREQ_PATH_SUFFIX);
-
-       ret = sysfs_read_int(path, &freq);
-       if (ret < 0)
-               return ret;
-
-       return freq;
-}
-
-static int tw3_dvfs_get_min_freq(char *res_name)
-{
-       char path[PATH_MAX];
-       int min_freq;
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s%s",
-               CPUFREQ_PATH_PREFIX,
-               res_name,
-               CPUFREQ_MIN_FREQ_PATH_SUFFIX);
-
-       ret = sysfs_read_int(path, &min_freq);
-       if (ret < 0)
-               return ret;
-
-       return min_freq;
-}
-
-static int tw3_dvfs_set_min_freq(char *res_name, int freq)
-{
-       char path[PATH_MAX];
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s%s",
-               CPUFREQ_PATH_PREFIX,
-               res_name,
-               CPUFREQ_MIN_FREQ_PATH_SUFFIX);
-
-       ret = sysfs_write_int(path, freq);
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-
-static int tw3_dvfs_get_max_freq(char *res_name)
-{
-       char path[PATH_MAX];
-       int max_freq;
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s%s",
-                CPUFREQ_PATH_PREFIX,
-                res_name,
-                CPUFREQ_MAX_FREQ_PATH_SUFFIX);
-
-       ret = sysfs_read_int(path, &max_freq);
-       if (ret < 0)
-               return ret;
-
-       return max_freq;
-}
-
-static int tw3_dvfs_set_max_freq(char *res_name, int freq)
-{
-       char path[PATH_MAX];
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s%s",
-               CPUFREQ_PATH_PREFIX,
-               res_name,
-               CPUFREQ_MAX_FREQ_PATH_SUFFIX);
-
-       ret = sysfs_write_int(path, freq);
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-
-static struct pass_resource_dvfs_ops tw3_cpu_dvfs_ops =  {
-       .get_curr_governor = NULL,
-       .set_curr_governor = NULL,
-       .get_avail_governor = NULL,
-       .get_curr_freq = tw3_dvfs_get_curr_freq,
-       .get_min_freq = tw3_dvfs_get_min_freq,
-       .set_min_freq = tw3_dvfs_set_min_freq,
-       .get_max_freq = tw3_dvfs_get_max_freq,
-       .set_max_freq = tw3_dvfs_set_max_freq,
-       .get_up_threshold = NULL,
-       .set_up_threshold = NULL,
-       .get_load_table = NULL,
-};
-
-static int tw3_hotplug_get_online_min_num(char *res_name)
-{
-       char path[PATH_MAX];
-       int online_min_num;
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s",
-               CPUFREQ_PMQOS_PATH_PREFIX,
-               CPUFREQ_CPU_ONLINE_MIN_NUM_PATH_SUFFIX);
-
-       ret = sysfs_read_int(path, &online_min_num);
-       if (ret < 0)
-               return ret;
-
-       return online_min_num;
-}
-
-static int tw3_hotplug_set_online_min_num(char *res_name, int num)
-{
-       char path[PATH_MAX];
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       /* TODO: Can we turn off CPU0? */
-       snprintf(path, PATH_MAX, "%s%s",
-               CPUFREQ_PMQOS_PATH_PREFIX,
-               CPUFREQ_CPU_ONLINE_MIN_NUM_PATH_SUFFIX);
-
-       ret = sysfs_write_int(path, num);
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-
-static int tw3_hotplug_get_online_max_num(char *res_name)
-{
-       char path[PATH_MAX];
-       int online_max_num;
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s",
-               CPUFREQ_PMQOS_PATH_PREFIX,
-               CPUFREQ_CPU_ONLINE_MAX_NUM_PATH_SUFFIX);
-
-       ret = sysfs_read_int(path, &online_max_num);
-       if (ret < 0)
-               return ret;
-
-       return online_max_num;
-}
-
-static int tw3_hotplug_set_online_max_num(char *res_name, int num)
-{
-       char path[PATH_MAX];
-       int ret;
-
-       if (!res_name)
-               return -EINVAL;
-
-       /* TODO: Can we turn off CPU0? */
-       snprintf(path, PATH_MAX, "%s%s",
-               CPUFREQ_PMQOS_PATH_PREFIX,
-               CPUFREQ_CPU_ONLINE_MAX_NUM_PATH_SUFFIX);
-
-       ret = sysfs_write_int(path, num);
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-static struct pass_resource_hotplug_ops tw3_cpu_hotplug_ops = {
-       .get_online_state = NULL,
-       .set_online_state = NULL,
-       .get_online_min_num = tw3_hotplug_get_online_min_num,
-       .set_online_min_num = tw3_hotplug_set_online_min_num,
-       .get_online_max_num = tw3_hotplug_get_online_max_num,
-       .set_online_max_num = tw3_hotplug_set_online_max_num,
-};
-
-static int tw3_cpu_get_temp(char *res_thermal_name)
-{
-       char path[PATH_MAX + 1];
-       char buf[PATH_MAX + 1];
-       char *pos;
-       int temp = 0;
-       int ret;
-
-       if (!res_thermal_name)
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%s", TMU_PATH_PREFIX, res_thermal_name);
-
-       ret = sysfs_read_str(path, buf, PATH_MAX);
-       if (ret < 0)
-               return ret;
-
-       pos = strstr(buf, "temp:");
-       if (!pos || !(pos[5]))
-               return -EINVAL;
-       pos += 5;
-       temp = atoi(pos);
-
-       return temp;
-}
-
-static struct pass_resource_tmu_ops tw3_cpu_tmu_ops = {
-       .get_temp = tw3_cpu_get_temp,
-       .get_policy = NULL,
-};
-
-static int tw3_cpu_open(char *res_name, struct pass_resource_info *info,
-               struct pass_resource_common **common)
-{
-       struct pass_resource_cpu *cpu_res;
-
-       if (!res_name || !info)
-               return -EINVAL;
-
-       /* TODO: Possibility of a memory leak */
-       cpu_res = calloc(1, sizeof(struct pass_resource_cpu));
-       if (!cpu_res)
-               return -ENOMEM;
-
-       cpu_res->common.info = info;
-       cpu_res->dvfs = tw3_cpu_dvfs_ops;
-       cpu_res->hotplug = tw3_cpu_hotplug_ops;
-       cpu_res->tmu = tw3_cpu_tmu_ops;
-
-       *common = (struct pass_resource_common *) cpu_res;
-
-       return 0;
-}
-
-static int tw3_cpu_close(char *res_name, struct pass_resource_common *common)
-{
-       struct pass_resource_cpu *cpu_res;
-       int ret = 0;
-
-       if (!res_name || !common)
-               return -EINVAL;
-
-       cpu_res = (struct pass_resource_cpu *) common;
-
-       /*
-        * tw3 has weird pmqos sysfs node, thus we cannot apply save/restore
-        * feature as pass-hal-standard does. Instead of using standard
-        * interface, we manually restore the each resource state; pmqos
-        * request is unlocked by passing argument '-1' first, and resource
-        * state is restored by passing default value.
-        */
-       ret = cpu_res->hotplug.set_online_max_num(res_name,
-                                       CPUFREQ_PMQOS_REQUEST_UNLOCK);
-       if (ret < 0)
-               goto exit;
-       ret = cpu_res->hotplug.set_online_max_num(res_name,
-                                       CPUFREQ_DEFAULT_ONLINE_MAX_NUM);
-       if (ret < 0)
-               goto exit;
-
-       ret = cpu_res->hotplug.set_online_min_num(res_name,
-                                       CPUFREQ_PMQOS_REQUEST_UNLOCK);
-       if (ret < 0)
-               goto exit;
-       ret = cpu_res->hotplug.set_online_min_num(res_name,
-                                       CPUFREQ_DEFAULT_ONLINE_MIN_NUM);
-       if (ret < 0)
-               goto exit;
-
-       ret = cpu_res->dvfs.set_min_freq(res_name,
-                                       CPUFREQ_PMQOS_REQUEST_UNLOCK);
-       if (ret < 0)
-               goto exit;
-       ret = cpu_res->dvfs.set_min_freq(res_name, CPUFREQ_DEFAULT_MIN_FREQ);
-       if (ret < 0)
-               goto exit;
-
-       ret = cpu_res->dvfs.set_max_freq(res_name,
-                                       CPUFREQ_PMQOS_REQUEST_UNLOCK);
-       if (ret < 0)
-               goto exit;
-       ret = cpu_res->dvfs.set_max_freq(res_name, CPUFREQ_DEFAULT_MAX_FREQ);
-       if (ret < 0)
-               goto exit;
-
-exit:
-       free(common);
-
-       return ret;
-}
-
-HAL_MODULE_STRUCTURE = {
-       .magic = HAL_INFO_TAG,
-       .id = PASS_RESOURCE_CPU_ID,
-       .name = PASS_RESOURCE_CPU_NAME,
-       .open = tw3_cpu_open,
-       .close = tw3_cpu_close,
-};
diff --git a/src/hal-backend-power.c b/src/hal-backend-power.c
new file mode 100644 (file)
index 0000000..928e6d7
--- /dev/null
@@ -0,0 +1,474 @@
+/*
+ * HAL backend for hal-api-power which is used for PASS daemon
+ *
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <errno.h>
+#include <limits.h>
+#include <linux/types.h>
+#include <linux/un.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include <hal/hal-power-interface.h>
+
+#include "sysfs.h"
+
+#define BUFF_MAX       255
+
+/*************************
+ * H/W Resource Defintions
+ */
+#define CPUFREQ_PATH_PREFIX                    "/sys/devices/system/cpu/"
+#define CPUFREQ_PMQOS_PATH_PREFIX              "/sys/devices/system/cpu/cpufreq/pmqos"
+#define CPUFREQ_PATH_PREFIX                    "/sys/devices/system/cpu/"
+#define TMU_PATH_PREFIX                                "/sys/class/sec/temperature/"
+
+#define CPUFREQ_CPU_ONLINE_MIN_NUM_PATH_SUFFIX "/cpu_online_min"
+#define CPUFREQ_CPU_ONLINE_MAX_NUM_PATH_SUFFIX "/cpu_online_max"
+#define CPUFREQ_MAX_FREQ_PATH_SUFFIX           "/cpufreq/scaling_max_freq"
+#define CPUFREQ_MIN_FREQ_PATH_SUFFIX           "/cpufreq/scaling_min_freq"
+#define CPUFREQ_CURR_FREQ_PATH_SUFFIX          "/cpufreq/cpuinfo_cur_freq"
+
+#define CPUFREQ_DEFAULT_MIN_FREQ               0
+#define CPUFREQ_DEFAULT_MAX_FREQ               1014000
+#define CPUFREQ_DEFAULT_ONLINE_MIN_NUM         0
+#define CPUFREQ_DEFAULT_ONLINE_MAX_NUM         2
+
+#define CPUFREQ_PMQOS_REQUEST_UNLOCK           -1
+
+#define FAULT_AROUND_BYTES_PATH                "/sys/kernel/debug/fault_around_bytes"
+
+#define SCENARIO_INFO_SOCKET_PATH      "/dev/socket/scenario_info"
+
+/*************************************************
+ * HAL backend implementation for CPU H/W Resource
+ */
+static int tw3_dvfs_get_curr_freq(char *res_name)
+{
+       char path[PATH_MAX];
+       int freq, ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s%s",
+               CPUFREQ_PATH_PREFIX,
+               res_name,
+               CPUFREQ_CURR_FREQ_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &freq);
+       if (ret < 0)
+               return ret;
+
+       return freq;
+}
+
+static int tw3_dvfs_get_min_freq(char *res_name)
+{
+       char path[PATH_MAX];
+       int min_freq;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s%s",
+               CPUFREQ_PATH_PREFIX,
+               res_name,
+               CPUFREQ_MIN_FREQ_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &min_freq);
+       if (ret < 0)
+               return ret;
+
+       return min_freq;
+}
+
+static int tw3_dvfs_set_min_freq(char *res_name, int freq)
+{
+       char path[PATH_MAX];
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s%s",
+               CPUFREQ_PATH_PREFIX,
+               res_name,
+               CPUFREQ_MIN_FREQ_PATH_SUFFIX);
+
+       ret = sysfs_write_int(path, freq);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int tw3_dvfs_get_max_freq(char *res_name)
+{
+       char path[PATH_MAX];
+       int max_freq;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s%s",
+                CPUFREQ_PATH_PREFIX,
+                res_name,
+                CPUFREQ_MAX_FREQ_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &max_freq);
+       if (ret < 0)
+               return ret;
+
+       return max_freq;
+}
+
+static int tw3_dvfs_set_max_freq(char *res_name, int freq)
+{
+       char path[PATH_MAX];
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s%s",
+               CPUFREQ_PATH_PREFIX,
+               res_name,
+               CPUFREQ_MAX_FREQ_PATH_SUFFIX);
+
+       ret = sysfs_write_int(path, freq);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static struct pass_resource_dvfs_ops tw3_cpu_dvfs_ops =  {
+       .get_curr_governor = NULL,
+       .set_curr_governor = NULL,
+       .get_avail_governor = NULL,
+       .get_curr_freq = tw3_dvfs_get_curr_freq,
+       .get_min_freq = tw3_dvfs_get_min_freq,
+       .set_min_freq = tw3_dvfs_set_min_freq,
+       .get_max_freq = tw3_dvfs_get_max_freq,
+       .set_max_freq = tw3_dvfs_set_max_freq,
+       .get_up_threshold = NULL,
+       .set_up_threshold = NULL,
+       .get_load_table = NULL,
+};
+
+static int tw3_hotplug_get_online_min_num(char *res_name)
+{
+       char path[PATH_MAX];
+       int online_min_num;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s",
+               CPUFREQ_PMQOS_PATH_PREFIX,
+               CPUFREQ_CPU_ONLINE_MIN_NUM_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &online_min_num);
+       if (ret < 0)
+               return ret;
+
+       return online_min_num;
+}
+
+static int tw3_hotplug_set_online_min_num(char *res_name, int num)
+{
+       char path[PATH_MAX];
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       /* TODO: Can we turn off CPU0? */
+       snprintf(path, PATH_MAX, "%s%s",
+               CPUFREQ_PMQOS_PATH_PREFIX,
+               CPUFREQ_CPU_ONLINE_MIN_NUM_PATH_SUFFIX);
+
+       ret = sysfs_write_int(path, num);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int tw3_hotplug_get_online_max_num(char *res_name)
+{
+       char path[PATH_MAX];
+       int online_max_num;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s",
+               CPUFREQ_PMQOS_PATH_PREFIX,
+               CPUFREQ_CPU_ONLINE_MAX_NUM_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &online_max_num);
+       if (ret < 0)
+               return ret;
+
+       return online_max_num;
+}
+
+static int tw3_hotplug_set_online_max_num(char *res_name, int num)
+{
+       char path[PATH_MAX];
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       /* TODO: Can we turn off CPU0? */
+       snprintf(path, PATH_MAX, "%s%s",
+               CPUFREQ_PMQOS_PATH_PREFIX,
+               CPUFREQ_CPU_ONLINE_MAX_NUM_PATH_SUFFIX);
+
+       ret = sysfs_write_int(path, num);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+static struct pass_resource_hotplug_ops tw3_cpu_hotplug_ops = {
+       .get_online_state = NULL,
+       .set_online_state = NULL,
+       .get_online_min_num = tw3_hotplug_get_online_min_num,
+       .set_online_min_num = tw3_hotplug_set_online_min_num,
+       .get_online_max_num = tw3_hotplug_get_online_max_num,
+       .set_online_max_num = tw3_hotplug_set_online_max_num,
+};
+
+static int tw3_cpu_get_temp(char *res_thermal_name)
+{
+       char path[PATH_MAX + 1];
+       char buf[PATH_MAX + 1];
+       char *pos;
+       int temp = 0;
+       int ret;
+
+       if (!res_thermal_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s", TMU_PATH_PREFIX, res_thermal_name);
+
+       ret = sysfs_read_str(path, buf, PATH_MAX);
+       if (ret < 0)
+               return ret;
+
+       pos = strstr(buf, "temp:");
+       if (!pos || !(pos[5]))
+               return -EINVAL;
+       pos += 5;
+       temp = atoi(pos);
+
+       return temp;
+}
+
+static struct pass_resource_tmu_ops tw3_cpu_tmu_ops = {
+       .get_temp = tw3_cpu_get_temp,
+       .get_policy = NULL,
+};
+
+/*************************************************
+ * HAL backend implementation for Memory H/W Resource
+ */
+static int memory_get_fault_around_bytes(char *res_name)
+{
+       int ret, fault_around_bytes;
+
+       if (!res_name)
+               return -EINVAL;
+
+       ret = sysfs_read_int(FAULT_AROUND_BYTES_PATH, &fault_around_bytes);
+       if (ret < 0)
+               return ret;
+
+       return fault_around_bytes;
+}
+
+static int memory_set_fault_around_bytes(char *res_name,
+                                               int fault_around_bytes)
+{
+       int ret;
+
+       if ((!res_name) || (fault_around_bytes <= 0))
+               return -EINVAL;
+
+       ret = sysfs_write_int(FAULT_AROUND_BYTES_PATH, fault_around_bytes);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+/*************************************************
+ * HAL backend implementation for Non-standard H/W Resource
+ */
+static int tw3_set_pmqos_data(char *res_name, void *data)
+{
+       struct sockaddr_un addr;
+       int socket_fd, ret;
+
+       if (!res_name || !data)
+               return -EINVAL;
+
+       errno = 0;
+       socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
+       if (socket_fd == -1)
+               return -errno;
+
+       memset(&addr, 0, sizeof(addr));
+       snprintf(addr.sun_path, UNIX_PATH_MAX, "%s", SCENARIO_INFO_SOCKET_PATH);
+       addr.sun_family = AF_LOCAL;
+
+       errno = 0;
+       ret = connect(socket_fd, (struct sockaddr *) &addr, sizeof(addr));
+       if (ret) {
+               close(socket_fd);
+               return -errno;
+       }
+
+       errno = 0;
+       ret = send(socket_fd, data, strlen(data) + 1, MSG_NOSIGNAL);
+       if (ret)
+               ret = errno;
+
+       close(socket_fd);
+
+       return ret;
+}
+
+static int tw3_set_pmqos_data_nop(char *res_name, void *data)
+{
+       /*
+        * The tw3_set_pmqos_data function is required to send the PMQoS
+        * scenario information to the socket interface of the TRM and it
+        * is optional, which means that this HAL for nonstandard should work
+        * without TRM. For this reason, if there is no unix domain socket file
+        * for the PMQoS scenario, this nop function is assigned to the
+        * set_pmqos_data pointer rather than returning error.
+        */
+       return 0;
+}
+
+
+static int power_tw3_init(void **data)
+{
+       hal_backend_power_funcs *power_funcs = NULL;
+       struct pass_resource_cpu *cpu = NULL;
+       struct pass_resource_memory *memory = NULL;
+       struct pass_resource_nonstandard *nonstandard = NULL;
+       int ret;
+
+       /* Allocate memory */
+       power_funcs = calloc(1, sizeof(hal_backend_power_funcs));
+       if (!power_funcs)
+               return -ENOMEM;
+
+       cpu = calloc(1, sizeof(struct pass_resource_cpu));
+       if (!cpu) {
+               return -ENOMEM;
+               goto err;
+       }
+
+       memory = calloc(1, sizeof(struct pass_resource_memory));
+       if (!memory) {
+               ret = -ENOMEM;
+               goto err;
+       }
+
+       nonstandard = calloc(1, sizeof(struct pass_resource_nonstandard));
+       if (!nonstandard) {
+               ret = -ENOMEM;
+               goto err;
+       }
+
+       /* Initialize each h/w resource */
+       cpu->dvfs = tw3_cpu_dvfs_ops;
+       cpu->hotplug = tw3_cpu_hotplug_ops;
+       cpu->tmu = tw3_cpu_tmu_ops;
+
+       memory->get_fault_around_bytes = memory_get_fault_around_bytes;
+       memory->set_fault_around_bytes = memory_set_fault_around_bytes;
+
+       ret = access(SCENARIO_INFO_SOCKET_PATH, F_OK);
+       if (!ret)
+               nonstandard->set_pmqos_data = tw3_set_pmqos_data;
+       else
+               nonstandard->set_pmqos_data = tw3_set_pmqos_data_nop;
+
+       /* Initialize hal_backend_power_funcs  */
+       power_funcs->cpu = cpu;
+       power_funcs->memory = memory;
+       power_funcs->nonstandard = nonstandard;
+
+       *data = (void *)power_funcs;
+
+       return 0;
+err:
+       if (nonstandard)
+               free(nonstandard);
+       if (memory)
+               free(memory);
+       if (cpu)
+               free(cpu);
+
+       free(power_funcs);
+
+       return ret;
+}
+
+static int power_tw3_exit(void *data)
+{
+       hal_backend_power_funcs *funcs;
+
+       if (!data)
+               return -EINVAL;
+
+       funcs = (hal_backend_power_funcs *)data;
+
+       if (funcs->cpu)
+               free(funcs->cpu);
+       if (funcs->memory)
+               free(funcs->memory);
+       if (funcs->nonstandard)
+               free(funcs->nonstandard);
+
+       free(funcs);
+
+       return 0;
+}
+
+hal_backend hal_backend_power_data = {
+       .name = "power-tw3",
+       .vendor = "Samsung TW3",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = power_tw3_init,
+       .exit = power_tw3_exit,
+};
diff --git a/src/memory/CMakeLists.txt b/src/memory/CMakeLists.txt
deleted file mode 100644 (file)
index e7bd0a6..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(memory C)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog glib-2.0)
-
-#HAL version
-string(REPLACE "." ";" HAL_VERSION_LIST ${HAL_VERSION})
-list(GET HAL_VERSION_LIST 0 HAL_VERSION_MAJOR)
-list(GET HAL_VERSION_LIST 1 HAL_VERSION_MINOR)
-list(GET HAL_VERSION_LIST 2 HAL_VERSION_REVISION)
-list(GET HAL_VERSION_LIST 3 HAL_VERSION_RELEASE)
-add_definitions(-DVER_MAJOR=${HAL_VERSION_MAJOR} -DVER_MINOR=${HAL_VERSION_MINOR})
-add_definitions(-DVER_REVISION=${HAL_VERSION_REVISION} -DVER_RELEASE=${HAL_VERSION_RELEASE})
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-SET(SRCS ${PROJECT_NAME}.c
-       ../shared/sysfs.c)
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE ${SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${DEST_DIR} COMPONENT RuntimeLibraries)
diff --git a/src/memory/memory.c b/src/memory/memory.c
deleted file mode 100644 (file)
index c470501..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 <errno.h>
-#include <limits.h>
-#include <pass/hal.h>
-#include <pass/hal-log.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../shared/sysfs.h"
-
-#define FAULT_AROUND_BYTES_PATH                "/sys/kernel/debug/fault_around_bytes"
-
-static int tw3_memory_get_fault_around_bytes(char *res_name)
-{
-       int ret, fault_around_bytes;
-
-       if (!res_name)
-               return -EINVAL;
-
-       ret = sysfs_read_int(FAULT_AROUND_BYTES_PATH, &fault_around_bytes);
-       if (ret < 0)
-               return ret;
-
-       return fault_around_bytes;
-}
-
-static int tw3_memory_set_fault_around_bytes(char *res_name,
-                                               int fault_around_bytes)
-{
-       int ret;
-
-       if ((!res_name) || (fault_around_bytes <= 0))
-               return -EINVAL;
-
-       ret = sysfs_write_int(FAULT_AROUND_BYTES_PATH, fault_around_bytes);
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-
-static int tw3_memory_open(char *res_name, struct pass_resource_info *info,
-               struct pass_resource_common **common)
-{
-       struct pass_resource_memory *res;
-
-       if (!info)
-               return -EINVAL;
-
-       res = calloc(1, sizeof(struct pass_resource_memory));
-       if (!res)
-               return -ENOMEM;
-
-       res->common.info = info;
-       res->get_fault_around_bytes = tw3_memory_get_fault_around_bytes;
-       res->set_fault_around_bytes = tw3_memory_set_fault_around_bytes;
-
-       *common = (struct pass_resource_common *)res;
-
-       return 0;
-}
-
-static int tw3_memory_close(char *res_name, struct pass_resource_common *common)
-{
-       if (!common)
-               return -EINVAL;
-
-       free(common);
-
-       return 0;
-}
-
-HAL_MODULE_STRUCTURE = {
-       .magic = HAL_INFO_TAG,
-       .id = PASS_RESOURCE_MEMORY_ID,
-       .name = PASS_RESOURCE_MEMORY_NAME,
-       .open = tw3_memory_open,
-       .close = tw3_memory_close,
-};
diff --git a/src/nonstandard/CMakeLists.txt b/src/nonstandard/CMakeLists.txt
deleted file mode 100644 (file)
index 11777c0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(nonstandard C)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog glib-2.0)
-
-#HAL version
-string(REPLACE "." ";" HAL_VERSION_LIST ${HAL_VERSION})
-list(GET HAL_VERSION_LIST 0 HAL_VERSION_MAJOR)
-list(GET HAL_VERSION_LIST 1 HAL_VERSION_MINOR)
-list(GET HAL_VERSION_LIST 2 HAL_VERSION_REVISION)
-list(GET HAL_VERSION_LIST 3 HAL_VERSION_RELEASE)
-add_definitions(-DVER_MAJOR=${HAL_VERSION_MAJOR} -DVER_MINOR=${HAL_VERSION_MINOR})
-add_definitions(-DVER_REVISION=${HAL_VERSION_REVISION} -DVER_RELEASE=${HAL_VERSION_RELEASE})
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-SET(SRCS ${PROJECT_NAME}.c
-       ../shared/sysfs.c)
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE ${SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${DEST_DIR} COMPONENT RuntimeLibraries)
diff --git a/src/nonstandard/nonstandard.c b/src/nonstandard/nonstandard.c
deleted file mode 100644 (file)
index 70b01d7..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 <errno.h>
-#include <limits.h>
-#include <linux/types.h>
-#include <linux/un.h>
-#include <pass/hal.h>
-#include <pass/hal-log.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-#include "../shared/sysfs.h"
-
-#define SCENARIO_INFO_SOCKET_PATH      "/dev/socket/scenario_info"
-
-static int tw3_set_pmqos_data(char *res_name, void *data)
-{
-       struct sockaddr_un addr;
-       int socket_fd, ret;
-
-       if (!res_name || !data)
-               return -EINVAL;
-
-       errno = 0;
-       socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
-       if (socket_fd == -1)
-               return -errno;
-
-       memset(&addr, 0, sizeof(addr));
-       snprintf(addr.sun_path, UNIX_PATH_MAX, "%s", SCENARIO_INFO_SOCKET_PATH);
-       addr.sun_family = AF_LOCAL;
-
-       errno = 0;
-       ret = connect(socket_fd, (struct sockaddr *) &addr, sizeof(addr));
-       if (ret) {
-               close(socket_fd);
-               return -errno;
-       }
-
-       errno = 0;
-       ret = send(socket_fd, data, strlen(data) + 1, MSG_NOSIGNAL);
-       if (ret)
-               ret = errno;
-
-       close(socket_fd);
-
-       return ret;
-}
-
-static int tw3_set_pmqos_data_nop(char *res_name, void *data)
-{
-       /*
-        * The tw3_set_pmqos_data function is required to send the PMQoS
-        * scenario information to the socket interface of the TRM and it
-        * is optional, which means that this HAL for nonstandard should work
-        * without TRM. For this reason, if there is no unix domain socket file
-        * for the PMQoS scenario, this nop function is assigned to the
-        * set_pmqos_data pointer rather than returning error.
-        */
-       return 0;
-}
-
-static int tw3_nonstandard_open(char *res_name, struct pass_resource_info *info,
-               struct pass_resource_common **common)
-{
-       struct pass_resource_nonstandard *nonstandard_res;
-       int ret;
-
-       if (!res_name || !info)
-               return -EINVAL;
-
-       /* TODO: Possibility of a memory leak */
-       nonstandard_res = calloc(1, sizeof(struct pass_resource_nonstandard));
-       if (!nonstandard_res)
-               return -ENOMEM;
-
-       nonstandard_res->common.info = info;
-
-       ret = access(SCENARIO_INFO_SOCKET_PATH, F_OK);
-       if (!ret)
-               nonstandard_res->set_pmqos_data = tw3_set_pmqos_data;
-       else
-               nonstandard_res->set_pmqos_data = tw3_set_pmqos_data_nop;
-
-       *common = (struct pass_resource_common *) nonstandard_res;
-
-       return 0;
-}
-
-static int tw3_nonstandard_close(char *res_name, struct pass_resource_common *common)
-{
-       if (!res_name || !common)
-               return -EINVAL;
-
-       free(common);
-
-       return 0;
-}
-
-HAL_MODULE_STRUCTURE = {
-       .magic = HAL_INFO_TAG,
-       .id = PASS_RESOURCE_NONSTANDARD_ID,
-       .name = PASS_RESOURCE_NONSTANDARD_NAME,
-       .open = tw3_nonstandard_open,
-       .close = tw3_nonstandard_close,
-};
diff --git a/src/shared/sysfs.c b/src/shared/sysfs.c
deleted file mode 100644 (file)
index 1256076..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "sysfs.h"
-
-static int sysfs_read_buf(char *path, char *buf, int len)
-{
-       int r, fd;
-
-       if ((!path) || (!buf) || (len < 0))
-               return -EINVAL;
-
-       fd = open(path, O_RDONLY);
-       if (fd == -1)
-               return -ENOENT;
-
-       r = read(fd, buf, len);
-       close(fd);
-
-       if ((r < 0) || (r > len))
-               return -EIO;
-
-       buf[r] = '\0';
-
-       return 0;
-}
-
-static int sysfs_write_buf(char *path, char *buf)
-{
-       int w, fd;
-
-       if ((!path) || (!buf))
-               return -EINVAL;
-
-       fd = open(path, O_WRONLY);
-       if (fd == -1)
-               return -ENOENT;
-
-       w = write(fd, buf, strlen(buf));
-       close(fd);
-
-       if (w < 0)
-               return -EIO;
-
-       return 0;
-}
-
-int sysfs_read_int(char *path, int *val)
-{
-       char buf[MAX_BUF_SIZE + 1];
-       int r;
-
-       if ((!path) || (!val))
-               return -EINVAL;
-
-       r = sysfs_read_buf(path, buf, MAX_BUF_SIZE);
-       if (r < 0)
-               return r;
-
-       *val = atoi(buf);
-       return 0;
-}
-
-int sysfs_read_str(char *path, char *str, int len)
-{
-       int r;
-
-       if ((!path) || (!str) || (len <= 0))
-               return -EINVAL;
-
-       r = sysfs_read_buf(path, str, len);
-       if (r < 0)
-               return r;
-
-       return 0;
-}
-
-int sysfs_write_int(char *path, int val)
-{
-       char buf[MAX_BUF_SIZE + 1];
-       int w;
-
-       if (!path)
-               return -EINVAL;
-
-       snprintf(buf, MAX_BUF_SIZE, "%d", val);
-       w = sysfs_write_buf(path, buf);
-       if (w < 0)
-               return w;
-
-       return 0;
-}
-
-int sysfs_write_str(char *path, char *str)
-{
-       int w;
-
-       if ((!path) || (!str))
-               return -EINVAL;
-
-       w = sysfs_write_buf(path, str);
-       if (w < 0)
-               return w;
-
-       return 0;
-}
diff --git a/src/shared/sysfs.h b/src/shared/sysfs.h
deleted file mode 100644 (file)
index 157eb15..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 MAX_BUF_SIZE   255
-
-int sysfs_read_int(char *path, int *val);
-int sysfs_read_str(char *path, char *str, int len);
-int sysfs_write_int(char *path, int val);
-int sysfs_write_str(char *path, char *str);
diff --git a/src/sysfs.c b/src/sysfs.c
new file mode 100644 (file)
index 0000000..1256076
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * PASS (Power Aware System Service)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "sysfs.h"
+
+static int sysfs_read_buf(char *path, char *buf, int len)
+{
+       int r, fd;
+
+       if ((!path) || (!buf) || (len < 0))
+               return -EINVAL;
+
+       fd = open(path, O_RDONLY);
+       if (fd == -1)
+               return -ENOENT;
+
+       r = read(fd, buf, len);
+       close(fd);
+
+       if ((r < 0) || (r > len))
+               return -EIO;
+
+       buf[r] = '\0';
+
+       return 0;
+}
+
+static int sysfs_write_buf(char *path, char *buf)
+{
+       int w, fd;
+
+       if ((!path) || (!buf))
+               return -EINVAL;
+
+       fd = open(path, O_WRONLY);
+       if (fd == -1)
+               return -ENOENT;
+
+       w = write(fd, buf, strlen(buf));
+       close(fd);
+
+       if (w < 0)
+               return -EIO;
+
+       return 0;
+}
+
+int sysfs_read_int(char *path, int *val)
+{
+       char buf[MAX_BUF_SIZE + 1];
+       int r;
+
+       if ((!path) || (!val))
+               return -EINVAL;
+
+       r = sysfs_read_buf(path, buf, MAX_BUF_SIZE);
+       if (r < 0)
+               return r;
+
+       *val = atoi(buf);
+       return 0;
+}
+
+int sysfs_read_str(char *path, char *str, int len)
+{
+       int r;
+
+       if ((!path) || (!str) || (len <= 0))
+               return -EINVAL;
+
+       r = sysfs_read_buf(path, str, len);
+       if (r < 0)
+               return r;
+
+       return 0;
+}
+
+int sysfs_write_int(char *path, int val)
+{
+       char buf[MAX_BUF_SIZE + 1];
+       int w;
+
+       if (!path)
+               return -EINVAL;
+
+       snprintf(buf, MAX_BUF_SIZE, "%d", val);
+       w = sysfs_write_buf(path, buf);
+       if (w < 0)
+               return w;
+
+       return 0;
+}
+
+int sysfs_write_str(char *path, char *str)
+{
+       int w;
+
+       if ((!path) || (!str))
+               return -EINVAL;
+
+       w = sysfs_write_buf(path, str);
+       if (w < 0)
+               return w;
+
+       return 0;
+}
diff --git a/src/sysfs.h b/src/sysfs.h
new file mode 100644 (file)
index 0000000..157eb15
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * PASS (Power Aware System Service)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 MAX_BUF_SIZE   255
+
+int sysfs_read_int(char *path, int *val);
+int sysfs_read_str(char *path, char *str, int len);
+int sysfs_write_int(char *path, int val);
+int sysfs_write_str(char *path, char *str);