summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongwoo Lee <dwoo08.lee@samsung.com>2022-10-12 12:28:25 +0900
committerYoungjae Cho <y0.cho@samsung.com>2022-10-31 11:21:11 +0900
commit30ddc04de93b8e1a8e49f0985e883f17a3e2d64f (patch)
tree109fba85c7fb4fd94762a70fe03e46ef7d193417
parent7cefd01b6ef3af9c7fa482f2048d1719da39fd44 (diff)
downloadpass-30ddc04de93b8e1a8e49f0985e883f17a3e2d64f.tar.gz
pass-30ddc04de93b8e1a8e49f0985e883f17a3e2d64f.tar.bz2
pass-30ddc04de93b8e1a8e49f0985e883f17a3e2d64f.zip
resource: Apply system resource manager library
Now resource utilities is removed, and new resource manger library in libsyscommon which is extract from pass is used instead. Change-Id: I0ec3403ce297ef1c6d3899987bcb6fd5ad96abbd Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
-rw-r--r--CMakeLists.txt2
-rw-r--r--include/monitor/monitor.h6
-rw-r--r--include/util/common.h14
-rw-r--r--include/util/devices.h16
-rw-r--r--include/util/resource.h208
-rw-r--r--lib/resource-monitor/resource-monitor.c34
-rw-r--r--lib/resource-monitor/resource-monitor.h160
-rw-r--r--packaging/libpass-resource-monitor.pc.in2
-rw-r--r--packaging/pass.spec7
-rw-r--r--src/monitor/monitor-command.c4
-rw-r--r--src/monitor/monitor-thread.c2
-rw-r--r--src/monitor/monitor.c4
-rw-r--r--src/monitor/request-handler.c158
-rw-r--r--src/pass/pass-parser.c137
-rw-r--r--src/pass/pass.c7
-rw-r--r--src/pass/pass.h4
-rw-r--r--src/pmqos/pmqos-parser.c10
-rw-r--r--src/resource/resource-battery.c45
-rw-r--r--src/resource/resource-bus.c82
-rw-r--r--src/resource/resource-cpu.c85
-rw-r--r--src/resource/resource-disk.c69
-rw-r--r--src/resource/resource-display.c61
-rw-r--r--src/resource/resource-gpu.c83
-rw-r--r--src/resource/resource-memory.c52
-rw-r--r--src/resource/resource-network.c47
-rw-r--r--src/resource/resource-process-group.c128
-rw-r--r--src/resource/resource-process.c142
-rw-r--r--src/resource/resource-system.c86
-rw-r--r--src/thermal/thermal-parser.c8
-rw-r--r--src/util/common.c10
-rw-r--r--src/util/devices.c60
-rw-r--r--src/util/resource.c1047
-rw-r--r--tests/integration-test/resource-monitor-tests.cpp224
-rw-r--r--tools/resource-monitor/resource-monitor.c240
34 files changed, 971 insertions, 2273 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8b44fa6..98a25f8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,6 @@ SET(SRCS
src/util/common.c
src/util/device-notifier.c
src/util/devices.c
- src/util/resource.c
src/util/gdbus-util.c
src/util/timer.c
src/util/thread.c
@@ -72,6 +71,7 @@ SET(PKG_MODULES
gio-unix-2.0
libudev
libsystemd
+ libsyscommon
libnl-3.0
libnl-genl-3.0
json-c
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 25413f9..036fa63 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -19,14 +19,14 @@
#ifndef __MONITOR_H__
#define __MONITOR_H__
-#include <util/resource.h>
+#include <libsyscommon/resource-manager.h>
#include <util/thread.h>
#include <util/queue.h>
#define MONITOR_POLLING_DURATION 100
struct monitor_command {
- struct resource *resource;
+ struct syscommon_resman_resource *resource;
volatile bool done;
mtx_t lock;
cnd_t signal;
@@ -49,7 +49,7 @@ void monitor_thread_exit(struct monitor *monitor);
void monitor_command_wait_done(struct monitor_command *cmd);
void monitor_command_submit(struct monitor_command *cmd);
void monitor_command_submit_sync(struct monitor_command *cmd);
-void monitor_command_bind_resource(struct monitor_command *cmd, struct resource *res);
+void monitor_command_bind_resource(struct monitor_command *cmd, struct syscommon_resman_resource *res);
void monitor_command_unbind_resource(struct monitor_command *cmd);
int monitor_command_init(struct monitor_command **cmd);
void monitor_command_exit(struct monitor_command *cmd);
diff --git a/include/util/common.h b/include/util/common.h
index 213ed70..10f465a 100644
--- a/include/util/common.h
+++ b/include/util/common.h
@@ -35,20 +35,6 @@ typedef unsigned long long uint64;
#define BUFF_MAX 255
#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
-enum data_type {
- DATA_TYPE_UNKNOWN = 0,
- DATA_TYPE_INT,
- DATA_TYPE_INT64,
- DATA_TYPE_UINT,
- DATA_TYPE_UINT64,
- DATA_TYPE_DOUBLE,
- DATA_TYPE_STRING,
- DATA_TYPE_ARRAY,
- DATA_TYPE_PTR,
- DATA_TYPE_BOOLEAN,
- DATA_TYPE_NUM
-};
-
/*
* One byte digit has 3 position in decimal representation
* 2 - 5
diff --git a/include/util/devices.h b/include/util/devices.h
index ef53f26..1a896ea 100644
--- a/include/util/devices.h
+++ b/include/util/devices.h
@@ -51,17 +51,6 @@ enum device_ops_status {
DEVICE_OPS_STATUS_MAX,
};
-struct resource_device {
- char *name;
- int type;
-
- /*
- * Never initialize it by user of add_resource_device().
- * It will be initialized by add_resource_device function automatically.
- */
- int index;
-};
-
#define DEVICE_OPS_REGISTER(dev) \
static void __CONSTRUCTOR__ module_init(void) \
{ \
@@ -72,11 +61,6 @@ static void __DESTRUCTOR__ module_exit(void) \
remove_device(dev); \
}
-int get_resource_device_count(int resource_type);
-const struct resource_device *find_resource_device(int resource_type, int resource_index);
-int add_resource_device(struct resource_device *resource_device);
-void remove_resource_device(struct resource_device *resource_device);
-
void init_devices(void *data);
void exit_devices(void *data);
void add_device(const struct device_ops *dev);
diff --git a/include/util/resource.h b/include/util/resource.h
deleted file mode 100644
index f0e55d2..0000000
--- a/include/util/resource.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * PASS
- *
- * 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.
- */
-
-
-#ifndef __RESOURCE_H__
-#define __RESOURCE_H__
-
-#include <sys/time.h>
-#include <errno.h>
-#include <glib.h>
-#include "common.h"
-
-/* Resource flags */
-/*
- * This flags indicates that the resource has the only one resource count
- * such as system/memory resources.
- */
-#define RESOURCE_FLAG_COUNT_ONLY_ONE BIT(0)
-
-/*
- * This flag incidates that resource is either process or process-group
- * and is not physical h/w resource.
- */
-#define RESOURCE_FLAG_PROCESS BIT(1)
-
-/* Flags for resource_attribute */
-#define RESOURCE_ATTR_FLAG_PRIVATE BIT(0)
-#define RESOURCE_ATTR_FLAG_PUBLIC BIT(1)
-
-struct resource;
-struct resource_attribute;
-
-struct array_value {
- int type;
- int length;
- void *data;
-};
-
-struct resource_attribute_value {
- int type;
- void *data;
-};
-
-struct resource_attribute_ops {
- int (*set)(struct resource *res,
- const struct resource_attribute *attr,
- const void *data, int count);
- int (*get)(struct resource *res,
- const struct resource_attribute *attr,
- void *data);
- /*
- * If .is_supported ops is not implemented, use .get ops in order to
- * check whether the resource attribute is supported or not.
- */
- bool (*is_supported)(struct resource *res,
- const struct resource_attribute *attr);
-};
-
-struct resource_attribute {
- const char name[BUFF_MAX];
- const u_int64_t id;
- const int type;
- const u_int64_t flag;
- const struct resource_attribute_ops ops;
-};
-
-struct resource_control;
-
-struct resource_control_ops {
- const int (*set)(struct resource *res,
- const struct resource_control *ctrl,
- const void *data);
- const int (*get)(struct resource *res,
- const struct resource_control *ctrl,
- void **data);
-};
-
-struct resource_control {
- const char name[BUFF_MAX];
- const u_int64_t id;
- const struct resource_control_ops ops;
-};
-
-struct resource_driver_ops {
- int (*init)(void);
- void (*exit)(void);
- int (*create)(struct resource *res);
- void (*delete)(struct resource *res);
- /*
- * If prepare_update is specified, it will be called
- * at every update_resource_attrs().
- */
- int (*prepare_update)(struct resource *res);
-};
-
-struct resource_driver {
- const char *name;
- const int type;
- const u_int64_t flag;
- const int num_attrs;
- const struct resource_attribute *attrs;
- const int num_ctrls;
- const struct resource_control *ctrls;
- const struct resource_driver_ops ops;
-};
-
-struct resource {
- char *name;
- const struct resource_driver *driver;
- int type;
-
- int num_attrs;
- const struct resource_attribute *attrs;
- struct resource_attribute_value *attrs_value;
- int num_ctrls;
- const struct resource_control *ctrls;
-
- u_int64_t flag;
-
- void *priv;
-
- u_int64_t attr_interest;
- u_int64_t attr_supported;
-};
-
-#define RESOURCE_DRIVER_REGISTER(resource_driver) \
-static void __CONSTRUCTOR__ module_init(void) \
-{ \
- add_resource_driver(resource_driver); \
-} \
-static void __DESTRUCTOR__ module_exit(void) \
-{ \
- remove_resource_driver(resource_driver); \
-}
-
-/* Add/remove resource driver and device */
-const struct resource_driver *find_resource_driver(int resource_type);
-void add_resource_driver(const struct resource_driver *resource_driver);
-void remove_resource_driver(const struct resource_driver *resource_driver);
-
-/* Create/delete resource instance */
-int create_resource(struct resource **res, int resource_type);
-void delete_resource(struct resource *resource);
-
-/* Set flag of the resource to given flag mask */
-int set_resource_flag(struct resource *resource, u_int64_t flag_mask);
-
-/* Handle resource control */
-int set_resource_control(struct resource *resource, u_int64_t ctrl_id, const void *data);
-const char *get_resource_control_name(struct resource *resource, u_int64_t ctrl_id);
-
-/* Handle resource attribute */
-int update_resource_attrs(struct resource *resource);
-const struct resource_attribute *get_resource_attr(struct resource *resource, u_int64_t attr_id);
-struct resource_attribute_value *
-get_resource_attr_value(struct resource *resource, u_int64_t attr_id);
-int is_resource_attr_supported(struct resource *resource, u_int64_t attr_id, bool *supported);
-
-static inline bool
-resource_attr_supported_always(struct resource *resource,
- const struct resource_attribute *attr)
-{
- return true;
-}
-
-int get_resource_attrs_json(struct resource *resource, char **json_string);
-int get_resource_attr_json(struct resource *resource, u_int64_t attr_id, char **json_string);
-int get_resource_list_json(char **json_string);
-
-int get_resource_attr_int(struct resource *resource, u_int64_t attr_id, int32_t *data);
-int get_resource_attr_int64(struct resource *resource, u_int64_t attr_id, int64_t *data);
-int get_resource_attr_uint(struct resource *resource, u_int64_t attr_id, u_int32_t *data);
-int get_resource_attr_uint64(struct resource *resource, u_int64_t attr_id, u_int64_t *data);
-int get_resource_attr_double(struct resource *resource, u_int64_t attr_id, double *data);
-int get_resource_attr_string(struct resource *resource, u_int64_t attr_id, char *data);
-int get_resource_attr_array(struct resource *resource, u_int64_t attr_id,
- struct array_value **data);
-int get_resource_attr_ptr(struct resource *resource, u_int64_t attr_id, void **data);
-
-int set_resource_attr_interest(struct resource *resource, u_int64_t interest_mask);
-int unset_resource_attr_interest(struct resource *resource, u_int64_t interest_mask);
-bool is_resource_attr_interested(struct resource *resource, u_int64_t interest_mask);
-const char *get_resource_attr_name(struct resource *resource, u_int64_t attr_id);
-
-const char *get_resource_name(struct resource *resource);
-void *get_resource_privdata(struct resource *resource);
-int get_resource_type(struct resource *resource);
-
-int set_resource_privdata(struct resource *resource, void *priv);
-
-void init_resource_drivers(void);
-void exit_resource_drivers(void);
-#endif
diff --git a/lib/resource-monitor/resource-monitor.c b/lib/resource-monitor/resource-monitor.c
index 7a08699..75bff22 100644
--- a/lib/resource-monitor/resource-monitor.c
+++ b/lib/resource-monitor/resource-monitor.c
@@ -20,11 +20,15 @@
#define _GNU_SOURCE
#include <errno.h>
+
+#include <util/common.h>
#include <util/log.h>
#include <monitor/request.h>
-#include <util/resource.h>
#include <util/privilege.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
@@ -701,7 +705,7 @@ int pass_resource_monitor_get_value_string(int id, int resource_id, u_int64_t at
}
static int
-pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int data_type, void **array, int *length)
+pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int SYSCOMMON_RESMAN_DATA_TYPE, void **array, int *length)
{
char *array_item, *array_str, *buffer;
int array_len, array_type;
@@ -748,14 +752,14 @@ pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int data_
goto out_free;
}
- if (data_type != array_type) {
+ if (SYSCOMMON_RESMAN_DATA_TYPE != array_type) {
_E("[libpass] wrong data type");
ret = TIZEN_ERROR_INVALID_PARAMETER;
goto out_free;
}
switch (array_type) {
- case DATA_TYPE_INT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
{
int32_t *new_array = malloc(array_len * sizeof(int32_t));
@@ -771,7 +775,7 @@ pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int data_
*length = array_len;
break;
}
- case DATA_TYPE_INT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
{
int64_t *new_array = malloc(array_len * sizeof(int64_t));
@@ -787,7 +791,7 @@ pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int data_
*length = array_len;
break;
}
- case DATA_TYPE_UINT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
{
u_int32_t *new_array = malloc(array_len * sizeof(u_int32_t));
@@ -803,7 +807,7 @@ pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int data_
*length = array_len;
break;
}
- case DATA_TYPE_UINT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
{
u_int64_t *new_array = malloc(array_len * sizeof(u_int64_t));
@@ -819,7 +823,7 @@ pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int data_
*length = array_len;
break;
}
- case DATA_TYPE_DOUBLE:
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
{
double *new_array = malloc(array_len * sizeof(double));
@@ -835,7 +839,7 @@ pass_resource_monitor_get_array(int id, int res_id, u_int64_t attr_id, int data_
*length = array_len;
break;
}
- case DATA_TYPE_STRING:
+ case SYSCOMMON_RESMAN_DATA_TYPE_STRING:
{
char **new_array = calloc(array_len, sizeof(char *));
@@ -877,37 +881,37 @@ out_free:
EXPORT
int pass_resource_monitor_get_array_int(int id, int res_id, u_int64_t attr_id, int32_t **array, int *length)
{
- return pass_resource_monitor_get_array(id, res_id, attr_id, DATA_TYPE_INT, (void **)array, length);
+ return pass_resource_monitor_get_array(id, res_id, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_INT, (void **)array, length);
}
EXPORT
int pass_resource_monitor_get_array_int64(int id, int res_id, u_int64_t attr_id, int64_t **array, int *length)
{
- return pass_resource_monitor_get_array(id, res_id, attr_id, DATA_TYPE_INT64, (void **)array, length);
+ return pass_resource_monitor_get_array(id, res_id, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_INT64, (void **)array, length);
}
EXPORT
int pass_resource_monitor_get_array_uint(int id, int res_id, u_int64_t attr_id, u_int32_t **array, int *length)
{
- return pass_resource_monitor_get_array(id, res_id, attr_id, DATA_TYPE_UINT, (void **)array, length);
+ return pass_resource_monitor_get_array(id, res_id, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT, (void **)array, length);
}
EXPORT
int pass_resource_monitor_get_array_uint64(int id, int res_id, u_int64_t attr_id, u_int64_t **array, int *length)
{
- return pass_resource_monitor_get_array(id, res_id, attr_id, DATA_TYPE_UINT64, (void **)array, length);
+ return pass_resource_monitor_get_array(id, res_id, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT64, (void **)array, length);
}
EXPORT
int pass_resource_monitor_get_array_double(int id, int res_id, u_int64_t attr_id, double **array, int *length)
{
- return pass_resource_monitor_get_array(id, res_id, attr_id, DATA_TYPE_DOUBLE, (void **)array, length);
+ return pass_resource_monitor_get_array(id, res_id, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, (void **)array, length);
}
EXPORT
int pass_resource_monitor_get_array_string(int id, int res_id, u_int64_t attr_id, char ***array, int *length)
{
- return pass_resource_monitor_get_array(id, res_id, attr_id, DATA_TYPE_STRING, (void **)array, length);
+ return pass_resource_monitor_get_array(id, res_id, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_STRING, (void **)array, length);
}
int pass_resource_monitor_get_resource_timestamp(int id, int res_id, int64_t *start, int64_t *end)
diff --git a/lib/resource-monitor/resource-monitor.h b/lib/resource-monitor/resource-monitor.h
index 5c149ad..6e0e249 100644
--- a/lib/resource-monitor/resource-monitor.h
+++ b/lib/resource-monitor/resource-monitor.h
@@ -47,127 +47,121 @@ extern "C" {
#define RESOURCE_TYPE_NONSTANDARD 99
/**
- * @brief Resource flags
- */
-#define RESOURCE_FLAG_PRIVATE BIT(0)
-#define RESOURCE_FLAG_PUBLIC BIT(1)
-
-/**
* @brief Define the supported attributes according to resource type
*/
/* CPU Resource */
-#define CPU_ATTR_CUR_FREQ BIT(0) /* DATA_TYPE_INT */
-#define CPU_ATTR_MIN_FREQ BIT(1) /* DATA_TYPE_INT */
-#define CPU_ATTR_MAX_FREQ BIT(2) /* DATA_TYPE_INT */
-#define CPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
-#define CPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
-#define CPU_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
-#define CPU_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
+#define CPU_ATTR_CUR_FREQ BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define CPU_ATTR_MIN_FREQ BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define CPU_ATTR_MAX_FREQ BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define CPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define CPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define CPU_ATTR_CUR_GOVERNOR BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
+#define CPU_ATTR_NAME BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
#define CPU_CTRL_CLUSTER_ID BIT(0)
/* Memory Bus Resource */
-#define BUS_ATTR_CUR_FREQ BIT(0) /* DATA_TYPE_INT */
-#define BUS_ATTR_MIN_FREQ BIT(1) /* DATA_TYPE_INT */
-#define BUS_ATTR_MAX_FREQ BIT(2) /* DATA_TYPE_INT */
-#define BUS_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
-#define BUS_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
-#define BUS_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
-#define BUS_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
+#define BUS_ATTR_CUR_FREQ BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BUS_ATTR_MIN_FREQ BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BUS_ATTR_MAX_FREQ BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BUS_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BUS_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BUS_ATTR_CUR_GOVERNOR BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
+#define BUS_ATTR_NAME BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
#define BUS_CTRL_DEVICE_ID BIT(0)
/* GPU Resource */
-#define GPU_ATTR_CUR_FREQ BIT(0) /* DATA_TYPE_INT */
-#define GPU_ATTR_MIN_FREQ BIT(1) /* DATA_TYPE_INT */
-#define GPU_ATTR_MAX_FREQ BIT(2) /* DATA_TYPE_INT */
-#define GPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
-#define GPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
-#define GPU_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
-#define GPU_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
+#define GPU_ATTR_CUR_FREQ BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define GPU_ATTR_MIN_FREQ BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define GPU_ATTR_MAX_FREQ BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define GPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define GPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define GPU_ATTR_CUR_GOVERNOR BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
+#define GPU_ATTR_NAME BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
#define GPU_CTRL_DEVICE_ID BIT(0)
/* Memory Resource */
-#define MEMORY_ATTR_TOTAL BIT(0) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_AVAILABLE BIT(1) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_FREE BIT(2) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_BUFFER BIT(3) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_CACHED BIT(4) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_CMA_TOTAL BIT(5) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_CMA_FREE BIT(6) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_SWAP_TOTAL BIT(7) /* DATA_TYPE_UINT64 */
-#define MEMORY_ATTR_SWAP_FREE BIT(8) /* DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_TOTAL BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_AVAILABLE BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_FREE BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_BUFFER BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_CACHED BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_CMA_TOTAL BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_CMA_FREE BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_SWAP_TOTAL BIT(7) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define MEMORY_ATTR_SWAP_FREE BIT(8) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
/* Battery Resource */
-#define BATTERY_ATTR_CAPACITY BIT(0) /* DATA_TYPE_INT */
-#define BATTERY_ATTR_STATUS BIT(1) /* DATA_TYPE_STRING */
-#define BATTERY_ATTR_TEMPERATURE BIT(2) /* DATA_TYPE_INT */
-#define BATTERY_ATTR_VOLTAGE_NOW BIT(3) /* DATA_TYPE_INT */
-#define BATTERY_ATTR_CURRENT_NOW BIT(4) /* DATA_TYPE_INT */
-#define BATTERY_ATTR_PRESENT BIT(5) /* DATA_TYPE_INT */
-#define BATTERY_ATTR_ONLINE BIT(6) /* DATA_TYPE_INT */
+#define BATTERY_ATTR_CAPACITY BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BATTERY_ATTR_STATUS BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
+#define BATTERY_ATTR_TEMPERATURE BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BATTERY_ATTR_VOLTAGE_NOW BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BATTERY_ATTR_CURRENT_NOW BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BATTERY_ATTR_PRESENT BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define BATTERY_ATTR_ONLINE BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
/* Display Resource */
-#define DISPLAY_ATTR_FPS BIT(0) /* DATA_TYPE_DOUBLE */
-#define DISPLAY_ATTR_NAME BIT(1) /* DATA_TYPE_STRING */
+#define DISPLAY_ATTR_FPS BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define DISPLAY_ATTR_NAME BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
#define DISPLAY_CTRL_DEVICE_ID BIT(0)
/* System Resource */
-#define SYSTEM_ATTR_CPU_UTIL BIT(0) /* DATA_TYPE_DOUBLE */
-#define SYSTEM_ATTR_CPU_USER_UTIL BIT(1) /* DATA_TYPE_DOUBLE */
-#define SYSTEM_ATTR_CPU_SYS_UTIL BIT(2) /* DATA_TYPE_DOUBLE */
-#define SYSTEM_ATTR_PER_CPU_UTIL BIT(3) /* DATA_TYPE_ARRAY(DOUBLE) */
-#define SYSTEM_ATTR_PER_CPU_USER_UTIL BIT(4) /* DATA_TYPE_ARRAY(DOUBLE) */
-#define SYSTEM_ATTR_PER_CPU_SYS_UTIL BIT(5) /* DATA_TYPE_ARRAY(DOUBLE) */
-#define SYSTEM_ATTR_POSSIBLE_CPU BIT(6) /* DATA_TYPE_INT */
-#define SYSTEM_ATTR_ONLINE_CPU BIT(7) /* DATA_TYPE_INT */
+#define SYSTEM_ATTR_CPU_UTIL BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define SYSTEM_ATTR_CPU_USER_UTIL BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define SYSTEM_ATTR_CPU_SYS_UTIL BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define SYSTEM_ATTR_PER_CPU_UTIL BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_ARRAY(DOUBLE) */
+#define SYSTEM_ATTR_PER_CPU_USER_UTIL BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_ARRAY(DOUBLE) */
+#define SYSTEM_ATTR_PER_CPU_SYS_UTIL BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_ARRAY(DOUBLE) */
+#define SYSTEM_ATTR_POSSIBLE_CPU BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define SYSTEM_ATTR_ONLINE_CPU BIT(7) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
/* Process Resource */
-#define PROCESS_ATTR_CPU_UTIL BIT(0) /* DATA_TYPE_DOUBLE */
-#define PROCESS_ATTR_MEM_VIRT BIT(1) /* DATA_TYPE_UINT64 */
-#define PROCESS_ATTR_MEM_RSS BIT(2) /* DATA_TYPE_UINT64 */
-#define PROCESS_ATTR_MEM_RSS_PERCENT BIT(3) /* DATA_TYPE_DOUBLE */
-#define PROCESS_ATTR_DISK_READ_PER_SEC BIT(4) /* DATA_TYPE_DOUBLE */
-#define PROCESS_ATTR_DISK_WRITE_PER_SEC BIT(5) /* DATA_TYPE_DOUBLE */
-#define PROCESS_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
-#define PROCESS_ATTR_PGID BIT(7) /* DATA_TYPE_INT */
-#define PROCESS_ATTR_PPID BIT(8) /* DATA_TYPE_INT */
-#define PROCESS_ATTR_MEM_PSS BIT(9) /* DATA_TYPE_UINT64 */
-#define PROCESS_ATTR_MEM_SWAP BIT(10) /* DATA_TYPE_UINT64 */
-#define PROCESS_ATTR_MEM_SWAP_PSS BIT(11) /* DATA_TYPE_UINT64 */
-#define PROCESS_ATTR_MEM_GPU BIT(12) /* DATA_TYPE_UINT64 */
+#define PROCESS_ATTR_CPU_UTIL BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define PROCESS_ATTR_MEM_VIRT BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_ATTR_MEM_RSS BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_ATTR_MEM_RSS_PERCENT BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define PROCESS_ATTR_DISK_READ_PER_SEC BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define PROCESS_ATTR_DISK_WRITE_PER_SEC BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define PROCESS_ATTR_NAME BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
+#define PROCESS_ATTR_PGID BIT(7) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define PROCESS_ATTR_PPID BIT(8) /* SYSCOMMON_RESMAN_DATA_TYPE_INT */
+#define PROCESS_ATTR_MEM_PSS BIT(9) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_ATTR_MEM_SWAP BIT(10) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_ATTR_MEM_SWAP_PSS BIT(11) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_ATTR_MEM_GPU BIT(12) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
#define PROCESS_CTRL_TGID BIT(0)
/* Process List Resource */
-#define PROCESS_GROUP_ATTR_PID_LIST BIT(0) /* DATA_TYPE_ARRAY(INT) */
-#define PROCESS_GROUP_ATTR_NAME_LIST BIT(1) /* DATA_TYPE_ARRAY(STRING) */
-#define PROCESS_GROUP_ATTR_CPU_UTIL BIT(2) /* DATA_TYPE_DOUBLE */
-#define PROCESS_GROUP_ATTR_DISK_READ_PER_SEC BIT(3) /* DATA_TYPE_DOUBLE */
-#define PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC BIT(4) /* DATA_TYPE_DOUBLE */
-#define PROCESS_GROUP_ATTR_MEM_VIRT BIT(5) /* DATA_TYPE_UINT64 */
-#define PROCESS_GROUP_ATTR_MEM_RSS BIT(6) /* DATA_TYPE_UINT64 */
-#define PROCESS_GROUP_ATTR_MEM_PSS BIT(7) /* DATA_TYPE_UINT64 */
-#define PROCESS_GROUP_ATTR_MEM_SWAP BIT(8) /* DATA_TYPE_UINT64 */
-#define PROCESS_GROUP_ATTR_MEM_SWAP_PSS BIT(9) /* DATA_TYPE_UINT64 */
-#define PROCESS_GROUP_ATTR_MEM_GPU BIT(10) /* DATA_TYPE_UINT64 */
+#define PROCESS_GROUP_ATTR_PID_LIST BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_ARRAY(INT) */
+#define PROCESS_GROUP_ATTR_NAME_LIST BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_ARRAY(STRING) */
+#define PROCESS_GROUP_ATTR_CPU_UTIL BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define PROCESS_GROUP_ATTR_DISK_READ_PER_SEC BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define PROCESS_GROUP_ATTR_MEM_VIRT BIT(5) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_GROUP_ATTR_MEM_RSS BIT(6) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_GROUP_ATTR_MEM_PSS BIT(7) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_GROUP_ATTR_MEM_SWAP BIT(8) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_GROUP_ATTR_MEM_SWAP_PSS BIT(9) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define PROCESS_GROUP_ATTR_MEM_GPU BIT(10) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
#define PROCESS_GROUP_CTRL_ROOT_PID BIT(0)
/* Disk Resource */
-#define DISK_ATTR_NAME BIT(0) /* DATA_TYPE_STRING */
-#define DISK_ATTR_READ_PER_SEC BIT(1) /* DATA_TYPE_DOUBLE */
-#define DISK_ATTR_WRITE_PER_SEC BIT(2) /* DATA_TYPE_DOUBLE */
-#define DISK_ATTR_READ_TOTAL BIT(3) /* DATA_TYPE_UINT64 */
-#define DISK_ATTR_WRITE_TOTAL BIT(4) /* DATA_TYPE_UINT64 */
+#define DISK_ATTR_NAME BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
+#define DISK_ATTR_READ_PER_SEC BIT(1) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define DISK_ATTR_WRITE_PER_SEC BIT(2) /* SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE */
+#define DISK_ATTR_READ_TOTAL BIT(3) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
+#define DISK_ATTR_WRITE_TOTAL BIT(4) /* SYSCOMMON_RESMAN_DATA_TYPE_UINT64 */
#define DISK_CTRL_DEVICE_ID BIT(0)
/* Network Resource */
-#define NETWORK_ATTR_NAME BIT(0) /* DATA_TYPE_STRING */
+#define NETWORK_ATTR_NAME BIT(0) /* SYSCOMMON_RESMAN_DATA_TYPE_STRING */
#define NETWORK_CTRL_DEVICE_ID BIT(0)
diff --git a/packaging/libpass-resource-monitor.pc.in b/packaging/libpass-resource-monitor.pc.in
index e95a46f..f47bc2a 100644
--- a/packaging/libpass-resource-monitor.pc.in
+++ b/packaging/libpass-resource-monitor.pc.in
@@ -10,7 +10,7 @@ Name: ${package_name}
Description: ${package_name} library
Version: @VERSION@
-Requires:
+Requires: libsyscommon >= 4.2
Libs: -L${libdir} -l${package_name}
Cflags: -I${includedir}
CXXflags: -I${includedir}
diff --git a/packaging/pass.spec b/packaging/pass.spec
index dac786f..eef5666 100644
--- a/packaging/pass.spec
+++ b/packaging/pass.spec
@@ -4,6 +4,7 @@
%define haltest_name pass-haltests
%define unittest_name pass-unittest
%define libpass_resource_monitor_name libpass-resource-monitor
+%define libunified_resource_name libunified-resource
Name: %{daemon_name}
Summary: Power Aware System Service
@@ -25,6 +26,7 @@ BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(libnl-3.0)
BuildRequires: pkgconfig(libsystemd)
+BuildRequires: pkgconfig(libsyscommon)
BuildRequires: pkgconfig(json-c)
BuildRequires: pkgconfig(hal-api-power)
BuildRequires: pkgconfig(cynara-client)
@@ -139,7 +141,7 @@ systemctl daemon-reload
%license LICENSE
%manifest %{libpass_resource_monitor_name}.manifest
%defattr(-,root,root,-)
-%{_libdir}/*.so*
+%{_libdir}/%{libpass_resource_monitor_name}*.so*
%files -n %{libpass_resource_monitor_name}-devel
%license LICENSE
@@ -147,5 +149,4 @@ systemctl daemon-reload
%defattr(-,root,root,-)
%{_includedir}/%{name}/*.h
%{_libdir}/pkgconfig/%{libpass_resource_monitor_name}.pc
-%{_libdir}/*.so*
-
+%{_libdir}/%{libpass_resource_monitor_name}*.so*
diff --git a/src/monitor/monitor-command.c b/src/monitor/monitor-command.c
index 6009ee3..a9894e1 100644
--- a/src/monitor/monitor-command.c
+++ b/src/monitor/monitor-command.c
@@ -17,7 +17,7 @@
*/
#include <util/log.h>
-#include <util/resource.h>
+#include <libsyscommon/resource-manager.h>
#include <monitor/monitor.h>
static void _monitor_command_wait_done(struct monitor_command *cmd, int polling)
@@ -55,7 +55,7 @@ void monitor_command_submit_sync(struct monitor_command *cmd)
_monitor_command_wait_done(cmd, MONITOR_POLLING_DURATION);
}
-void monitor_command_bind_resource(struct monitor_command *cmd, struct resource *res)
+void monitor_command_bind_resource(struct monitor_command *cmd, struct syscommon_resman_resource *res)
{
if (cmd->resource) {
_E("resource is already bound\n");
diff --git a/src/monitor/monitor-thread.c b/src/monitor/monitor-thread.c
index 8cd535a..132e224 100644
--- a/src/monitor/monitor-thread.c
+++ b/src/monitor/monitor-thread.c
@@ -38,7 +38,7 @@ new_command:
return THREAD_RETURN_CONTINUE;
}
- update_resource_attrs(cmd->resource);
+ syscommon_resman_update_resource_attrs(cmd->resource);
cmd->done = true;
smp_wmb();
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 0fc9a1a..60a2c93 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -72,7 +72,7 @@ static int monitor_setup(void *data, void *user_data)
{
int ret;
- init_resource_drivers();
+ syscommon_resman_init_resource_drivers();
ret = request_server_init();
if (ret < 0) {
@@ -99,7 +99,7 @@ static void monitor_exit(void *data)
{
monitor_thread_exit(&g_monitor);
request_server_exit();
- exit_resource_drivers();
+ syscommon_resman_exit_resource_drivers();
unregister_notifier(DEVICE_NOTIFIER_INIT_DONE, monitor_setup, NULL);
}
diff --git a/src/monitor/request-handler.c b/src/monitor/request-handler.c
index fe241b2..d503ab6 100644
--- a/src/monitor/request-handler.c
+++ b/src/monitor/request-handler.c
@@ -27,11 +27,14 @@
#include <util/common.h>
#include <util/devices.h>
#include <util/log.h>
-#include <util/resource.h>
#include <util/thread.h>
#include <monitor/request.h>
#include <monitor/monitor.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <libsyscommon/resource-device.h>
+
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
@@ -56,7 +59,7 @@ struct request_client {
struct resource_instance {
int id;
- struct resource *res;
+ struct syscommon_resman_resource *res;
int64_t ts_start;
int64_t ts_end;
@@ -86,7 +89,7 @@ get_resource_instance_by_id(struct request_client *client, int resource_id)
return g_hash_table_lookup(client->resource_table, GINT_TO_POINTER(resource_id));
}
-static struct resource *
+static struct syscommon_resman_resource *
get_resource_by_id(struct request_client *client, int resource_id)
{
struct resource_instance *res_inst = get_resource_instance_by_id(client, resource_id);
@@ -123,7 +126,7 @@ static int handle_request_create_resource(struct request_client *client, char *a
*/
resource_type = atoi(args);
- ret = create_resource(&res_inst->res, resource_type);
+ ret = syscommon_resman_create_resource(&res_inst->res, resource_type);
if (ret < 0) {
_E("failed to create resource, res:type(%d)\n", resource_type);
free(res_inst);
@@ -169,7 +172,7 @@ inline __attribute__((always_inline)) int64_t get_time_now(void)
static int handle_request_update_resource(struct request_client *client, char *args)
{
struct resource_instance *res_inst;
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id;
int ret;
@@ -193,33 +196,33 @@ static int handle_request_update_resource(struct request_client *client, char *a
res = res_inst->res;
res_inst->ts_start = get_time_now();
- ret = update_resource_attrs(res);
+ ret = syscommon_resman_update_resource_attrs(res);
res_inst->ts_end = get_time_now();
if (ret < 0) {
res_inst->ts_start = res_inst->ts_end = 0;
_E("failed to update resource attributes, res:name(%s)id(%d)\n",
- get_resource_name(res), resource_id);
+ syscommon_resman_get_resource_name(res), resource_id);
return ret;
}
return 0;
}
-static int get_resource_count(int resource_type)
+static int syscommon_resman_get_resource_count(int resource_type)
{
- const struct resource_driver *driver;
- int count = get_resource_device_count(resource_type);
+ const struct syscommon_resman_resource_driver *driver;
+ int count = syscommon_resman_get_resource_device_count(resource_type);
if (count > 0)
return count;
- driver = find_resource_driver(resource_type);
+ driver = syscommon_resman_find_resource_driver(resource_type);
if (!driver)
return -EINVAL;
- if (driver->flag & RESOURCE_FLAG_COUNT_ONLY_ONE)
+ if (driver->flag & SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE)
return 1;
- else if (driver->flag & RESOURCE_FLAG_PROCESS)
+ else if (driver->flag & SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_UNCOUNTABLE)
return -EINVAL;
return 0;
@@ -241,7 +244,7 @@ static int handle_request_get_resource_count(struct request_client *client, char
*/
resource_type = atoi(args);
- ret = get_resource_count(resource_type);
+ ret = syscommon_resman_get_resource_count(resource_type);
if (ret < 0) {
_E("failed to get resource device count, res:type(%d)\n", resource_type);
return ret;
@@ -254,13 +257,13 @@ static int handle_request_get_resource_count(struct request_client *client, char
static void update_resource(gpointer key, gpointer value, gpointer user_data)
{
struct resource_instance *res_inst = value;
- struct resource *res = res_inst->res;
+ struct syscommon_resman_resource *res = res_inst->res;
int ret;
- ret = update_resource_attrs(res);
+ ret = syscommon_resman_update_resource_attrs(res);
if (ret < 0)
_E("failed to update resource attributes (name:%s,id:%d)\n",
- get_resource_name(res), res_inst->id);
+ syscommon_resman_get_resource_name(res), res_inst->id);
}
@@ -283,7 +286,7 @@ static int handle_request_update_resource_all(struct request_client *client, cha
static int handle_request_set_resource_attr(struct request_client *client, char *args, int request_type)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t interest_masks;
@@ -311,21 +314,21 @@ static int handle_request_set_resource_attr(struct request_client *client, char
switch (request_type) {
case REQUEST_SET_RESOURCE_ATTR:
- ret = set_resource_attr_interest(res, interest_masks);
+ ret = syscommon_resman_set_resource_attr_interest(res, interest_masks);
if (ret < 0)
_E("failed to set attribute interest, client(%d) | res:name(%s)id(%d)\n",
client->socket_fd,
- get_resource_name(res), resource_id);
+ syscommon_resman_get_resource_name(res), resource_id);
break;
case REQUEST_UNSET_RESOURCE_ATTR:
- ret = unset_resource_attr_interest(res, interest_masks);
+ ret = syscommon_resman_unset_resource_attr_interest(res, interest_masks);
if (ret < 0)
_E("failed to unset attribute interest, client(%d) | res:name(%s)id(%d)\n",
client->socket_fd,
- get_resource_name(res), resource_id);
+ syscommon_resman_get_resource_name(res), resource_id);
break;
case REQUEST_IS_RESOURCE_ATTR_SET:
- ret = (int)is_resource_attr_interested(res, interest_masks);
+ ret = (int)syscommon_resman_is_resource_attr_interested(res, interest_masks);
break;
default:
return -EINVAL;
@@ -336,7 +339,7 @@ static int handle_request_set_resource_attr(struct request_client *client, char
static int handle_request_set_resource_flag(struct request_client *client, char *args)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t flag_mask;
@@ -362,11 +365,11 @@ static int handle_request_set_resource_flag(struct request_client *client, char
return -EINVAL;
}
- ret = set_resource_flag(res, flag_mask);
+ ret = syscommon_resman_set_resource_flag(res, flag_mask);
if (ret < 0) {
_E("failed to set flag to %"PRIu64", client(%d) | res:name(%s)id(%d)\n",
flag_mask, client->socket_fd,
- get_resource_name(res), resource_id);
+ syscommon_resman_get_resource_name(res), resource_id);
return ret;
}
@@ -401,12 +404,12 @@ static int handle_request_is_resource_attr_supported(struct request_client *clie
return -EINVAL;
}
- return is_resource_attr_supported(res, attr_id, supported);
+ return syscommon_resman_is_resource_attr_supported(res, attr_id, supported);
}
static int handle_request_set_resource_ctrl(struct request_client *client, char *args)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, value, ret;
u_int64_t ctrl_id;
@@ -432,12 +435,12 @@ static int handle_request_set_resource_ctrl(struct request_client *client, char
return -EINVAL;
}
- ret = set_resource_control(res, ctrl_id, (void *)(intptr_t)value);
+ ret = syscommon_resman_set_resource_control(res, ctrl_id, (void *)(intptr_t)value);
if (ret < 0) {
_E("failed to set resource control, client(%d) | res:name(%s)id(%d) | ctrl:name(%s)id(%"PRId64")val(%d)\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_control_name(res, ctrl_id), ctrl_id, value);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_control_name(res, ctrl_id), ctrl_id, value);
return ret;
}
@@ -448,7 +451,7 @@ static int
handle_request_get_json(struct request_client *client, char *args,
int request_type, char **json_string)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
u_int64_t attr_id;
int resource_id;
@@ -488,11 +491,11 @@ handle_request_get_json(struct request_client *client, char *args,
skip_res:
switch (request_type) {
case REQUEST_GET_RESOURCE_JSON:
- return get_resource_attrs_json(res, json_string);
+ return syscommon_resman_get_resource_attrs_json(res, json_string);
case REQUEST_GET_VALUE_JSON:
- return get_resource_attr_json(res, attr_id, json_string);
+ return syscommon_resman_get_resource_attr_json(res, attr_id, json_string);
case REQUEST_GET_RESOURCE_LIST_JSON:
- return get_resource_list_json(json_string);
+ return syscommon_resman_get_resource_list_json(json_string);
default:
return -EINVAL;
}
@@ -500,7 +503,7 @@ skip_res:
static int handle_request_get_value_int(struct request_client *client, char *args, int32_t *value)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t attr_id;
@@ -526,12 +529,12 @@ static int handle_request_get_value_int(struct request_client *client, char *arg
return -EINVAL;
}
- ret = get_resource_attr_int(res, attr_id, value);
+ ret = syscommon_resman_get_resource_attr_int(res, attr_id, value);
if (ret < 0) {
_E("failed to get int value, client(%d) | res:name(%s)id(%d) | attr:name(%s)id(%"PRId64")\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_attr_name(res, attr_id), attr_id);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_attr_name(res, attr_id), attr_id);
return ret;
}
@@ -540,7 +543,7 @@ static int handle_request_get_value_int(struct request_client *client, char *arg
static int handle_request_get_value_int64(struct request_client *client, char *args, int64_t *value)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t attr_id;
@@ -566,12 +569,12 @@ static int handle_request_get_value_int64(struct request_client *client, char *a
return -EINVAL;
}
- ret = get_resource_attr_int64(res, attr_id, value);
+ ret = syscommon_resman_get_resource_attr_int64(res, attr_id, value);
if (ret < 0) {
_E("failed to get int64 value, client(%d) | res:name(%s)id(%d) | attr:name(%s)id(%"PRId64")\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_attr_name(res, attr_id), attr_id);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_attr_name(res, attr_id), attr_id);
return ret;
}
@@ -581,7 +584,7 @@ static int handle_request_get_value_int64(struct request_client *client, char *a
static int
handle_request_get_value_uint(struct request_client *client, char *args, u_int32_t *value)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t attr_id;
@@ -607,12 +610,12 @@ handle_request_get_value_uint(struct request_client *client, char *args, u_int32
return -EINVAL;
}
- ret = get_resource_attr_uint(res, attr_id, value);
+ ret = syscommon_resman_get_resource_attr_uint(res, attr_id, value);
if (ret < 0) {
_E("failed to get uint value, client(%d) | res:name(%s)id(%d) | attr:name(%s)id(%"PRId64")\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_attr_name(res, attr_id), attr_id);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_attr_name(res, attr_id), attr_id);
return ret;
}
@@ -622,7 +625,7 @@ handle_request_get_value_uint(struct request_client *client, char *args, u_int32
static int
handle_request_get_value_uint64(struct request_client *client, char *args, u_int64_t *value)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t attr_id;
@@ -648,12 +651,12 @@ handle_request_get_value_uint64(struct request_client *client, char *args, u_int
return -EINVAL;
}
- ret = get_resource_attr_uint64(res, attr_id, value);
+ ret = syscommon_resman_get_resource_attr_uint64(res, attr_id, value);
if (ret < 0) {
_E("failed to get uint64 value, client(%d) | res:name(%s)id(%d) | attr:name(%s)id(%"PRId64")\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_attr_name(res, attr_id), attr_id);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_attr_name(res, attr_id), attr_id);
return ret;
}
@@ -662,7 +665,7 @@ handle_request_get_value_uint64(struct request_client *client, char *args, u_int
static int handle_request_get_value_double(struct request_client *client, char *args, double *value)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t attr_id;
@@ -688,12 +691,12 @@ static int handle_request_get_value_double(struct request_client *client, char *
return -EINVAL;
}
- ret = get_resource_attr_double(res, attr_id, value);
+ ret = syscommon_resman_get_resource_attr_double(res, attr_id, value);
if (ret < 0) {
_E("failed to get double value, client(%d) | res:name(%s)id(%d) | attr:name(%s)id(%"PRId64")\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_attr_name(res, attr_id), attr_id);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_attr_name(res, attr_id), attr_id);
return ret;
}
@@ -702,7 +705,7 @@ static int handle_request_get_value_double(struct request_client *client, char *
static int handle_request_get_value_string(struct request_client *client, char *args, char *value)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t attr_id;
@@ -728,12 +731,12 @@ static int handle_request_get_value_string(struct request_client *client, char *
return -EINVAL;
}
- ret = get_resource_attr_string(res, attr_id, value);
+ ret = syscommon_resman_get_resource_attr_string(res, attr_id, value);
if (ret < 0) {
_E("failed to get string value, client(%d) | res:name(%s)id(%d) | attr:name(%s)id(%"PRId64")\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_attr_name(res, attr_id), attr_id);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_attr_name(res, attr_id), attr_id);
return ret;
}
@@ -741,9 +744,9 @@ static int handle_request_get_value_string(struct request_client *client, char *
}
static int
-handle_request_get_value_array(struct request_client *client, char *args, struct array_value **arr)
+handle_request_get_value_array(struct request_client *client, char *args, struct syscommon_resman_array_value **arr)
{
- struct resource *res;
+ struct syscommon_resman_resource *res;
int resource_id, ret;
u_int64_t attr_id;
@@ -769,19 +772,19 @@ handle_request_get_value_array(struct request_client *client, char *args, struct
return -EINVAL;
}
- ret = get_resource_attr_array(res, attr_id, arr);
+ ret = syscommon_resman_get_resource_attr_array(res, attr_id, arr);
if (ret < 0) {
_E("failed to get array value, client(%d) | (res:name(%s)id(%d) | attr:name(%s)id(%"PRId64")\n",
client->socket_fd,
- get_resource_name(res), resource_id,
- get_resource_attr_name(res, attr_id), attr_id);
+ syscommon_resman_get_resource_name(res), resource_id,
+ syscommon_resman_get_resource_attr_name(res, attr_id), attr_id);
return ret;
}
return 0;
}
-static int get_resource_ts(struct resource_instance *inst, int64_t *ts_start, int64_t *ts_end)
+static int syscommon_resman_get_resource_ts(struct resource_instance *inst, int64_t *ts_start, int64_t *ts_end)
{
if (!inst)
return -EINVAL;
@@ -817,11 +820,11 @@ handle_request_get_resource_ts(struct request_client *client, char *args,
return -EINVAL;
}
- ret = get_resource_ts(res_inst, start, end);
+ ret = syscommon_resman_get_resource_ts(res_inst, start, end);
if (ret < 0) {
_E("failed to get timestamp value, client(%d) | res:name(%s)id(%d)\n",
client->socket_fd,
- get_resource_name(res_inst->res), resource_id);
+ syscommon_resman_get_resource_name(res_inst->res), resource_id);
return ret;
}
@@ -987,7 +990,7 @@ static int handle_request(struct request_client *client, char *request)
break;
case REQUEST_GET_VALUE_ARRAY:
{
- struct array_value *array;
+ struct syscommon_resman_array_value *array;
int i;
ret = handle_request_get_value_array(client, args, &array);
@@ -1001,42 +1004,42 @@ static int handle_request(struct request_client *client, char *request)
ADD_RESPONSE(response, buffer_len, "%d|%d|", array->type, array->length);
switch (array->type) {
- case DATA_TYPE_INT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
for (i = 0; i < array->length - 1; i++)
ADD_RESPONSE(response, buffer_len, "%d,",
((int32_t *)array->data)[i]);
ADD_RESPONSE(response, buffer_len, "%d$",
((int32_t *)array->data)[i]);
break;
- case DATA_TYPE_INT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
for (i = 0; i < array->length - 1; i++)
ADD_RESPONSE(response, buffer_len, "%"PRId64",",
((int64_t *)array->data)[i]);
ADD_RESPONSE(response, buffer_len, "%"PRId64"$",
((int64_t *)array->data)[i]);
break;
- case DATA_TYPE_UINT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
for (i = 0; i < array->length - 1; i++)
ADD_RESPONSE(response, buffer_len, "%u,",
((u_int32_t *)array->data)[i]);
ADD_RESPONSE(response, buffer_len, "%u$",
((u_int32_t *)array->data)[i]);
break;
- case DATA_TYPE_UINT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
for (i = 0; i < array->length - 1; i++)
ADD_RESPONSE(response, buffer_len, "%"PRIu64",",
((u_int64_t *)array->data)[i]);
ADD_RESPONSE(response, buffer_len, "%"PRIu64"$",
((u_int64_t *)array->data)[i]);
break;
- case DATA_TYPE_DOUBLE:
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
for (i = 0; i < array->length - 1; i++)
ADD_RESPONSE(response, buffer_len, "%lf,",
((double *)array->data)[i]);
ADD_RESPONSE(response, buffer_len, "%lf$",
((double *)array->data)[i]);
break;
- case DATA_TYPE_STRING:
+ case SYSCOMMON_RESMAN_DATA_TYPE_STRING:
for (i = 0; i < array->length - 1; i++)
ADD_RESPONSE(response, buffer_len, "%s,",
((char **)array->data)[i]);
@@ -1145,7 +1148,7 @@ static void delete_resource_instance(struct resource_instance *res_inst)
if (!res_inst)
return;
- delete_resource(res_inst->res);
+ syscommon_resman_delete_resource(res_inst->res);
free(res_inst);
}
@@ -1161,8 +1164,9 @@ static int create_request_client(int socket_fd)
}
client->socket_fd = socket_fd;
- client->resource_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify)delete_resource_instance);
+ client->resource_table =
+ g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
+ (GDestroyNotify)delete_resource_instance);
create_daemon_thread(&client->worker, request_handler_func, client);
diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c
index 4e16a43..c2c2c67 100644
--- a/src/pass/pass-parser.c
+++ b/src/pass/pass-parser.c
@@ -41,6 +41,7 @@
#include <hal/hal-power.h>
#include <util/common.h>
+#include <libsyscommon/resource-type.h>
#include "pass.h"
@@ -117,26 +118,26 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
/* Get property values */
struct config_property scenario_properties[] = {
- { "name", DATA_TYPE_STRING, true, (void *)&scenario->name },
- { "target_level", DATA_TYPE_INT, true, (void *)&scenario->level },
- { "support", DATA_TYPE_BOOLEAN, false, (void *)&support },
- { "overridable", DATA_TYPE_BOOLEAN, false, (void *)&overridable },
+ { "name", SYSCOMMON_RESMAN_DATA_TYPE_STRING, true, (void *)&scenario->name },
+ { "target_level", SYSCOMMON_RESMAN_DATA_TYPE_INT, true, (void *)&scenario->level },
+ { "support", SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN, false, (void *)&support },
+ { "overridable", SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN, false, (void *)&overridable },
/* - property for only pmqos module */
- { "cpuhp_min_level", DATA_TYPE_INT, false, (void *)&scenario->pmqos.min_level },
- { "cpuhp_max_level", DATA_TYPE_INT, false, (void *)&scenario->pmqos.max_level },
+ { "cpuhp_min_level", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&scenario->pmqos.min_level },
+ { "cpuhp_max_level", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&scenario->pmqos.max_level },
/* - property for only thermal module */
- { "timer_interval_ms", DATA_TYPE_INT, false, (void *)&scenario->thermal.timer_interval },
+ { "timer_interval_ms", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&scenario->thermal.timer_interval },
};
ret += get_property_set(obj, scenario_properties, ARRAY_SIZE(scenario_properties));
temperature = get_object_from_object(obj, "temperature");
if (temperature) {
- ret += get_property(temperature, "start", DATA_TYPE_INT,
+ ret += get_property(temperature, "start", SYSCOMMON_RESMAN_DATA_TYPE_INT,
true, (void *)&scenario->thermal.temp_start);
- ret += get_property(temperature, "end", DATA_TYPE_INT,
+ ret += get_property(temperature, "end", SYSCOMMON_RESMAN_DATA_TYPE_INT,
true, (void *)&scenario->thermal.temp_end);
- ret += get_property(temperature, "threshold", DATA_TYPE_INT,
+ ret += get_property(temperature, "threshold", SYSCOMMON_RESMAN_DATA_TYPE_INT,
false, (void *)&scenario->thermal.threshold);
/* if threshold is not presented, using temp_end as default */
@@ -248,39 +249,39 @@ static int parse_level(struct pass_resource *res, json_object *obj,
/* Get property values */
struct config_property level_properties[] = {
- { "level", DATA_TYPE_INT, true, (void *)&level },
- { "dvfs,minimum_frequency_khz", DATA_TYPE_INT, false, (void *)&target_level->limit_min_freq },
- { "dvfs,maximum_frequency_khz", DATA_TYPE_INT, false, (void *)&target_level->limit_max_freq },
- { "hotplug,number_of_minimum_cpu", DATA_TYPE_INT, false, (void *)&target_level->limit_min_cpu },
- { "hotplug,number_of_maximum_cpu", DATA_TYPE_INT, false, (void *)&target_level->limit_max_cpu },
-
- { "hotplug,num_down_cond", DATA_TYPE_INT, false, (void *)&target_level->num_down_cond },
- { "hotplug,num_down_cond_freq", DATA_TYPE_INT, false, (void *)&target_level->down_cond[0].freq },
- { "hotplug,num_down_cond_nr_running", DATA_TYPE_INT, false, (void *)&target_level->down_cond[0].nr_running },
- { "hotplug,num_down_cond_busy_cpu", DATA_TYPE_INT, false, (void *)&target_level->down_cond[0].busy_cpu },
-
- { "hotplug,num_up_cond", DATA_TYPE_INT, false, (void *)&target_level->num_up_cond },
- { "hotplug,num_up_cond_freq", DATA_TYPE_INT, false, (void *)&target_level->up_cond[0].freq },
- { "hotplug,num_up_cond_nr_running", DATA_TYPE_INT, false, (void *)&target_level->up_cond[0].nr_running },
- { "hotplug,num_up_cond_busy_cpu", DATA_TYPE_INT, false, (void *)&target_level->up_cond[0].busy_cpu },
-
- { "hotplug,num_right_cond", DATA_TYPE_INT, false, (void *)&target_level->num_right_cond },
- { "hotplug,num_right_cond_freq", DATA_TYPE_INT, false, (void *)&target_level->right_cond[0].freq },
- { "hotplug,num_right_cond_nr_running", DATA_TYPE_INT, false, (void *)&target_level->right_cond[0].nr_running },
- { "hotplug,num_right_cond_busy_cpu", DATA_TYPE_INT, false, (void *)&target_level->right_cond[0].busy_cpu },
-
- { "hotplug,num_left_cond", DATA_TYPE_INT, false, (void *)&target_level->num_left_cond },
- { "hotplug,num_left_cond_freq", DATA_TYPE_INT, false, (void *)&target_level->left_cond[0].freq },
- { "hotplug,num_left_cond_nr_running", DATA_TYPE_INT, false, (void *)&target_level->left_cond[0].nr_running },
- { "hotplug,num_left_cond_busy_cpu", DATA_TYPE_INT, false, (void *)&target_level->left_cond[0].busy_cpu },
-
- { "hotplug,governor_timeout_sec", DATA_TYPE_DOUBLE, false, (void *)&target_level->gov_timeout },
-
- { "memory,fault_around_bytes", DATA_TYPE_INT, false, (void *)&target_level->fault_around_bytes },
-
- { "thermal,cooling_device_state", DATA_TYPE_INT, false, (void *)&target_level->cooling_device_state },
- { "battery,charging_status", DATA_TYPE_INT, false, (void *)&target_level->charging_status },
- { "battery,charging_current_uA", DATA_TYPE_INT, false, (void *)&target_level->charging_current_uA },
+ { "level", SYSCOMMON_RESMAN_DATA_TYPE_INT, true, (void *)&level },
+ { "dvfs,minimum_frequency_khz", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->limit_min_freq },
+ { "dvfs,maximum_frequency_khz", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->limit_max_freq },
+ { "hotplug,number_of_minimum_cpu", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->limit_min_cpu },
+ { "hotplug,number_of_maximum_cpu", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->limit_max_cpu },
+
+ { "hotplug,num_down_cond", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->num_down_cond },
+ { "hotplug,num_down_cond_freq", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->down_cond[0].freq },
+ { "hotplug,num_down_cond_nr_running", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->down_cond[0].nr_running },
+ { "hotplug,num_down_cond_busy_cpu", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->down_cond[0].busy_cpu },
+
+ { "hotplug,num_up_cond", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->num_up_cond },
+ { "hotplug,num_up_cond_freq", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->up_cond[0].freq },
+ { "hotplug,num_up_cond_nr_running", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->up_cond[0].nr_running },
+ { "hotplug,num_up_cond_busy_cpu", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->up_cond[0].busy_cpu },
+
+ { "hotplug,num_right_cond", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->num_right_cond },
+ { "hotplug,num_right_cond_freq", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->right_cond[0].freq },
+ { "hotplug,num_right_cond_nr_running", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->right_cond[0].nr_running },
+ { "hotplug,num_right_cond_busy_cpu", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->right_cond[0].busy_cpu },
+
+ { "hotplug,num_left_cond", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->num_left_cond },
+ { "hotplug,num_left_cond_freq", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->left_cond[0].freq },
+ { "hotplug,num_left_cond_nr_running", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->left_cond[0].nr_running },
+ { "hotplug,num_left_cond_busy_cpu", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->left_cond[0].busy_cpu },
+
+ { "hotplug,governor_timeout_sec", SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, false, (void *)&target_level->gov_timeout },
+
+ { "memory,fault_around_bytes", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->fault_around_bytes },
+
+ { "thermal,cooling_device_state", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->cooling_device_state },
+ { "battery,charging_status", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->charging_status },
+ { "battery,charging_current_uA", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&target_level->charging_current_uA },
};
ret += get_property_set(obj, level_properties, ARRAY_SIZE(level_properties));
@@ -322,7 +323,7 @@ static int parse_pmqos(struct pass_resource *res, json_object *obj)
/* Get property values */
struct config_property pmqos_scenario_properties[] = {
- { "pmqos_support", DATA_TYPE_INT, true, (void *)&res->pmqos.state },
+ { "pmqos_support", SYSCOMMON_RESMAN_DATA_TYPE_INT, true, (void *)&res->pmqos.state },
};
ret += get_property_set(obj, pmqos_scenario_properties,
@@ -383,8 +384,8 @@ static int parse_thermal(struct pass_resource *res, json_object *obj)
/* Get property values */
struct config_property thermal_properties[] = {
- { "thermal_support", DATA_TYPE_INT, true, (void *)&res->thermal.state },
- { "thermal_timer_interval_ms", DATA_TYPE_INT, false, (void *)&res->thermal.timer_interval },
+ { "thermal_support", SYSCOMMON_RESMAN_DATA_TYPE_INT, true, (void *)&res->thermal.state },
+ { "thermal_timer_interval_ms", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&res->thermal.timer_interval },
};
ret += get_property_set(obj, thermal_properties, ARRAY_SIZE(thermal_properties));
@@ -448,15 +449,15 @@ static int parse_cpuhp(struct pass_resource *res, json_object *obj)
/* Get property values */
struct config_property cpuhp_properties[] = {
- { "cpuhp_support", DATA_TYPE_INT, true, (void *)&res->config_data.state },
- { "cpuhp_governor", DATA_TYPE_INT, false, (void *)&res->config_data.gov_type },
- { "cpuhp_timer_interval_ms", DATA_TYPE_INT, false, (void *)&res->config_data.gov_timeout },
- { "cpuhp_min_level", DATA_TYPE_INT, false, (void *)&cpuhp_min_level },
- { "cpuhp_max_level", DATA_TYPE_INT, false, (void *)&cpuhp_max_level },
- { "cpuhp_init_level", DATA_TYPE_INT, false, (void *)&cpuhp_init_level },
- { "cpuhp_cpu_threshold", DATA_TYPE_INT, false, (void *)&res->cpuhp.pass_cpu_threshold },
- { "cpuhp_up_threshold", DATA_TYPE_INT, false, (void *)&res->cpuhp.up_threshold },
- { "cpuhp_down_threshold", DATA_TYPE_INT, false, (void *)&res->cpuhp.down_threshold },
+ { "cpuhp_support", SYSCOMMON_RESMAN_DATA_TYPE_INT, true, (void *)&res->config_data.state },
+ { "cpuhp_governor", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&res->config_data.gov_type },
+ { "cpuhp_timer_interval_ms", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&res->config_data.gov_timeout },
+ { "cpuhp_min_level", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&cpuhp_min_level },
+ { "cpuhp_max_level", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&cpuhp_max_level },
+ { "cpuhp_init_level", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&cpuhp_init_level },
+ { "cpuhp_cpu_threshold", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&res->cpuhp.pass_cpu_threshold },
+ { "cpuhp_up_threshold", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&res->cpuhp.up_threshold },
+ { "cpuhp_down_threshold", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&res->cpuhp.down_threshold },
};
ret += get_property_set(obj, cpuhp_properties, ARRAY_SIZE(cpuhp_properties));
@@ -532,8 +533,8 @@ static int parse_header(struct pass_resource *res, json_object *obj)
/* Get property values */
struct config_property header_properties[] = {
- { "support", DATA_TYPE_BOOLEAN, true, (void *)&support },
- { "init_level", DATA_TYPE_INT, true, (void *)&init_level },
+ { "support", SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN, true, (void *)&support },
+ { "init_level", SYSCOMMON_RESMAN_DATA_TYPE_INT, true, (void *)&init_level },
};
ret += get_property_set(obj, header_properties, ARRAY_SIZE(header_properties));
@@ -650,17 +651,17 @@ static int parse_resource_data(struct pass *pass, int id, json_object *obj)
/* Get property values */
struct config_property resource_properties[] = {
- { "device_type", DATA_TYPE_STRING, true, (void *)device_type },
- { "device_name", DATA_TYPE_STRING, true, (void *)config_data->res_name },
- { "device_config_path", DATA_TYPE_STRING, true, (void *)config_data->path_conf_file },
+ { "device_type", SYSCOMMON_RESMAN_DATA_TYPE_STRING, true, (void *)device_type },
+ { "device_name", SYSCOMMON_RESMAN_DATA_TYPE_STRING, true, (void *)config_data->res_name },
+ { "device_config_path", SYSCOMMON_RESMAN_DATA_TYPE_STRING, true, (void *)config_data->path_conf_file },
- { "thermal_device_name", DATA_TYPE_STRING, false, (void *)config_data->res_thermal_name },
- { "cooling_device_name", DATA_TYPE_STRING, false, (void *)config_data->res_cooling_name },
- { "thermal_priority", DATA_TYPE_INT, false, (void *)&config_data->res_thermal_priority },
+ { "thermal_device_name", SYSCOMMON_RESMAN_DATA_TYPE_STRING, false, (void *)config_data->res_thermal_name },
+ { "cooling_device_name", SYSCOMMON_RESMAN_DATA_TYPE_STRING, false, (void *)config_data->res_cooling_name },
+ { "thermal_priority", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&config_data->res_thermal_priority },
- { "cpu,cpu_load_path", DATA_TYPE_STRING, false, (void *)config_data->path_load_table },
- { "cpu,number_of_cpus", DATA_TYPE_INT, false, (void *)&config_data->num_cpus },
- { "cpu,first_cpu", DATA_TYPE_INT, false, (void *)&config_data->cpu },
+ { "cpu,cpu_load_path", SYSCOMMON_RESMAN_DATA_TYPE_STRING, false, (void *)config_data->path_load_table },
+ { "cpu,number_of_cpus", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&config_data->num_cpus },
+ { "cpu,first_cpu", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&config_data->cpu },
};
ret += get_property_set(obj, resource_properties, ARRAY_SIZE(resource_properties));
@@ -736,8 +737,8 @@ static int parse_resource(struct pass *pass, json_object *obj)
/* Get property values */
struct config_property board_properties[] = {
- { "board_name", DATA_TYPE_STRING, false, (void *)board_name },
- { "board_name_path", DATA_TYPE_STRING, false, (void *)board_name_path },
+ { "board_name", SYSCOMMON_RESMAN_DATA_TYPE_STRING, false, (void *)board_name },
+ { "board_name_path", SYSCOMMON_RESMAN_DATA_TYPE_STRING, false, (void *)board_name_path },
};
ret += get_property_set(obj, board_properties, ARRAY_SIZE(board_properties));
diff --git a/src/pass/pass.c b/src/pass/pass.c
index 295e23f..50f3d2e 100644
--- a/src/pass/pass.c
+++ b/src/pass/pass.c
@@ -37,7 +37,8 @@
#include <util/device-notifier.h>
#include <util/devices.h>
#include <util/gdbus-util.h>
-#include <util/resource.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-device.h>
#include "pass.h"
#include "pass-parser.h"
@@ -287,7 +288,7 @@ static int pass_init_resource(struct pass_resource *res)
res->device->name = res->config_data.res_name;
res->device->type = res->config_data.res_type;
- ret = add_resource_device(res->device);
+ ret = syscommon_resman_add_resource_device(res->device);
if (ret < 0) {
_E("cannot add resource device (res_name:%s, res_type%d)",
res->config_data.res_name,
@@ -334,7 +335,7 @@ static int pass_exit_resource(struct pass_resource *res)
int ret;
/* Remove resource_device */
- remove_resource_device(res->device);
+ syscommon_resman_remove_resource_device(res->device);
free(res->device);
res->device = NULL;
diff --git a/src/pass/pass.h b/src/pass/pass.h
index 009eed4..1f41600 100644
--- a/src/pass/pass.h
+++ b/src/pass/pass.h
@@ -39,6 +39,8 @@
#include <util/common.h>
#include <util/log.h>
+#include <libsyscommon/resource-device.h>
+
#define PASS_LEVEL_COND_MAX 3
struct pass_resource;
@@ -642,7 +644,7 @@ struct pass_resource {
struct pass_thermal thermal;
/** Instance of resouce device containing h/w resource information */
- struct resource_device *device;
+ struct syscommon_resman_resource_device *device;
};
/******************************************************
diff --git a/src/pmqos/pmqos-parser.c b/src/pmqos/pmqos-parser.c
index 6c16c4f..b99f30a 100644
--- a/src/pmqos/pmqos-parser.c
+++ b/src/pmqos/pmqos-parser.c
@@ -40,6 +40,8 @@
#include <util/log.h>
#include <util/common.h>
+#include <libsyscommon/resource-type.h>
+
#include "pmqos.h"
/**
@@ -56,9 +58,9 @@ static int pmqos_parse_scenario(json_object *obj, struct scenario *scenario)
bool support;
int ret = 0;
struct config_property pmqos_scenario_properties[] = {
- { "name", DATA_TYPE_STRING, true, (void *)name },
- { "support", DATA_TYPE_BOOLEAN, false, (void *)&support },
- { "max_duration_ms", DATA_TYPE_INT, false, (void *)&max_duration_ms },
+ { "name", SYSCOMMON_RESMAN_DATA_TYPE_STRING, true, (void *)name },
+ { "support", SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN, false, (void *)&support },
+ { "max_duration_ms", SYSCOMMON_RESMAN_DATA_TYPE_INT, false, (void *)&max_duration_ms },
};
/* Get property values */
@@ -93,7 +95,7 @@ static int pmqos_load_config(json_object *obj, struct pmqos_scenario *scenarios)
json_object *pmqos_scenario_list = NULL;
int num_scenarios = 0, ret = 0, i;
struct config_property pmqos_header_properties[] = {
- {"pmqos_support", DATA_TYPE_BOOLEAN, false, (void *)&pmqos_support },
+ {"pmqos_support", SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN, false, (void *)&pmqos_support },
};
/* Get property values */
diff --git a/src/resource/resource-battery.c b/src/resource/resource-battery.c
index 07699b1..ecb4554 100644
--- a/src/resource/resource-battery.c
+++ b/src/resource/resource-battery.c
@@ -26,12 +26,13 @@
#include <util/common.h>
#include <util/log.h>
-#include <util/resource.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
#include <resource-monitor/resource-monitor.h>
-static int battery_get_info(struct resource *res,
- const struct resource_attribute *attr,
+static int battery_get_info(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
char *path = NULL;
@@ -71,8 +72,8 @@ static int battery_get_info(struct resource *res,
return 0;
}
-static int battery_get_status(struct resource *res,
- const struct resource_attribute *attr,
+static int battery_get_status(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
char *buf = (char *)data;
@@ -88,70 +89,70 @@ static int battery_get_status(struct resource *res,
return 0;
}
-static const struct resource_attribute battery_attrs[] = {
+static const struct syscommon_resman_resource_attribute battery_attrs[] = {
{
.name = "BATTERY_ATTR_CAPACITY",
.id = BATTERY_ATTR_CAPACITY,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = battery_get_info,
}
}, {
.name = "BATTERY_ATTR_STATUS",
.id = BATTERY_ATTR_STATUS,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = battery_get_status,
}
}, {
.name = "BATTERY_ATTR_TEMPERATURE",
.id = BATTERY_ATTR_TEMPERATURE,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = battery_get_info,
}
}, {
.name = "BATTERY_ATTR_VOLTAGE_NOW",
.id = BATTERY_ATTR_VOLTAGE_NOW,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = battery_get_info,
}
}, {
.name = "BATTERY_ATTR_CURRENT_NOW",
.id = BATTERY_ATTR_CURRENT_NOW,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = battery_get_info,
}
}, {
.name = "BATTERY_ATTR_PRESENT",
.id = BATTERY_ATTR_PRESENT,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = battery_get_info,
}
}, {
.name = "BATTERY_ATTR_ONLINE",
.id = BATTERY_ATTR_ONLINE,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = battery_get_info,
}
},
};
-static const struct resource_driver battery_resource_driver = {
+static const struct syscommon_resman_resource_driver battery_resource_driver = {
.name = "BATTERY",
.type = RESOURCE_TYPE_BATTERY,
.attrs = battery_attrs,
.num_attrs = ARRAY_SIZE(battery_attrs),
};
-RESOURCE_DRIVER_REGISTER(&battery_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&battery_resource_driver)
diff --git a/src/resource/resource-bus.c b/src/resource/resource-bus.c
index 22807f6..b32bd5f 100644
--- a/src/resource/resource-bus.c
+++ b/src/resource/resource-bus.c
@@ -29,7 +29,9 @@
#include <util/common.h>
#include <util/devices.h>
#include <util/log.h>
-#include <util/resource.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <libsyscommon/resource-device.h>
#include <resource-monitor/resource-monitor.h>
@@ -38,8 +40,8 @@ struct bus_context {
int index;
};
-static int bus_get_value_from_hal_power(struct resource *res,
- const struct resource_attribute *attr,
+static int bus_get_value_from_hal_power(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct bus_context *ctx;
@@ -50,17 +52,17 @@ static int bus_get_value_from_hal_power(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: BUS_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
- type = get_resource_type(res);
+ type = syscommon_resman_get_resource_type(res);
switch (attr->id) {
case BUS_ATTR_CUR_FREQ:
@@ -90,8 +92,8 @@ static int bus_get_value_from_hal_power(struct resource *res,
return 0;
}
-static int bus_get_string_value(struct resource *res,
- const struct resource_attribute *attr,
+static int bus_get_string_value(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct bus_context *ctx;
@@ -101,19 +103,19 @@ static int bus_get_string_value(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: BUS_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
switch (attr->id) {
case BUS_ATTR_CUR_GOVERNOR:
- val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ val = hal_power_dvfs_get_curr_governor(syscommon_resman_get_resource_type(res),
ctx->device_name, buf);
if (val < 0)
return -EINVAL;
@@ -126,85 +128,85 @@ static int bus_get_string_value(struct resource *res,
return 0;
}
-static const struct resource_attribute bus_attrs[] = {
+static const struct syscommon_resman_resource_attribute bus_attrs[] = {
{
.name = "BUS_ATTR_CUR_FREQ",
.id = BUS_ATTR_CUR_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = bus_get_value_from_hal_power,
},
}, {
.name = "BUS_ATTR_MIN_FREQ",
.id = BUS_ATTR_MIN_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = bus_get_value_from_hal_power,
},
}, {
.name = "BUS_ATTR_MAX_FREQ",
.id = BUS_ATTR_MAX_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = bus_get_value_from_hal_power,
}
}, {
.name = "BUS_ATTR_AVAILABLE_MIN_FREQ",
.id = BUS_ATTR_AVAILABLE_MIN_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = bus_get_value_from_hal_power,
}
}, {
.name = "BUS_ATTR_AVAILABLE_MAX_FREQ",
.id = BUS_ATTR_AVAILABLE_MAX_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = bus_get_value_from_hal_power,
}
}, {
.name = "BUS_ATTR_CUR_GOVERNOR",
.id = BUS_ATTR_CUR_GOVERNOR,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = bus_get_string_value,
}
}, {
.name = "BUS_ATTR_NAME",
.id = BUS_ATTR_NAME,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = bus_get_string_value,
}
},
};
-static int bus_setup_device_id(struct resource *res,
- const struct resource_control *ctrl,
+static int bus_setup_device_id(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct bus_context *ctx;
- const struct resource_device *device;
+ const struct syscommon_resman_resource_device *device;
int device_id = (int)(intptr_t)data;
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- device = find_resource_device(get_resource_type(res), device_id);
+ device = syscommon_resman_find_resource_device(syscommon_resman_get_resource_type(res), device_id);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- get_resource_name(res), device_id);
+ syscommon_resman_get_resource_name(res), device_id);
return -EINVAL;
}
@@ -217,7 +219,7 @@ static int bus_setup_device_id(struct resource *res,
return 0;
}
-static const struct resource_control bus_ctrls[] = {
+static const struct syscommon_resman_resource_control bus_ctrls[] = {
{
.name = "BUS_CTRL_DEVICE_ID",
.id = BUS_CTRL_DEVICE_ID,
@@ -227,7 +229,7 @@ static const struct resource_control bus_ctrls[] = {
},
};
-static int bus_create(struct resource *res)
+static int bus_create(struct syscommon_resman_resource *res)
{
struct bus_context *ctx;
@@ -235,19 +237,19 @@ static int bus_create(struct resource *res)
if (!ctx)
return -ENOMEM;
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
return 0;
}
-static void bus_delete(struct resource *res)
+static void bus_delete(struct syscommon_resman_resource *res)
{
struct bus_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
@@ -256,10 +258,10 @@ static void bus_delete(struct resource *res)
ctx->device_name = NULL;
}
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
-static const struct resource_driver bus_resource_driver = {
+static const struct syscommon_resman_resource_driver bus_resource_driver = {
.name = "BUS",
.type = RESOURCE_TYPE_BUS,
.attrs = bus_attrs,
@@ -271,4 +273,4 @@ static const struct resource_driver bus_resource_driver = {
.delete = bus_delete,
},
};
-RESOURCE_DRIVER_REGISTER(&bus_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&bus_resource_driver)
diff --git a/src/resource/resource-cpu.c b/src/resource/resource-cpu.c
index aa2d405..89e3180 100644
--- a/src/resource/resource-cpu.c
+++ b/src/resource/resource-cpu.c
@@ -29,7 +29,10 @@
#include <util/common.h>
#include <util/devices.h>
#include <util/log.h>
-#include <util/resource.h>
+
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <libsyscommon/resource-device.h>
#include <resource-monitor/resource-monitor.h>
@@ -38,8 +41,8 @@ struct cpu_context {
int index;
};
-static int cpu_get_value_from_hal_power(struct resource *res,
- const struct resource_attribute *attr,
+static int cpu_get_value_from_hal_power(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct cpu_context *ctx;
@@ -49,17 +52,17 @@ static int cpu_get_value_from_hal_power(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: CPU_CTRL_CLUSTER_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
- type = get_resource_type(res);
+ type = syscommon_resman_get_resource_type(res);
switch (attr->id) {
case CPU_ATTR_CUR_FREQ:
@@ -89,8 +92,8 @@ static int cpu_get_value_from_hal_power(struct resource *res,
return 0;
}
-static int cpu_get_string_value(struct resource *res,
- const struct resource_attribute *attr,
+static int cpu_get_string_value(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct cpu_context *ctx;
@@ -100,19 +103,19 @@ static int cpu_get_string_value(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: CPU_CTRL_CLUSTER_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
switch (attr->id) {
case CPU_ATTR_CUR_GOVERNOR:
- val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ val = hal_power_dvfs_get_curr_governor(syscommon_resman_get_resource_type(res),
ctx->device_name, buf);
if (val < 0)
return -EINVAL;
@@ -125,85 +128,85 @@ static int cpu_get_string_value(struct resource *res,
return 0;
}
-static const struct resource_attribute cpu_attrs[] = {
+static const struct syscommon_resman_resource_attribute cpu_attrs[] = {
{
.name = "CPU_ATTR_CUR_FREQ",
.id = CPU_ATTR_CUR_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = cpu_get_value_from_hal_power,
},
}, {
.name = "CPU_ATTR_MIN_FREQ",
.id = CPU_ATTR_MIN_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = cpu_get_value_from_hal_power,
},
}, {
.name = "CPU_ATTR_MAX_FREQ",
.id = CPU_ATTR_MAX_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = cpu_get_value_from_hal_power,
}
}, {
.name = "CPU_ATTR_AVAILABLE_MIN_FREQ",
.id = CPU_ATTR_AVAILABLE_MIN_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = cpu_get_value_from_hal_power,
}
}, {
.name = "CPU_ATTR_AVAILABLE_MAX_FREQ",
.id = CPU_ATTR_AVAILABLE_MAX_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = cpu_get_value_from_hal_power,
}
}, {
.name = "CPU_ATTR_CUR_GOVERNOR",
.id = CPU_ATTR_CUR_GOVERNOR,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = cpu_get_string_value,
}
}, {
.name = "CPU_ATTR_NAME",
.id = CPU_ATTR_NAME,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = cpu_get_string_value,
}
},
};
-static int cpu_setup_cluster_id(struct resource *res,
- const struct resource_control *ctrl,
+static int cpu_setup_cluster_id(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct cpu_context *ctx;
- const struct resource_device *device;
+ const struct syscommon_resman_resource_device *device;
int resource_index = (int)(intptr_t)data;
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- device = find_resource_device(get_resource_type(res), resource_index);
+ device = syscommon_resman_find_resource_device(syscommon_resman_get_resource_type(res), resource_index);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- get_resource_name(res), resource_index);
+ syscommon_resman_get_resource_name(res), resource_index);
return -EINVAL;
}
@@ -216,7 +219,7 @@ static int cpu_setup_cluster_id(struct resource *res,
return 0;
}
-static const struct resource_control cpu_ctrls[] = {
+static const struct syscommon_resman_resource_control cpu_ctrls[] = {
{
.name = "CPU_CTRL_CLUSTER_ID",
.id = CPU_CTRL_CLUSTER_ID,
@@ -226,27 +229,27 @@ static const struct resource_control cpu_ctrls[] = {
},
};
-static int cpu_create(struct resource *res)
+static int cpu_create(struct syscommon_resman_resource *res)
{
- struct cpu_context *ctx = get_resource_privdata(res);
+ struct cpu_context *ctx = syscommon_resman_get_resource_privdata(res);
ctx = calloc(1, sizeof(struct cpu_context));
if (!ctx)
return -ENOMEM;
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
return 0;
}
-static void cpu_delete(struct resource *res)
+static void cpu_delete(struct syscommon_resman_resource *res)
{
struct cpu_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
@@ -256,10 +259,10 @@ static void cpu_delete(struct resource *res)
}
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
-static const struct resource_driver cpu_resource_driver = {
+static const struct syscommon_resman_resource_driver cpu_resource_driver = {
.name = "CPU",
.type = RESOURCE_TYPE_CPU,
.attrs = cpu_attrs,
@@ -271,5 +274,5 @@ static const struct resource_driver cpu_resource_driver = {
.delete = cpu_delete,
},
};
-RESOURCE_DRIVER_REGISTER(&cpu_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&cpu_resource_driver)
diff --git a/src/resource/resource-disk.c b/src/resource/resource-disk.c
index 02b08eb..aff1ce3 100644
--- a/src/resource/resource-disk.c
+++ b/src/resource/resource-disk.c
@@ -29,7 +29,10 @@
#include <util/common.h>
#include <util/devices.h>
#include <util/log.h>
-#include <util/resource.h>
+
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <libsyscommon/resource-device.h>
#include <resource-monitor/resource-monitor.h>
@@ -74,8 +77,8 @@ struct disk_context {
u_int32_t write_total;
};
-static int disk_get_value(struct resource *res,
- const struct resource_attribute *attr,
+static int disk_get_value(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct disk_context *ctx;
@@ -83,13 +86,13 @@ static int disk_get_value(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("DISK_CTRL_DEVICE_ID is not yet initialized, res:name(%s) | attr:name(%s)id(%"PRId64")\n",
- get_resource_name(res), get_resource_attr_name(res, attr->id), attr->id);
+ syscommon_resman_get_resource_name(res), syscommon_resman_get_resource_attr_name(res, attr->id), attr->id);
return -EINVAL;
}
@@ -116,69 +119,69 @@ static int disk_get_value(struct resource *res,
return 0;
}
-static const struct resource_attribute disk_attrs[] = {
+static const struct syscommon_resman_resource_attribute disk_attrs[] = {
{
.name = "DISK_ATTR_NAME",
.id = DISK_ATTR_NAME,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = disk_get_value,
},
}, {
.name = "DISK_ATTR_READ_PER_SEC",
.id = DISK_ATTR_READ_PER_SEC,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = disk_get_value,
},
}, {
.name = "DISK_ATTR_WRITE_PER_SEC",
.id = DISK_ATTR_WRITE_PER_SEC,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = disk_get_value,
},
}, {
.name = "DISK_ATTR_READ_TOTAL",
.id = DISK_ATTR_READ_TOTAL,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = disk_get_value,
},
}, {
.name = "DISK_ATTR_WRITE_TOTAL",
.id = DISK_ATTR_WRITE_TOTAL,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = disk_get_value,
},
},
};
-static int disk_setup_device_id(struct resource *res,
- const struct resource_control *ctrl,
+static int disk_setup_device_id(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct disk_context *ctx;
- const struct resource_device *device;
+ const struct syscommon_resman_resource_device *device;
int resource_index = (int)(intptr_t)data;
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- device = find_resource_device(get_resource_type(res), resource_index);
+ device = syscommon_resman_find_resource_device(syscommon_resman_get_resource_type(res), resource_index);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- get_resource_name(res), resource_index);
+ syscommon_resman_get_resource_name(res), resource_index);
return -EINVAL;
}
@@ -191,7 +194,7 @@ static int disk_setup_device_id(struct resource *res,
return 0;
}
-static const struct resource_control disk_ctrls[] = {
+static const struct syscommon_resman_resource_control disk_ctrls[] = {
{
.name = "DISK_CTRL_DEVICE_ID",
.id = DISK_CTRL_DEVICE_ID,
@@ -327,7 +330,7 @@ static int calculate_disk_stats(struct disk_context *ctx)
return 0;
}
-static int disk_create(struct resource *res)
+static int disk_create(struct syscommon_resman_resource *res)
{
struct disk_context *ctx;
@@ -337,19 +340,19 @@ static int disk_create(struct resource *res)
ctx->index = -1;
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
return 0;
}
-static void disk_delete(struct resource *res)
+static void disk_delete(struct syscommon_resman_resource *res)
{
struct disk_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
@@ -357,10 +360,10 @@ static void disk_delete(struct resource *res)
free(ctx->device_name);
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
-static int disk_prepare_update(struct resource *res)
+static int disk_prepare_update(struct syscommon_resman_resource *res)
{
struct disk_context *ctx;
int ret;
@@ -368,13 +371,13 @@ static int disk_prepare_update(struct resource *res)
if (!res)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: DISK_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -400,7 +403,7 @@ static int disk_prepare_update(struct resource *res)
return 0;
}
-static const struct resource_driver disk_resource_driver = {
+static const struct syscommon_resman_resource_driver disk_resource_driver = {
.name = "DISK",
.type = RESOURCE_TYPE_DISK,
.attrs = disk_attrs,
@@ -413,4 +416,4 @@ static const struct resource_driver disk_resource_driver = {
.prepare_update = disk_prepare_update,
},
};
-RESOURCE_DRIVER_REGISTER(&disk_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&disk_resource_driver)
diff --git a/src/resource/resource-display.c b/src/resource/resource-display.c
index 8c2ccfc..154b7af 100644
--- a/src/resource/resource-display.c
+++ b/src/resource/resource-display.c
@@ -28,10 +28,13 @@
#include <util/common.h>
#include <util/devices.h>
#include <util/log.h>
-#include <util/resource.h>
#include <util/gdbus-util.h>
#include <util/thread.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <libsyscommon/resource-device.h>
+
#include <resource-monitor/resource-monitor.h>
#define DBUS_ENLIGHTENMENT_NAME "org.enlightenment.wm"
@@ -130,8 +133,8 @@ err_conn:
return ret;
}
-static int display_get_fps(struct resource *res,
- const struct resource_attribute *attr,
+static int display_get_fps(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct display_context *ctx;
@@ -140,13 +143,13 @@ static int display_get_fps(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: DISPLAY_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -155,8 +158,8 @@ static int display_get_fps(struct resource *res,
return 0;
}
-static int display_get_name(struct resource *res,
- const struct resource_attribute *attr,
+static int display_get_name(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct display_context *ctx;
@@ -165,13 +168,13 @@ static int display_get_name(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: DISPLAY_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -180,45 +183,45 @@ static int display_get_name(struct resource *res,
return 0;
}
-static const struct resource_attribute display_attrs[] = {
+static const struct syscommon_resman_resource_attribute display_attrs[] = {
{
.name = "DISPLAY_ATTR_FPS",
.id = DISPLAY_ATTR_FPS,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = display_get_fps,
},
}, {
.name = "DISPLAY_ATTR_NAME",
.id = DISPLAY_ATTR_NAME,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = display_get_name,
},
},
};
-static int display_setup_device_id(struct resource *res,
- const struct resource_control *ctrl,
+static int display_setup_device_id(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct display_context *ctx;
- const struct resource_device *device;
+ const struct syscommon_resman_resource_device *device;
int resource_index = (int)(intptr_t)data;
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- device = find_resource_device(get_resource_type(res), resource_index);
+ device = syscommon_resman_find_resource_device(syscommon_resman_get_resource_type(res), resource_index);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- get_resource_name(res), resource_index);
+ syscommon_resman_get_resource_name(res), resource_index);
return -EINVAL;
}
@@ -231,7 +234,7 @@ static int display_setup_device_id(struct resource *res,
return 0;
}
-static const struct resource_control display_ctrls[] = {
+static const struct syscommon_resman_resource_control display_ctrls[] = {
{
.name = "DISPLAY_CTRL_DEVICE_ID",
.id = DISPLAY_CTRL_DEVICE_ID,
@@ -251,7 +254,7 @@ static int display_monitor_func(void *data, void **result)
return THREAD_RETURN_CONTINUE;
}
-static int display_create(struct resource *res)
+static int display_create(struct syscommon_resman_resource *res)
{
int ret = 0;
struct display_context *ctx;
@@ -262,7 +265,7 @@ static int display_create(struct resource *res)
ctx->index = -1;
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
g_mutex_lock(&g_fps_monitor.display_lock);
if (g_fps_monitor.holder++ == 0)
@@ -272,14 +275,14 @@ static int display_create(struct resource *res)
return ret;
}
-static void display_delete(struct resource *res)
+static void display_delete(struct syscommon_resman_resource *res)
{
struct display_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
@@ -287,7 +290,7 @@ static void display_delete(struct resource *res)
free(ctx->device_name);
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
g_mutex_lock(&g_fps_monitor.display_lock);
if (--g_fps_monitor.holder == 0)
@@ -299,7 +302,7 @@ static int display_init(void)
{
int ret;
- g_fps_monitor.resource_count = get_resource_device_count(RESOURCE_TYPE_DISPLAY);
+ g_fps_monitor.resource_count = syscommon_resman_get_resource_device_count(RESOURCE_TYPE_DISPLAY);
if (g_fps_monitor.resource_count < 0)
return g_fps_monitor.resource_count;
@@ -328,7 +331,7 @@ static void display_exit(void)
g_fps_monitor.resource_count = 0;
}
-static const struct resource_driver display_resource_driver = {
+static const struct syscommon_resman_resource_driver display_resource_driver = {
.name = "DISPLAY",
.type = RESOURCE_TYPE_DISPLAY,
.attrs = display_attrs,
@@ -342,4 +345,4 @@ static const struct resource_driver display_resource_driver = {
.exit = display_exit,
},
};
-RESOURCE_DRIVER_REGISTER(&display_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&display_resource_driver)
diff --git a/src/resource/resource-gpu.c b/src/resource/resource-gpu.c
index f112845..0d9bf31 100644
--- a/src/resource/resource-gpu.c
+++ b/src/resource/resource-gpu.c
@@ -29,7 +29,10 @@
#include <util/common.h>
#include <util/devices.h>
#include <util/log.h>
-#include <util/resource.h>
+
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <libsyscommon/resource-device.h>
#include <resource-monitor/resource-monitor.h>
@@ -38,8 +41,8 @@ struct gpu_context {
int index;
};
-static int gpu_get_value_from_hal_power(struct resource *res,
- const struct resource_attribute *attr,
+static int gpu_get_value_from_hal_power(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct gpu_context *ctx;
@@ -50,17 +53,17 @@ static int gpu_get_value_from_hal_power(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: GPU_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
- type = get_resource_type(res);
+ type = syscommon_resman_get_resource_type(res);
switch (attr->id) {
case GPU_ATTR_CUR_FREQ:
@@ -90,8 +93,8 @@ static int gpu_get_value_from_hal_power(struct resource *res,
return 0;
}
-static int gpu_get_string_value(struct resource *res,
- const struct resource_attribute *attr,
+static int gpu_get_string_value(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct gpu_context *ctx;
@@ -101,19 +104,19 @@ static int gpu_get_string_value(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: GPU_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
switch (attr->id) {
case GPU_ATTR_CUR_GOVERNOR:
- val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ val = hal_power_dvfs_get_curr_governor(syscommon_resman_get_resource_type(res),
ctx->device_name, buf);
if (val < 0)
return -EINVAL;
@@ -126,85 +129,85 @@ static int gpu_get_string_value(struct resource *res,
return 0;
}
-static const struct resource_attribute gpu_attrs[] = {
+static const struct syscommon_resman_resource_attribute gpu_attrs[] = {
{
.name = "GPU_ATTR_CUR_FREQ",
.id = GPU_ATTR_CUR_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = gpu_get_value_from_hal_power,
},
}, {
.name = "GPU_ATTR_MIN_FREQ",
.id = GPU_ATTR_MIN_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = gpu_get_value_from_hal_power,
},
}, {
.name = "GPU_ATTR_MAX_FREQ",
.id = GPU_ATTR_MAX_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = gpu_get_value_from_hal_power,
}
}, {
.name = "GPU_ATTR_AVAILABLE_MIN_FREQ",
.id = GPU_ATTR_AVAILABLE_MIN_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = gpu_get_value_from_hal_power,
}
}, {
.name = "GPU_ATTR_AVAILABLE_MAX_FREQ",
.id = GPU_ATTR_AVAILABLE_MAX_FREQ,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = gpu_get_value_from_hal_power,
}
}, {
.name = "GPU_ATTR_CUR_GOVERNOR",
.id = GPU_ATTR_CUR_GOVERNOR,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = gpu_get_string_value,
}
}, {
.name = "GPU_ATTR_NAME",
.id = GPU_ATTR_NAME,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = gpu_get_string_value,
}
},
};
-static int gpu_setup_device_id(struct resource *res,
- const struct resource_control *ctrl,
+static int gpu_setup_device_id(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct gpu_context *ctx;
- const struct resource_device *device;
+ const struct syscommon_resman_resource_device *device;
int resource_index = (int)(intptr_t)data;
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- device = find_resource_device(get_resource_type(res), resource_index);
+ device = syscommon_resman_find_resource_device(syscommon_resman_get_resource_type(res), resource_index);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- get_resource_name(res), resource_index);
+ syscommon_resman_get_resource_name(res), resource_index);
return -EINVAL;
}
@@ -217,7 +220,7 @@ static int gpu_setup_device_id(struct resource *res,
return 0;
}
-static const struct resource_control gpu_ctrls[] = {
+static const struct syscommon_resman_resource_control gpu_ctrls[] = {
{
.name = "GPU_CTRL_DEVICE_ID",
.id = GPU_CTRL_DEVICE_ID,
@@ -227,7 +230,7 @@ static const struct resource_control gpu_ctrls[] = {
},
};
-static int gpu_create(struct resource *res)
+static int gpu_create(struct syscommon_resman_resource *res)
{
struct gpu_context *ctx;
@@ -235,19 +238,19 @@ static int gpu_create(struct resource *res)
if (!ctx)
return -ENOMEM;
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
return 0;
}
-static void gpu_delete(struct resource *res)
+static void gpu_delete(struct syscommon_resman_resource *res)
{
struct gpu_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
@@ -256,10 +259,10 @@ static void gpu_delete(struct resource *res)
ctx->device_name = NULL;
}
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
-static const struct resource_driver gpu_resource_driver = {
+static const struct syscommon_resman_resource_driver gpu_resource_driver = {
.name = "GPU",
.type = RESOURCE_TYPE_GPU,
.attrs = gpu_attrs,
@@ -271,4 +274,4 @@ static const struct resource_driver gpu_resource_driver = {
.delete = gpu_delete,
},
};
-RESOURCE_DRIVER_REGISTER(&gpu_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&gpu_resource_driver)
diff --git a/src/resource/resource-memory.c b/src/resource/resource-memory.c
index 1ddfa14..cee56f9 100644
--- a/src/resource/resource-memory.c
+++ b/src/resource/resource-memory.c
@@ -26,9 +26,11 @@
#include <util/common.h>
#include <util/log.h>
-#include <util/resource.h>
#include <util/kernel.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+
#include <resource-monitor/resource-monitor.h>
#define PROC_MEM_INFO_MEM_AVAILABLE "MemAvailable"
@@ -74,8 +76,8 @@ static int memory_get_swap_total(u_int64_t *val)
return 0;
}
-static int memory_get_memory_info(struct resource *res,
- const struct resource_attribute *attr,
+static int memory_get_memory_info(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
u_int64_t *val = (u_int64_t *)data;
@@ -122,87 +124,87 @@ static int memory_get_memory_info(struct resource *res,
return 0;
}
-static const struct resource_attribute memory_attrs[] = {
+static const struct syscommon_resman_resource_attribute memory_attrs[] = {
{
.name = "MEMORY_ATTR_TOTAL",
.id = MEMORY_ATTR_TOTAL,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
},
}, {
.name = "MEMORY_ATTR_AVAILABLE",
.id = MEMORY_ATTR_AVAILABLE,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
},
}, {
.name = "MEMORY_ATTR_FREE",
.id = MEMORY_ATTR_FREE,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
}
}, {
.name = "MEMORY_ATTR_BUFFER",
.id = MEMORY_ATTR_BUFFER,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
}
}, {
.name = "MEMORY_ATTR_CACHED",
.id = MEMORY_ATTR_CACHED,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
}
}, {
.name = "MEMORY_ATTR_CMA_TOTAL",
.id = MEMORY_ATTR_CMA_TOTAL,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
}
}, {
.name = "MEMORY_ATTR_CMA_FREE",
.id = MEMORY_ATTR_CMA_FREE,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
}
}, {
.name = "MEMORY_ATTR_SWAP_TOTAL",
.id = MEMORY_ATTR_SWAP_TOTAL,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
}
}, {
.name = "MEMORY_ATTR_SWAP_FREE",
.id = MEMORY_ATTR_SWAP_FREE,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = memory_get_memory_info,
}
},
};
-static const struct resource_driver memory_resource_driver = {
+static const struct syscommon_resman_resource_driver memory_resource_driver = {
.name = "MEMORY",
.type = RESOURCE_TYPE_MEMORY,
- .flag = RESOURCE_FLAG_COUNT_ONLY_ONE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE,
.attrs = memory_attrs,
.num_attrs = ARRAY_SIZE(memory_attrs),
};
-RESOURCE_DRIVER_REGISTER(&memory_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&memory_resource_driver)
diff --git a/src/resource/resource-network.c b/src/resource/resource-network.c
index aabadb4..d5b6507 100644
--- a/src/resource/resource-network.c
+++ b/src/resource/resource-network.c
@@ -29,7 +29,10 @@
#include <util/common.h>
#include <util/devices.h>
#include <util/log.h>
-#include <util/resource.h>
+
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <libsyscommon/resource-device.h>
#include <resource-monitor/resource-monitor.h>
@@ -38,8 +41,8 @@ struct network_context {
int index;
};
-static int network_get_name(struct resource *res,
- const struct resource_attribute *attr,
+static int network_get_name(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct network_context *ctx;
@@ -48,13 +51,13 @@ static int network_get_name(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->device_name) {
_E("%s: NETWORK_CTRL_DEVICE_ID is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -63,37 +66,37 @@ static int network_get_name(struct resource *res,
return 0;
}
-static const struct resource_attribute network_attrs[] = {
+static const struct syscommon_resman_resource_attribute network_attrs[] = {
{
.name = "NETWORK_ATTR_NAME",
.id = NETWORK_ATTR_NAME,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = network_get_name,
},
},
};
-static int network_setup_device_id(struct resource *res,
- const struct resource_control *ctrl,
+static int network_setup_device_id(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct network_context *ctx;
- const struct resource_device *device;
+ const struct syscommon_resman_resource_device *device;
int resource_index = (int)(intptr_t)data;
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- device = find_resource_device(get_resource_type(res), resource_index);
+ device = syscommon_resman_find_resource_device(syscommon_resman_get_resource_type(res), resource_index);
if (!device) {
_E("Not available resource: type: %s, index: %d\n",
- get_resource_name(res), resource_index);
+ syscommon_resman_get_resource_name(res), resource_index);
return -EINVAL;
}
@@ -106,7 +109,7 @@ static int network_setup_device_id(struct resource *res,
return 0;
}
-static const struct resource_control network_ctrls[] = {
+static const struct syscommon_resman_resource_control network_ctrls[] = {
{
.name = "NETWORK_CTRL_DEVICE_ID",
.id = NETWORK_CTRL_DEVICE_ID,
@@ -116,7 +119,7 @@ static const struct resource_control network_ctrls[] = {
},
};
-static int network_create(struct resource *res)
+static int network_create(struct syscommon_resman_resource *res)
{
struct network_context *ctx;
@@ -126,19 +129,19 @@ static int network_create(struct resource *res)
ctx->index = -1;
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
return 0;
}
-static void network_delete(struct resource *res)
+static void network_delete(struct syscommon_resman_resource *res)
{
struct network_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
@@ -146,10 +149,10 @@ static void network_delete(struct resource *res)
free(ctx->device_name);
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
-static const struct resource_driver network_resource_driver = {
+static const struct syscommon_resman_resource_driver network_resource_driver = {
.name = "NETWORK",
.type = RESOURCE_TYPE_NETWORK,
.attrs = network_attrs,
@@ -161,4 +164,4 @@ static const struct resource_driver network_resource_driver = {
.delete = network_delete,
},
};
-RESOURCE_DRIVER_REGISTER(&network_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&network_resource_driver)
diff --git a/src/resource/resource-process-group.c b/src/resource/resource-process-group.c
index 3985ac6..fcad513 100644
--- a/src/resource/resource-process-group.c
+++ b/src/resource/resource-process-group.c
@@ -17,10 +17,12 @@
*/
#include <util/log.h>
-#include <util/resource.h>
#include <util/kernel.h>
#include <linux/taskstats.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+
#include <resource-monitor/resource-monitor.h>
#define PROC_DIR_PATH "/proc/"
@@ -53,12 +55,12 @@ static u_int64_t total_memory;
static long jiffy;
static bool taskstat_support;
-static int process_group_get_pid_list(struct resource *res,
- const struct resource_attribute *attr,
+static int process_group_get_pid_list(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_group_context *ctx;
- struct array_value *list = data;
+ struct syscommon_resman_array_value *list = data;
struct process_info_node *node;
GHashTableIter iter;
gpointer key, value;
@@ -68,7 +70,7 @@ static int process_group_get_pid_list(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
@@ -78,7 +80,7 @@ static int process_group_get_pid_list(struct resource *res,
if (list->data)
free(list->data);
- list->type = DATA_TYPE_INT;
+ list->type = SYSCOMMON_RESMAN_DATA_TYPE_INT;
list->length = g_hash_table_size(ctx->pi_map);
data_array = list->data = malloc(sizeof(int) * list->length);
if (!data_array)
@@ -93,12 +95,12 @@ static int process_group_get_pid_list(struct resource *res,
return 0;
}
-static int process_group_get_name_list(struct resource *res,
- const struct resource_attribute *attr,
+static int process_group_get_name_list(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_group_context *ctx;
- struct array_value *list = data;
+ struct syscommon_resman_array_value *list = data;
struct process_info_node *node;
GHashTableIter iter;
gpointer key, value;
@@ -108,7 +110,7 @@ static int process_group_get_name_list(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
@@ -122,7 +124,7 @@ static int process_group_get_name_list(struct resource *res,
free(data_array);
}
- list->type = DATA_TYPE_STRING;
+ list->type = SYSCOMMON_RESMAN_DATA_TYPE_STRING;
list->length = g_hash_table_size(ctx->pi_map);
/* last item will be null for boundary check */
@@ -146,8 +148,8 @@ static int process_group_get_name_list(struct resource *res,
return 0;
}
-static int process_group_get_cpu_util(struct resource *res,
- const struct resource_attribute *attr,
+static int process_group_get_cpu_util(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_group_context *ctx;
@@ -156,7 +158,7 @@ static int process_group_get_cpu_util(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
@@ -168,8 +170,8 @@ static int process_group_get_cpu_util(struct resource *res,
return 0;
}
-static int process_group_get_mem(struct resource *res,
- const struct resource_attribute *attr,
+static int process_group_get_mem(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_group_context *ctx;
@@ -178,7 +180,7 @@ static int process_group_get_mem(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
@@ -211,8 +213,8 @@ static int process_group_get_mem(struct resource *res,
return 0;
}
-static int process_group_get_disk_attrs(struct resource *res,
- const struct resource_attribute *attr,
+static int process_group_get_disk_attrs(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_group_context *ctx;
@@ -220,7 +222,7 @@ static int process_group_get_disk_attrs(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
@@ -240,24 +242,24 @@ static int process_group_get_disk_attrs(struct resource *res,
return 0;
}
-static bool process_group_check_taskstat_support(struct resource *resource,
- const struct resource_attribute *attr)
+static bool process_group_check_taskstat_support(struct syscommon_resman_resource *resource,
+ const struct syscommon_resman_resource_attribute *attr)
{
return taskstat_support;
}
-static bool process_group_check_gpu_support(struct resource *resource,
- const struct resource_attribute *attr)
+static bool process_group_check_gpu_support(struct syscommon_resman_resource *resource,
+ const struct syscommon_resman_resource_attribute *attr)
{
return taskstat_support && kernel_check_gpu_support();
}
-static const struct resource_attribute process_group_attrs[] = {
+static const struct syscommon_resman_resource_attribute process_group_attrs[] = {
{
.name = "PROCESS_GROUP_ATTR_PID_LIST",
.id = PROCESS_GROUP_ATTR_PID_LIST,
- .type = DATA_TYPE_ARRAY,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_pid_list,
.is_supported = process_group_check_taskstat_support,
@@ -265,8 +267,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_NAME_LIST",
.id = PROCESS_GROUP_ATTR_NAME_LIST,
- .type = DATA_TYPE_ARRAY,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_name_list,
.is_supported = process_group_check_taskstat_support,
@@ -274,8 +276,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_CPU_UTIL",
.id = PROCESS_GROUP_ATTR_CPU_UTIL,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_cpu_util,
.is_supported = process_group_check_taskstat_support,
@@ -283,8 +285,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_DISK_READ_PER_SEC",
.id = PROCESS_GROUP_ATTR_DISK_READ_PER_SEC,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_disk_attrs,
.is_supported = process_group_check_taskstat_support,
@@ -292,8 +294,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC",
.id = PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_disk_attrs,
.is_supported = process_group_check_taskstat_support,
@@ -301,8 +303,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_MEM_VIRT",
.id = PROCESS_GROUP_ATTR_MEM_VIRT,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_mem,
.is_supported = process_group_check_taskstat_support,
@@ -310,8 +312,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_MEM_RSS",
.id = PROCESS_GROUP_ATTR_MEM_RSS,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_mem,
.is_supported = process_group_check_taskstat_support,
@@ -319,8 +321,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_MEM_PSS",
.id = PROCESS_GROUP_ATTR_MEM_PSS,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_mem,
.is_supported = process_group_check_taskstat_support,
@@ -328,8 +330,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_MEM_SWAP",
.id = PROCESS_GROUP_ATTR_MEM_SWAP,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_mem,
.is_supported = process_group_check_taskstat_support,
@@ -337,8 +339,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_MEM_SWAP_PSS",
.id = PROCESS_GROUP_ATTR_MEM_SWAP_PSS,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_mem,
.is_supported = process_group_check_taskstat_support,
@@ -346,8 +348,8 @@ static const struct resource_attribute process_group_attrs[] = {
}, {
.name = "PROCESS_GROUP_ATTR_MEM_GPU",
.id = PROCESS_GROUP_ATTR_MEM_GPU,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_group_get_mem,
.is_supported = process_group_check_gpu_support,
@@ -355,8 +357,8 @@ static const struct resource_attribute process_group_attrs[] = {
},
};
-static int process_group_setup_root_pid(struct resource *res,
- const struct resource_control *ctrl,
+static int process_group_setup_root_pid(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct taskstats stats;
@@ -367,7 +369,7 @@ static int process_group_setup_root_pid(struct resource *res,
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
@@ -390,7 +392,7 @@ static int process_group_setup_root_pid(struct resource *res,
return 0;
}
-static const struct resource_control process_group_ctrls[] = {
+static const struct syscommon_resman_resource_control process_group_ctrls[] = {
{
.name = "PROCESS_GROUP_CTRL_ROOT_PID",
.id = PROCESS_GROUP_CTRL_ROOT_PID,
@@ -431,7 +433,7 @@ static u_int64_t get_total_cpu_time(void)
return total_time;
}
-static int update_aggr_taskstats(struct process_group_context *ctx, struct resource *res)
+static int update_aggr_taskstats(struct process_group_context *ctx, struct syscommon_resman_resource *res)
{
struct process_info_node *node;
struct taskstats *prev, *curr;
@@ -443,7 +445,7 @@ static int update_aggr_taskstats(struct process_group_context *ctx, struct resou
gpointer key, value;
pid_t pid;
int ret;
- bool include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
+ bool include_gpu_mem = syscommon_resman_is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
memset(&ctx->info, 0, sizeof(ctx->info));
@@ -517,7 +519,7 @@ static int update_aggr_taskstats(struct process_group_context *ctx, struct resou
return 0;
}
-static int process_group_prepare_update(struct resource *res)
+static int process_group_prepare_update(struct syscommon_resman_resource *res)
{
struct process_group_context *ctx;
struct process_info_node *pnode, *parent_pnode;
@@ -533,7 +535,7 @@ static int process_group_prepare_update(struct resource *res)
if (!res)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
@@ -660,7 +662,7 @@ out_close:
return ret;
}
-static int process_group_create(struct resource *res)
+static int process_group_create(struct syscommon_resman_resource *res)
{
struct process_group_context *ctx;
@@ -671,19 +673,19 @@ static int process_group_create(struct resource *res)
ctx->pid = -1;
ctx->pi_map = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free_node);
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
return 0;
}
-static void process_group_delete(struct resource *res)
+static void process_group_delete(struct syscommon_resman_resource *res)
{
struct process_group_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
@@ -693,7 +695,7 @@ static void process_group_delete(struct resource *res)
}
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
static int process_group_init(void)
@@ -715,10 +717,10 @@ static int process_group_init(void)
return 0;
}
-static const struct resource_driver process_group_driver = {
+static const struct syscommon_resman_resource_driver process_group_driver = {
.name = "PROCESS_GROUP",
.type = RESOURCE_TYPE_PROCESS_GROUP,
- .flag = RESOURCE_FLAG_PROCESS,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_UNCOUNTABLE,
.attrs = process_group_attrs,
.num_attrs = ARRAY_SIZE(process_group_attrs),
.ctrls = process_group_ctrls,
@@ -730,4 +732,4 @@ static const struct resource_driver process_group_driver = {
.init = process_group_init,
},
};
-RESOURCE_DRIVER_REGISTER(&process_group_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&process_group_driver)
diff --git a/src/resource/resource-process.c b/src/resource/resource-process.c
index f6c2a8b..f386638 100644
--- a/src/resource/resource-process.c
+++ b/src/resource/resource-process.c
@@ -20,9 +20,11 @@
#include <linux/taskstats.h>
#include <util/log.h>
-#include <util/resource.h>
#include <util/kernel.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+
#include <resource-monitor/resource-monitor.h>
struct process_context {
@@ -43,8 +45,8 @@ static u_int64_t total_memory;
static long jiffy;
static bool taskstat_support;
-static int process_get_cpu_util(struct resource *res,
- const struct resource_attribute *attr,
+static int process_get_cpu_util(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_context *ctx;
@@ -54,13 +56,13 @@ static int process_get_cpu_util(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->tgid) {
_E("resource %s is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -77,8 +79,8 @@ static int process_get_cpu_util(struct resource *res,
return 0;
}
-static int process_get_mem_attrs(struct resource *res,
- const struct resource_attribute *attr,
+static int process_get_mem_attrs(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_context *ctx;
@@ -88,13 +90,13 @@ static int process_get_mem_attrs(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->tgid) {
_E("resource %s is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -135,8 +137,8 @@ static int process_get_mem_attrs(struct resource *res,
return 0;
}
-static int process_get_disk_attrs(struct resource *res,
- const struct resource_attribute *attr,
+static int process_get_disk_attrs(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_context *ctx;
@@ -146,13 +148,13 @@ static int process_get_disk_attrs(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->tgid) {
_E("resource %s is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -174,8 +176,8 @@ static int process_get_disk_attrs(struct resource *res,
return 0;
}
-static int process_get_context_data(struct resource *res,
- const struct resource_attribute *attr,
+static int process_get_context_data(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct process_context *ctx;
@@ -183,13 +185,13 @@ static int process_get_context_data(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
if (!ctx->tgid) {
_E("resource %s is not yet initialized\n",
- get_resource_name(res));
+ syscommon_resman_get_resource_name(res));
return -EINVAL;
}
@@ -249,24 +251,24 @@ static int process_get_context_data(struct resource *res,
return 0;
}
-static bool process_check_taskstat_support(struct resource *resource,
- const struct resource_attribute *attr)
+static bool process_check_taskstat_support(struct syscommon_resman_resource *resource,
+ const struct syscommon_resman_resource_attribute *attr)
{
return taskstat_support;
}
-static bool process_check_gpu_support(struct resource *resource,
- const struct resource_attribute *attr)
+static bool process_check_gpu_support(struct syscommon_resman_resource *resource,
+ const struct syscommon_resman_resource_attribute *attr)
{
return kernel_check_gpu_support();
}
-static const struct resource_attribute process_attrs[] = {
+static const struct syscommon_resman_resource_attribute process_attrs[] = {
{
.name = "PROCESS_ATTR_CPU_UTIL",
.id = PROCESS_ATTR_CPU_UTIL,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_cpu_util,
.is_supported = process_check_taskstat_support,
@@ -274,8 +276,8 @@ static const struct resource_attribute process_attrs[] = {
}, {
.name = "PROCESS_ATTR_MEM_VIRT",
.id = PROCESS_ATTR_MEM_VIRT,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_mem_attrs,
.is_supported = process_check_taskstat_support,
@@ -283,8 +285,8 @@ static const struct resource_attribute process_attrs[] = {
}, {
.name = "PROCESS_ATTR_MEM_RSS",
.id = PROCESS_ATTR_MEM_RSS,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_mem_attrs,
.is_supported = process_check_taskstat_support,
@@ -292,8 +294,8 @@ static const struct resource_attribute process_attrs[] = {
}, {
.name = "PROCESS_ATTR_MEM_RSS_PERCENT",
.id = PROCESS_ATTR_MEM_RSS_PERCENT,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_mem_attrs,
.is_supported = process_check_taskstat_support,
@@ -301,8 +303,8 @@ static const struct resource_attribute process_attrs[] = {
}, {
.name = "PROCESS_ATTR_DISK_READ_PER_SEC",
.id = PROCESS_ATTR_DISK_READ_PER_SEC,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_disk_attrs,
.is_supported = process_check_taskstat_support,
@@ -310,8 +312,8 @@ static const struct resource_attribute process_attrs[] = {
}, {
.name = "PROCESS_ATTR_DISK_WRITE_PER_SEC",
.id = PROCESS_ATTR_DISK_WRITE_PER_SEC,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_disk_attrs,
.is_supported = process_check_taskstat_support,
@@ -319,62 +321,62 @@ static const struct resource_attribute process_attrs[] = {
}, {
.name = "PROCESS_ATTR_NAME",
.id = PROCESS_ATTR_NAME,
- .type = DATA_TYPE_STRING,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_context_data,
- .is_supported = resource_attr_supported_always,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
},
}, {
.name = "PROCESS_ATTR_PGID",
.id = PROCESS_ATTR_PGID,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_context_data,
- .is_supported = resource_attr_supported_always,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
},
}, {
.name = "PROCESS_ATTR_PPID",
.id = PROCESS_ATTR_PPID,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_context_data,
- .is_supported = resource_attr_supported_always,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
},
}, {
.name = "PROCESS_ATTR_MEM_PSS",
.id = PROCESS_ATTR_MEM_PSS,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_mem_attrs,
- .is_supported = resource_attr_supported_always,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
},
}, {
.name = "PROCESS_ATTR_MEM_SWAP",
.id = PROCESS_ATTR_MEM_SWAP,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_mem_attrs,
- .is_supported = resource_attr_supported_always,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
},
}, {
.name = "PROCESS_ATTR_MEM_SWAP_PSS",
.id = PROCESS_ATTR_MEM_SWAP_PSS,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_mem_attrs,
- .is_supported = resource_attr_supported_always,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
},
}, {
.name = "PROCESS_ATTR_MEM_GPU",
.id = PROCESS_ATTR_MEM_GPU,
- .type = DATA_TYPE_UINT64,
- .flag = RESOURCE_ATTR_FLAG_PRIVATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE,
.ops = {
.get = process_get_mem_attrs,
.is_supported = process_check_gpu_support,
@@ -402,8 +404,8 @@ static u_int64_t get_total_cpu_time(void)
return total_time;
}
-static int process_setup_tgid(struct resource *res,
- const struct resource_control *ctrl,
+static int process_setup_tgid(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_control *ctrl,
const void *data)
{
struct process_context *ctx;
@@ -413,11 +415,11 @@ static int process_setup_tgid(struct resource *res,
if (!res || !ctrl)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- include_gpu_mem = is_resource_attr_interested(res, PROCESS_ATTR_MEM_GPU);
+ include_gpu_mem = syscommon_resman_is_resource_attr_interested(res, PROCESS_ATTR_MEM_GPU);
memset(ctx, 0, sizeof(*ctx));
ctx->tgid = (pid_t)(intptr_t)data;
@@ -450,7 +452,7 @@ static int process_setup_tgid(struct resource *res,
return 0;
}
-static const struct resource_control process_ctrls[] = {
+static const struct syscommon_resman_resource_control process_ctrls[] = {
{
.name = "PROCESS_CTRL_TGID",
.id = PROCESS_CTRL_TGID,
@@ -460,7 +462,7 @@ static const struct resource_control process_ctrls[] = {
},
};
-static int process_prepare_update(struct resource *res)
+static int process_prepare_update(struct syscommon_resman_resource *res)
{
struct process_context *ctx;
u_int64_t total_time;
@@ -470,11 +472,11 @@ static int process_prepare_update(struct resource *res)
if (!res)
return -EINVAL;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return -EINVAL;
- include_gpu_mem = is_resource_attr_interested(res, PROCESS_ATTR_MEM_GPU);
+ include_gpu_mem = syscommon_resman_is_resource_attr_interested(res, PROCESS_ATTR_MEM_GPU);
if (taskstat_support) {
memcpy(&ctx->prev, &ctx->curr, sizeof(struct taskstats));
@@ -497,7 +499,7 @@ static int process_prepare_update(struct resource *res)
return 0;
}
-static int process_create(struct resource *res)
+static int process_create(struct syscommon_resman_resource *res)
{
struct process_context *ctx;
@@ -505,24 +507,24 @@ static int process_create(struct resource *res)
if (!ctx)
return -ENOMEM;
- set_resource_privdata(res, ctx);
+ syscommon_resman_set_resource_privdata(res, ctx);
return 0;
}
-static void process_delete(struct resource *res)
+static void process_delete(struct syscommon_resman_resource *res)
{
struct process_context *ctx;
if (!res)
return;
- ctx = get_resource_privdata(res);
+ ctx = syscommon_resman_get_resource_privdata(res);
if (!ctx)
return;
free(ctx);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
static int process_init(void)
@@ -543,10 +545,10 @@ static int process_init(void)
return 0;
}
-static const struct resource_driver process_resource_driver = {
+static const struct syscommon_resman_resource_driver process_resource_driver = {
.name = "PROCESS",
.type = RESOURCE_TYPE_PROCESS,
- .flag = RESOURCE_FLAG_PROCESS,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_UNCOUNTABLE,
.attrs = process_attrs,
.num_attrs = ARRAY_SIZE(process_attrs),
.ctrls = process_ctrls,
@@ -558,4 +560,4 @@ static const struct resource_driver process_resource_driver = {
.prepare_update = process_prepare_update,
},
};
-RESOURCE_DRIVER_REGISTER(&process_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&process_resource_driver)
diff --git a/src/resource/resource-system.c b/src/resource/resource-system.c
index 010c948..e615ca9 100644
--- a/src/resource/resource-system.c
+++ b/src/resource/resource-system.c
@@ -28,9 +28,11 @@
#include <util/common.h>
#include <util/log.h>
-#include <util/resource.h>
#include <util/kernel.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+
#include <resource-monitor/resource-monitor.h>
struct system_resource_data {
@@ -77,8 +79,8 @@ static double __calculate_cpu_util(int64_t id, struct cpu_stat *prev,
return util;
}
-static int system_get_avg_cpu_util(struct resource *res,
- const struct resource_attribute *attr,
+static int system_get_avg_cpu_util(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct system_resource_data *sysdata;
@@ -88,7 +90,7 @@ static int system_get_avg_cpu_util(struct resource *res,
if (!res || !attr || !data)
return -EINVAL;
- sysdata = get_resource_privdata(res);
+ sysdata = syscommon_resman_get_resource_privdata(res);
if (!sysdata)
return -EINVAL;
@@ -98,7 +100,7 @@ static int system_get_avg_cpu_util(struct resource *res,
&sysdata->curr_cpus[i]);
if (util < 0.0) {
_W("failed to calculate per-cpu util (%s: %s)\n",
- get_resource_name(res), attr->name);
+ syscommon_resman_get_resource_name(res), attr->name);
continue;
}
@@ -116,23 +118,23 @@ static int system_get_avg_cpu_util(struct resource *res,
return 0;
}
-static int system_get_per_cpu_util(struct resource *res,
- const struct resource_attribute *attr,
+static int system_get_per_cpu_util(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
struct system_resource_data *sysdata;
- struct array_value *array = (struct array_value *)data;
+ struct syscommon_resman_array_value *array = (struct syscommon_resman_array_value *)data;
double *utils;
int i;
if (!res || !attr || !data)
return -EINVAL;
- sysdata = get_resource_privdata(res);
+ sysdata = syscommon_resman_get_resource_privdata(res);
if (!sysdata)
return -EINVAL;
- array->type = DATA_TYPE_DOUBLE;
+ array->type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE;
array->length = sysdata->num_possible_cpus;
if (array->data)
@@ -150,7 +152,7 @@ static int system_get_per_cpu_util(struct resource *res,
&sysdata->curr_cpus[i]);
if (utils[i] < 0) {
_W("failed to calculate per-cpu util (%s: %s)\n",
- get_resource_name(res), attr->name);
+ syscommon_resman_get_resource_name(res), attr->name);
utils[i] = 0;
}
}
@@ -158,8 +160,8 @@ static int system_get_per_cpu_util(struct resource *res,
return 0;
}
-static int system_get_cpu_num(struct resource *res,
- const struct resource_attribute *attr,
+static int system_get_cpu_num(struct syscommon_resman_resource *res,
+ const struct syscommon_resman_resource_attribute *attr,
void *data)
{
int *cpu_num = (int *)data;
@@ -181,78 +183,78 @@ static int system_get_cpu_num(struct resource *res,
return 0;
}
-static const struct resource_attribute system_attrs[] = {
+static const struct syscommon_resman_resource_attribute system_attrs[] = {
{
.name = "SYSTEM_ATTR_CPU_UTIL",
.id = SYSTEM_ATTR_CPU_UTIL,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_avg_cpu_util,
}
}, {
.name = "SYSTEM_ATTR_CPU_USER_UTIL",
.id = SYSTEM_ATTR_CPU_USER_UTIL,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_avg_cpu_util,
}
}, {
.name = "SYSTEM_ATTR_CPU_SYS_UTIL",
.id = SYSTEM_ATTR_CPU_SYS_UTIL,
- .type = DATA_TYPE_DOUBLE,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_avg_cpu_util,
}
}, {
.name = "SYSTEM_ATTR_PER_CPU_UTIL",
.id = SYSTEM_ATTR_PER_CPU_UTIL,
- .type = DATA_TYPE_ARRAY,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_per_cpu_util,
}
}, {
.name = "SYSTEM_ATTR_PER_CPU_USER_UTIL",
.id = SYSTEM_ATTR_PER_CPU_USER_UTIL,
- .type = DATA_TYPE_ARRAY,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_per_cpu_util,
}
}, {
.name = "SYSTEM_ATTR_PER_CPU_SYS_UTIL",
.id = SYSTEM_ATTR_PER_CPU_SYS_UTIL,
- .type = DATA_TYPE_ARRAY,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_per_cpu_util,
}
}, {
.name = "SYSTEM_ATTR_POSSIBLE_CPU",
.id = SYSTEM_ATTR_POSSIBLE_CPU,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_cpu_num,
}
}, {
.name = "SYSTEM_ATTR_ONLINE_CPU",
.id = SYSTEM_ATTR_ONLINE_CPU,
- .type = DATA_TYPE_INT,
- .flag = RESOURCE_ATTR_FLAG_PUBLIC,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC,
.ops = {
.get = system_get_cpu_num,
}
},
};
-static int system_create(struct resource *res)
+static int system_create(struct syscommon_resman_resource *res)
{
struct system_resource_data *sysdata;
- const char *res_name = get_resource_name(res);
+ const char *res_name = syscommon_resman_get_resource_name(res);
int ret;
sysdata = calloc(1, sizeof(struct system_resource_data));
@@ -282,7 +284,7 @@ static int system_create(struct resource *res)
goto err_prev_cpus;
}
- set_resource_privdata(res, (void *)sysdata);
+ syscommon_resman_set_resource_privdata(res, (void *)sysdata);
return 0;
@@ -295,30 +297,30 @@ err:
return ret;
}
-static void system_delete(struct resource *res)
+static void system_delete(struct syscommon_resman_resource *res)
{
struct system_resource_data *sysdata;
if (!res)
return;
- sysdata = get_resource_privdata(res);
+ sysdata = syscommon_resman_get_resource_privdata(res);
if (!sysdata)
return;
free(sysdata->prev_cpus);
free(sysdata->curr_cpus);
free(sysdata);
- set_resource_privdata(res, NULL);
+ syscommon_resman_set_resource_privdata(res, NULL);
}
-static int system_driver_prepare_update(struct resource *res)
+static int system_driver_prepare_update(struct syscommon_resman_resource *res)
{
struct system_resource_data *sysdata;
- const char *res_name = get_resource_name(res);
+ const char *res_name = syscommon_resman_get_resource_name(res);
int ret;
- sysdata = get_resource_privdata(res);
+ sysdata = syscommon_resman_get_resource_privdata(res);
if (!sysdata)
return -EINVAL;
@@ -336,10 +338,10 @@ static int system_driver_prepare_update(struct resource *res)
return 0;
}
-static const struct resource_driver system_resource_driver = {
+static const struct syscommon_resman_resource_driver system_resource_driver = {
.name = "SYSTEM",
.type = RESOURCE_TYPE_SYSTEM,
- .flag = RESOURCE_FLAG_COUNT_ONLY_ONE,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE,
.attrs = system_attrs,
.num_attrs = ARRAY_SIZE(system_attrs),
.ops = {
@@ -348,4 +350,4 @@ static const struct resource_driver system_resource_driver = {
.prepare_update = system_driver_prepare_update,
},
};
-RESOURCE_DRIVER_REGISTER(&system_resource_driver)
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&system_resource_driver)
diff --git a/src/thermal/thermal-parser.c b/src/thermal/thermal-parser.c
index 781a31d..0da06df 100644
--- a/src/thermal/thermal-parser.c
+++ b/src/thermal/thermal-parser.c
@@ -38,6 +38,8 @@
#include <util/log.h>
#include <util/common.h>
+#include <libsyscommon/resource-type.h>
+
#include "thermal.h"
/**
@@ -53,8 +55,8 @@ static int thermal_parse_scenario(json_object *obj, struct scenario *scenario)
bool support;
int ret = 0;
struct config_property thermal_scenario_properties[] = {
- { "name", DATA_TYPE_STRING, true, (void *)name },
- {"support", DATA_TYPE_BOOLEAN, false, (void *)&support },
+ { "name", SYSCOMMON_RESMAN_DATA_TYPE_STRING, true, (void *)name },
+ {"support", SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN, false, (void *)&support },
};
/* Get property values */
@@ -87,7 +89,7 @@ static int thermal_load_config(json_object *obj, struct thermal_scenario *scenar
json_object *thermal_scenario_list = NULL;
int num_scenarios = 0, ret = 0, i;
struct config_property thermal_header_properties[] = {
- {"thermal_support", DATA_TYPE_BOOLEAN, false, (void *)&thermal_support },
+ {"thermal_support", SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN, false, (void *)&thermal_support },
};
/* Get property values */
diff --git a/src/util/common.c b/src/util/common.c
index d58c2e0..65635ad 100644
--- a/src/util/common.c
+++ b/src/util/common.c
@@ -37,6 +37,8 @@
#include <util/log.h>
#include <util/common.h>
+#include <libsyscommon/resource-type.h>
+
#define BUFF_MAX 255
static int sys_read_buf(const char *file, char *buf)
@@ -152,24 +154,24 @@ int get_property(json_object *obj, const char *key,
bool val_bool;
switch (type) {
- case DATA_TYPE_INT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
ret = get_int_from_object(obj, key, (int *)data);
if (ret < 0)
*(int *)data = ret;
break;
- case DATA_TYPE_DOUBLE:
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
ret = get_double_from_object(obj, key, (double *)data);
if (ret < 0)
*(double *)data = (double)ret;
break;
- case DATA_TYPE_STRING:
+ case SYSCOMMON_RESMAN_DATA_TYPE_STRING:
val_str = get_string_from_object(obj, key);
if (!val_str)
ret = -EINVAL;
else
snprintf((char *)data, BUFF_MAX, "%s", val_str);
break;
- case DATA_TYPE_BOOLEAN:
+ case SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN:
ret = get_boolean_from_object(obj, key, (bool *)&val_bool);
if (ret < 0)
*(bool *)data = true;
diff --git a/src/util/devices.c b/src/util/devices.c
index 565db53..0ad12dd 100644
--- a/src/util/devices.c
+++ b/src/util/devices.c
@@ -24,66 +24,6 @@
#include <util/log.h>
static GList *dev_head;
-static GList *g_resource_device_head;
-
-int get_resource_device_count(int resource_type)
-{
- GList *node;
- struct resource_device *device;
- int count = 0;
-
- for (node = g_resource_device_head; node != NULL; node = node->next) {
- device = node->data;
- if (device->type == resource_type)
- count++;
- }
-
- return count;
-}
-
-const struct resource_device *find_resource_device(int resource_type,
- int resource_index)
-{
- GList *node;
- const struct resource_device *device;
-
- for (node = g_resource_device_head; node != NULL; node = node->next) {
- device = node->data;
- if (device->type == resource_type &&
- device->index == resource_index)
- return device;
- }
-
- return NULL;
-}
-
-int add_resource_device(struct resource_device *device)
-{
- int count;
-
- if (!device)
- return -EINVAL;
-
- count = get_resource_device_count(device->type);
- if (count < 0)
- return count;
-
- device->index = count;
-
- g_resource_device_head =
- g_list_append(g_resource_device_head, (gpointer)device);
-
- return 0;
-}
-
-void remove_resource_device(struct resource_device *device)
-{
- if (!device)
- return;
-
- g_resource_device_head =
- g_list_remove(g_resource_device_head, (gpointer)device);
-}
void add_device(const struct device_ops *dev)
{
diff --git a/src/util/resource.c b/src/util/resource.c
deleted file mode 100644
index 75fb89e..0000000
--- a/src/util/resource.c
+++ /dev/null
@@ -1,1047 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * 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 <glib.h>
-#include <stdio.h>
-#include <json.h>
-
-#include <util/common.h>
-#include <util/resource.h>
-#include <util/log.h>
-
-#include <resource-monitor/resource-monitor.h>
-
-#define RESOURCE_ATTR_MASK (ULLONG_MAX)
-#define BIT64_INDEX(id) (63 - __builtin_clzll(id))
-#define RESOURCE_ATTR_INDEX(id) BIT64_INDEX(id)
-#define RESOURCE_CTRL_INDEX(id) BIT64_INDEX(id)
-
-static GList *g_resource_driver_head;
-
-static gint __compare_resource_type(gconstpointer data, gconstpointer input)
-{
- struct resource_driver *driver = (struct resource_driver *)data;
- int type = *(int *)input;
-
- if (driver->type == type)
- return 0;
- return -1;
-}
-
-const struct resource_driver *find_resource_driver(int resource_type)
-{
- GList *node;
-
- node = g_list_find_custom(g_resource_driver_head,
- &resource_type, __compare_resource_type);
-
- if (!node)
- return NULL;
- return (struct resource_driver *)node->data;
-}
-
-void add_resource_driver(const struct resource_driver *driver)
-{
- if (!driver)
- return;
-
- g_resource_driver_head =
- g_list_append(g_resource_driver_head, (gpointer)driver);
-}
-
-void remove_resource_driver(const struct resource_driver *driver)
-{
- if (!driver)
- return;
-
- g_resource_driver_head =
- g_list_remove(g_resource_driver_head, (gpointer)driver);
-}
-
-static void do_delete_resource(struct resource *resource)
-{
- if (!resource->name)
- free(resource->name);
- if (!resource->attrs_value)
- free(resource->attrs_value);
- resource->attrs = NULL;
- resource->num_attrs = 0;
-
- free(resource);
-}
-
-void delete_resource(struct resource *resource)
-{
- if (!resource)
- return;
-
- if (resource->driver && resource->driver->ops.delete)
- resource->driver->ops.delete(resource);
-
- unset_resource_attr_interest(resource, RESOURCE_ATTR_MASK);
-
- do_delete_resource(resource);
-}
-
-int create_resource(struct resource **res, int resource_type)
-{
- const struct resource_driver *driver = NULL;
- struct resource *resource = NULL;
- int i, ret;
-
- if (!res)
- return -EINVAL;
-
- driver = find_resource_driver(resource_type);
- if (!driver) {
- _E("failed to find resource driver, res:type(%d)\n",
- resource_type);
- return -EINVAL;
- }
-
- resource = calloc(1, sizeof(*resource));
- if (!resource)
- return -ENOMEM;
-
- resource->type = resource_type;
- resource->name = g_strdup(driver->name);
- resource->driver = driver;
- resource->num_attrs = driver->num_attrs;
- resource->attrs = driver->attrs;
- resource->attrs_value = calloc(resource->num_attrs,
- sizeof(*resource->attrs_value));
- if (!resource->attrs_value) {
- do_delete_resource(resource);
- return -ENOMEM;
- }
-
- for (i = 0; i < resource->num_attrs; i++)
- resource->attrs_value[i].type = driver->attrs[i].type;
-
- resource->ctrls = driver->ctrls;
- resource->num_ctrls = driver->num_ctrls;
- resource->flag = RESOURCE_FLAG_PRIVATE;
-
- if (driver->ops.create) {
- ret = driver->ops.create(resource);
- if (ret < 0) {
- _E("failed to initialize resource driver, res:type(%s)\n",
- resource->name);
- do_delete_resource(resource);
- return ret;
- }
- }
-
- *res = resource;
-
- return 0;
-}
-
-int set_resource_flag(struct resource *resource, u_int64_t flag_mask)
-{
- if (!resource)
- return -EINVAL;
-
- resource->flag = flag_mask;
- return 0;
-}
-
-int set_resource_control(struct resource *resource, u_int64_t ctrl_id, const void *data)
-{
- const struct resource_control *ctrl;
- int ctrl_index = RESOURCE_CTRL_INDEX(ctrl_id);
- int ret;
-
- if (!resource || ctrl_index < 0 || ctrl_index >= resource->num_ctrls) {
- _E("Invalid parameter\n");
- return -EINVAL;
- }
-
- ctrl = &resource->ctrls[ctrl_index];
- if (!ctrl->ops.set)
- return -ENOTSUP;
-
- ret = ctrl->ops.set(resource, ctrl, data);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-const char *get_resource_control_name(struct resource *resource, u_int64_t ctrl_id)
-{
- const struct resource_control *ctrl;
- int ctrl_index = RESOURCE_CTRL_INDEX(ctrl_id);
-
- if (!resource || ctrl_index < 0 || ctrl_index >= resource->num_ctrls) {
- _E("Invalid parameter\n");
- return NULL;
- }
-
- ctrl = &resource->ctrls[ctrl_index];
-
- return ctrl->name;
-}
-
-static int update_resource_attr(struct resource *resource, u_int64_t attr_id)
-{
- int attr_index = RESOURCE_ATTR_INDEX(attr_id);
- const struct resource_attribute *attr = NULL;
- struct resource_attribute_value *attr_value = NULL;
- int ret;
-
- if (!resource || attr_index < 0 || attr_index >= resource->num_attrs) {
- _E("Invalid parameter\n");
- return -EINVAL;
- }
-
- attr = &resource->attrs[attr_index];
-
- if (!attr->ops.get) {
- _E("don't support get ops of resource attribute value, res:type(%s) | attr:name(%s)id(%"PRId64")\n",
- resource->name, attr->name, attr_id);
- return -EINVAL;
- }
-
- attr_value = &resource->attrs_value[attr_index];
-
- ret = attr->ops.get(resource, attr, attr_value->data);
- if (ret < 0) {
- _E("failed to get resource attribute value, res:type(%s) | attr:name(%s)id(%"PRId64")\n",
- resource->name, attr->name, attr_id);
- return ret;
- }
-
- return 0;
-}
-
-int update_resource_attrs(struct resource *resource)
-{
- int i, ret;
-
- if (!resource || !resource->type)
- return -EINVAL;
-
- if (resource->driver && resource->driver->ops.prepare_update) {
- ret = resource->driver->ops.prepare_update(resource);
- if (ret < 0) {
- _E("failed to prepare_update resource driver, res:type(%s)\n",
- resource->name);
- return ret;
- }
- }
-
- for (i = 0; i < resource->num_attrs; i++) {
- if (!(resource->attrs[i].id & resource->attr_interest))
- continue;
- ret = update_resource_attr(resource, resource->attrs[i].id);
- if (ret < 0) {
- _E("failed to update resource attribute, res:type(%s) | attr:name(%s)id(%"PRId64")\n",
- resource->name, resource->attrs[i].name, resource->attrs[i].id);
- }
- }
-
- return 0;
-}
-
-const struct resource_attribute *
-get_resource_attr(struct resource *resource, u_int64_t attr_id)
-{
- int attr_index = RESOURCE_ATTR_INDEX(attr_id);
-
- if (!resource || attr_index < 0 || attr_index >= resource->num_attrs) {
- _E("Invalid parameter\n");
- return NULL;
- }
-
- return &resource->attrs[attr_index];
-}
-
-struct resource_attribute_value *
-get_resource_attr_value(struct resource *resource, u_int64_t attr_id)
-{
- int attr_index = RESOURCE_ATTR_INDEX(attr_id);
-
- if (!resource || attr_index < 0 || attr_index >= resource->num_attrs) {
- _E("Invalid parameter\n");
- return NULL;
- }
-
- return &resource->attrs_value[attr_index];
-}
-
-int is_resource_attr_supported(struct resource *resource, u_int64_t attr_id, bool *supported)
-{
- const struct resource_attribute *attr = NULL;
- int attr_index = RESOURCE_ATTR_INDEX(attr_id);
- int ret;
- bool is_supported = false;
-
- if (!resource || attr_index < 0 || attr_index >= resource->num_attrs) {
- _E("Invalid parameter\n");
- return -EINVAL;
- }
-
- attr = &resource->attrs[attr_index];
-
- if (attr->id & resource->attr_supported) {
- is_supported = true;
- } else if (attr->ops.is_supported) {
- is_supported = attr->ops.is_supported(resource, attr);
- } else if (attr->ops.get) {
- /*
- * Optionally, if .is_supported ops is not implemented,
- * use .get ops in order to check whether the resource attribute
- * is supported or not.
- */
- char data[BUFF_MAX] = {0, };
-
- ret = attr->ops.get(resource, attr, (void *)data);
- is_supported = (ret < 0) ? false : true;
- }
-
- if (is_supported)
- resource->attr_supported |= attr->id;
-
- *supported = is_supported;
-
- return 0;
-}
-
-static bool check_attr_validate(struct resource *resource, u_int64_t attr_id, int type)
-{
- const struct resource_attribute *attr = get_resource_attr(resource, attr_id);
-
- if (!attr) {
- _E("Invalid parameter\n");
- return false;
- }
-
- if (attr->type != type) {
- _E("Invalid data type(%d), res:type(%s) | attr:name(%s)id(%"PRId64",%d)\n",
- type, resource->name, attr->name, attr->id, attr->type);
- return false;
- }
-
- if (!(attr->id & resource->attr_interest)) {
- _E("Invalid interest state, res:type(%s) | attr:name(%s)id(%"PRId64")type(%d)\n",
- resource->name, attr->name, attr->id, attr->type);
- return false;
- }
-
- return true;
-}
-
-static json_object *_get_resource_attr_json(const struct resource_attribute *attr,
- const struct resource_attribute_value *attr_value)
-{
- json_object *jobj_attr, *jobj_attr_name, *jobj_attr_type, *jobj_attr_value, *jobj_temp;
- struct array_value *array;
- int i;
-
- switch (attr->type) {
- case DATA_TYPE_INT:
- jobj_attr_value = json_object_new_int(*((int32_t *)attr_value->data));
- break;
- case DATA_TYPE_UINT:
- jobj_attr_value = json_object_new_int(*((u_int32_t *)attr_value->data));
- break;
- case DATA_TYPE_INT64:
- jobj_attr_value = json_object_new_int64(*((int64_t *)attr_value->data));
- break;
- case DATA_TYPE_UINT64:
- jobj_attr_value = json_object_new_uint64(*((u_int64_t *)attr_value->data));
- break;
- case DATA_TYPE_DOUBLE:
- jobj_attr_value = json_object_new_double(*((double *)attr_value->data));
- break;
- case DATA_TYPE_STRING:
- jobj_attr_value = json_object_new_string((char *)attr_value->data);
- break;
- case DATA_TYPE_ARRAY:
- array = attr_value->data;
-
- jobj_attr_value = json_object_new_array();
-
- switch (array->type) {
- case DATA_TYPE_INT:
- for (i = 0; i < array->length; i++) {
- int32_t *item = array->data;
-
- jobj_temp = json_object_new_int(item[i]);
- json_object_array_add(jobj_attr_value, jobj_temp);
- }
- break;
- case DATA_TYPE_UINT:
- for (i = 0; i < array->length; i++) {
- u_int32_t *item = array->data;
-
- jobj_temp = json_object_new_int(item[i]);
- json_object_array_add(jobj_attr_value, jobj_temp);
- }
- break;
- case DATA_TYPE_INT64:
- for (i = 0; i < array->length; i++) {
- int64_t *item = array->data;
-
- jobj_temp = json_object_new_int64(item[i]);
- json_object_array_add(jobj_attr_value, jobj_temp);
- }
- break;
- case DATA_TYPE_UINT64:
- for (i = 0; i < array->length; i++) {
- u_int64_t *item = array->data;
-
- jobj_temp = json_object_new_uint64(item[i]);
- json_object_array_add(jobj_attr_value, jobj_temp);
- }
- break;
- case DATA_TYPE_DOUBLE:
- for (i = 0; i < array->length; i++) {
- double *item = array->data;
-
- jobj_temp = json_object_new_double(item[i]);
- json_object_array_add(jobj_attr_value, jobj_temp);
- }
- break;
- case DATA_TYPE_STRING:
- for (i = 0; i < array->length; i++) {
- char **item = array->data;
-
- jobj_temp = json_object_new_string(item[i]);
- json_object_array_add(jobj_attr_value, jobj_temp);
- }
- break;
- default:
- _E("wrong attribute data type in array\n");
- json_object_put(jobj_attr_value);
- jobj_attr_value = json_object_new_null();
- }
- break;
- default:
- _E("wrong attribute data type\n");
- jobj_attr_value = json_object_new_null();
- }
- jobj_attr = json_object_new_object();
-
- jobj_attr_name = json_object_new_string(attr->name);
- /*
- * Since actually JSON format has no data type limitation itself, in many
- * cases except converting JSON into json-c, type is not required. So,
- * for the case of converting JSON generated here to json-c object again
- * json_type is stored in each attributes.
- */
- jobj_attr_type = json_object_new_int(json_object_get_type(jobj_attr_value));
-
- json_object_object_add(jobj_attr, "name", jobj_attr_name);
- json_object_object_add(jobj_attr, "json_type", jobj_attr_type);
- json_object_object_add(jobj_attr, "value", jobj_attr_value);
-
- return jobj_attr;
-}
-
-static void _put_resource_attr_json(json_object *jobj_attr)
-{
- json_object *jobj_attr_value;
-
- json_object_object_del(jobj_attr, "name");
- json_object_object_del(jobj_attr, "json_type");
-
- if (json_object_object_get_ex(jobj_attr, "value", &jobj_attr_value) &&
- json_object_is_type(jobj_attr_value, json_type_array))
- json_object_array_del_idx(jobj_attr_value, 0,
- json_object_array_length(jobj_attr_value));
-
- json_object_object_del(jobj_attr, "value");
-}
-
-int get_resource_attrs_json(struct resource *resource, char **json_string)
-{
- json_object *jobj_root, *jobj_res_name, *jobj_res_type, *jobj_res_attrs, *jobj_attr;
- const struct resource_attribute *attr;
- const struct resource_attribute_value *attr_value;
- int i;
-
- if (!resource || !resource->type)
- return -EINVAL;
-
- jobj_root = json_object_new_object();
-
- jobj_res_name = json_object_new_string(resource->name);
- jobj_res_type = json_object_new_int(resource->type);
- jobj_res_attrs = json_object_new_array();
-
- for (i = 0; i < resource->num_attrs; i++) {
- if (!(resource->attrs[i].id & resource->attr_interest))
- continue;
-
- attr = &resource->attrs[i];
- attr_value = &resource->attrs_value[i];
-
- jobj_attr = _get_resource_attr_json(attr, attr_value);
-
- json_object_array_add(jobj_res_attrs, jobj_attr);
- }
-
- json_object_object_add(jobj_root, "res_name", jobj_res_name);
- json_object_object_add(jobj_root, "res_type", jobj_res_type);
- json_object_object_add(jobj_root, "res_attrs", jobj_res_attrs);
-
- *json_string = strdup(json_object_to_json_string(jobj_root));
-
- for (i = 0; i < json_object_array_length(jobj_res_attrs); i++) {
- jobj_attr = json_object_array_get_idx(jobj_res_attrs, i);
- _put_resource_attr_json(jobj_attr);
- }
- json_object_array_del_idx(jobj_res_attrs, 0, json_object_array_length(jobj_res_attrs));
-
- json_object_object_del(jobj_root, "res_attrs");
- json_object_object_del(jobj_root, "res_type");
- json_object_object_del(jobj_root, "res_name");
- json_object_put(jobj_root);
-
- return 0;
-}
-
-int get_resource_attr_json(struct resource *resource, u_int64_t attr_id, char **json_string)
-{
- const struct resource_attribute *attr;
- const struct resource_attribute_value *attr_value;
- json_object *jobj_attr;
-
- attr = get_resource_attr(resource, attr_id);
- attr_value = get_resource_attr_value(resource, attr_id);
-
- if (!attr || !attr_value)
- return -EINVAL;
-
- jobj_attr = _get_resource_attr_json(attr, attr_value);
-
- *json_string = strdup(json_object_to_json_string(jobj_attr));
-
- _put_resource_attr_json(jobj_attr);
-
- return 0;
-}
-
-static json_object *get_resource_driver_json(const struct resource_driver *driver)
-{
- json_object *jobj_drv, *jobj_drv_name, *jobj_drv_type;
- json_object *jobj_drv_attrs_array, *jobj_drv_attr, *jobj_drv_ctrls_array, *jobj_drv_ctrl;
- json_object *jobj_drv_attr_name, *jobj_drv_attr_type, *jobj_drv_attr_id;
- json_object *jobj_drv_ctrl_name, *jobj_drv_ctrl_id;
- const struct resource_attribute *attr;
- const struct resource_control *ctrl;
- int i;
-
- jobj_drv = json_object_new_object();
-
- jobj_drv_name = json_object_new_string(driver->name);
- jobj_drv_type = json_object_new_int(driver->type);
-
- jobj_drv_attrs_array = json_object_new_array();
-
- for (i = 0; i < driver->num_attrs; i++) {
- attr = &driver->attrs[i];
-
- jobj_drv_attr = json_object_new_object();
-
- jobj_drv_attr_name = json_object_new_string(attr->name);
- jobj_drv_attr_type = json_object_new_int(attr->type);
- jobj_drv_attr_id = json_object_new_uint64(attr->id);
-
- json_object_object_add(jobj_drv_attr, "name", jobj_drv_attr_name);
- json_object_object_add(jobj_drv_attr, "type", jobj_drv_attr_type);
- json_object_object_add(jobj_drv_attr, "id", jobj_drv_attr_id);
-
- json_object_array_add(jobj_drv_attrs_array, jobj_drv_attr);
- }
-
- jobj_drv_ctrls_array = json_object_new_array();
-
- for (i = 0; i < driver->num_ctrls; i++) {
- ctrl = &driver->ctrls[i];
-
- jobj_drv_ctrl = json_object_new_object();
-
- jobj_drv_ctrl_name = json_object_new_string(ctrl->name);
- jobj_drv_ctrl_id = json_object_new_uint64(ctrl->id);
-
- json_object_object_add(jobj_drv_ctrl, "name", jobj_drv_ctrl_name);
- json_object_object_add(jobj_drv_ctrl, "id", jobj_drv_ctrl_id);
-
- json_object_array_add(jobj_drv_ctrls_array, jobj_drv_ctrl);
- }
-
- json_object_object_add(jobj_drv, "name", jobj_drv_name);
- json_object_object_add(jobj_drv, "type", jobj_drv_type);
- json_object_object_add(jobj_drv, "attrs", jobj_drv_attrs_array);
- json_object_object_add(jobj_drv, "ctrls", jobj_drv_ctrls_array);
-
- return jobj_drv;
-}
-
-void put_resource_driver_json(json_object *jobj_drv)
-{
- json_object *jobj_array, *jobj_obj;
- int i;
-
- if (json_object_object_get_ex(jobj_drv, "ctrls", &jobj_array)) {
- for (i = 0; i < json_object_array_length(jobj_array); i++) {
- jobj_obj = json_object_array_get_idx(jobj_array, i);
-
- json_object_object_del(jobj_obj, "id");
- json_object_object_del(jobj_obj, "name");
- }
- json_object_array_del_idx(jobj_array, 0, json_object_array_length(jobj_array));
- }
-
- if (json_object_object_get_ex(jobj_drv, "attrs", &jobj_array)) {
- for (i = 0; i < json_object_array_length(jobj_array); i++) {
- jobj_obj = json_object_array_get_idx(jobj_array, i);
-
- json_object_object_del(jobj_obj, "id");
- json_object_object_del(jobj_obj, "type");
- json_object_object_del(jobj_obj, "name");
- }
- json_object_array_del_idx(jobj_array, 0, json_object_array_length(jobj_array));
- }
-
- json_object_object_del(jobj_drv, "ctrls");
- json_object_object_del(jobj_drv, "attrs");
- json_object_object_del(jobj_drv, "type");
- json_object_object_del(jobj_drv, "name");
-}
-
-int get_resource_list_json(char **json_string)
-{
- const struct resource_driver *driver;
- json_object *jobj_root, *jobj_drvs_array, *jobj_drv;
- int i;
-
- jobj_root = json_object_new_object();
- jobj_drvs_array = json_object_new_array();
-
- for (i = 0; i < g_list_length(g_resource_driver_head); i++) {
- driver = g_list_nth(g_list_first(g_resource_driver_head), i)->data;
-
- jobj_drv = get_resource_driver_json(driver);
- json_object_array_add(jobj_drvs_array, jobj_drv);
- }
-
- json_object_object_add(jobj_root, "resources", jobj_drvs_array);
-
- *json_string = strdup(json_object_to_json_string(jobj_root));
-
- for (i = 0; i < json_object_array_length(jobj_drvs_array); i++) {
- jobj_drv = json_object_array_get_idx(jobj_drvs_array, i);
-
- put_resource_driver_json(jobj_drv);
- }
- json_object_array_del_idx(jobj_drvs_array, 0, json_object_array_length(jobj_drvs_array));
-
- json_object_object_del(jobj_root, "resources");
- json_object_put(jobj_root);
-
- return 0;
-}
-
-int get_resource_attr_int(struct resource *resource, u_int64_t attr_id, int32_t *data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_INT))
- return -EINVAL;
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value)
- return -EINVAL;
-
- *data = *((int32_t *)attr_value->data);
-
- return 0;
-}
-
-int get_resource_attr_int64(struct resource *resource, u_int64_t attr_id, int64_t *data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_INT64))
- return -EINVAL;
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value)
- return -EINVAL;
-
- *data = *((int64_t *)attr_value->data);
-
- return 0;
-}
-
-int get_resource_attr_uint(struct resource *resource, u_int64_t attr_id, u_int32_t *data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_UINT))
- return -EINVAL;
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value)
- return -EINVAL;
-
- *data = *((u_int32_t *)attr_value->data);
-
- return 0;
-}
-
-int get_resource_attr_uint64(struct resource *resource, u_int64_t attr_id, u_int64_t *data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_UINT64))
- return -EINVAL;
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value)
- return -EINVAL;
-
- *data = *((u_int64_t *)attr_value->data);
-
- return 0;
-}
-
-int get_resource_attr_double(struct resource *resource, u_int64_t attr_id, double *data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_DOUBLE))
- return -EINVAL;
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value)
- return -EINVAL;
-
- *data = *((double *)attr_value->data);
-
- return 0;
-}
-
-int get_resource_attr_string(struct resource *resource, u_int64_t attr_id, char *data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_STRING)) {
- _E("Invalid parameter\n");
- return -EINVAL;
- }
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value) {
- _E("failed to get attribute value\n");
- return -EINVAL;
- }
-
- strncpy(data, (char *)attr_value->data, BUFF_MAX);
-
- return 0;
-}
-
-int get_resource_attr_array(struct resource *resource, u_int64_t attr_id, struct array_value **data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_ARRAY))
- return -EINVAL;
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value)
- return -EINVAL;
-
- *data = (struct array_value *)attr_value->data;
-
- return 0;
-}
-
-int get_resource_attr_ptr(struct resource *resource, u_int64_t attr_id, void **data)
-{
- struct resource_attribute_value *attr_value = NULL;
-
- if (!check_attr_validate(resource, attr_id, DATA_TYPE_PTR))
- return -EINVAL;
-
- attr_value = get_resource_attr_value(resource, attr_id);
- if (!attr_value)
- return -EINVAL;
-
- *data = attr_value->data;
-
- return 0;
-}
-
-#define RESOURCE_FLAG_VISIBILITY_MASK (RESOURCE_FLAG_PRIVATE | RESOURCE_FLAG_PUBLIC)
-#define RESOURCE_ATTR_FLAG_VISIBILITY_MASK (RESOURCE_ATTR_FLAG_PRIVATE | RESOURCE_ATTR_FLAG_PUBLIC)
-
-static inline bool is_resource_attr_visible(struct resource *resource, const struct resource_attribute *attr)
-{
- u_int64_t res_visibility, attr_visibility;
-
- res_visibility = resource->flag & RESOURCE_FLAG_VISIBILITY_MASK;
- attr_visibility = attr->flag & RESOURCE_ATTR_FLAG_VISIBILITY_MASK;
-
- /* bigger visibility means smaller privilege */
- if (res_visibility > attr_visibility)
- return false;
-
- return true;
-}
-
-int set_resource_attr_interest(struct resource *resource, u_int64_t interest_mask)
-{
- struct resource_attribute_value *attr_value;
- int i, ret;
- bool supported;
-
- if (!resource)
- return -EINVAL;
-
- for (i = 0; i < resource->num_attrs; i++) {
- if (!(resource->attrs[i].id & interest_mask))
- continue;
-
- ret = is_resource_attr_supported(resource, resource->attrs[i].id,
- &supported);
- if (ret < 0) {
- goto err;
- } else if (!supported){
- ret = -ENOTSUP;
- goto err;
- }
-
- if (!is_resource_attr_visible(resource, &resource->attrs[i])) {
- _E("res:name(%s) does not have enough privilege to read the attr:name(%s)",
- resource->name, resource->attrs[i].name);
- ret = -EACCES;
- goto err;
- }
-
- attr_value = get_resource_attr_value(resource, resource->attrs[i].id);
- if (!attr_value) {
- _E("failed to get attribute value, res:type(%s) | attr:name(%s)",
- resource->name, resource->attrs[i].name);
- ret = -EINVAL;
- goto err;
- }
-
- /*
- * In resource monitor, each resource has a lot of attributes, but
- * only updated attributes are selected by clients on demand. So,
- * instead of allocating memory at the resource creation, allocate
- * at the set interest.
- */
- if (!attr_value->data) {
- switch (attr_value->type) {
- case DATA_TYPE_INT:
- attr_value->data = calloc(1, sizeof(int32_t));
- break;
- case DATA_TYPE_INT64:
- attr_value->data = calloc(1, sizeof(int64_t));
- break;
- case DATA_TYPE_UINT:
- attr_value->data = calloc(1, sizeof(u_int32_t));
- break;
- case DATA_TYPE_UINT64:
- attr_value->data = calloc(1, sizeof(u_int64_t));
- break;
- case DATA_TYPE_DOUBLE:
- attr_value->data = calloc(1, sizeof(double));
- break;
- case DATA_TYPE_STRING:
- attr_value->data = calloc(BUFF_MAX, sizeof(char));
- break;
- case DATA_TYPE_ARRAY:
- attr_value->data = calloc(1, sizeof(struct array_value));
- break;
- default:
- _E("Not supported data type(%d)", attr_value->type);
- ret = -EINVAL;
- goto err;
- }
-
- if (!attr_value->data) {
- _E("failed to allocate attr_value memory, res:type(%s) | attr:name(%s)",
- resource->name, resource->attrs[i].name);
- ret = -ENOMEM;
- goto err;
- }
- }
- }
-
- resource->attr_interest |= interest_mask;
-
- return 0;
-
-err:
- for (; i >= 0; i--) {
- if (!(resource->attrs[i].id & interest_mask))
- continue;
-
- attr_value = get_resource_attr_value(resource, resource->attrs[i].id);
- if (!attr_value)
- continue;
-
- if (attr_value->data) {
- free(attr_value->data);
- attr_value->data = NULL;
- }
- }
-
- return ret;
-}
-
-int unset_resource_attr_interest(struct resource *resource, u_int64_t interest_mask)
-{
- struct resource_attribute_value *attr_value;
- int i;
-
- if (!resource)
- return -EINVAL;
-
- if (!is_resource_attr_interested(resource, interest_mask))
- return -EINVAL;
-
- for (i = 0; i < resource->num_attrs; i++) {
- if (!(resource->attrs[i].id & interest_mask))
- continue;
-
- attr_value = get_resource_attr_value(resource, resource->attrs[i].id);
- if (!attr_value) {
- _E("failed to get attribute value, res:type(%s) | attr:name(%s)",
- resource->name, resource->attrs[i].name);
- return -EINVAL;
- }
-
- if (attr_value->data) {
- switch (attr_value->type) {
- case DATA_TYPE_ARRAY:
- {
- struct array_value *array = attr_value->data;
-
- if (array->data) {
- free(array->data);
- array->data = NULL;
- }
- /* fall through */
- }
- case DATA_TYPE_INT:
- case DATA_TYPE_INT64:
- case DATA_TYPE_UINT:
- case DATA_TYPE_UINT64:
- case DATA_TYPE_DOUBLE:
- case DATA_TYPE_STRING:
- free(attr_value->data);
- attr_value->data = NULL;
- break;
- default:
- _E("Not supported data type(%d)", attr_value->type);
- return -EINVAL;
- }
- }
- }
-
- resource->attr_interest &= ~interest_mask;
-
- return 0;
-}
-
-bool is_resource_attr_interested(struct resource *resource, u_int64_t interest_mask)
-{
- if (!resource)
- return false;
-
- if (resource->attr_interest != (resource->attr_interest | interest_mask))
- return false;
-
- return true;
-}
-
-const char *get_resource_attr_name(struct resource *resource, u_int64_t attr_id)
-{
- const struct resource_attribute *attr;
-
- attr = get_resource_attr(resource, attr_id);
- if (!attr)
- return NULL;
-
- return attr->name;
-}
-
-const char *get_resource_name(struct resource *resource)
-{
- return resource ? resource->name : NULL;
-}
-
-void *get_resource_privdata(struct resource *resource)
-{
- return resource ? resource->priv : NULL;
-}
-
-int get_resource_type(struct resource *resource)
-{
- return resource ? resource->type : -EINVAL;
-}
-
-int set_resource_privdata(struct resource *resource, void *priv)
-{
- if (!resource)
- return -EINVAL;
-
- resource->priv = priv;
-
- return 0;
-}
-
-void init_resource_drivers(void)
-{
- struct resource_driver *driver;
- int i, ret = 0;
-
- for (i = 0; i < g_list_length(g_resource_driver_head); i++) {
- driver = g_list_nth(g_list_first(g_resource_driver_head), i)->data;
-
- if (driver->ops.init) {
- ret = driver->ops.init();
- if (ret < 0) {
- _D("failed to init resource driver: %s\n", driver->name);
- remove_resource_driver(driver);
- }
- }
- }
-}
-
-void exit_resource_drivers(void)
-{
- const struct resource_driver *driver;
- int i;
-
- for (i = 0; i < g_list_length(g_resource_driver_head); i++) {
- driver = g_list_nth(g_list_first(g_resource_driver_head), i)->data;
-
- if (driver->ops.exit)
- driver->ops.exit();
- }
-}
diff --git a/tests/integration-test/resource-monitor-tests.cpp b/tests/integration-test/resource-monitor-tests.cpp
index f10237a..b29061d 100644
--- a/tests/integration-test/resource-monitor-tests.cpp
+++ b/tests/integration-test/resource-monitor-tests.cpp
@@ -25,6 +25,8 @@
#include <util/common.h>
+#include <libsyscommon/resource-type.h>
+
#include <vector>
#include <memory>
@@ -177,7 +179,7 @@ TEST_F(ResourceMonitorTest,
EXPECT_TRUE(id > 0);
int res_id = pass_resource_monitor_create_resource(id, res_type);
- ret = pass_resource_monitor_set_resource_flag(id, res_id, RESOURCE_FLAG_PUBLIC);
+ ret = pass_resource_monitor_set_resource_flag(id, res_id, SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC);
EXPECT_EQ(ret, 0);
ret = pass_resource_monitor_set_resource_ctrl(id, res_id, ctrl_id, getpid());
@@ -193,7 +195,7 @@ TEST_F(ResourceMonitorTest,
EXPECT_EQ(ret, 0);
}
-struct resource_attr_info {
+struct syscommon_resman_resource_attr_info {
u_int64_t attr_id;
int attr_type;
int array_type;
@@ -208,7 +210,7 @@ public:
int count;
const u_int64_t ctrl_id;
const int num_attrs;
- vector<struct resource_attr_info> attrs;
+ vector<struct syscommon_resman_resource_attr_info> attrs;
PhysicalResourceInfo(
const int type_,
@@ -218,7 +220,7 @@ public:
int count_,
const u_int64_t ctrl_id_,
const int num_attrs_,
- vector<struct resource_attr_info> attrs_) :
+ vector<struct syscommon_resman_resource_attr_info> attrs_) :
type(type_),
name(name_),
mon_id(mon_id_),
@@ -241,14 +243,14 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
CPU_CTRL_CLUSTER_ID,
7,
- vector<struct resource_attr_info> {
- { .attr_id = CPU_ATTR_CUR_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = CPU_ATTR_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = CPU_ATTR_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = CPU_ATTR_AVAILABLE_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = CPU_ATTR_AVAILABLE_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = CPU_ATTR_CUR_GOVERNOR, .attr_type = DATA_TYPE_STRING, },
- { .attr_id = CPU_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = CPU_ATTR_CUR_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = CPU_ATTR_MIN_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = CPU_ATTR_MAX_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = CPU_ATTR_AVAILABLE_MIN_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = CPU_ATTR_AVAILABLE_MAX_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = CPU_ATTR_CUR_GOVERNOR, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .attr_id = CPU_ATTR_NAME, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
}
),
@@ -260,14 +262,14 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
BUS_CTRL_DEVICE_ID,
7,
- vector<struct resource_attr_info> {
- { .attr_id = BUS_ATTR_CUR_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BUS_ATTR_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BUS_ATTR_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BUS_ATTR_AVAILABLE_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BUS_ATTR_AVAILABLE_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BUS_ATTR_CUR_GOVERNOR, .attr_type = DATA_TYPE_STRING, },
- { .attr_id = BUS_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = BUS_ATTR_CUR_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BUS_ATTR_MIN_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BUS_ATTR_MAX_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BUS_ATTR_AVAILABLE_MIN_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BUS_ATTR_AVAILABLE_MAX_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BUS_ATTR_CUR_GOVERNOR, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .attr_id = BUS_ATTR_NAME, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
}
),
@@ -279,14 +281,14 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
GPU_CTRL_DEVICE_ID,
7,
- vector<struct resource_attr_info> {
- { .attr_id = GPU_ATTR_CUR_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = GPU_ATTR_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = GPU_ATTR_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = GPU_ATTR_AVAILABLE_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = GPU_ATTR_AVAILABLE_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
- { .attr_id = GPU_ATTR_CUR_GOVERNOR, .attr_type = DATA_TYPE_STRING, },
- { .attr_id = GPU_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = GPU_ATTR_CUR_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = GPU_ATTR_MIN_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = GPU_ATTR_MAX_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = GPU_ATTR_AVAILABLE_MIN_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = GPU_ATTR_AVAILABLE_MAX_FREQ, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = GPU_ATTR_CUR_GOVERNOR, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .attr_id = GPU_ATTR_NAME, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
}
),
@@ -298,16 +300,16 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
0,
9,
- vector<struct resource_attr_info> {
- { .attr_id = MEMORY_ATTR_TOTAL, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_AVAILABLE, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_FREE, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_BUFFER, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_CACHED, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_CMA_TOTAL, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_CMA_FREE, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_SWAP_TOTAL, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = MEMORY_ATTR_SWAP_FREE, .attr_type = DATA_TYPE_UINT64, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = MEMORY_ATTR_TOTAL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_AVAILABLE, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_FREE, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_BUFFER, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_CACHED, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_CMA_TOTAL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_CMA_FREE, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_SWAP_TOTAL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = MEMORY_ATTR_SWAP_FREE, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
}
),
@@ -319,14 +321,14 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
0,
7,
- vector<struct resource_attr_info> {
- { .attr_id = BATTERY_ATTR_CAPACITY, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BATTERY_ATTR_STATUS, .attr_type = DATA_TYPE_STRING, },
- { .attr_id = BATTERY_ATTR_TEMPERATURE, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BATTERY_ATTR_VOLTAGE_NOW, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BATTERY_ATTR_CURRENT_NOW, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BATTERY_ATTR_PRESENT, .attr_type = DATA_TYPE_INT, },
- { .attr_id = BATTERY_ATTR_ONLINE, .attr_type = DATA_TYPE_INT, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = BATTERY_ATTR_CAPACITY, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BATTERY_ATTR_STATUS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .attr_id = BATTERY_ATTR_TEMPERATURE, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BATTERY_ATTR_VOLTAGE_NOW, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BATTERY_ATTR_CURRENT_NOW, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BATTERY_ATTR_PRESENT, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = BATTERY_ATTR_ONLINE, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
}
),
@@ -338,9 +340,9 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
DISPLAY_CTRL_DEVICE_ID,
2,
- vector<struct resource_attr_info> {
- { .attr_id = DISPLAY_ATTR_FPS, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = DISPLAY_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = DISPLAY_ATTR_FPS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = DISPLAY_ATTR_NAME, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
}
),
@@ -352,15 +354,15 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
0,
8,
- vector<struct resource_attr_info> {
- { .attr_id = SYSTEM_ATTR_CPU_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = SYSTEM_ATTR_CPU_USER_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = SYSTEM_ATTR_CPU_SYS_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = SYSTEM_ATTR_PER_CPU_UTIL, .attr_type = DATA_TYPE_ARRAY, .array_type = DATA_TYPE_DOUBLE, },
- { .attr_id = SYSTEM_ATTR_PER_CPU_USER_UTIL, .attr_type = DATA_TYPE_ARRAY, .array_type = DATA_TYPE_DOUBLE, },
- { .attr_id = SYSTEM_ATTR_PER_CPU_SYS_UTIL, .attr_type = DATA_TYPE_ARRAY, .array_type = DATA_TYPE_DOUBLE, },
- { .attr_id = SYSTEM_ATTR_POSSIBLE_CPU, .attr_type = DATA_TYPE_INT, },
- { .attr_id = SYSTEM_ATTR_ONLINE_CPU, .attr_type = DATA_TYPE_INT, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = SYSTEM_ATTR_CPU_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = SYSTEM_ATTR_CPU_USER_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = SYSTEM_ATTR_CPU_SYS_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = SYSTEM_ATTR_PER_CPU_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .array_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = SYSTEM_ATTR_PER_CPU_USER_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .array_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = SYSTEM_ATTR_PER_CPU_SYS_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .array_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = SYSTEM_ATTR_POSSIBLE_CPU, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = SYSTEM_ATTR_ONLINE_CPU, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
}
),
@@ -372,12 +374,12 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
DISK_CTRL_DEVICE_ID,
5,
- vector<struct resource_attr_info> {
- { .attr_id = DISK_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
- { .attr_id = DISK_ATTR_READ_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = DISK_ATTR_WRITE_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = DISK_ATTR_READ_TOTAL, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = DISK_ATTR_WRITE_TOTAL, .attr_type = DATA_TYPE_UINT64, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = DISK_ATTR_NAME, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .attr_id = DISK_ATTR_READ_PER_SEC, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = DISK_ATTR_WRITE_PER_SEC, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = DISK_ATTR_READ_TOTAL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = DISK_ATTR_WRITE_TOTAL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
}
),
@@ -389,8 +391,8 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
0,
NETWORK_CTRL_DEVICE_ID,
1,
- vector<struct resource_attr_info> {
- { .attr_id = NETWORK_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = NETWORK_ATTR_NAME, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
}
)
@@ -482,7 +484,7 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_set_resource_ctrl)
}
static int __pass_resource_monitor_set_resource_attr(int mon_id, int res_id, int num_attrs,
- std::vector<struct resource_attr_info> attrs)
+ std::vector<struct syscommon_resman_resource_attr_info> attrs)
{
int i, ret;
u_int64_t mask = 0;
@@ -507,7 +509,7 @@ static int __pass_resource_monitor_set_resource_attr(int mon_id, int res_id, int
}
static int __pass_resource_monitor_unset_resource_attr(int mon_id, int res_id, int num_attrs,
- std::vector<struct resource_attr_info> attrs)
+ std::vector<struct syscommon_resman_resource_attr_info> attrs)
{
int i, ret;
u_int64_t mask = 0;
@@ -532,7 +534,7 @@ static int __pass_resource_monitor_unset_resource_attr(int mon_id, int res_id, i
}
static bool __pass_resource_monitor_is_resource_attr_set(int mon_id, int res_id, int num_attrs,
- std::vector<struct resource_attr_info> attrs)
+ std::vector<struct syscommon_resman_resource_attr_info> attrs)
{
int i, ret;
u_int64_t mask = 0;
@@ -722,7 +724,7 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_is_resource_attr_set)
}
static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_attrs,
- std::vector<struct resource_attr_info> attrs)
+ std::vector<struct syscommon_resman_resource_attr_info> attrs)
{
int i, ret, err_count = 0;
@@ -737,37 +739,37 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
continue;
switch (attrs[i].attr_type) {
- case DATA_TYPE_INT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
int32_t value_int32;
ret = pass_resource_monitor_get_value_int(mon_id, res_id,
attrs[i].attr_id, &value_int32);
EXPECT_EQ(ret, 0);
break;
- case DATA_TYPE_INT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
int64_t value_int64;
ret = pass_resource_monitor_get_value_int64(mon_id, res_id,
attrs[i].attr_id, &value_int64);
EXPECT_EQ(ret, 0);
break;
- case DATA_TYPE_UINT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
u_int32_t value_uint32;
ret = pass_resource_monitor_get_value_uint(mon_id, res_id,
attrs[i].attr_id, &value_uint32);
EXPECT_EQ(ret, 0);
break;
- case DATA_TYPE_UINT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
u_int64_t value_uint64;
ret = pass_resource_monitor_get_value_uint64(mon_id, res_id,
attrs[i].attr_id, &value_uint64);
EXPECT_EQ(ret, 0);
break;
- case DATA_TYPE_DOUBLE:
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
double value_double;
ret = pass_resource_monitor_get_value_double(mon_id, res_id,
attrs[i].attr_id, &value_double);
EXPECT_EQ(ret, 0);
break;
- case DATA_TYPE_STRING:
+ case SYSCOMMON_RESMAN_DATA_TYPE_STRING:
{
char *value_str = NULL;
ret = pass_resource_monitor_get_value_string(mon_id, res_id,
@@ -776,11 +778,11 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
EXPECT_EQ(ret, 0);
break;
}
- case DATA_TYPE_ARRAY:
+ case SYSCOMMON_RESMAN_DATA_TYPE_ARRAY:
int length;
switch (attrs[i].array_type) {
- case DATA_TYPE_INT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
{
int32_t *array = NULL;
ret = pass_resource_monitor_get_array_int(mon_id, res_id,
@@ -789,7 +791,7 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
EXPECT_EQ(ret, 0);
break;
}
- case DATA_TYPE_INT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
{
int64_t *array = NULL;;
ret = pass_resource_monitor_get_array_int64(mon_id, res_id,
@@ -798,7 +800,7 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
EXPECT_EQ(ret, 0);
break;
}
- case DATA_TYPE_UINT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
{
u_int32_t *array = NULL;
ret = pass_resource_monitor_get_array_uint(mon_id, res_id,
@@ -807,7 +809,7 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
EXPECT_EQ(ret, 0);
break;
}
- case DATA_TYPE_UINT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
{
u_int64_t *array = NULL;
ret = pass_resource_monitor_get_array_uint64(mon_id, res_id,
@@ -816,7 +818,7 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
EXPECT_EQ(ret, 0);
break;
}
- case DATA_TYPE_DOUBLE:
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
{
double *array = NULL;
ret = pass_resource_monitor_get_array_double(mon_id, res_id,
@@ -825,7 +827,7 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
EXPECT_EQ(ret, 0);
break;
}
- case DATA_TYPE_STRING:
+ case SYSCOMMON_RESMAN_DATA_TYPE_STRING:
{
char **array = NULL;
ret = pass_resource_monitor_get_array_string(mon_id, res_id,
@@ -915,7 +917,7 @@ public:
int res_id;
const u_int64_t ctrl_id;
const int num_attrs;
- vector<struct resource_attr_info> attrs;
+ vector<struct syscommon_resman_resource_attr_info> attrs;
ProcessResourceInfo(
const int type_,
@@ -924,7 +926,7 @@ public:
int res_id_,
const u_int64_t ctrl_id_,
const int num_attrs_,
- vector<struct resource_attr_info> attrs_) :
+ vector<struct syscommon_resman_resource_attr_info> attrs_) :
type(type_),
name(name_),
mon_id(mon_id_),
@@ -945,20 +947,20 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, ProcessResourceMonitorTest,
-1,
PROCESS_CTRL_TGID,
13,
- vector<struct resource_attr_info> {
- { .attr_id = PROCESS_ATTR_CPU_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = PROCESS_ATTR_MEM_VIRT, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_ATTR_MEM_RSS, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_ATTR_MEM_RSS_PERCENT, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = PROCESS_ATTR_DISK_READ_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = PROCESS_ATTR_DISK_WRITE_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = PROCESS_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
- { .attr_id = PROCESS_ATTR_PGID, .attr_type = DATA_TYPE_INT, },
- { .attr_id = PROCESS_ATTR_PPID, .attr_type = DATA_TYPE_INT, },
- { .attr_id = PROCESS_ATTR_MEM_PSS, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_ATTR_MEM_SWAP, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_ATTR_MEM_SWAP_PSS, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_ATTR_MEM_GPU, .attr_type = DATA_TYPE_UINT64, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = PROCESS_ATTR_CPU_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = PROCESS_ATTR_MEM_VIRT, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_ATTR_MEM_RSS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_ATTR_MEM_RSS_PERCENT, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = PROCESS_ATTR_DISK_READ_PER_SEC, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = PROCESS_ATTR_DISK_WRITE_PER_SEC, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = PROCESS_ATTR_NAME, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .attr_id = PROCESS_ATTR_PGID, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = PROCESS_ATTR_PPID, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = PROCESS_ATTR_MEM_PSS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_ATTR_MEM_SWAP, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_ATTR_MEM_SWAP_PSS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_ATTR_MEM_GPU, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
}
),
@@ -969,18 +971,18 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, ProcessResourceMonitorTest,
-1,
PROCESS_GROUP_CTRL_ROOT_PID,
11,
- vector<struct resource_attr_info> {
- { .attr_id = PROCESS_GROUP_ATTR_PID_LIST, .attr_type = DATA_TYPE_ARRAY, .array_type = DATA_TYPE_INT, },
- { .attr_id = PROCESS_GROUP_ATTR_NAME_LIST, .attr_type = DATA_TYPE_ARRAY, .array_type = DATA_TYPE_STRING, },
- { .attr_id = PROCESS_GROUP_ATTR_CPU_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = PROCESS_GROUP_ATTR_DISK_READ_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
- { .attr_id = PROCESS_GROUP_ATTR_MEM_VIRT, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_GROUP_ATTR_MEM_RSS, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_GROUP_ATTR_MEM_PSS, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_GROUP_ATTR_MEM_SWAP, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_GROUP_ATTR_MEM_SWAP_PSS, .attr_type = DATA_TYPE_UINT64, },
- { .attr_id = PROCESS_GROUP_ATTR_MEM_GPU, .attr_type = DATA_TYPE_UINT64, },
+ vector<struct syscommon_resman_resource_attr_info> {
+ { .attr_id = PROCESS_GROUP_ATTR_PID_LIST, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .array_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .attr_id = PROCESS_GROUP_ATTR_NAME_LIST, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .array_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .attr_id = PROCESS_GROUP_ATTR_CPU_UTIL, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = PROCESS_GROUP_ATTR_DISK_READ_PER_SEC, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .attr_id = PROCESS_GROUP_ATTR_MEM_VIRT, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_GROUP_ATTR_MEM_RSS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_GROUP_ATTR_MEM_PSS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_GROUP_ATTR_MEM_SWAP, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_GROUP_ATTR_MEM_SWAP_PSS, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
+ { .attr_id = PROCESS_GROUP_ATTR_MEM_GPU, .attr_type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, },
}
)
));
diff --git a/tools/resource-monitor/resource-monitor.c b/tools/resource-monitor/resource-monitor.c
index ab1ae31..815fd4d 100644
--- a/tools/resource-monitor/resource-monitor.c
+++ b/tools/resource-monitor/resource-monitor.c
@@ -28,13 +28,15 @@
#include <util/common.h>
+#include <libsyscommon/resource-type.h>
+
#include "resource-monitor.h"
#define BUFF_MAX 255
#define MAX_RESOURCE 100
#define MAX_ATTR 64
-struct resource_attr_data {
+struct syscommon_resman_resource_attr_data {
const u_int64_t id;
const int type;
const int array_type;
@@ -50,117 +52,117 @@ struct resource_attr_data {
char *value_string;
};
-static struct resource_attr_data cpu_attrs[] = {
- { .id = CPU_ATTR_NAME, .type = DATA_TYPE_STRING, .name = "CPU_ATTR_NAME", .unit = "", .desc = "CPU cluster name", },
- { .id = CPU_ATTR_CUR_FREQ, .type = DATA_TYPE_INT, .name = "CPU_ATTR_CUR_FREQ", .unit = "kHz", .desc = "Current CPU frequency", },
- { .id = CPU_ATTR_MIN_FREQ, .type = DATA_TYPE_INT, .name = "CPU_ATTR_MIN_FREQ", .unit = "kHz", .desc = "Current CPU minimum frequency", },
- { .id = CPU_ATTR_MAX_FREQ, .type = DATA_TYPE_INT, .name = "CPU_ATTR_MAX_FREQ", .unit = "kHz", .desc = "Current CPU maximum frequency", },
- { .id = CPU_ATTR_AVAILABLE_MIN_FREQ, .type = DATA_TYPE_INT, .name = "CPU_ATTR_AVAILABLE_MIN_FREQ", .unit = "kHz", .desc = "Available CPU minimum frequency", },
- { .id = CPU_ATTR_AVAILABLE_MAX_FREQ, .type = DATA_TYPE_INT, .name = "CPU_ATTR_AVAILABLE_MAX_FREQ", .unit = "kHz", .desc = "Available CPU maximum frequency", },
- { .id = CPU_ATTR_CUR_GOVERNOR, .type = DATA_TYPE_STRING, .name = "CPU_ATTR_CUR_GOVERNOR", .unit = "", .desc = "Current CPU frequency governor name", },
+static struct syscommon_resman_resource_attr_data cpu_attrs[] = {
+ { .id = CPU_ATTR_NAME, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "CPU_ATTR_NAME", .unit = "", .desc = "CPU cluster name", },
+ { .id = CPU_ATTR_CUR_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "CPU_ATTR_CUR_FREQ", .unit = "kHz", .desc = "Current CPU frequency", },
+ { .id = CPU_ATTR_MIN_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "CPU_ATTR_MIN_FREQ", .unit = "kHz", .desc = "Current CPU minimum frequency", },
+ { .id = CPU_ATTR_MAX_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "CPU_ATTR_MAX_FREQ", .unit = "kHz", .desc = "Current CPU maximum frequency", },
+ { .id = CPU_ATTR_AVAILABLE_MIN_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "CPU_ATTR_AVAILABLE_MIN_FREQ", .unit = "kHz", .desc = "Available CPU minimum frequency", },
+ { .id = CPU_ATTR_AVAILABLE_MAX_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "CPU_ATTR_AVAILABLE_MAX_FREQ", .unit = "kHz", .desc = "Available CPU maximum frequency", },
+ { .id = CPU_ATTR_CUR_GOVERNOR, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "CPU_ATTR_CUR_GOVERNOR", .unit = "", .desc = "Current CPU frequency governor name", },
};
-static struct resource_attr_data bus_attrs[] = {
- { .id = BUS_ATTR_NAME, .type = DATA_TYPE_STRING, .name = "BUS_ATTR_NAME", .unit = "", .desc = "Bus device name", },
- { .id = BUS_ATTR_CUR_FREQ, .type = DATA_TYPE_INT, .name = "BUS_ATTR_CUR_FREQ", .unit = "kHz", .desc = "Current bus frequency", },
- { .id = BUS_ATTR_MIN_FREQ, .type = DATA_TYPE_INT, .name = "BUS_ATTR_MIN_FREQ", .unit = "kHz", .desc = "Current bus minimum frequency", },
- { .id = BUS_ATTR_MAX_FREQ, .type = DATA_TYPE_INT, .name = "BUS_ATTR_MAX_FREQ", .unit = "kHz", .desc = "Current bus maximum frequency", },
- { .id = BUS_ATTR_AVAILABLE_MIN_FREQ, .type = DATA_TYPE_INT, .name = "BUS_ATTR_AVAILABLE_MIN_FREQ", .unit = "kHz", .desc = "Available bus minimum frequency", },
- { .id = BUS_ATTR_AVAILABLE_MAX_FREQ, .type = DATA_TYPE_INT, .name = "BUS_ATTR_AVAILABLE_MAX_FREQ", .unit = "kHz", .desc = "Available bus maximum frequency", },
- { .id = BUS_ATTR_CUR_GOVERNOR, .type = DATA_TYPE_STRING, .name = "BUS_ATTR_CUR_GOVERNOR", .unit = "", .desc = "Current bus frequency governor name", },
+static struct syscommon_resman_resource_attr_data bus_attrs[] = {
+ { .id = BUS_ATTR_NAME, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "BUS_ATTR_NAME", .unit = "", .desc = "Bus device name", },
+ { .id = BUS_ATTR_CUR_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BUS_ATTR_CUR_FREQ", .unit = "kHz", .desc = "Current bus frequency", },
+ { .id = BUS_ATTR_MIN_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BUS_ATTR_MIN_FREQ", .unit = "kHz", .desc = "Current bus minimum frequency", },
+ { .id = BUS_ATTR_MAX_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BUS_ATTR_MAX_FREQ", .unit = "kHz", .desc = "Current bus maximum frequency", },
+ { .id = BUS_ATTR_AVAILABLE_MIN_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BUS_ATTR_AVAILABLE_MIN_FREQ", .unit = "kHz", .desc = "Available bus minimum frequency", },
+ { .id = BUS_ATTR_AVAILABLE_MAX_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BUS_ATTR_AVAILABLE_MAX_FREQ", .unit = "kHz", .desc = "Available bus maximum frequency", },
+ { .id = BUS_ATTR_CUR_GOVERNOR, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "BUS_ATTR_CUR_GOVERNOR", .unit = "", .desc = "Current bus frequency governor name", },
};
-static struct resource_attr_data gpu_attrs[] = {
- { .id = GPU_ATTR_NAME, .type = DATA_TYPE_STRING, .name = "GPU_ATTR_NAME", .unit = "", .desc = "GPU device name", },
- { .id = GPU_ATTR_CUR_FREQ, .type = DATA_TYPE_INT, .name = "GPU_ATTR_CUR_FREQ", .unit = "kHz", .desc = "Current GPU frequency", },
- { .id = GPU_ATTR_MIN_FREQ, .type = DATA_TYPE_INT, .name = "GPU_ATTR_MIN_FREQ", .unit = "kHz", .desc = "Current GPU minimum frequency", },
- { .id = GPU_ATTR_MAX_FREQ, .type = DATA_TYPE_INT, .name = "GPU_ATTR_MAX_FREQ", .unit = "kHz", .desc = "Current GPU maximum frequency", },
- { .id = GPU_ATTR_AVAILABLE_MIN_FREQ, .type = DATA_TYPE_INT, .name = "GPU_ATTR_AVAILABLE_MIN_FREQ", .unit = "kHz", .desc = "Available GPU minimum frequency", },
- { .id = GPU_ATTR_AVAILABLE_MAX_FREQ, .type = DATA_TYPE_INT, .name = "GPU_ATTR_AVAILABLE_MAX_FREQ", .unit = "kHz", .desc = "Available GPU maximum frequency", },
- { .id = GPU_ATTR_CUR_GOVERNOR, .type = DATA_TYPE_STRING, .name = "GPU_ATTR_CUR_GOVERNOR", .unit = "", .desc = "Current GPU frequency governor name", },
+static struct syscommon_resman_resource_attr_data gpu_attrs[] = {
+ { .id = GPU_ATTR_NAME, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "GPU_ATTR_NAME", .unit = "", .desc = "GPU device name", },
+ { .id = GPU_ATTR_CUR_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "GPU_ATTR_CUR_FREQ", .unit = "kHz", .desc = "Current GPU frequency", },
+ { .id = GPU_ATTR_MIN_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "GPU_ATTR_MIN_FREQ", .unit = "kHz", .desc = "Current GPU minimum frequency", },
+ { .id = GPU_ATTR_MAX_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "GPU_ATTR_MAX_FREQ", .unit = "kHz", .desc = "Current GPU maximum frequency", },
+ { .id = GPU_ATTR_AVAILABLE_MIN_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "GPU_ATTR_AVAILABLE_MIN_FREQ", .unit = "kHz", .desc = "Available GPU minimum frequency", },
+ { .id = GPU_ATTR_AVAILABLE_MAX_FREQ, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "GPU_ATTR_AVAILABLE_MAX_FREQ", .unit = "kHz", .desc = "Available GPU maximum frequency", },
+ { .id = GPU_ATTR_CUR_GOVERNOR, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "GPU_ATTR_CUR_GOVERNOR", .unit = "", .desc = "Current GPU frequency governor name", },
};
-static struct resource_attr_data memory_attrs[] = {
- { .id = MEMORY_ATTR_TOTAL, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_TOTAL", .unit = "kB", .desc = "Memory total size", },
- { .id = MEMORY_ATTR_AVAILABLE, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_AVAILABLE", .unit = "kB", .desc = "Memory available size", },
- { .id = MEMORY_ATTR_FREE, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_FREE", .unit = "kB", .desc = "Memory free size", },
- { .id = MEMORY_ATTR_BUFFER, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_BUFFER", .unit = "kB", .desc = "Memorry buffer size", },
- { .id = MEMORY_ATTR_CACHED, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_CACHED", .unit = "kB", .desc = "Memory cached size", },
- { .id = MEMORY_ATTR_CMA_TOTAL, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_CMA_TOTAL", .unit = "kB", .desc = "CMA memory total size", },
- { .id = MEMORY_ATTR_CMA_FREE, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_CMA_FREE", .unit = "kB", .desc = "CMA memory free size", },
- { .id = MEMORY_ATTR_SWAP_TOTAL, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_SWAP_TOTAL", .unit = "kB", .desc = "Swap memory total size", },
- { .id = MEMORY_ATTR_SWAP_FREE, .type = DATA_TYPE_UINT64, .name = "MEMORY_ATTR_SWAP_FREE", .unit = "kB", .desc = "Swap memory free size", },
+static struct syscommon_resman_resource_attr_data memory_attrs[] = {
+ { .id = MEMORY_ATTR_TOTAL, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_TOTAL", .unit = "kB", .desc = "Memory total size", },
+ { .id = MEMORY_ATTR_AVAILABLE, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_AVAILABLE", .unit = "kB", .desc = "Memory available size", },
+ { .id = MEMORY_ATTR_FREE, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_FREE", .unit = "kB", .desc = "Memory free size", },
+ { .id = MEMORY_ATTR_BUFFER, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_BUFFER", .unit = "kB", .desc = "Memorry buffer size", },
+ { .id = MEMORY_ATTR_CACHED, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_CACHED", .unit = "kB", .desc = "Memory cached size", },
+ { .id = MEMORY_ATTR_CMA_TOTAL, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_CMA_TOTAL", .unit = "kB", .desc = "CMA memory total size", },
+ { .id = MEMORY_ATTR_CMA_FREE, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_CMA_FREE", .unit = "kB", .desc = "CMA memory free size", },
+ { .id = MEMORY_ATTR_SWAP_TOTAL, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_SWAP_TOTAL", .unit = "kB", .desc = "Swap memory total size", },
+ { .id = MEMORY_ATTR_SWAP_FREE, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "MEMORY_ATTR_SWAP_FREE", .unit = "kB", .desc = "Swap memory free size", },
};
-static struct resource_attr_data battery_attrs[] = {
- { .id = BATTERY_ATTR_CAPACITY, .type = DATA_TYPE_INT, .name = "BATTERY_ATTR_CAPACITY", .unit = "%", .desc = "Battery capacity", },
- { .id = BATTERY_ATTR_STATUS, .type = DATA_TYPE_STRING, .name = "BATTERY_ATTR_STATUS", .unit = "", .desc = "Battery status", },
- { .id = BATTERY_ATTR_TEMPERATURE, .type = DATA_TYPE_INT, .name = "BATTERY_ATTR_TEMPERATURE", .unit = "", .desc = "Battery temperature", },
- { .id = BATTERY_ATTR_VOLTAGE_NOW, .type = DATA_TYPE_INT, .name = "BATTERY_ATTR_VOLTAGE_NOW", .unit = "uV", .desc = "Battery voltage figure", },
- { .id = BATTERY_ATTR_CURRENT_NOW, .type = DATA_TYPE_INT, .name = "BATTERY_ATTR_CURRENT_NOW", .unit = "uA", .desc = "Battery current figure", },
- { .id = BATTERY_ATTR_PRESENT, .type = DATA_TYPE_INT, .name = "BATTERY_ATTR_PRESENT", .unit = "", .desc = "Battery connected status", },
- { .id = BATTERY_ATTR_ONLINE, .type = DATA_TYPE_INT, .name = "BATTERY_ATTR_ONLINE", .unit = "", .desc = "Battery charger connector status", },
+static struct syscommon_resman_resource_attr_data battery_attrs[] = {
+ { .id = BATTERY_ATTR_CAPACITY, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BATTERY_ATTR_CAPACITY", .unit = "%", .desc = "Battery capacity", },
+ { .id = BATTERY_ATTR_STATUS, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "BATTERY_ATTR_STATUS", .unit = "", .desc = "Battery status", },
+ { .id = BATTERY_ATTR_TEMPERATURE, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BATTERY_ATTR_TEMPERATURE", .unit = "", .desc = "Battery temperature", },
+ { .id = BATTERY_ATTR_VOLTAGE_NOW, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BATTERY_ATTR_VOLTAGE_NOW", .unit = "uV", .desc = "Battery voltage figure", },
+ { .id = BATTERY_ATTR_CURRENT_NOW, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BATTERY_ATTR_CURRENT_NOW", .unit = "uA", .desc = "Battery current figure", },
+ { .id = BATTERY_ATTR_PRESENT, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BATTERY_ATTR_PRESENT", .unit = "", .desc = "Battery connected status", },
+ { .id = BATTERY_ATTR_ONLINE, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "BATTERY_ATTR_ONLINE", .unit = "", .desc = "Battery charger connector status", },
};
-static struct resource_attr_data display_attrs[] = {
- { .id = DISPLAY_ATTR_NAME, .type = DATA_TYPE_STRING, .name = "DISPLAY_ATTR_NAME", .unit = "", .desc = "Display device name", },
- { .id = DISPLAY_ATTR_FPS, .type = DATA_TYPE_DOUBLE, .name = "DISPLAY_ATTR_FPS", .unit = "fps", .desc = "Frame per second", },
+static struct syscommon_resman_resource_attr_data display_attrs[] = {
+ { .id = DISPLAY_ATTR_NAME, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "DISPLAY_ATTR_NAME", .unit = "", .desc = "Display device name", },
+ { .id = DISPLAY_ATTR_FPS, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "DISPLAY_ATTR_FPS", .unit = "fps", .desc = "Frame per second", },
};
-static struct resource_attr_data system_attrs[] = {
- { .id = SYSTEM_ATTR_CPU_UTIL, .type = DATA_TYPE_DOUBLE, .name = "SYSTEM_ATTR_CPU_UTIL", .unit = "%", .desc = "CPU average utilization", },
- { .id = SYSTEM_ATTR_CPU_USER_UTIL, .type = DATA_TYPE_DOUBLE, .name = "SYSTEM_ATTR_CPU_USER_UTIL", .unit = "%", .desc = "CPU average utilization on user", },
- { .id = SYSTEM_ATTR_CPU_SYS_UTIL, .type = DATA_TYPE_DOUBLE, .name = "SYSTEM_ATTR_CPU_SYS_UTIL", .unit = "%", .desc = "CPU average utilization on system", },
- { .id = SYSTEM_ATTR_PER_CPU_UTIL, .type = DATA_TYPE_ARRAY, .name = "SYSTEM_ATTR_PER_CPU_UTIL", .unit = "%", .desc = "Per-CPU utilization", .array_type = DATA_TYPE_DOUBLE, },
- { .id = SYSTEM_ATTR_PER_CPU_USER_UTIL, .type = DATA_TYPE_ARRAY, .name = "SYSTEM_ATTR_PER_CPU_USER_UTIL", .unit = "%", .desc = "Per-CPU utilization on user", .array_type = DATA_TYPE_DOUBLE, },
- { .id = SYSTEM_ATTR_PER_CPU_SYS_UTIL, .type = DATA_TYPE_ARRAY, .name = "SYSTEM_ATTR_PER_CPU_SYS_UTIL", .unit = "%", .desc = "Per-CPU utilization on system", .array_type = DATA_TYPE_DOUBLE, },
- { .id = SYSTEM_ATTR_POSSIBLE_CPU, .type = DATA_TYPE_INT, .name = "SYSTEM_ATTR_POSSIBLE_CPU", .unit = "ea", .desc = "Number of possible CPU", },
- { .id = SYSTEM_ATTR_ONLINE_CPU, .type = DATA_TYPE_INT, .name = "SYSTEM_ATTR_ONLINE_CPU", .unit = "ea", .desc = "Number of online CPU", },
+static struct syscommon_resman_resource_attr_data system_attrs[] = {
+ { .id = SYSTEM_ATTR_CPU_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "SYSTEM_ATTR_CPU_UTIL", .unit = "%", .desc = "CPU average utilization", },
+ { .id = SYSTEM_ATTR_CPU_USER_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "SYSTEM_ATTR_CPU_USER_UTIL", .unit = "%", .desc = "CPU average utilization on user", },
+ { .id = SYSTEM_ATTR_CPU_SYS_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "SYSTEM_ATTR_CPU_SYS_UTIL", .unit = "%", .desc = "CPU average utilization on system", },
+ { .id = SYSTEM_ATTR_PER_CPU_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .name = "SYSTEM_ATTR_PER_CPU_UTIL", .unit = "%", .desc = "Per-CPU utilization", .array_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .id = SYSTEM_ATTR_PER_CPU_USER_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .name = "SYSTEM_ATTR_PER_CPU_USER_UTIL", .unit = "%", .desc = "Per-CPU utilization on user", .array_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .id = SYSTEM_ATTR_PER_CPU_SYS_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .name = "SYSTEM_ATTR_PER_CPU_SYS_UTIL", .unit = "%", .desc = "Per-CPU utilization on system", .array_type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, },
+ { .id = SYSTEM_ATTR_POSSIBLE_CPU, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "SYSTEM_ATTR_POSSIBLE_CPU", .unit = "ea", .desc = "Number of possible CPU", },
+ { .id = SYSTEM_ATTR_ONLINE_CPU, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "SYSTEM_ATTR_ONLINE_CPU", .unit = "ea", .desc = "Number of online CPU", },
};
-struct resource_attr_data process_attrs[] = {
- { .id = PROCESS_ATTR_NAME, .type = DATA_TYPE_STRING, .name = "PROCESS_ATTR_NAME", .unit = "", .desc = "Process name", },
- { .id = PROCESS_ATTR_CPU_UTIL, .type = DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_CPU_UTIL", .unit = "%", .desc = "Process CPU utilization", },
- { .id = PROCESS_ATTR_MEM_VIRT, .type = DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_VIRT", .unit = "kB", .desc = "Process VIRT memory size", },
- { .id = PROCESS_ATTR_MEM_RSS, .type = DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_RSS", .unit = "kB", .desc = "Process RSS(Resident Set Size) memory size", },
- { .id = PROCESS_ATTR_MEM_RSS_PERCENT, .type = DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_MEM_RSS_PERCENT", .unit = "%", .desc = "Process RSS(Resident Set Size) memory percent", },
- { .id = PROCESS_ATTR_DISK_READ_PER_SEC, .type = DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_DISK_READ_PER_SEC", .unit = "kB/s", .desc = "Process disk read per second", },
- { .id = PROCESS_ATTR_DISK_WRITE_PER_SEC, .type = DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_DISK_WRITE_PER_SEC", .unit = "kB/s", .desc = "Process disk write per second", },
- { .id = PROCESS_ATTR_PGID, .type = DATA_TYPE_INT, .name = "PROCESS_ATTR_PGID", .unit = "", .desc = "Process group ID", },
- { .id = PROCESS_ATTR_PPID, .type = DATA_TYPE_INT, .name = "PROCESS_ATTR_PPID", .unit = "", .desc = "Process parent PID(Process ID)", },
- { .id = PROCESS_ATTR_MEM_PSS, .type = DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_PSS", .unit = "kB", .desc = "Process PSS(Propotional Set Size) memory size", },
- { .id = PROCESS_ATTR_MEM_SWAP, .type = DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_SWAP", .unit = "kB", .desc = "Process Swap memory size", },
- { .id = PROCESS_ATTR_MEM_SWAP_PSS, .type = DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_SWAP_PSS", .unit = "kB", .desc = "Process Swap PSS(Propotional Set Size) memory size", },
- { .id = PROCESS_ATTR_MEM_GPU, .type = DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_GPU", .unit = "kB", .desc = "Process GPU memory size", },
+struct syscommon_resman_resource_attr_data process_attrs[] = {
+ { .id = PROCESS_ATTR_NAME, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "PROCESS_ATTR_NAME", .unit = "", .desc = "Process name", },
+ { .id = PROCESS_ATTR_CPU_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_CPU_UTIL", .unit = "%", .desc = "Process CPU utilization", },
+ { .id = PROCESS_ATTR_MEM_VIRT, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_VIRT", .unit = "kB", .desc = "Process VIRT memory size", },
+ { .id = PROCESS_ATTR_MEM_RSS, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_RSS", .unit = "kB", .desc = "Process RSS(Resident Set Size) memory size", },
+ { .id = PROCESS_ATTR_MEM_RSS_PERCENT, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_MEM_RSS_PERCENT", .unit = "%", .desc = "Process RSS(Resident Set Size) memory percent", },
+ { .id = PROCESS_ATTR_DISK_READ_PER_SEC, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_DISK_READ_PER_SEC", .unit = "kB/s", .desc = "Process disk read per second", },
+ { .id = PROCESS_ATTR_DISK_WRITE_PER_SEC, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "PROCESS_ATTR_DISK_WRITE_PER_SEC", .unit = "kB/s", .desc = "Process disk write per second", },
+ { .id = PROCESS_ATTR_PGID, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "PROCESS_ATTR_PGID", .unit = "", .desc = "Process group ID", },
+ { .id = PROCESS_ATTR_PPID, .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, .name = "PROCESS_ATTR_PPID", .unit = "", .desc = "Process parent PID(Process ID)", },
+ { .id = PROCESS_ATTR_MEM_PSS, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_PSS", .unit = "kB", .desc = "Process PSS(Propotional Set Size) memory size", },
+ { .id = PROCESS_ATTR_MEM_SWAP, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_SWAP", .unit = "kB", .desc = "Process Swap memory size", },
+ { .id = PROCESS_ATTR_MEM_SWAP_PSS, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_SWAP_PSS", .unit = "kB", .desc = "Process Swap PSS(Propotional Set Size) memory size", },
+ { .id = PROCESS_ATTR_MEM_GPU, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_ATTR_MEM_GPU", .unit = "kB", .desc = "Process GPU memory size", },
};
-struct resource_attr_data process_group_attrs[] = {
- { .id = PROCESS_GROUP_ATTR_PID_LIST, .type = DATA_TYPE_ARRAY, .name = "PROCESS_GROUP_ATTR_PID_LIST", .unit = "", .desc = "Process-group PID(Process ID) list", .array_type = DATA_TYPE_INT, },
- { .id = PROCESS_GROUP_ATTR_NAME_LIST, .type = DATA_TYPE_ARRAY, .name = "PROCESS_GROUP_ATTR_NAME_LIST", .unit = "", .desc = "Process-group name list", .array_type = DATA_TYPE_STRING, },
- { .id = PROCESS_GROUP_ATTR_CPU_UTIL, .type = DATA_TYPE_DOUBLE, .name = "PROCESS_GROUP_ATTR_CPU_UTIL", .unit = "%", .desc = "Process-group CPU utilization", },
- { .id = PROCESS_GROUP_ATTR_DISK_READ_PER_SEC, .type = DATA_TYPE_DOUBLE, .name = "PROCESS_GROUP_ATTR_DISK_READ_PER_SEC", .unit = "kB/s", .desc = "Process-group disk read per second", },
- { .id = PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC, .type = DATA_TYPE_DOUBLE, .name = "PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC", .unit = "kB/s", .desc = "Process-group disk write per second", },
- { .id = PROCESS_GROUP_ATTR_MEM_VIRT, .type = DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_VIRT", .unit = "kB", .desc = "Process-group VIRT memory size", },
- { .id = PROCESS_GROUP_ATTR_MEM_RSS, .type = DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_RSS", .unit = "kB", .desc = "Process-group RSS(Resident Set Size) memory size", },
- { .id = PROCESS_GROUP_ATTR_MEM_PSS, .type = DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_PSS", .unit = "kB", .desc = "Process-group PSS(Propotional Set Size) memory size", },
- { .id = PROCESS_GROUP_ATTR_MEM_SWAP, .type = DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_SWAP", .unit = "kB", .desc = "Process-group Swap memory size", },
- { .id = PROCESS_GROUP_ATTR_MEM_SWAP_PSS, .type = DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_SWAP_PSS", .unit = "kB", .desc = "Process-group Swap PSS(Propotional Set Size) memory size", },
- { .id = PROCESS_GROUP_ATTR_MEM_GPU, .type = DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_GPU", .unit = "kB", .desc = "Process-group GPU memory size", },
+struct syscommon_resman_resource_attr_data process_group_attrs[] = {
+ { .id = PROCESS_GROUP_ATTR_PID_LIST, .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .name = "PROCESS_GROUP_ATTR_PID_LIST", .unit = "", .desc = "Process-group PID(Process ID) list", .array_type = SYSCOMMON_RESMAN_DATA_TYPE_INT, },
+ { .id = PROCESS_GROUP_ATTR_NAME_LIST, .type = SYSCOMMON_RESMAN_DATA_TYPE_ARRAY, .name = "PROCESS_GROUP_ATTR_NAME_LIST", .unit = "", .desc = "Process-group name list", .array_type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, },
+ { .id = PROCESS_GROUP_ATTR_CPU_UTIL, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "PROCESS_GROUP_ATTR_CPU_UTIL", .unit = "%", .desc = "Process-group CPU utilization", },
+ { .id = PROCESS_GROUP_ATTR_DISK_READ_PER_SEC, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "PROCESS_GROUP_ATTR_DISK_READ_PER_SEC", .unit = "kB/s", .desc = "Process-group disk read per second", },
+ { .id = PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "PROCESS_GROUP_ATTR_DISK_WRITE_PER_SEC", .unit = "kB/s", .desc = "Process-group disk write per second", },
+ { .id = PROCESS_GROUP_ATTR_MEM_VIRT, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_VIRT", .unit = "kB", .desc = "Process-group VIRT memory size", },
+ { .id = PROCESS_GROUP_ATTR_MEM_RSS, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_RSS", .unit = "kB", .desc = "Process-group RSS(Resident Set Size) memory size", },
+ { .id = PROCESS_GROUP_ATTR_MEM_PSS, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_PSS", .unit = "kB", .desc = "Process-group PSS(Propotional Set Size) memory size", },
+ { .id = PROCESS_GROUP_ATTR_MEM_SWAP, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_SWAP", .unit = "kB", .desc = "Process-group Swap memory size", },
+ { .id = PROCESS_GROUP_ATTR_MEM_SWAP_PSS, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_SWAP_PSS", .unit = "kB", .desc = "Process-group Swap PSS(Propotional Set Size) memory size", },
+ { .id = PROCESS_GROUP_ATTR_MEM_GPU, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "PROCESS_GROUP_ATTR_MEM_GPU", .unit = "kB", .desc = "Process-group GPU memory size", },
};
-struct resource_attr_data disk_attrs[] = {
- { .id = DISK_ATTR_NAME, .type = DATA_TYPE_STRING, .name = "DISK_ATTR_NAME", .unit = "", .desc = "Disk device name", },
- { .id = DISK_ATTR_READ_PER_SEC, .type = DATA_TYPE_DOUBLE, .name = "DISK_ATTR_READ_PER_SEC", .unit = "kB/s", .desc = "Disk read per second", },
- { .id = DISK_ATTR_WRITE_PER_SEC, .type = DATA_TYPE_DOUBLE, .name = "DISK_ATTR_WRITE_PER_SEC", .unit = "kB/s", .desc = "Disk write per second", },
- { .id = DISK_ATTR_READ_TOTAL, .type = DATA_TYPE_UINT64, .name = "DISK_ATTR_READ_TOTAL", .unit = "kB", .desc = "Disk read total size", },
- { .id = DISK_ATTR_WRITE_TOTAL, .type = DATA_TYPE_UINT64, .name = "DISK_ATTR_WRITE_TOTAL", .unit = "kB", .desc = "Disk write total size", },
+struct syscommon_resman_resource_attr_data disk_attrs[] = {
+ { .id = DISK_ATTR_NAME, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "DISK_ATTR_NAME", .unit = "", .desc = "Disk device name", },
+ { .id = DISK_ATTR_READ_PER_SEC, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "DISK_ATTR_READ_PER_SEC", .unit = "kB/s", .desc = "Disk read per second", },
+ { .id = DISK_ATTR_WRITE_PER_SEC, .type = SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE, .name = "DISK_ATTR_WRITE_PER_SEC", .unit = "kB/s", .desc = "Disk write per second", },
+ { .id = DISK_ATTR_READ_TOTAL, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "DISK_ATTR_READ_TOTAL", .unit = "kB", .desc = "Disk read total size", },
+ { .id = DISK_ATTR_WRITE_TOTAL, .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64, .name = "DISK_ATTR_WRITE_TOTAL", .unit = "kB", .desc = "Disk write total size", },
};
-struct resource_attr_data network_attrs[] = {
- { .id = NETWORK_ATTR_NAME, .type = DATA_TYPE_STRING, .name = "NETWORK_ATTR_NAME", .unit = "", .desc = "Network device name", },
+struct syscommon_resman_resource_attr_data network_attrs[] = {
+ { .id = NETWORK_ATTR_NAME, .type = SYSCOMMON_RESMAN_DATA_TYPE_STRING, .name = "NETWORK_ATTR_NAME", .unit = "", .desc = "Network device name", },
};
-struct resource_data {
+struct syscommon_resman_resource_data {
int mon_id;
int res_index;
int res_id;
@@ -171,10 +173,10 @@ struct resource_data {
u_int64_t ctrl_id;
int ctrl_val;
int num_attrs;
- struct resource_attr_data attrs[MAX_ATTR];
+ struct syscommon_resman_resource_attr_data attrs[MAX_ATTR];
};
-struct resource_monitor_data {
+struct syscommon_resman_resource_monitor_data {
unsigned int pid;
unsigned int ppid;
int secs;
@@ -182,7 +184,7 @@ struct resource_monitor_data {
int mon_id;
int num_res;
- struct resource_data res[MAX_RESOURCE];
+ struct syscommon_resman_resource_data res[MAX_RESOURCE];
} g_data;
struct __resource_type {
@@ -190,7 +192,7 @@ struct __resource_type {
u_int64_t ctrl_id;
int ctrl_val;
int num_attrs;
- struct resource_attr_data *attrs;
+ struct syscommon_resman_resource_attr_data *attrs;
int res_count;
} g_resource_type[] = {
@@ -254,7 +256,7 @@ struct __resource_type {
},
};
-static inline void create_resource_and_set_attrs(struct resource_data *res, int ctrl_val)
+static inline void create_resource_and_set_attrs(struct syscommon_resman_resource_data *res, int ctrl_val)
{
int i, ret;
bool supported;
@@ -282,7 +284,7 @@ static inline void create_resource_and_set_attrs(struct resource_data *res, int
pass_resource_monitor_set_resource_attr(res->mon_id, res->res_id, res->mask);
}
-static inline void unset_attrs_and_delete_resource(struct resource_data *res)
+static inline void unset_attrs_and_delete_resource(struct syscommon_resman_resource_data *res)
{
if (!res)
return;
@@ -291,7 +293,7 @@ static inline void unset_attrs_and_delete_resource(struct resource_data *res)
pass_resource_monitor_delete_resource(res->mon_id, res->res_id);
}
-static inline int get_resource_attr_array_value(struct resource_data *res, int idx)
+static inline int syscommon_resman_get_resource_attr_array_value(struct syscommon_resman_resource_data *res, int idx)
{
int i;
int ret = 0;
@@ -304,7 +306,7 @@ static inline int get_resource_attr_array_value(struct resource_data *res, int i
return -1;
switch (res->attrs[idx].array_type) {
- case DATA_TYPE_DOUBLE:
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
ret = pass_resource_monitor_get_array_double(
res->mon_id, res->res_id,
res->attrs[idx].id, &array, &length);
@@ -331,11 +333,11 @@ static inline int get_resource_attr_array_value(struct resource_data *res, int i
free(array);
break;
- case DATA_TYPE_INT:
- case DATA_TYPE_INT64:
- case DATA_TYPE_UINT:
- case DATA_TYPE_UINT64:
- case DATA_TYPE_STRING:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_STRING:
printf("%40s | %-5s | %s", "Not Implemented",
res->attrs[idx].unit, res->attrs[idx].desc);
break;
@@ -346,7 +348,7 @@ static inline int get_resource_attr_array_value(struct resource_data *res, int i
return ret;
}
-static inline void get_resource_attr_value(struct resource_data *res, int i)
+static inline void syscommon_resman_get_resource_attr_value(struct syscommon_resman_resource_data *res, int i)
{
bool supported;
int ret = 0;
@@ -368,7 +370,7 @@ static inline void get_resource_attr_value(struct resource_data *res, int i)
}
switch (res->attrs[i].type) {
- case DATA_TYPE_INT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
ret = pass_resource_monitor_get_value_int(
res->mon_id, res->res_id,
res->attrs[i].id,
@@ -379,7 +381,7 @@ static inline void get_resource_attr_value(struct resource_data *res, int i)
res->attrs[i].value_int32,
res->attrs[i].unit, res->attrs[i].desc);
break;
- case DATA_TYPE_INT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
ret = pass_resource_monitor_get_value_int64(
res->mon_id, res->res_id,
res->attrs[i].id,
@@ -390,7 +392,7 @@ static inline void get_resource_attr_value(struct resource_data *res, int i)
res->attrs[i].value_int64,
res->attrs[i].unit, res->attrs[i].desc);
break;
- case DATA_TYPE_UINT:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
ret = pass_resource_monitor_get_value_uint(
res->mon_id, res->res_id,
res->attrs[i].id,
@@ -401,7 +403,7 @@ static inline void get_resource_attr_value(struct resource_data *res, int i)
res->attrs[i].value_uint32,
res->attrs[i].unit, res->attrs[i].desc);
break;
- case DATA_TYPE_UINT64:
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
ret = pass_resource_monitor_get_value_uint64(
res->mon_id, res->res_id,
res->attrs[i].id,
@@ -412,7 +414,7 @@ static inline void get_resource_attr_value(struct resource_data *res, int i)
res->attrs[i].value_uint64,
res->attrs[i].unit, res->attrs[i].desc);
break;
- case DATA_TYPE_DOUBLE:
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
ret = pass_resource_monitor_get_value_double(
res->mon_id, res->res_id,
res->attrs[i].id,
@@ -423,7 +425,7 @@ static inline void get_resource_attr_value(struct resource_data *res, int i)
res->attrs[i].value_double,
res->attrs[i].unit, res->attrs[i].desc);
break;
- case DATA_TYPE_STRING:
+ case SYSCOMMON_RESMAN_DATA_TYPE_STRING:
ret = pass_resource_monitor_get_value_string(
res->mon_id, res->res_id,
res->attrs[i].id,
@@ -435,11 +437,11 @@ static inline void get_resource_attr_value(struct resource_data *res, int i)
res->attrs[i].unit, res->attrs[i].desc);
g_free(res->attrs[i].value_string);
break;
- case DATA_TYPE_ARRAY:
- ret = get_resource_attr_array_value(res, i);
+ case SYSCOMMON_RESMAN_DATA_TYPE_ARRAY:
+ ret = syscommon_resman_get_resource_attr_array_value(res, i);
break;
- case DATA_TYPE_PTR:
- case DATA_TYPE_BOOLEAN:
+ case SYSCOMMON_RESMAN_DATA_TYPE_PTR:
+ case SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN:
printf("(%40s) | %-5s | %s", "Not Implemented",
res->attrs[i].unit, res->attrs[i].desc);
break;
@@ -494,20 +496,20 @@ static int resource_monitor_init(void)
continue;
for (j = 0; j < count; j++) {
- struct resource_data *res = &g_data.res[g_data.num_res++];
+ struct syscommon_resman_resource_data *res = &g_data.res[g_data.num_res++];
res->mon_id = g_data.mon_id;
res->res_index = j;
res->type = g_resource_type[i].type;
res->ctrl_id = g_resource_type[i].ctrl_id;
res->num_attrs = g_resource_type[i].num_attrs;
- memcpy(res->attrs, g_resource_type[i].attrs, sizeof(struct resource_attr_data) * res->num_attrs);
+ memcpy(res->attrs, g_resource_type[i].attrs, sizeof(struct syscommon_resman_resource_attr_data) * res->num_attrs);
res->ctrl_val = g_resource_type[i].ctrl_val;
}
}
for (i = 0; i < g_data.num_res; i++) {
- struct resource_data *res = &g_data.res[i];
+ struct syscommon_resman_resource_data *res = &g_data.res[i];
if (res->ctrl_val > 0)
create_resource_and_set_attrs(res, res->ctrl_val);
@@ -537,11 +539,11 @@ static void resource_monitor(void)
printf("-------------------------------------------------------------------------------------------------------------------------------\n");
for (i = 0; i < g_data.num_res; i++) {
- struct resource_data *res = &g_data.res[i];
+ struct syscommon_resman_resource_data *res = &g_data.res[i];
for (j = 0; j < res->num_attrs; j++) {
printf("%2d:%2d| %40s | ", i, j, res->attrs[j].name);
- get_resource_attr_value(res, j);
+ syscommon_resman_get_resource_attr_value(res, j);
printf("\n");
}
printf("\n");