pass-hal: rpi: Update pass-hal-rpi by using hal-api-power interface 61/251361/10
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 7 Jan 2021 13:21:59 +0000 (22:21 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 14 Jan 2021 09:13:00 +0000 (18:13 +0900)
Prior pass-hal-rpi 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-rpi 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: Ib705482d398b5d0d3b3249b896fb477e882f5da6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt
packaging/pass-hal-rpi.spec
scripts/pass.conf
src/cpu/CMakeLists.txt [deleted file]
src/hal-backend-power.c [moved from src/cpu/cpu.c with 61% similarity]
src/memory/CMakeLists.txt [deleted file]
src/memory/memory.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 090d0a7..229820d 100644 (file)
@@ -1,27 +1,38 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(pass-hal-rpi 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_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-cpu0.conf
        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-memory.conf)
-INSTALL(FILES ${CONF_FILES} DESTINATION ${CONF_DIR})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-hal.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/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 b781ec6..e7ddc69 100644 (file)
@@ -2,7 +2,7 @@
 %define release 1
 
 Name:       pass-hal-rpi
-Summary:    PASS hal for RPI4
+Summary:    Power HAL for RPI4
 Version:    %{version}
 Release:    %{release}
 Group:      System/Hardware Adaptation
@@ -16,21 +16,22 @@ Requires(post): /sbin/ldconfig
 Requires(post): /bin/systemctl
 Requires(postun): /sbin/ldconfig
 Requires(postun): /bin/systemctl
-Requires: pass >= 1.1.0
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pass-hal-devel >= 1.1.0
+BuildRequires:  pkgconfig(hal-api-common)
+BuildRequires:  pkgconfig(hal-api-power)
 
 %description
-PASS hal for RPI4
+Power HAL for RPI4
 
 %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,7 +41,7 @@ rm -rf %{buildroot}
 %make_install
 %post
 /sbin/ldconfig
-systemd-tmpfiles %{_prefix}/lib/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
@@ -53,8 +54,9 @@ fi
 
 %files
 %manifest %{name}.manifest
-%{_libdir}/pass/*.so
-%{_prefix}/lib/tmpfiles.d/pass-hal.conf
-%config %{_sysconfdir}/pass/pass.conf
-%config %{_sysconfdir}/pass/pass-cpu0.conf
-%config %{_sysconfdir}/pass/pass-memory.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-cpu0.conf
+%config %{_hal_sysconfdir}/pass/pass-memory.conf
index e0fe5b5..3f52562 100644 (file)
@@ -10,11 +10,11 @@ pass_num_resources=2
 pass_res_type=cpu
 pass_res_name=cpu0
 pass_res_thermal_name=thermal_zone0
-pass_path_conf_file=/etc/pass/pass-cpu0.conf
+pass_path_conf_file=/hal/etc/pass/pass-cpu0.conf
 pass_first_cpu=0
 pass_num_cpus=4
 
 [PassResource1]
 pass_res_type=memory
 pass_res_name=memory
-pass_path_conf_file=/etc/pass/pass-memory.conf
+pass_path_conf_file=/hal/etc/pass/pass-memory.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 61%
rename from src/cpu/cpu.c
rename to src/hal-backend-power.c
index 635f490..403f790 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 <stdio.h>
 #include <stdlib.h>
 
-#include "../shared/sysfs.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_CURR_GOVERNOR_PATH_SUFFIX      "/cpufreq/scaling_governor"
 #define CPUFREQ_AVAIL_GOVERNOR_PATH_SUFFIX     "/cpufreq/scaling_available_governors"
 #define TMU_POLICY_PATH_SUFFIX                 "/policy"
 #define TMU_TEMP_MASK                          0xFFFFF
 
-static int standard_dvfs_get_curr_governor(char *res_name, char *governor)
+#define FAULT_AROUND_BYTES_PATH                "/sys/kernel/debug/fault_around_bytes"
+
+/*************************************************
+ * HAL backend implementation for CPU H/W Resource
+ */
+static int cpu_dvfs_get_curr_governor(char *res_name, char *governor)
 {
        char path[PATH_MAX];
        int ret;
@@ -68,7 +80,7 @@ static int standard_dvfs_get_curr_governor(char *res_name, char *governor)
        return 0;
 }
 
-static int standard_dvfs_set_curr_governor(char *res_name, char *governor)
+static int cpu_dvfs_set_curr_governor(char *res_name, char *governor)
 {
        char path[PATH_MAX];
        int ret;
@@ -88,7 +100,7 @@ static int standard_dvfs_set_curr_governor(char *res_name, char *governor)
        return 0;
 }
 
-static int standard_dvfs_get_curr_freq(char *res_name)
+static int cpu_dvfs_get_curr_freq(char *res_name)
 {
        char path[PATH_MAX];
        int freq, ret;
@@ -108,7 +120,7 @@ static int standard_dvfs_get_curr_freq(char *res_name)
        return freq;
 }
 
-static int standard_dvfs_get_min_freq(char *res_name)
+static int cpu_dvfs_get_min_freq(char *res_name)
 {
        char path[PATH_MAX];
        int freq, ret;
@@ -128,7 +140,7 @@ static int standard_dvfs_get_min_freq(char *res_name)
        return freq;
 }
 
-static int standard_dvfs_set_min_freq(char *res_name, int freq)
+static int cpu_dvfs_set_min_freq(char *res_name, int freq)
 {
        char path[PATH_MAX];
        int ret;
@@ -148,7 +160,7 @@ static int standard_dvfs_set_min_freq(char *res_name, int freq)
        return 0;
 }
 
-static int standard_dvfs_get_max_freq(char *res_name)
+static int cpu_dvfs_get_max_freq(char *res_name)
 {
        char path[PATH_MAX];
        int freq, ret;
@@ -168,7 +180,7 @@ static int standard_dvfs_get_max_freq(char *res_name)
        return freq;
 }
 
-static int standard_dvfs_set_max_freq(char *res_name, int freq)
+static int cpu_dvfs_set_max_freq(char *res_name, int freq)
 {
        char path[PATH_MAX];
        int ret;
@@ -187,7 +199,7 @@ static int standard_dvfs_set_max_freq(char *res_name, int freq)
        return 0;
 }
 
-static int standard_dvfs_get_available_min_freq(char *res_name)
+static int cpu_dvfs_get_available_min_freq(char *res_name)
 {
        char path[PATH_MAX];
        int val, ret;
@@ -208,7 +220,7 @@ static int standard_dvfs_get_available_min_freq(char *res_name)
 }
 
 
-static int standard_dvfs_get_available_max_freq(char *res_name)
+static int cpu_dvfs_get_available_max_freq(char *res_name)
 {
        char path[PATH_MAX];
        int val, ret;
@@ -228,7 +240,7 @@ static int standard_dvfs_get_available_max_freq(char *res_name)
        return val;
 }
 
-static int standard_dvfs_get_up_threshold(char *res_name)
+static int cpu_dvfs_get_up_threshold(char *res_name)
 {
        char path[PATH_MAX];
        int val, ret;
@@ -248,7 +260,7 @@ static int standard_dvfs_get_up_threshold(char *res_name)
        return val;
 }
 
-static int standard_dvfs_set_up_threshold(char *res_name, int up_threshold)
+static int cpu_dvfs_set_up_threshold(char *res_name, int up_threshold)
 {
        char path[PATH_MAX];
        int ret;
@@ -268,21 +280,21 @@ static int standard_dvfs_set_up_threshold(char *res_name, int up_threshold)
        return 0;
 }
 
-static struct pass_resource_dvfs_ops standard_cpu_dvfs_ops =  {
-       .get_curr_governor = standard_dvfs_get_curr_governor,
-       .set_curr_governor = standard_dvfs_set_curr_governor,
-       .get_curr_freq = standard_dvfs_get_curr_freq,
-       .get_min_freq = standard_dvfs_get_min_freq,
-       .set_min_freq = standard_dvfs_set_min_freq,
-       .get_max_freq = standard_dvfs_get_max_freq,
-       .set_max_freq = standard_dvfs_set_max_freq,
-       .get_available_min_freq = standard_dvfs_get_available_min_freq,
-       .get_available_max_freq = standard_dvfs_get_available_max_freq,
-       .get_up_threshold = standard_dvfs_get_up_threshold,
-       .set_up_threshold = standard_dvfs_set_up_threshold,
+static struct pass_resource_dvfs_ops cpu_dvfs_ops =  {
+       .get_curr_governor = cpu_dvfs_get_curr_governor,
+       .set_curr_governor = cpu_dvfs_set_curr_governor,
+       .get_curr_freq = cpu_dvfs_get_curr_freq,
+       .get_min_freq = cpu_dvfs_get_min_freq,
+       .set_min_freq = cpu_dvfs_set_min_freq,
+       .get_max_freq = cpu_dvfs_get_max_freq,
+       .set_max_freq = cpu_dvfs_set_max_freq,
+       .get_available_min_freq = cpu_dvfs_get_available_min_freq,
+       .get_available_max_freq = cpu_dvfs_get_available_max_freq,
+       .get_up_threshold = cpu_dvfs_get_up_threshold,
+       .set_up_threshold = cpu_dvfs_set_up_threshold,
 };
 
-static int standard_hotplug_get_online_state(char *res_name, int cpu)
+static int cpu_hotplug_get_online_state(char *res_name, int cpu)
 {
        char path[PATH_MAX];
        int ret, online;
@@ -302,7 +314,7 @@ static int standard_hotplug_get_online_state(char *res_name, int cpu)
        return online;
 }
 
-static int standard_hotplug_set_online_state(char *res_name, int cpu, int on)
+static int cpu_hotplug_set_online_state(char *res_name, int cpu, int on)
 {
        char path[PATH_MAX];
        int ret;
@@ -319,7 +331,6 @@ static int standard_hotplug_set_online_state(char *res_name, int cpu, int on)
         * opertaion.
         */
        if (on == 0 && cpu == 0) {
-               _E("cannot turn off the CPU0");
                return 0;
        }
 
@@ -335,16 +346,16 @@ static int standard_hotplug_set_online_state(char *res_name, int cpu, int on)
        return 0;
 }
 
-static struct pass_resource_hotplug_ops standard_cpu_hotplus_ops = {
-       .get_online_state = standard_hotplug_get_online_state,
-       .set_online_state = standard_hotplug_set_online_state,
+static struct pass_resource_hotplug_ops cpu_hotplug_ops = {
+       .get_online_state = cpu_hotplug_get_online_state,
+       .set_online_state = cpu_hotplug_set_online_state,
        .get_online_min_num = NULL,
        .set_online_min_num = NULL,
        .get_online_max_num = NULL,
        .set_online_max_num = NULL,
 };
 
-static int standard_tmu_get_temp(char *res_thermal_name)
+static int cpu_tmu_get_temp(char *res_thermal_name)
 {
        char path[PATH_MAX];
        int temp, ret;
@@ -374,7 +385,7 @@ static int standard_tmu_get_temp(char *res_thermal_name)
        return (((temp & TMU_TEMP_MASK) + 500) / 1000);
 }
 
-static int standard_tmu_get_policy(char *res_thermal_name, char *policy)
+static int cpu_tmu_get_policy(char *res_thermal_name, char *policy)
 {
        char path[PATH_MAX];
        int ret;
@@ -394,47 +405,119 @@ static int standard_tmu_get_policy(char *res_thermal_name, char *policy)
        return 0;
 }
 
-static struct pass_resource_tmu_ops standard_cpu_tmu_ops = {
-       .get_temp = standard_tmu_get_temp,
-       .get_policy = standard_tmu_get_policy,
+static struct pass_resource_tmu_ops cpu_tmu_ops = {
+       .get_temp = cpu_tmu_get_temp,
+       .get_policy = cpu_tmu_get_policy,
 };
 
-static int standard_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)
+{
+       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)
 {
-       struct pass_resource_cpu *cpu_res;
+       int ret;
 
-       if (!info)
+       if ((!res_name) || (fault_around_bytes <= 0))
                return -EINVAL;
 
-       cpu_res = calloc(1, sizeof(struct pass_resource_cpu));
-       if (!cpu_res)
+       ret = sysfs_write_int(FAULT_AROUND_BYTES_PATH, fault_around_bytes);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+/************************
+ * HAL backend power data
+ */
+static int power_rpi4_init(void **data)
+{
+       hal_backend_power_funcs *power_funcs = NULL;
+       struct pass_resource_cpu *cpu = NULL;
+       struct pass_resource_memory *memory = 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;
+       }
+
+       /* Initialize each h/w resource */
+       cpu->dvfs = cpu_dvfs_ops;
+       cpu->hotplug = cpu_hotplug_ops;
+       cpu->tmu = cpu_tmu_ops;
+
+       memory->get_fault_around_bytes = memory_get_fault_around_bytes;
+       memory->set_fault_around_bytes = memory_set_fault_around_bytes;
 
-       cpu_res->common.info = info;
-       cpu_res->dvfs = standard_cpu_dvfs_ops;
-       cpu_res->hotplug = standard_cpu_hotplus_ops;
-       cpu_res->tmu = standard_cpu_tmu_ops;
+       /* Initialize hal_backend_power_funcs  */
+       power_funcs->cpu = cpu;
+       power_funcs->memory = memory;
 
-       *common = (struct pass_resource_common *) cpu_res;
+       *data = (void *)power_funcs;
 
        return 0;
+err:
+       if (memory)
+               free(memory);
+       if (cpu)
+               free(cpu);
+
+       free(power_funcs);
+
+       return ret;
 }
 
-static int standard_cpu_close(char *res_name, struct pass_resource_common *common)
+static int power_rpi4_exit(void *data)
 {
-       if (!common)
+       hal_backend_power_funcs *funcs;
+
+       if (!data)
                return -EINVAL;
 
-       free(common);
+       funcs = (hal_backend_power_funcs *)data;
+
+       if (funcs->cpu)
+               free(funcs->cpu);
+       if (funcs->memory)
+               free(funcs->memory);
+
+       free(funcs);
 
        return 0;
 }
 
-HAL_MODULE_STRUCTURE = {
-       .magic = HAL_INFO_TAG,
-       .id = PASS_RESOURCE_CPU_ID,
-       .name = PASS_RESOURCE_CPU_NAME,
-       .open = standard_cpu_open,
-       .close = standard_cpu_close,
+hal_backend hal_backend_power_data = {
+       .name = "power-rpi4",
+       .vendor = "Rasberry Pi",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = power_rpi4_init,
+       .exit = power_rpi4_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 cd11a6e..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2020 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 <pass/hal.h>
-#include <pass/hal-log.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "../shared/sysfs.h"
-
-#define FAULT_AROUND_BYTES_PATH                "/sys/kernel/debug/fault_around_bytes"
-
-static int rpi_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 rpi_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 rpi_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 = rpi_memory_get_fault_around_bytes;
-       res->set_fault_around_bytes = rpi_memory_set_fault_around_bytes;
-
-       *common = (struct pass_resource_common *)res;
-
-       return 0;
-}
-
-static int rpi_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 = rpi_memory_open,
-       .close = rpi_memory_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