036fa63a4b43f661aee9d70a6313d94299344c40
[platform/core/system/pass.git] / include / monitor / monitor.h
1 /*
2  * PASS (Power Aware System Service)
3  *
4  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __MONITOR_H__
20 #define __MONITOR_H__
21
22 #include <libsyscommon/resource-manager.h>
23 #include <util/thread.h>
24 #include <util/queue.h>
25
26 #define MONITOR_POLLING_DURATION 100
27
28 struct monitor_command {
29         struct syscommon_resman_resource *resource;
30         volatile bool done;
31         mtx_t lock;
32         cnd_t signal;
33 };
34
35 struct monitor {
36         struct thread *thread;
37         struct queue *q;
38         void *priv;
39         mtx_t lock;
40         cnd_t signal;
41 };
42
43 struct monitor *monitor_get(void);
44 gboolean monitor_get_debug_mode(void);
45 void monitor_set_debug_mode(gboolean on);
46 int monitor_thread_init(struct monitor *monitor);
47 void monitor_thread_exit(struct monitor *monitor);
48
49 void monitor_command_wait_done(struct monitor_command *cmd);
50 void monitor_command_submit(struct monitor_command *cmd);
51 void monitor_command_submit_sync(struct monitor_command *cmd);
52 void monitor_command_bind_resource(struct monitor_command *cmd, struct syscommon_resman_resource *res);
53 void monitor_command_unbind_resource(struct monitor_command *cmd);
54 int monitor_command_init(struct monitor_command **cmd);
55 void monitor_command_exit(struct monitor_command *cmd);
56
57 int request_server_init(void);
58 void request_server_exit(void);
59
60
61 #endif