Merge remote-tracking branch 'sensor/tizen'
[platform/core/csapi/tizenfx.git] / src / Tizen.System.Information / Interop / Interop.RuntimeInfo.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.System;
20
21 internal static partial class Interop
22 {
23     internal static partial class RuntimeInfo
24     {
25         public delegate void RuntimeInformationChangedCallback(RuntimeInformationKey key, IntPtr userData);
26
27         [StructLayout(LayoutKind.Sequential)]
28         public struct MemoryInfo
29         {
30             public readonly int Total;
31             public readonly int Used;
32             public readonly int Free;
33             public readonly int Cache;
34             public readonly int Swap;
35         }
36
37         [StructLayout(LayoutKind.Sequential)]
38         public struct ProcessMemoryInfo
39         {
40             public readonly int Vsz;
41             public readonly int Rss;
42             public readonly int Pss;
43             public readonly int SharedClean;
44             public readonly int SharedDirty;
45             public readonly int PrivateClean;
46             public readonly int PrivateDirty;
47         }
48
49         [StructLayout(LayoutKind.Sequential)]
50         public struct CpuUsage
51         {
52             public readonly double User;
53             public readonly double System;
54             public readonly double Nice;
55             public readonly double IoWait;
56         }
57
58         [StructLayout(LayoutKind.Sequential)]
59         public struct ProcessCpuUsage
60         {
61             public readonly uint UTime;
62             public readonly uint STime;
63         }
64
65         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_int")]
66         public static extern int GetValue(RuntimeInformationKey key, out int status);
67
68         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_bool")]
69         public static extern int GetValue(RuntimeInformationKey key, out bool status);
70
71         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_double")]
72         public static extern int GetValue(RuntimeInformationKey key, out double status);
73
74         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_string")]
75         public static extern int GetValue(RuntimeInformationKey key, out string status);
76
77         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_system_memory_info")]
78         public static extern int GetSystemMemoryInfo(out MemoryInfo memoryInfo);
79
80         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_process_memory_info")]
81         public static extern int GetProcessMemoryInfo(int[] pid, int size, out ProcessMemoryInfo[] array);
82
83         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_cpu_usage")]
84         public static extern int GetCpuUsage(out CpuUsage cpuUsage);
85
86         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_process_cpu_usage")]
87         public static extern int GetProcessCpuUsage(int[] pid, int size, out ProcessCpuUsage[] array);
88
89         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_count")]
90         public static extern int GetProcessorCount(out int processorCount);
91
92         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_current_frequency")]
93         public static extern int GetProcessorCurrentFrequency(int coreId, out int cpuFreq);
94
95         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_max_frequency")]
96         public static extern int GetProcessorMaxFrequency(int coreId, out int cpuFreq);
97
98         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_set_changed_cb")]
99         public static extern int SetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey, RuntimeInformationChangedCallback cb, IntPtr userData);
100
101         [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_unset_changed_cb")]
102         public static extern int UnsetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey);
103     }
104 }