]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/host_info.h
xnu-3789.21.4.tar.gz
[apple/xnu.git] / osfmk / mach / host_info.h
1 /*
2 * Copyright (c) 2000-2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56
57 /*
58 * File: mach/host_info.h
59 *
60 * Definitions for host_info call.
61 */
62
63 #ifndef _MACH_HOST_INFO_H_
64 #define _MACH_HOST_INFO_H_
65
66 #include <mach/message.h>
67 #include <mach/vm_statistics.h>
68 #include <mach/machine.h>
69 #include <mach/machine/vm_types.h>
70 #include <mach/time_value.h>
71
72 #include <sys/cdefs.h>
73
74 /*
75 * Generic information structure to allow for expansion.
76 */
77 typedef integer_t *host_info_t; /* varying array of int. */
78 typedef integer_t *host_info64_t; /* varying array of int. */
79
80 #define HOST_INFO_MAX (1024) /* max array size */
81 typedef integer_t host_info_data_t[HOST_INFO_MAX];
82
83 #define KERNEL_VERSION_MAX (512)
84 typedef char kernel_version_t[KERNEL_VERSION_MAX];
85
86 #define KERNEL_BOOT_INFO_MAX (4096)
87 typedef char kernel_boot_info_t[KERNEL_BOOT_INFO_MAX];
88
89 /*
90 * Currently defined information.
91 */
92 /* host_info() */
93 typedef integer_t host_flavor_t;
94 #define HOST_BASIC_INFO 1 /* basic info */
95 #define HOST_SCHED_INFO 3 /* scheduling info */
96 #define HOST_RESOURCE_SIZES 4 /* kernel struct sizes */
97 #define HOST_PRIORITY_INFO 5 /* priority information */
98 #define HOST_SEMAPHORE_TRAPS 7 /* Has semaphore traps */
99 #define HOST_MACH_MSG_TRAP 8 /* Has mach_msg_trap */
100 #define HOST_VM_PURGABLE 9 /* purg'e'able memory info */
101 #define HOST_DEBUG_INFO_INTERNAL 10 /* Used for kernel internal development tests only */
102 #define HOST_CAN_HAS_DEBUGGER 11
103
104 #ifdef MACH_KERNEL_PRIVATE
105 struct host_basic_info_old {
106 integer_t max_cpus; /* max number of cpus possible */
107 uint32_t avail_cpus; /* number of cpus now available */
108 natural_t memory_size; /* size of memory in bytes */
109 cpu_type_t cpu_type; /* cpu type */
110 cpu_subtype_t cpu_subtype; /* cpu subtype */
111 };
112
113 typedef struct host_basic_info_old host_basic_info_data_old_t;
114 typedef struct host_basic_info_old *host_basic_info_old_t;
115 #define HOST_BASIC_INFO_OLD_COUNT ((mach_msg_type_number_t) \
116 (sizeof(host_basic_info_data_old_t)/sizeof(integer_t)))
117 #endif /* MACH_KERNEL_PRIVATE */
118
119 struct host_can_has_debugger_info {
120 boolean_t can_has_debugger;
121 };
122 typedef struct host_can_has_debugger_info host_can_has_debugger_info_data_t;
123 typedef struct host_can_has_debugger_info *host_can_has_debugger_info_t;
124 #define HOST_CAN_HAS_DEBUGGER_COUNT ((mach_msg_type_number_t) \
125 (sizeof(host_can_has_debugger_info_data_t)/sizeof(integer_t)))
126
127 #pragma pack(4)
128
129 struct host_basic_info {
130 integer_t max_cpus; /* max number of CPUs possible */
131 integer_t avail_cpus; /* number of CPUs now available */
132 natural_t memory_size; /* size of memory in bytes, capped at 2 GB */
133 cpu_type_t cpu_type; /* cpu type */
134 cpu_subtype_t cpu_subtype; /* cpu subtype */
135 cpu_threadtype_t cpu_threadtype; /* cpu threadtype */
136 integer_t physical_cpu; /* number of physical CPUs now available */
137 integer_t physical_cpu_max; /* max number of physical CPUs possible */
138 integer_t logical_cpu; /* number of logical cpu now available */
139 integer_t logical_cpu_max; /* max number of physical CPUs possible */
140 uint64_t max_mem; /* actual size of physical memory */
141 };
142
143 #pragma pack()
144
145 typedef struct host_basic_info host_basic_info_data_t;
146 typedef struct host_basic_info *host_basic_info_t;
147 #define HOST_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
148 (sizeof(host_basic_info_data_t)/sizeof(integer_t)))
149
150 struct host_sched_info {
151 integer_t min_timeout; /* minimum timeout in milliseconds */
152 integer_t min_quantum; /* minimum quantum in milliseconds */
153 };
154
155 typedef struct host_sched_info host_sched_info_data_t;
156 typedef struct host_sched_info *host_sched_info_t;
157 #define HOST_SCHED_INFO_COUNT ((mach_msg_type_number_t) \
158 (sizeof(host_sched_info_data_t)/sizeof(integer_t)))
159
160 struct kernel_resource_sizes {
161 natural_t task;
162 natural_t thread;
163 natural_t port;
164 natural_t memory_region;
165 natural_t memory_object;
166 };
167
168 typedef struct kernel_resource_sizes kernel_resource_sizes_data_t;
169 typedef struct kernel_resource_sizes *kernel_resource_sizes_t;
170 #define HOST_RESOURCE_SIZES_COUNT ((mach_msg_type_number_t) \
171 (sizeof(kernel_resource_sizes_data_t)/sizeof(integer_t)))
172
173 struct host_priority_info {
174 integer_t kernel_priority;
175 integer_t system_priority;
176 integer_t server_priority;
177 integer_t user_priority;
178 integer_t depress_priority;
179 integer_t idle_priority;
180 integer_t minimum_priority;
181 integer_t maximum_priority;
182 };
183
184 typedef struct host_priority_info host_priority_info_data_t;
185 typedef struct host_priority_info *host_priority_info_t;
186 #define HOST_PRIORITY_INFO_COUNT ((mach_msg_type_number_t) \
187 (sizeof(host_priority_info_data_t)/sizeof(integer_t)))
188
189 /* host_statistics() */
190 #define HOST_LOAD_INFO 1 /* System loading stats */
191 #define HOST_VM_INFO 2 /* Virtual memory stats */
192 #define HOST_CPU_LOAD_INFO 3 /* CPU load stats */
193
194 /* host_statistics64() */
195 #define HOST_VM_INFO64 4 /* 64-bit virtual memory stats */
196 #define HOST_EXTMOD_INFO64 5 /* External modification stats */
197 #define HOST_EXPIRED_TASK_INFO 6 /* Statistics for expired tasks */
198
199
200 struct host_load_info {
201 integer_t avenrun[3]; /* scaled by LOAD_SCALE */
202 integer_t mach_factor[3]; /* scaled by LOAD_SCALE */
203 };
204
205 typedef struct host_load_info host_load_info_data_t;
206 typedef struct host_load_info *host_load_info_t;
207 #define HOST_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
208 (sizeof(host_load_info_data_t)/sizeof(integer_t)))
209
210 typedef struct vm_purgeable_info host_purgable_info_data_t;
211 typedef struct vm_purgeable_info *host_purgable_info_t;
212 #define HOST_VM_PURGABLE_COUNT ((mach_msg_type_number_t) \
213 (sizeof(host_purgable_info_data_t)/sizeof(integer_t)))
214
215 /* in <mach/vm_statistics.h> */
216 /* vm_statistics64 */
217 #define HOST_VM_INFO64_COUNT ((mach_msg_type_number_t) \
218 (sizeof(vm_statistics64_data_t)/sizeof(integer_t)))
219
220 /* size of the latest version of the structure */
221 #define HOST_VM_INFO64_LATEST_COUNT HOST_VM_INFO64_COUNT
222 #define HOST_VM_INFO64_REV1_COUNT HOST_VM_INFO64_LATEST_COUNT
223 /* previous versions: adjust the size according to what was added each time */
224 #define HOST_VM_INFO64_REV0_COUNT /* added compression and swapper info (14 ints) */\
225 ((mach_msg_type_number_t) \
226 (HOST_VM_INFO64_REV1_COUNT - 14))
227
228 /* in <mach/vm_statistics.h> */
229 /* vm_extmod_statistics */
230 #define HOST_EXTMOD_INFO64_COUNT ((mach_msg_type_number_t) \
231 (sizeof(vm_extmod_statistics_data_t)/sizeof(integer_t)))
232
233 /* size of the latest version of the structure */
234 #define HOST_EXTMOD_INFO64_LATEST_COUNT HOST_EXTMOD_INFO64_COUNT
235
236 /* vm_statistics */
237 #define HOST_VM_INFO_COUNT ((mach_msg_type_number_t) \
238 (sizeof(vm_statistics_data_t)/sizeof(integer_t)))
239
240 /* size of the latest version of the structure */
241 #define HOST_VM_INFO_LATEST_COUNT HOST_VM_INFO_COUNT
242 #define HOST_VM_INFO_REV2_COUNT HOST_VM_INFO_LATEST_COUNT
243 /* previous versions: adjust the size according to what was added each time */
244 #define HOST_VM_INFO_REV1_COUNT /* added "speculative_count" (1 int) */ \
245 ((mach_msg_type_number_t) \
246 (HOST_VM_INFO_REV2_COUNT - 1))
247 #define HOST_VM_INFO_REV0_COUNT /* added "purgable" info (2 ints) */ \
248 ((mach_msg_type_number_t) \
249 (HOST_VM_INFO_REV1_COUNT - 2))
250
251 struct host_cpu_load_info { /* number of ticks while running... */
252 natural_t cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */
253 };
254
255 typedef struct host_cpu_load_info host_cpu_load_info_data_t;
256 typedef struct host_cpu_load_info *host_cpu_load_info_t;
257 #define HOST_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
258 (sizeof (host_cpu_load_info_data_t) / sizeof (integer_t)))
259
260 #ifdef PRIVATE
261 /*
262 * CPU Statistics information
263 */
264 struct _processor_statistics_np {
265 int32_t ps_cpuid;
266
267 uint32_t ps_csw_count;
268 uint32_t ps_preempt_count;
269 uint32_t ps_preempted_rt_count;
270 uint32_t ps_preempted_by_rt_count;
271
272 uint32_t ps_rt_sched_count;
273
274 uint32_t ps_interrupt_count;
275 uint32_t ps_ipi_count;
276 uint32_t ps_timer_pop_count;
277
278 uint64_t ps_runq_count_sum __attribute((aligned(8)));
279
280 uint32_t ps_idle_transitions;
281 uint32_t ps_quantum_timer_expirations;
282 };
283
284 struct host_debug_info_internal {
285 uint64_t config_bank:1, /* built configurations */
286 config_atm:1,
287 config_csr:1,
288 config_coalitions:1,
289 config_unused:60;
290 };
291
292 typedef struct host_debug_info_internal *host_debug_info_internal_t;
293 typedef struct host_debug_info_internal host_debug_info_internal_data_t;
294 #define HOST_DEBUG_INFO_INTERNAL_COUNT ((mach_msg_type_number_t)\
295 (sizeof (host_debug_info_internal_data_t) / sizeof(integer_t)))
296
297 #endif /* PRIVATE */
298
299 #ifdef KERNEL_PRIVATE
300
301 extern kern_return_t set_sched_stats_active(
302 boolean_t active);
303
304 extern kern_return_t get_sched_statistics(
305 struct _processor_statistics_np *out,
306 uint32_t *count);
307 #endif /* KERNEL_PRIVATE */
308
309
310 #endif /* _MACH_HOST_INFO_H_ */