2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
21 internal static partial class Interop
23 internal static partial class RuntimeInfo
25 public delegate void RuntimeInformationChangedCallback(RuntimeInformationKey key, IntPtr userData);
27 [StructLayout(LayoutKind.Sequential)]
28 public struct MemoryInfo
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;
37 [StructLayout(LayoutKind.Sequential)]
38 public struct ProcessMemoryInfo
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;
49 [StructLayout(LayoutKind.Sequential)]
50 public struct CpuUsage
52 public readonly double User;
53 public readonly double System;
54 public readonly double Nice;
55 public readonly double IoWait;
58 [StructLayout(LayoutKind.Sequential)]
59 public struct ProcessCpuUsage
61 public readonly uint UTime;
62 public readonly uint STime;
65 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_int")]
66 public static extern int GetValue(RuntimeInformationKey key, out int status);
68 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_bool")]
69 public static extern int GetValue(RuntimeInformationKey key, out bool status);
71 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_double")]
72 public static extern int GetValue(RuntimeInformationKey key, out double status);
74 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_string")]
75 public static extern int GetValue(RuntimeInformationKey key, out string status);
77 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_system_memory_info")]
78 public static extern int GetSystemMemoryInfo(out MemoryInfo memoryInfo);
80 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_process_memory_info")]
81 public static extern int GetProcessMemoryInfo(int[] pid, int size, out ProcessMemoryInfo[] array);
83 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_cpu_usage")]
84 public static extern int GetCpuUsage(out CpuUsage cpuUsage);
86 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_process_cpu_usage")]
87 public static extern int GetProcessCpuUsage(int[] pid, int size, out ProcessCpuUsage[] array);
89 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_count")]
90 public static extern int GetProcessorCount(out int processorCount);
92 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_current_frequency")]
93 public static extern int GetProcessorCurrentFrequency(int coreId, out int cpuFreq);
95 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_max_frequency")]
96 public static extern int GetProcessorMaxFrequency(int coreId, out int cpuFreq);
98 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_set_changed_cb")]
99 public static extern int SetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey, RuntimeInformationChangedCallback cb, IntPtr userData);
101 [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_unset_changed_cb")]
102 public static extern int UnsetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey);