--- /dev/null
+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)
--- /dev/null
+/*
+ * 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 <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 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,
+};