···11+/*
22+ * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+5959+/*
6060+ * File: mach/host_info.h
6161+ *
6262+ * Definitions for host_info call.
6363+ */
6464+6565+#ifndef _MACH_HOST_INFO_H_
6666+#define _MACH_HOST_INFO_H_
6767+6868+#include <mach/message.h>
6969+#include <mach/vm_statistics.h>
7070+#include <mach/machine.h>
7171+#include <mach/machine/vm_types.h>
7272+#include <mach/time_value.h>
7373+7474+#include <sys/cdefs.h>
7575+7676+/*
7777+ * Generic information structure to allow for expansion.
7878+ */
7979+typedef integer_t *host_info_t; /* varying array of int. */
8080+typedef integer_t *host_info64_t; /* varying array of int. */
8181+8282+#define HOST_INFO_MAX (1024) /* max array size */
8383+typedef integer_t host_info_data_t[HOST_INFO_MAX];
8484+8585+#define KERNEL_VERSION_MAX (512)
8686+typedef char kernel_version_t[KERNEL_VERSION_MAX];
8787+8888+#define KERNEL_BOOT_INFO_MAX (4096)
8989+typedef char kernel_boot_info_t[KERNEL_BOOT_INFO_MAX];
9090+9191+/*
9292+ * Currently defined information.
9393+ */
9494+/* host_info() */
9595+typedef integer_t host_flavor_t;
9696+#define HOST_BASIC_INFO 1 /* basic info */
9797+#define HOST_SCHED_INFO 3 /* scheduling info */
9898+#define HOST_RESOURCE_SIZES 4 /* kernel struct sizes */
9999+#define HOST_PRIORITY_INFO 5 /* priority information */
100100+#define HOST_SEMAPHORE_TRAPS 7 /* Has semaphore traps */
101101+#define HOST_MACH_MSG_TRAP 8 /* Has mach_msg_trap */
102102+103103+#ifdef MACH_KERNEL_PRIVATE
104104+struct host_basic_info_old {
105105+ integer_t max_cpus; /* max number of cpus possible */
106106+ uint32_t avail_cpus; /* number of cpus now available */
107107+ natural_t memory_size; /* size of memory in bytes */
108108+ cpu_type_t cpu_type; /* cpu type */
109109+ cpu_subtype_t cpu_subtype; /* cpu subtype */
110110+};
111111+112112+typedef struct host_basic_info_old host_basic_info_data_old_t;
113113+typedef struct host_basic_info_old *host_basic_info_old_t;
114114+#define HOST_BASIC_INFO_OLD_COUNT ((mach_msg_type_number_t) \
115115+ (sizeof(host_basic_info_data_old_t)/sizeof(integer_t)))
116116+#endif
117117+118118+#pragma pack(4)
119119+120120+struct host_basic_info {
121121+ integer_t max_cpus; /* max number of CPUs possible */
122122+ integer_t avail_cpus; /* number of CPUs now available */
123123+ natural_t memory_size; /* size of memory in bytes, capped at 2 GB */
124124+ cpu_type_t cpu_type; /* cpu type */
125125+ cpu_subtype_t cpu_subtype; /* cpu subtype */
126126+ cpu_threadtype_t cpu_threadtype; /* cpu threadtype */
127127+ integer_t physical_cpu; /* number of physical CPUs now available */
128128+ integer_t physical_cpu_max; /* max number of physical CPUs possible */
129129+ integer_t logical_cpu; /* number of logical cpu now available */
130130+ integer_t logical_cpu_max; /* max number of physical CPUs possible */
131131+ uint64_t max_mem; /* actual size of physical memory */
132132+};
133133+134134+#pragma pack()
135135+136136+typedef struct host_basic_info host_basic_info_data_t;
137137+typedef struct host_basic_info *host_basic_info_t;
138138+#define HOST_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
139139+ (sizeof(host_basic_info_data_t)/sizeof(integer_t)))
140140+141141+struct host_sched_info {
142142+ integer_t min_timeout; /* minimum timeout in milliseconds */
143143+ integer_t min_quantum; /* minimum quantum in milliseconds */
144144+};
145145+146146+typedef struct host_sched_info host_sched_info_data_t;
147147+typedef struct host_sched_info *host_sched_info_t;
148148+#define HOST_SCHED_INFO_COUNT ((mach_msg_type_number_t) \
149149+ (sizeof(host_sched_info_data_t)/sizeof(integer_t)))
150150+151151+struct kernel_resource_sizes {
152152+ natural_t task;
153153+ natural_t thread;
154154+ natural_t port;
155155+ natural_t memory_region;
156156+ natural_t memory_object;
157157+};
158158+159159+typedef struct kernel_resource_sizes kernel_resource_sizes_data_t;
160160+typedef struct kernel_resource_sizes *kernel_resource_sizes_t;
161161+#define HOST_RESOURCE_SIZES_COUNT ((mach_msg_type_number_t) \
162162+ (sizeof(kernel_resource_sizes_data_t)/sizeof(integer_t)))
163163+164164+struct host_priority_info {
165165+ integer_t kernel_priority;
166166+ integer_t system_priority;
167167+ integer_t server_priority;
168168+ integer_t user_priority;
169169+ integer_t depress_priority;
170170+ integer_t idle_priority;
171171+ integer_t minimum_priority;
172172+ integer_t maximum_priority;
173173+};
174174+175175+typedef struct host_priority_info host_priority_info_data_t;
176176+typedef struct host_priority_info *host_priority_info_t;
177177+#define HOST_PRIORITY_INFO_COUNT ((mach_msg_type_number_t) \
178178+ (sizeof(host_priority_info_data_t)/sizeof(integer_t)))
179179+180180+/* host_statistics() */
181181+#define HOST_LOAD_INFO 1 /* System loading stats */
182182+#define HOST_VM_INFO 2 /* Virtual memory stats */
183183+#define HOST_CPU_LOAD_INFO 3 /* CPU load stats */
184184+185185+/* host_statistics64() */
186186+#define HOST_VM_INFO64 4 /* 64-bit virtual memory stats */
187187+#define HOST_EXTMOD_INFO64 5 /* External modification stats */
188188+189189+190190+struct host_load_info {
191191+ integer_t avenrun[3]; /* scaled by LOAD_SCALE */
192192+ integer_t mach_factor[3]; /* scaled by LOAD_SCALE */
193193+};
194194+195195+typedef struct host_load_info host_load_info_data_t;
196196+typedef struct host_load_info *host_load_info_t;
197197+#define HOST_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
198198+ (sizeof(host_load_info_data_t)/sizeof(integer_t)))
199199+200200+/* in <mach/vm_statistics.h> */
201201+/* vm_statistics64 */
202202+#define HOST_VM_INFO64_COUNT ((mach_msg_type_number_t) \
203203+ (sizeof(vm_statistics64_data_t)/sizeof(integer_t)))
204204+205205+/* size of the latest version of the structure */
206206+#define HOST_VM_INFO64_LATEST_COUNT HOST_VM_INFO64_COUNT
207207+208208+/* in <mach/vm_statistics.h> */
209209+/* vm_extmod_statistics */
210210+#define HOST_EXTMOD_INFO64_COUNT ((mach_msg_type_number_t) \
211211+ (sizeof(vm_extmod_statistics_data_t)/sizeof(integer_t)))
212212+213213+/* size of the latest version of the structure */
214214+#define HOST_EXTMOD_INFO64_LATEST_COUNT HOST_EXTMOD_INFO64_COUNT
215215+216216+/* vm_statistics */
217217+#define HOST_VM_INFO_COUNT ((mach_msg_type_number_t) \
218218+ (sizeof(vm_statistics_data_t)/sizeof(integer_t)))
219219+220220+/* size of the latest version of the structure */
221221+#define HOST_VM_INFO_LATEST_COUNT HOST_VM_INFO_COUNT
222222+#define HOST_VM_INFO_REV2_COUNT HOST_VM_INFO_LATEST_COUNT
223223+/* previous versions: adjust the size according to what was added each time */
224224+#define HOST_VM_INFO_REV1_COUNT /* added "speculative_count" (1 int) */ \
225225+ ((mach_msg_type_number_t) \
226226+ (HOST_VM_INFO_REV2_COUNT - 1))
227227+#define HOST_VM_INFO_REV0_COUNT /* added "purgable" info (2 ints) */ \
228228+ ((mach_msg_type_number_t) \
229229+ (HOST_VM_INFO_REV1_COUNT - 2))
230230+231231+struct host_cpu_load_info { /* number of ticks while running... */
232232+ natural_t cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */
233233+};
234234+235235+typedef struct host_cpu_load_info host_cpu_load_info_data_t;
236236+typedef struct host_cpu_load_info *host_cpu_load_info_t;
237237+#define HOST_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
238238+ (sizeof (host_cpu_load_info_data_t) / sizeof (integer_t)))
239239+240240+#ifdef PRIVATE
241241+/*
242242+ * CPU Statistics information
243243+ */
244244+struct _processor_statistics_np {
245245+ int32_t ps_cpuid;
246246+247247+ uint32_t ps_csw_count;
248248+ uint32_t ps_preempt_count;
249249+ uint32_t ps_preempted_rt_count;
250250+ uint32_t ps_preempted_by_rt_count;
251251+252252+ uint32_t ps_rt_sched_count;
253253+254254+ uint32_t ps_interrupt_count;
255255+ uint32_t ps_ipi_count;
256256+ uint32_t ps_timer_pop_count;
257257+258258+ uint64_t ps_runq_count_sum __attribute((aligned(8)));
259259+260260+ uint32_t ps_idle_transitions;
261261+ uint32_t ps_quantum_timer_expirations;
262262+};
263263+264264+#endif /* PRIVATE */
265265+266266+#ifdef KERNEL_PRIVATE
267267+268268+extern kern_return_t set_sched_stats_active(
269269+ boolean_t active);
270270+271271+extern kern_return_t get_sched_statistics(
272272+ struct _processor_statistics_np *out,
273273+ uint32_t *count);
274274+#endif /* KERNEL_PRIVATE */
275275+276276+277277+#endif /* _MACH_HOST_INFO_H_ */