e94b37c74c798d09dd119c9ff0811898c8e5f785
[platform/core/system/swap-manager.git] / daemon / sys_stat.h
1 /*
2  *  DA manager
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Jaewon Lim <jaewon81.lim@samsung.com>
9  * Woojin Jung <woojin2.jung@samsung.com>
10  * Juyoung Kim <j0.kim@samsung.com>
11  * Cherepanov Vitaliy <v.cherepanov@samsung.com>
12  * Nikita Kalyazin    <n.kalyazin@samsung.com>
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License");
15  * you may not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  * - Samsung RnD Institute Russia
29  *
30  */
31
32
33 #ifndef _SYS_STAT_
34 #define _SYS_STAT_
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #define CHARGERFD                                       "/sys/class/power_supply/battery/charge_now"
41 #define VOLTAGEFD                                       "/sys/class/power_supply/battery/voltage_now"
42
43 #define BRIGHTNESS_FILENAME                     "brightness"
44 #define MAX_BRIGHTNESS_FILENAME         "max_brightness"
45 #define BRIGHTNESS_PARENT_DIR           "/sys/class/backlight"
46
47 #define EMUL_BRIGHTNESSFD                       "/sys/class/backlight/emulator/brightness"
48 #define EMUL_MAX_BRIGHTNESSFD           "/sys/class/backlight/emulator/max_brightness"
49
50 #define AUDIOFD                                         "/sys/devices/platform/soc-audio/WM1811 Voice/dapm_widget"
51
52 #define MFCFD                                           "/sys/devices/platform/samsung-pd.0/power/runtime_status"
53
54 #define FREQFD                                          "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
55
56 #define CPUDIR                                          "/sys/devices/system/cpu"
57 #define CPUFREQ_FILE                            "cpufreq/stats/time_in_state"
58 #define CPUNUM_OF_FREQ                          CPUDIR"/cpu0/"CPUFREQ_FILE
59
60
61 #define MEMINFOFD                                       "/sys/class/memnotify/meminfo"
62 #define UMSFD                                           "/mnt/ums"
63 #define MMCBLKFD                                        "/dev/mmcblk1"
64 #define MMCFD                                           "/mnt/mmc"
65
66 #define PROCSTAT                                        "/proc/stat"
67 #define PROCMEMINFO                                     "/proc/meminfo"
68 #define PROCCPUINFO                                     "/proc/cpuinfo"
69
70 #define MEM_TYPE_TOTAL                          1
71 #define MEM_TYPE_USED                           2
72 #define MEM_TYPE_FREE                           3
73
74 #define FSINFO_TYPE_TOTAL                       1
75 #define FSINFO_TYPE_FREE                        2
76
77 #define NWTYPE_SIZE 128
78 #define MAXNAMESIZE 16
79
80
81 #include <stdint.h>
82 #include "da_protocol.h"
83
84 typedef unsigned long long tic_t;
85
86 typedef struct {
87         unsigned int pid;
88         char command[MAXNAMESIZE];
89         char state;
90         int ppid;
91         int pgrp;
92         int sid;
93         int tty_nr;
94         int tty_pgrp;
95         unsigned long flags;
96         unsigned long minor_fault;
97         unsigned long cminor_fault;
98         unsigned long major_fault;
99         unsigned long cmajor_fault;
100         unsigned long long utime;
101         unsigned long long stime;
102         unsigned long long cutime;
103         unsigned long long cstime;
104         long priority;
105         long nice;
106         int numofthread;
107         long dummy;
108         unsigned long long start_time;
109         unsigned long vir_mem;
110         unsigned long sh_mem;
111         long res_memblock;
112         unsigned long pss;
113 } proc_t;
114
115 typedef struct {
116         unsigned long freq;
117         tic_t tick;
118         tic_t tick_sav;
119 } cpufreq_t;
120
121 typedef struct {
122         tic_t u, n, s, i, w, x, y, z;
123         tic_t u_sav, n_sav, s_sav, i_sav, w_sav, x_sav, y_sav, z_sav;
124         unsigned int id;                // cpu id
125         float cpu_usage;                // cpu load for this core
126         int sav_load_index;             // saved cpu load sampling index
127         int cur_load_index;             // current cpu load sampling index
128         cpufreq_t* pfreq;               // frequency information of cpu
129         int sav_freq_index;             // sav cpu frequency sampling index
130         int cur_freq_index;             // current cpu frequency sampling index
131         long long idle_ticks;
132         long long total_ticks;
133 } CPU_t;        // for each cpu core
134
135 typedef struct _mem_t {
136         const char* name;               // memory slot name
137         unsigned long* slot;    // memory value slot
138 } mem_t;
139
140 struct target_info_t {
141         uint64_t sys_mem_size;
142         uint64_t storage_size;
143         uint32_t bluetooth_supp;
144         uint32_t gps_supp;
145         uint32_t wifi_supp;
146         uint32_t camera_count;
147         char network_type[NWTYPE_SIZE];
148         uint32_t max_brightness;
149         uint32_t cpu_core_count;
150 };
151
152 int get_system_info(struct system_info_t *sys_info);
153
154 int get_device_info(char* buffer, int buffer_len);
155
156 int get_file_status(int* pfd, const char* filename);
157
158 int initialize_system_info();
159
160 int finalize_system_info();
161
162 int fill_target_info(struct target_info_t *target_info);
163
164 int init_system_file_descriptors();
165 void close_system_file_descriptors();
166 int sys_stat_prepare(void);
167 #ifdef __cplusplus
168 }
169 #endif
170
171 #endif