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>
CMakeLists.txt
packaging/pass-hal-tw3.spec
scripts/pass.conf
src/cpu/CMakeLists.txt [deleted file]
src/hal-backend-power.c [moved from src/cpu/cpu.c with 58% similarity]
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/sysfs.c [moved from src/shared/sysfs.c with 100% similarity]
src/sysfs.h [moved from src/shared/sysfs.h with 100% similarity]

index 63a158d..447ed6d 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 e751a58..ded4200 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 fcd8696..3397edf 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)
similarity index 58%
rename from src/cpu/cpu.c
rename to src/hal-backend-power.c
index 169ce13..928e6d7 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * PASS (Power Aware System Service)
+ * HAL backend for hal-api-power which is used for PASS daemon
  *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * 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.
  * 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 <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 "../shared/sysfs.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 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];
@@ -278,90 +295,180 @@ static struct pass_resource_tmu_ops tw3_cpu_tmu_ops = {
        .get_policy = NULL,
 };
 
-static int tw3_cpu_open(char *res_name, struct pass_resource_info *info,
-               struct pass_resource_common **common)
+/*************************************************
+ * HAL backend implementation for Memory H/W Resource
+ */
+static int memory_get_fault_around_bytes(char *res_name)
 {
-       struct pass_resource_cpu *cpu_res;
+       int ret, fault_around_bytes;
 
-       if (!res_name || !info)
+       if (!res_name)
                return -EINVAL;
 
-       /* TODO: Possibility of a memory leak */
-       cpu_res = calloc(1, sizeof(struct pass_resource_cpu));
-       if (!cpu_res)
-               return -ENOMEM;
+       ret = sysfs_read_int(FAULT_AROUND_BYTES_PATH, &fault_around_bytes);
+       if (ret < 0)
+               return ret;
+
+       return fault_around_bytes;
+}
 
-       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;
+static int memory_set_fault_around_bytes(char *res_name,
+                                               int fault_around_bytes)
+{
+       int ret;
 
-       *common = (struct pass_resource_common *) cpu_res;
+       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_cpu_close(char *res_name, struct pass_resource_common *common)
+/*************************************************
+ * HAL backend implementation for Non-standard H/W Resource
+ */
+static int tw3_set_pmqos_data(char *res_name, void *data)
 {
-       struct pass_resource_cpu *cpu_res;
-       int ret = 0;
+       struct sockaddr_un addr;
+       int socket_fd, ret;
 
-       if (!res_name || !common)
+       if (!res_name || !data)
                return -EINVAL;
 
-       cpu_res = (struct pass_resource_cpu *) common;
+       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)
+{
        /*
-        * 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.
+        * 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.
         */
-       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;
+       return 0;
+}
 
-       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;
+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;
 
-       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;
+       /* Allocate memory */
+       power_funcs = calloc(1, sizeof(hal_backend_power_funcs));
+       if (!power_funcs)
+               return -ENOMEM;
 
-exit:
-       free(common);
+       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;
 }
 
-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,
+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,
-};
similarity index 100%
rename from src/shared/sysfs.c
rename to src/sysfs.c
similarity index 100%
rename from src/shared/sysfs.h
rename to src/sysfs.h