2 * PASS (Power Aware System Service) - Tizen Monitor Header File
4 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
29 #define BIT(x) (1ULL << x)
32 * @brief Define the supported resource type for monitoring
34 #define RESOURCE_TYPE_UNKNOWN 0
35 #define RESOURCE_TYPE_CPU 1
36 #define RESOURCE_TYPE_BUS 2
37 #define RESOURCE_TYPE_GPU 3
38 #define RESOURCE_TYPE_MEMORY 4
39 #define RESOURCE_TYPE_BATTERY 5
40 #define RESOURCE_TYPE_PROCESS 6
41 #define RESOURCE_TYPE_DISPLAY 7
42 #define RESOURCE_TYPE_SYSTEM 8
43 #define RESOURCE_TYPE_NONSTANDARD 99
46 * @brief Define the supported attributes according to resource type
50 #define CPU_ATTR_CUR_FREQ BIT(0) /* DATA_TYPE_INT */
51 #define CPU_ATTR_MIN_FREQ BIT(1) /* DATA_TYPE_INT */
52 #define CPU_ATTR_MAX_FREQ BIT(2) /* DATA_TYPE_INT */
53 #define CPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
54 #define CPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
55 #define CPU_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
57 #define CPU_CTRL_CLUSTER_ID BIT(0)
59 /* Memory Bus Resource */
60 #define BUS_ATTR_CUR_FREQ BIT(0) /* DATA_TYPE_INT */
61 #define BUS_ATTR_MIN_FREQ BIT(1) /* DATA_TYPE_INT */
62 #define BUS_ATTR_MAX_FREQ BIT(2) /* DATA_TYPE_INT */
63 #define BUS_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
64 #define BUS_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
65 #define BUS_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
67 #define BUS_CTRL_DEVICE_ID BIT(0)
70 #define GPU_ATTR_CUR_FREQ BIT(0) /* DATA_TYPE_INT */
71 #define GPU_ATTR_MIN_FREQ BIT(1) /* DATA_TYPE_INT */
72 #define GPU_ATTR_MAX_FREQ BIT(2) /* DATA_TYPE_INT */
73 #define GPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
74 #define GPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
75 #define GPU_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
77 #define GPU_CTRL_DEVICE_ID BIT(0)
80 #define MEMORY_ATTR_TOTAL BIT(0) /* DATA_TYPE_UINT64 */
81 #define MEMORY_ATTR_AVAILABLE BIT(1) /* DATA_TYPE_UINT64 */
82 #define MEMORY_ATTR_FREE BIT(2) /* DATA_TYPE_UINT64 */
83 #define MEMORY_ATTR_BUFFER BIT(3) /* DATA_TYPE_UINT64 */
84 #define MEMORY_ATTR_CACHED BIT(4) /* DATA_TYPE_UINT64 */
85 #define MEMORY_ATTR_CMA_TOTAL BIT(5) /* DATA_TYPE_UINT64 */
86 #define MEMORY_ATTR_CMA_FREE BIT(6) /* DATA_TYPE_UINT64 */
88 /* Battery Resource */
89 #define BATTERY_ATTR_CAPACITY BIT(0) /* DATA_TYPE_INT */
90 #define BATTERY_ATTR_STATUS BIT(1) /* DATA_TYPE_STRING */
91 #define BATTERY_ATTR_TEMPERATURE BIT(2) /* DATA_TYPE_INT */
92 #define BATTERY_ATTR_VOLTAGE_NOW BIT(3) /* DATA_TYPE_INT */
93 #define BATTERY_ATTR_CURRENT_NOW BIT(4) /* DATA_TYPE_INT */
94 #define BATTERY_ATTR_PRESENT BIT(5) /* DATA_TYPE_INT */
95 #define BATTERY_ATTR_ONLINE BIT(6) /* DATA_TYPE_INT */
97 /* Display Resource */
98 #define DISPLAY_ATTR_FPS BIT(0) /* DATA_TYPE_DOUBLE */
100 #define DISPLAY_CTRL_DEVICE_ID BIT(0)
102 /* System Resource */
103 #define SYSTEM_ATTR_CPU_UTIL BIT(0) /* DATA_TYPE_DOUBLE */
104 #define SYSTEM_ATTR_CPU_USER_UTIL BIT(1) /* DATA_TYPE_DOUBLE */
105 #define SYSTEM_ATTR_CPU_SYS_UTIL BIT(2) /* DATA_TYPE_DOUBLE */
106 #define SYSTEM_ATTR_PER_CPU_UTIL BIT(3) /* DATA_TYPE_ARRAY */
107 #define SYSTEM_ATTR_PER_CPU_USER_UTIL BIT(4) /* DATA_TYPE_ARRAY */
108 #define SYSTEM_ATTR_PER_CPU_SYS_UTIL BIT(5) /* DATA_TYPE_ARRAY */
109 #define SYSTEM_ATTR_POSSIBLE_CPU BIT(6) /* DATA_TYPE_INT */
110 #define SYSTEM_ATTR_ONLINE_CPU BIT(7) /* DATA_TYPE_INT */
112 /* Process Resource */
113 #define PROCESS_ATTR_CPU_UTIL BIT(0) /* DATA_TYPE_DOUBLE */
114 #define PROCESS_ATTR_MEM_VIRT BIT(1) /* DATA_TYPE_UINT64 */
115 #define PROCESS_ATTR_MEM_RSS BIT(2) /* DATA_TYPE_UINT64 */
116 #define PROCESS_ATTR_MEM_RSS_PERCENT BIT(3) /* DATA_TYPE_DOUBLE */
117 #define PROCESS_ATTR_DISK_READ_BPS BIT(4) /* DATA_TYPE_UINT */
118 #define PROCESS_ATTR_DISK_WRITE_BPS BIT(5) /* DATA_TYPE_UINT */
119 #define PROCESS_ATTR_COMM BIT(6) /* DATA_TYPE_STRING */
120 #define PROCESS_ATTR_PGID BIT(7) /* DATA_TYPE_INT */
121 #define PROCESS_ATTR_PPID BIT(8) /* DATA_TYPE_INT */
123 #define PROCESS_CTRL_TGID BIT(0)
126 * @brief Initialize the tizen monitor
127 * @return @c positive integer as tizen monitor id on success, otherwise a negative error value
129 int tmonitor_init(void);
132 * @brief Exit the tizem monitor
133 * @param[in] Id of tizen monitor which be returnted by tmonitor_init
134 * @return @c 0 on success, otherwise a negative error value
136 int tmonitor_exit(int id);
139 * @brief Get the count of supported resources according to resource type
140 * @param[in] Tizen monitor id
141 * @param[in] Resource type
142 * @return @c positive integer as resource count on success, otherwise a negative error value
144 int tmonitor_get_resource_count(int id, int resource_type);
147 * @brief Create resource for given resource_type
148 * @param[in] Tizen monitor id which be returnted by tmonitor_init
149 * @param[in] Resource type
150 * @return @c positive integer as resource id on success, otherwise a negative error value
152 int tmonitor_create_resource(int id, int resource_type);
155 * @brief Delete resource of given resource id
156 * @param[in] Tizen monitor id which be returnted by tmonitor_init
157 * @param[in] Resource id
158 * @return @c 0 on success, otherwise a negative error value
160 int tmonitor_delete_resource(int id, int resource_id);
163 * @brief Set the resource control with value which is diffierential according to resource control id
164 * @param[in] Tizen monitor id
165 * @param[in] Resource id
166 * @param[in] Resource control id
167 * @param[in] Value for resource control id
168 * @return @c 0 on success, otherwise a negative error value
170 int tmonitor_set_resource_ctrl(int id, int resource_id, u_int64_t ctrl_id, int value);
173 * @brief Set the interested attributes for monitoring
174 * @param[in] Tizen monitor id
175 * @param[in] Resource id
176 * @param[in] Attribute mask including the various attributes
177 * @return @c 0 on success, otherwise a negative error value
179 int tmonitor_set_resource_attr(int id, int resource_id, u_int64_t attr_mask);
182 * @brief Unset the interested attributes for monitoring
183 * @param[in] Tizen monitor id
184 * @param[in] Resource id
185 * @param[in] Attribute mask including the various attributes
186 * @return @c 0 on success, otherwise a negative error value
188 int tmonitor_unset_resource_attr(int id, int resource_id, u_int64_t attr_mask);
191 * @brief Check whether a resouce attribute is supported or not
192 * @param[in] Tizen monitor id
193 * @param[in] Resource id
194 * @param[in] Resource attribute id
195 * @return @c 0 on success, otherwise a negative error value
197 bool tmonitor_is_resource_attr_supported(int id, int resource_id, u_int64_t attr_id);
200 * @brief Update value of the interested attributes for all created resource
201 * @param[in] Tizen monitor id
202 * @return @c 0 on success, otherwise a negative error value
204 int tmonitor_update(int id);
207 * @brief Update value of the interested attributes for a resource
208 * @param[in] Tizen monitor id
209 * @param[in] Resource id
210 * @return @c 0 on success, otherwise a negative error value
212 int tmonitor_update_resource(int id, int resource_id);
215 * @brief Get [int/int64/uint/uint64/double/string] value of resource attribute
216 * @param[in] Tizen monitor id
217 * @param[in] Resource id
218 * @param[in] Resource attribute id
219 * @param[out] Value retrieved from resource attribute
220 * @return @ 0 on success, otherwise a negative error value
222 int tmonitor_get_value_int(int id, int resource_id, u_int64_t attr, int32_t *value);
223 int tmonitor_get_value_int64(int id, int resource_id, u_int64_t attr, int64_t *value);
224 int tmonitor_get_value_uint(int id, int resource_id, u_int64_t attr, u_int32_t *value);
225 int tmonitor_get_value_uint64(int id, int resource_id, u_int64_t attr, u_int64_t *value);
226 int tmonitor_get_value_double(int id, int resource_id, u_int64_t attr, double *value);
227 int tmonitor_get_value_string(int id, int resource_id, u_int64_t attr, char *value);
230 * @brief Get [int/int64/uint/uint64/double/string] array of resource attribute
231 * @param[in] Tizen monitor id
232 * @param[in] Resource id
233 * @param[in] Resource attribute id
234 * @param[out] Array retrieved from resource attribute
235 * @param[out] Length of array
236 * @return @ 0 on success, otherwise a negative error value
238 int tmonitor_get_array_int(int id, int res_id, u_int64_t attr, int32_t **array, int *length);
239 int tmonitor_get_array_int64(int id, int res_id, u_int64_t attr, int64_t **array, int *length);
240 int tmonitor_get_array_uint(int id, int res_id, u_int64_t attr, u_int32_t **array, int *length);
241 int tmonitor_get_array_uint64(int id, int res_id, u_int64_t attr, u_int64_t **array, int *length);
242 int tmonitor_get_array_double(int id, int res_id, u_int64_t attr, double **array, int *length);
243 int tmonitor_get_array_string(int id, int res_id, u_int64_t attr, char ***array, int *length);
248 #endif /* __TMONITOR__ */