util: Change directgory name from include/pass to include/util 81/269981/4
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 19 Jan 2022 10:03:37 +0000 (19:03 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 24 Jan 2022 09:23:58 +0000 (18:23 +0900)
Change directory name from include/pass to include/util
because 'include/util' directory declares the utility functions.

Change-Id: Ie3dc727aac7ff4c074bea7ab5bec632685a9685e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
32 files changed:
include/pass/common.h [deleted file]
include/pass/device-notifier.h [deleted file]
include/pass/devices.h [deleted file]
include/pass/gdbus-definition.h [deleted file]
include/pass/gdbus-util.h [deleted file]
include/pass/log.h [deleted file]
include/util/common.h [new file with mode: 0644]
include/util/device-notifier.h [new file with mode: 0644]
include/util/devices.h [new file with mode: 0644]
include/util/gdbus-definition.h [new file with mode: 0644]
include/util/gdbus-util.h [new file with mode: 0644]
include/util/log.h [new file with mode: 0644]
src/main.c
src/pass/pass-cpuhp.c
src/pass/pass-hal.c
src/pass/pass-parser.c
src/pass/pass-pmqos.c
src/pass/pass-resmon-source.c
src/pass/pass-resmon.c
src/pass/pass-thermal.c
src/pass/pass.c
src/pass/pass.h
src/pmqos/pmqos-parser.c
src/pmqos/pmqos.c
src/thermal/thermal-parser.c
src/thermal/thermal.c
src/util/common.c
src/util/device-notifier.c
src/util/devices.c
src/util/gdbus-util.c
unittest/pass-unittests.cpp
unittest/power-haltests.cpp

diff --git a/include/pass/common.h b/include/pass/common.h
deleted file mode 100644 (file)
index d0f0100..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * PASS
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __CORE_COMMON_H__
-#define __CORE_COMMON_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <error.h>
-#include <stdbool.h>
-#include <unistd.h>
-
-#include <json-c/json.h>
-#include <json-c/arraylist.h>
-
-typedef unsigned int uint32;
-typedef unsigned long long uint64;
-
-#define BUFF_MAX        255
-#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
-
-/*
- * One byte digit has 3 position in decimal representation
- * 2 - 5
- * 4 - 10
- * 8 - 20
- * >8 - compile time error
- * plus 1 null termination byte
- * plus 1 for negative prefix
- */
-#define MAX_DEC_SIZE(type) \
-       (2 + (sizeof(type) <= 1 ? 3 : \
-       sizeof(type) <= 2 ? 5 : \
-       sizeof(type) <= 4 ? 10 : \
-       sizeof(type) <= 8 ? 20 : \
-       sizeof(int[-2*(sizeof(type) > 8)])))
-
-#ifndef __CONSTRUCTOR__
-#define __CONSTRUCTOR__ __attribute__ ((constructor))
-#endif
-
-#ifndef __DESTRUCTOR__
-#define __DESTRUCTOR__ __attribute__ ((destructor))
-#endif
-
-#ifndef __WEAK__
-#define __WEAK__ __attribute__ ((weak))
-#endif
-
-#ifndef max
-#define max(a, b)                      \
-       __extension__ ({                \
-               typeof(a) _a = (a);     \
-               typeof(b) _b = (b);     \
-               _a > _b ? _a : _b;      \
-       })
-#endif
-
-#ifndef min
-#define min(a, b)                      \
-       __extension__ ({                \
-               typeof(a) _a = (a);     \
-               typeof(b) _b = (b);     \
-               _a < _b ? _a : _b;      \
-       })
-#endif
-
-#ifndef SEC_TO_MSEC
-#define SEC_TO_MSEC(x)         ((x)*1000)
-#endif
-#ifndef MSEC_TO_USEC
-#define MSEC_TO_USEC(x)                ((unsigned int)(x)*1000)
-#endif
-#ifndef NSEC_TO_MSEC
-#define NSEC_TO_MSEC(x)                ((double)x/1000000)
-#endif
-#ifndef USEC_TO_MSEC
-#define USEC_TO_MSEC(x)                ((double)x/1000)
-#endif
-
-int sys_get_str(const char *fname, char *str);
-
-const char *get_string_from_object(json_object *obj, const char *key);
-const int get_int_from_object(json_object *obj, const char *key);
-const double get_double_from_object(json_object *obj, const char *key);
-const int get_boolean_from_object(json_object *obj, const char *key);
-json_object *get_object_from_object(json_object *obj, const char *key);
-#endif /* __CORE_COMMON_H__ */
diff --git a/include/pass/device-notifier.h b/include/pass/device-notifier.h
deleted file mode 100644 (file)
index 4af325a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * PASS
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 __DEVICE_NOTIFIER_H__
-#define __DEVICE_NOTIFIER_H__
-
-#include <stdbool.h>
-#include <pass/common.h>
-
-enum device_notifier_type {
-       DEVICE_NOTIFIER_INIT_DONE,
-       DEVICE_NOTIFIER_PMQOS,
-       DEVICE_NOTIFIER_THERMAL,
-       DEVICE_NOTIFIER_THERMAL_GET_SCENARIO,
-       DEVICE_NOTIFIER_MAX,
-};
-
-struct device_notifier {
-       bool is_used;
-       enum device_notifier_type status;
-       int (*func)(void *data, void *user_data);
-       void *user_data;
-};
-
-/* data structure for DEVICE_NOTIFIER_THERMAL */
-struct device_notifier_thermal_data {
-       char *name;
-       char scenario[BUFF_MAX];
-       int priority;
-};
-
-/*
- * This is for internal callback method.
- */
-int register_notifier(enum device_notifier_type status,
-               int (*func)(void *data, void *user_data), void *user_data);
-int unregister_notifier(enum device_notifier_type status,
-               int (*func)(void *data, void *user_data), void *user_data);
-void device_notify(enum device_notifier_type status, void *value);
-
-#endif /* __DEVICE_NOTIFIER_H__ */
diff --git a/include/pass/devices.h b/include/pass/devices.h
deleted file mode 100644 (file)
index 1a896ea..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * PASS
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __DEVICES_H__
-#define __DEVICES_H__
-
-#include <errno.h>
-#include "common.h"
-
-enum device_priority {
-       DEVICE_PRIORITY_NORMAL = 0,
-       DEVICE_PRIORITY_HIGH,
-};
-
-enum device_flags {
-       NORMAL_MODE                   = 0x00000001,
-};
-
-struct device_ops {
-       enum device_priority priority;
-       char *name;
-       int (*probe) (void *data);
-       void (*init) (void *data);
-       void (*exit) (void *data);
-       int (*start) (enum device_flags flags);
-       int (*stop) (enum device_flags flags);
-       int (*status) (void);
-       int (*execute) (void *data);
-};
-
-enum device_ops_status {
-       DEVICE_OPS_STATUS_UNINIT,
-       DEVICE_OPS_STATUS_START,
-       DEVICE_OPS_STATUS_STOP,
-       DEVICE_OPS_STATUS_MAX,
-};
-
-#define DEVICE_OPS_REGISTER(dev)       \
-static void __CONSTRUCTOR__ module_init(void)  \
-{      \
-       add_device(dev);        \
-}      \
-static void __DESTRUCTOR__ module_exit(void)   \
-{      \
-       remove_device(dev);     \
-}
-
-void init_devices(void *data);
-void exit_devices(void *data);
-void add_device(const struct device_ops *dev);
-void remove_device(const struct device_ops *dev);
-#endif
diff --git a/include/pass/gdbus-definition.h b/include/pass/gdbus-definition.h
deleted file mode 100644 (file)
index 5072341..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2018 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 __GDBUS_DEFINITION_H__
-#define __GDBUS_DEFINITION_H__
-
-typedef enum {
-       PASS_DBUS_CORE,
-       PASS_DBUS_THERMAL,
-       PASS_DBUS_MAX,
-} passdbus;
-
-/* Dbus definition for PASS */
-#define DBUS_PASS_BUS_NAME                     "org.tizen.system.pass"
-#define DBUS_PASS_PATH                         "/Org/Tizen/System/Pass"
-
-#define DBUS_CORE_INTERFACE                    "org.tizen.system.pass.core"
-#define DBUS_CORE_PATH                         "/Org/Tizen/System/Pass/Core"
-#define DBUS_CORE_I_START_HANDLER              "handle_start"
-#define DBUS_CORE_I_STOP_HANDLER               "handle_stop"
-
-#define DBUS_PMQOS_INTERFACE                   "org.tizen.system.pass.pmqos"
-#define DBUS_PMQOS_PATH                                "/Org/Tizen/System/Pass/Pmqos"
-#define DBUS_PMQOS_I_START_HANDLER             "handle_start"
-#define DBUS_PMQOS_I_STOP_HANDLER              "handle_stop"
-#define DBUS_PMQOS_I_APPLAUNCH_HANDLER         "handle_app_launch"
-#define DBUS_PMQOS_I_ULTRAPOWERSAVING_HANDLER  "handle_ultra_power_saving"
-#define DBUS_PMQOS_I_SET_SCENARIO_HANDLER      "handle_set_scenario"
-
-#define DBUS_THERMAL_BUS_NAME                  "org.tizen.system.thermal"
-#define DBUS_THERMAL_INTERFACE                 "org.tizen.system.thermal"
-#define DBUS_THERMAL_PATH                      "/Org/Tizen/System/Thermal"
-#define DBUS_THERMAL_I_START_HANDLER           "handle_start"
-#define DBUS_THERMAL_I_STOP_HANDLER            "handle_stop"
-#define DBUS_THERMAL_SIGNAL                    "CoolDownModeChanged"
-#define DBUS_THERMAL_METHOD                    "handle_get_cool_down_status"
-
-/* Dbus definition for systemd */
-#define SYSTEMD_DBUS_NAME                      "org.freedesktop.systemd1"
-#define SYSTEMD_DBUS_OBJECT_PATH               "/org/freedesktop/systemd1"
-#define SYSTEMD_DBUS_IFACE_FOR_PROPS           "org.freedesktop.DBus.Properties"
-#define SYSTEMD_DBUS_METHOD_GET_PROP           "Get"
-#define SYSTEMD_DBUS_METHOD_GET_PROP_ARG_TYPE  "(ss)"
-#define SYSTEMD_DBUS_METHOD_GET_PROP_RET_TYPE  "(v)"
-#define SYSTEMD_DBUS_IFACE_MANAGER             SYSTEMD_DBUS_NAME ".Manager"
-
-#endif /* __GDBUS_DEFINITION_H__ */
diff --git a/include/pass/gdbus-util.h b/include/pass/gdbus-util.h
deleted file mode 100644 (file)
index 2f8e078..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GDBUS_UTIL_H__
-#define __GDBUS_UTIL_H__
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <stdbool.h>
-
-#include "pass/pass-dbus-stub.h"
-#include "pmqos/pmqos-dbus-stub.h"
-#include "thermal/thermal-dbus-stub.h"
-
-#include "gdbus-definition.h"
-
-struct pass_gdbus_signal_info {
-       const gchar *handler;
-       GCallback cb;
-       gpointer cb_data;
-       gulong ret_id;
-};
-
-int pass_gdbus_register_systemd_startup_callback(GDBusSignalCallback cb,
-               gpointer user_data, guint *id);
-int pass_gdbus_unregister_systemd_startup_callback(guint id);
-int pass_gdbus_get_systemd_dbus_property_string(const char *iface,
-               const char *prop, const char **value);
-int pass_gdbus_export_interface(passdbus idx, gpointer instance, const char *obj_path);
-int pass_gdbus_get_name(passdbus idx, const char *name);
-int pass_gdbus_connect_signal(gpointer instance, int num_signals,
-               struct pass_gdbus_signal_info *signal_infos);
-void pass_gdbus_disconnect_signal(gpointer instance, int num_signals,
-               struct pass_gdbus_signal_info *signal_infos);
-int pass_gdbus_send_broadcast_signal(passdbus idx, char *path, char *interface,
-               char *method, GVariant *arg);
-
-SystemPassCore *pass_gdbus_get_instance_core(void);
-void pass_gdbus_put_instance_core(SystemPassCore **instance);
-SystemPassPmqos *pass_gdbus_get_instance_pmqos(void);
-void pass_gdbus_put_instance_pmqos(SystemPassPmqos **instance);
-SystemThermal *pass_gdbus_get_instance_thermal(void);
-void pass_gdbus_put_instance_thermal(SystemThermal **instance);
-
-int pass_gdbus_get_system_connection(passdbus idx);
-void pass_gdbus_put_system_connection(passdbus idx);
-#endif /* __GDBUS_UTIL_H__ */
diff --git a/include/pass/log.h b/include/pass/log.h
deleted file mode 100644 (file)
index 1edba9f..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __LOG_H__
-#define __LOG_H__
-
-#include <dlog.h>
-
-#define _D(fmt, arg...)                do { SLOGD(fmt, ##arg); } while (0)
-#define _I(fmt, arg...)                do { SLOGI(fmt, ##arg); } while (0)
-#define _W(fmt, arg...)                do { SLOGW(fmt, ##arg); } while (0)
-#define _E(fmt, arg...)                do { SLOGE(fmt, ##arg); } while (0)
-#endif
diff --git a/include/util/common.h b/include/util/common.h
new file mode 100644 (file)
index 0000000..d0f0100
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * PASS
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __CORE_COMMON_H__
+#define __CORE_COMMON_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <error.h>
+#include <stdbool.h>
+#include <unistd.h>
+
+#include <json-c/json.h>
+#include <json-c/arraylist.h>
+
+typedef unsigned int uint32;
+typedef unsigned long long uint64;
+
+#define BUFF_MAX        255
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+
+/*
+ * One byte digit has 3 position in decimal representation
+ * 2 - 5
+ * 4 - 10
+ * 8 - 20
+ * >8 - compile time error
+ * plus 1 null termination byte
+ * plus 1 for negative prefix
+ */
+#define MAX_DEC_SIZE(type) \
+       (2 + (sizeof(type) <= 1 ? 3 : \
+       sizeof(type) <= 2 ? 5 : \
+       sizeof(type) <= 4 ? 10 : \
+       sizeof(type) <= 8 ? 20 : \
+       sizeof(int[-2*(sizeof(type) > 8)])))
+
+#ifndef __CONSTRUCTOR__
+#define __CONSTRUCTOR__ __attribute__ ((constructor))
+#endif
+
+#ifndef __DESTRUCTOR__
+#define __DESTRUCTOR__ __attribute__ ((destructor))
+#endif
+
+#ifndef __WEAK__
+#define __WEAK__ __attribute__ ((weak))
+#endif
+
+#ifndef max
+#define max(a, b)                      \
+       __extension__ ({                \
+               typeof(a) _a = (a);     \
+               typeof(b) _b = (b);     \
+               _a > _b ? _a : _b;      \
+       })
+#endif
+
+#ifndef min
+#define min(a, b)                      \
+       __extension__ ({                \
+               typeof(a) _a = (a);     \
+               typeof(b) _b = (b);     \
+               _a < _b ? _a : _b;      \
+       })
+#endif
+
+#ifndef SEC_TO_MSEC
+#define SEC_TO_MSEC(x)         ((x)*1000)
+#endif
+#ifndef MSEC_TO_USEC
+#define MSEC_TO_USEC(x)                ((unsigned int)(x)*1000)
+#endif
+#ifndef NSEC_TO_MSEC
+#define NSEC_TO_MSEC(x)                ((double)x/1000000)
+#endif
+#ifndef USEC_TO_MSEC
+#define USEC_TO_MSEC(x)                ((double)x/1000)
+#endif
+
+int sys_get_str(const char *fname, char *str);
+
+const char *get_string_from_object(json_object *obj, const char *key);
+const int get_int_from_object(json_object *obj, const char *key);
+const double get_double_from_object(json_object *obj, const char *key);
+const int get_boolean_from_object(json_object *obj, const char *key);
+json_object *get_object_from_object(json_object *obj, const char *key);
+#endif /* __CORE_COMMON_H__ */
diff --git a/include/util/device-notifier.h b/include/util/device-notifier.h
new file mode 100644 (file)
index 0000000..5dbf47e
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * PASS
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __DEVICE_NOTIFIER_H__
+#define __DEVICE_NOTIFIER_H__
+
+#include <stdbool.h>
+#include <util/common.h>
+
+enum device_notifier_type {
+       DEVICE_NOTIFIER_INIT_DONE,
+       DEVICE_NOTIFIER_PMQOS,
+       DEVICE_NOTIFIER_THERMAL,
+       DEVICE_NOTIFIER_THERMAL_GET_SCENARIO,
+       DEVICE_NOTIFIER_MAX,
+};
+
+struct device_notifier {
+       bool is_used;
+       enum device_notifier_type status;
+       int (*func)(void *data, void *user_data);
+       void *user_data;
+};
+
+/* data structure for DEVICE_NOTIFIER_THERMAL */
+struct device_notifier_thermal_data {
+       char *name;
+       char scenario[BUFF_MAX];
+       int priority;
+};
+
+/*
+ * This is for internal callback method.
+ */
+int register_notifier(enum device_notifier_type status,
+               int (*func)(void *data, void *user_data), void *user_data);
+int unregister_notifier(enum device_notifier_type status,
+               int (*func)(void *data, void *user_data), void *user_data);
+void device_notify(enum device_notifier_type status, void *value);
+
+#endif /* __DEVICE_NOTIFIER_H__ */
diff --git a/include/util/devices.h b/include/util/devices.h
new file mode 100644 (file)
index 0000000..1a896ea
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * PASS
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __DEVICES_H__
+#define __DEVICES_H__
+
+#include <errno.h>
+#include "common.h"
+
+enum device_priority {
+       DEVICE_PRIORITY_NORMAL = 0,
+       DEVICE_PRIORITY_HIGH,
+};
+
+enum device_flags {
+       NORMAL_MODE                   = 0x00000001,
+};
+
+struct device_ops {
+       enum device_priority priority;
+       char *name;
+       int (*probe) (void *data);
+       void (*init) (void *data);
+       void (*exit) (void *data);
+       int (*start) (enum device_flags flags);
+       int (*stop) (enum device_flags flags);
+       int (*status) (void);
+       int (*execute) (void *data);
+};
+
+enum device_ops_status {
+       DEVICE_OPS_STATUS_UNINIT,
+       DEVICE_OPS_STATUS_START,
+       DEVICE_OPS_STATUS_STOP,
+       DEVICE_OPS_STATUS_MAX,
+};
+
+#define DEVICE_OPS_REGISTER(dev)       \
+static void __CONSTRUCTOR__ module_init(void)  \
+{      \
+       add_device(dev);        \
+}      \
+static void __DESTRUCTOR__ module_exit(void)   \
+{      \
+       remove_device(dev);     \
+}
+
+void init_devices(void *data);
+void exit_devices(void *data);
+void add_device(const struct device_ops *dev);
+void remove_device(const struct device_ops *dev);
+#endif
diff --git a/include/util/gdbus-definition.h b/include/util/gdbus-definition.h
new file mode 100644 (file)
index 0000000..5072341
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * PASS (Power Aware System Service)
+ *
+ * Copyright (c) 2018 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 __GDBUS_DEFINITION_H__
+#define __GDBUS_DEFINITION_H__
+
+typedef enum {
+       PASS_DBUS_CORE,
+       PASS_DBUS_THERMAL,
+       PASS_DBUS_MAX,
+} passdbus;
+
+/* Dbus definition for PASS */
+#define DBUS_PASS_BUS_NAME                     "org.tizen.system.pass"
+#define DBUS_PASS_PATH                         "/Org/Tizen/System/Pass"
+
+#define DBUS_CORE_INTERFACE                    "org.tizen.system.pass.core"
+#define DBUS_CORE_PATH                         "/Org/Tizen/System/Pass/Core"
+#define DBUS_CORE_I_START_HANDLER              "handle_start"
+#define DBUS_CORE_I_STOP_HANDLER               "handle_stop"
+
+#define DBUS_PMQOS_INTERFACE                   "org.tizen.system.pass.pmqos"
+#define DBUS_PMQOS_PATH                                "/Org/Tizen/System/Pass/Pmqos"
+#define DBUS_PMQOS_I_START_HANDLER             "handle_start"
+#define DBUS_PMQOS_I_STOP_HANDLER              "handle_stop"
+#define DBUS_PMQOS_I_APPLAUNCH_HANDLER         "handle_app_launch"
+#define DBUS_PMQOS_I_ULTRAPOWERSAVING_HANDLER  "handle_ultra_power_saving"
+#define DBUS_PMQOS_I_SET_SCENARIO_HANDLER      "handle_set_scenario"
+
+#define DBUS_THERMAL_BUS_NAME                  "org.tizen.system.thermal"
+#define DBUS_THERMAL_INTERFACE                 "org.tizen.system.thermal"
+#define DBUS_THERMAL_PATH                      "/Org/Tizen/System/Thermal"
+#define DBUS_THERMAL_I_START_HANDLER           "handle_start"
+#define DBUS_THERMAL_I_STOP_HANDLER            "handle_stop"
+#define DBUS_THERMAL_SIGNAL                    "CoolDownModeChanged"
+#define DBUS_THERMAL_METHOD                    "handle_get_cool_down_status"
+
+/* Dbus definition for systemd */
+#define SYSTEMD_DBUS_NAME                      "org.freedesktop.systemd1"
+#define SYSTEMD_DBUS_OBJECT_PATH               "/org/freedesktop/systemd1"
+#define SYSTEMD_DBUS_IFACE_FOR_PROPS           "org.freedesktop.DBus.Properties"
+#define SYSTEMD_DBUS_METHOD_GET_PROP           "Get"
+#define SYSTEMD_DBUS_METHOD_GET_PROP_ARG_TYPE  "(ss)"
+#define SYSTEMD_DBUS_METHOD_GET_PROP_RET_TYPE  "(v)"
+#define SYSTEMD_DBUS_IFACE_MANAGER             SYSTEMD_DBUS_NAME ".Manager"
+
+#endif /* __GDBUS_DEFINITION_H__ */
diff --git a/include/util/gdbus-util.h b/include/util/gdbus-util.h
new file mode 100644 (file)
index 0000000..2f8e078
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * PASS (Power Aware System Service)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GDBUS_UTIL_H__
+#define __GDBUS_UTIL_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdbool.h>
+
+#include "pass/pass-dbus-stub.h"
+#include "pmqos/pmqos-dbus-stub.h"
+#include "thermal/thermal-dbus-stub.h"
+
+#include "gdbus-definition.h"
+
+struct pass_gdbus_signal_info {
+       const gchar *handler;
+       GCallback cb;
+       gpointer cb_data;
+       gulong ret_id;
+};
+
+int pass_gdbus_register_systemd_startup_callback(GDBusSignalCallback cb,
+               gpointer user_data, guint *id);
+int pass_gdbus_unregister_systemd_startup_callback(guint id);
+int pass_gdbus_get_systemd_dbus_property_string(const char *iface,
+               const char *prop, const char **value);
+int pass_gdbus_export_interface(passdbus idx, gpointer instance, const char *obj_path);
+int pass_gdbus_get_name(passdbus idx, const char *name);
+int pass_gdbus_connect_signal(gpointer instance, int num_signals,
+               struct pass_gdbus_signal_info *signal_infos);
+void pass_gdbus_disconnect_signal(gpointer instance, int num_signals,
+               struct pass_gdbus_signal_info *signal_infos);
+int pass_gdbus_send_broadcast_signal(passdbus idx, char *path, char *interface,
+               char *method, GVariant *arg);
+
+SystemPassCore *pass_gdbus_get_instance_core(void);
+void pass_gdbus_put_instance_core(SystemPassCore **instance);
+SystemPassPmqos *pass_gdbus_get_instance_pmqos(void);
+void pass_gdbus_put_instance_pmqos(SystemPassPmqos **instance);
+SystemThermal *pass_gdbus_get_instance_thermal(void);
+void pass_gdbus_put_instance_thermal(SystemThermal **instance);
+
+int pass_gdbus_get_system_connection(passdbus idx);
+void pass_gdbus_put_system_connection(passdbus idx);
+#endif /* __GDBUS_UTIL_H__ */
diff --git a/include/util/log.h b/include/util/log.h
new file mode 100644 (file)
index 0000000..1edba9f
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * PASS (Power Aware System Service)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LOG_H__
+#define __LOG_H__
+
+#include <dlog.h>
+
+#define _D(fmt, arg...)                do { SLOGD(fmt, ##arg); } while (0)
+#define _I(fmt, arg...)                do { SLOGI(fmt, ##arg); } while (0)
+#define _W(fmt, arg...)                do { SLOGW(fmt, ##arg); } while (0)
+#define _E(fmt, arg...)                do { SLOGE(fmt, ##arg); } while (0)
+#endif
index 41e7f098f2a402d5f9a3fc7193bbaa62fa72587c..180a32683a3ea1140023263cc8af80369ea0d4ae 100644 (file)
 #include <gio/gio.h>
 #include <sys/reboot.h>
 
-#include <pass/common.h>
-#include <pass/device-notifier.h>
-#include <pass/devices.h>
-#include <pass/gdbus-util.h>
-#include <pass/log.h>
+#include <util/common.h>
+#include <util/device-notifier.h>
+#include <util/devices.h>
+#include <util/gdbus-util.h>
+#include <util/log.h>
 
 GMainLoop *g_mainloop;
 
index 15f36a725e3ae5291c7f80d2dc9ad38c1ad72247..784839956a431df3cf3a7c3f2aef5ac3f687d641 100644 (file)
@@ -41,7 +41,7 @@
 #include <stdlib.h>
 #include <sys/time.h>
 
-#include <pass/device-notifier.h>
+#include <util/device-notifier.h>
 
 #include "pass.h"
 #include "pass-rescon.h"
index 81e984eb342350cf5e33301be3d07dd415842446..f5d81b519bfe42d53eab71f89eba854d1c8a40ee 100644 (file)
@@ -33,7 +33,7 @@
 #include <errno.h>
 #include <fcntl.h>
 
-#include <pass/common.h>
+#include <util/common.h>
 
 #include "pass.h"
 #include "pass-hal.h"
index 3c3baf077120443e7454fd81d155207a69cde8c4..51ab81755f942e9b68f4fc0b95bb937ec74a3be5 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <hal/hal-power.h>
 
-#include <pass/common.h>
+#include <util/common.h>
 
 #include "pass.h"
 
index 484377facc58c3003b1d1b31c3f075f5f80874b0..62547fec66e207360d2566b9bcbe82bdf1b468dd 100644 (file)
@@ -32,7 +32,7 @@
 #include <sys/time.h>
 #include <inttypes.h>
 
-#include <pass/device-notifier.h>
+#include <util/device-notifier.h>
 
 #include "pass.h"
 #include "pass-rescon.h"
index fc40cbc16993a20dbbf550ab18e75597a5890d75..91807d5a016051eb8c7f771f5c9d6dbfc0b530c4 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <inttypes.h>
 
-#include <pass/log.h>
+#include <util/log.h>
 
 #include "pass.h"
 #include "pass-hal.h"
index 183ec093a13f9c5dbf66552d9f91bf6a3504709b..a445a7edeb951481d0f8d4e009337a6950034a98 100644 (file)
@@ -39,7 +39,7 @@
 #include <glib-unix.h>
 #include <libudev.h>
 
-#include <pass/log.h>
+#include <util/log.h>
 
 #include "pass.h"
 #include "pass-hal.h"
index dda35bc47283382f5376207b584d296573a1c080..cd7945352c49759426e01e8c7380b627ffb4115f 100644 (file)
@@ -25,8 +25,8 @@
  * @ingroup    COM_POWER_MGNT
  */
 
-#include <pass/log.h>
-#include <pass/device-notifier.h>
+#include <util/log.h>
+#include <util/device-notifier.h>
 
 #include "pass.h"
 #include "pass-rescon.h"
index 9a4bb9a5ef69889e00ae934f4f4ec94c6ef9acd3..b0a56bd1ab6dcf10da33946d3a1295becd309428 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <pass/common.h>
-#include <pass/device-notifier.h>
-#include <pass/devices.h>
-#include <pass/gdbus-util.h>
+#include <util/common.h>
+#include <util/device-notifier.h>
+#include <util/devices.h>
+#include <util/gdbus-util.h>
 
 #include "pass.h"
 #include "pass-parser.h"
index e9795d815a02fd7338d5a9836276da5a30f6c219..e7272ccd78f8725953b5aa7cf2d7380ad3c65a40 100644 (file)
@@ -36,8 +36,8 @@
 #include <stdio.h>
 #include <glib.h>
 
-#include <pass/common.h>
-#include <pass/log.h>
+#include <util/common.h>
+#include <util/log.h>
 
 #define PASS_LEVEL_COND_MAX    3
 
index d0fec4975e45d7fadc95926da4ab2e8e19313985..26d6a95b24390ccb186bf4aa95ca9b9b233ebed5 100644 (file)
@@ -37,8 +37,8 @@
 #include <gio/gio.h>
 #include <glib-object.h>
 
-#include <pass/log.h>
-#include <pass/common.h>
+#include <util/log.h>
+#include <util/common.h>
 
 #include "pmqos.h"
 
index ec64276d7c3eb608d4266531ff9adbe92c47d349..404b9ca79295f53e9a37d20744a0d7f8d97e85b5 100644 (file)
 #include <stdio.h>
 #include <limits.h>
 
-#include <pass/common.h>
-#include <pass/devices.h>
-#include <pass/device-notifier.h>
-#include <pass/gdbus-util.h>
-#include <pass/log.h>
+#include <util/common.h>
+#include <util/devices.h>
+#include <util/device-notifier.h>
+#include <util/gdbus-util.h>
+#include <util/log.h>
 
 #include "pmqos.h"
 
index 8a4a9f051d0dab14dbaef13311538c4473f9fe74..2b497748fbac63a6b5a7016a05c7cb2e5ff4ffb4 100644 (file)
@@ -35,8 +35,8 @@
 #include <errno.h>
 #include <string.h>
 
-#include <pass/log.h>
-#include <pass/common.h>
+#include <util/log.h>
+#include <util/common.h>
 
 #include "thermal.h"
 
index 4788e33d8d5e0c7255f2a27268d1edfb429c290d..037e84aa5bc3fda605b6aad33042cac2c53b4cdc 100644 (file)
 #include <string.h>
 #include <limits.h>
 
-#include <pass/common.h>
-#include <pass/devices.h>
-#include <pass/device-notifier.h>
-#include <pass/gdbus-util.h>
-#include <pass/log.h>
+#include <util/common.h>
+#include <util/devices.h>
+#include <util/device-notifier.h>
+#include <util/gdbus-util.h>
+#include <util/log.h>
 
 #include "thermal.h"
 
index 0497e28caf6c28863f46f04280b9bfef8ab4eaff..04dc78b613648eafa8e893a6222093f8f8aa0c0c 100644 (file)
@@ -35,8 +35,8 @@
 #include <mntent.h>
 #include <limits.h>
 
-#include <pass/log.h>
-#include <pass/common.h>
+#include <util/log.h>
+#include <util/common.h>
 
 #define BUFF_MAX       255
 
index 2c6e99baf8666d9dddccd4b30057ba10fe4ec978..dee8c08dffe970dbb73fc8fe660431774fa12779 100644 (file)
@@ -18,9 +18,9 @@
 
 #include <glib.h>
 
-#include <pass/common.h>
-#include <pass/device-notifier.h>
-#include <pass/log.h>
+#include <util/common.h>
+#include <util/device-notifier.h>
+#include <util/log.h>
 
 #define DEVICE_NOTIFIER_MAX_COUNT      255
 
index 6ea302502e5c3776da4c0f4efd6548d643262971..0ad12dd4e9fae930add471961b60e6dd7148a567 100644 (file)
@@ -19,9 +19,9 @@
 #include <glib.h>
 #include <stdio.h>
 
-#include <pass/common.h>
-#include <pass/devices.h>
-#include <pass/log.h>
+#include <util/common.h>
+#include <util/devices.h>
+#include <util/log.h>
 
 static GList *dev_head;
 
index eca425d81c449a2502fe3c3efde3a82b2b52b79c..53d6da92b4c77f2b4facecaed78a28020f28e9c7 100644 (file)
@@ -20,8 +20,8 @@
 #include <stdbool.h>
 #include <systemd/sd-daemon.h>
 
-#include <pass/gdbus-util.h>
-#include <pass/log.h>
+#include <util/gdbus-util.h>
+#include <util/log.h>
 
 static GDBusConnection *g_dbus_sys_conn[PASS_DBUS_MAX] = {NULL, };
 static int dbus_name_owned;
index 5711c01618eb1835518452f7cf7e9d408504c7cc..af539480b8e0a0cc334603863f02f8458033fa6a 100644 (file)
@@ -20,7 +20,7 @@
 #include <gio/gio.h>
 #include <gtest/gtest.h>
 
-#include <pass/gdbus-definition.h>
+#include <util/gdbus-definition.h>
 
 class PowerMgntTest : public testing::Test {
 public:
index bc9bb6839f968f29bbaaa49032ec1c236b608dd5..bf91eaa69732ea14ae894856ed063878562dffb9 100644 (file)
@@ -19,7 +19,8 @@
 
 #include <gio/gio.h>
 #include <gtest/gtest.h>
-#include <pass/gdbus-definition.h>
+
+#include <util/gdbus-definition.h>
 
 extern "C" {
 #include "pass-hal.h"