master
  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 */
 77typedef integer_t       *host_info_t;           /* varying array of int. */
 78typedef integer_t       *host_info64_t;         /* varying array of int. */
 79
 80#define HOST_INFO_MAX   (1024)          /* max array size */
 81typedef integer_t       host_info_data_t[HOST_INFO_MAX];
 82
 83#define KERNEL_VERSION_MAX (512)
 84typedef char    kernel_version_t[KERNEL_VERSION_MAX];
 85
 86#define KERNEL_BOOT_INFO_MAX (4096)
 87typedef char    kernel_boot_info_t[KERNEL_BOOT_INFO_MAX];
 88
 89/*
 90 *	Currently defined information.
 91 */
 92/* host_info() */
 93typedef 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#define HOST_PREFERRED_USER_ARCH 12     /* Get the preferred user-space architecture */
104
105
106struct host_can_has_debugger_info {
107	boolean_t       can_has_debugger;
108};
109typedef struct host_can_has_debugger_info       host_can_has_debugger_info_data_t;
110typedef struct host_can_has_debugger_info       *host_can_has_debugger_info_t;
111#define HOST_CAN_HAS_DEBUGGER_COUNT ((mach_msg_type_number_t) \
112	        (sizeof(host_can_has_debugger_info_data_t)/sizeof(integer_t)))
113
114#pragma pack(push, 4)
115
116struct host_basic_info {
117	integer_t               max_cpus;               /* max number of CPUs possible */
118	integer_t               avail_cpus;             /* number of CPUs now available */
119	natural_t               memory_size;            /* size of memory in bytes, capped at 2 GB */
120	cpu_type_t              cpu_type;               /* cpu type */
121	cpu_subtype_t           cpu_subtype;            /* cpu subtype */
122	cpu_threadtype_t        cpu_threadtype;         /* cpu threadtype */
123	integer_t               physical_cpu;           /* number of physical CPUs now available */
124	integer_t               physical_cpu_max;       /* max number of physical CPUs possible */
125	integer_t               logical_cpu;            /* number of logical cpu now available */
126	integer_t               logical_cpu_max;        /* max number of physical CPUs possible */
127	uint64_t                max_mem;                /* actual size of physical memory */
128};
129
130#pragma pack(pop)
131
132typedef struct host_basic_info  host_basic_info_data_t;
133typedef struct host_basic_info  *host_basic_info_t;
134#define HOST_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
135	        (sizeof(host_basic_info_data_t)/sizeof(integer_t)))
136
137struct host_sched_info {
138	integer_t       min_timeout;    /* minimum timeout in milliseconds */
139	integer_t       min_quantum;    /* minimum quantum in milliseconds */
140};
141
142typedef struct host_sched_info  host_sched_info_data_t;
143typedef struct host_sched_info  *host_sched_info_t;
144#define HOST_SCHED_INFO_COUNT ((mach_msg_type_number_t) \
145	        (sizeof(host_sched_info_data_t)/sizeof(integer_t)))
146
147struct kernel_resource_sizes {
148	natural_t       task;
149	natural_t       thread;
150	natural_t       port;
151	natural_t       memory_region;
152	natural_t       memory_object;
153};
154
155typedef struct kernel_resource_sizes    kernel_resource_sizes_data_t;
156typedef struct kernel_resource_sizes    *kernel_resource_sizes_t;
157#define HOST_RESOURCE_SIZES_COUNT ((mach_msg_type_number_t) \
158	        (sizeof(kernel_resource_sizes_data_t)/sizeof(integer_t)))
159
160struct host_priority_info {
161	integer_t       kernel_priority;
162	integer_t       system_priority;
163	integer_t       server_priority;
164	integer_t       user_priority;
165	integer_t       depress_priority;
166	integer_t       idle_priority;
167	integer_t       minimum_priority;
168	integer_t       maximum_priority;
169};
170
171typedef struct host_priority_info       host_priority_info_data_t;
172typedef struct host_priority_info       *host_priority_info_t;
173#define HOST_PRIORITY_INFO_COUNT ((mach_msg_type_number_t) \
174	        (sizeof(host_priority_info_data_t)/sizeof(integer_t)))
175
176/* host_statistics() */
177#define HOST_LOAD_INFO          1       /* System loading stats */
178#define HOST_VM_INFO            2       /* Virtual memory stats */
179#define HOST_CPU_LOAD_INFO      3       /* CPU load stats */
180
181/* host_statistics64() */
182#define HOST_VM_INFO64          4       /* 64-bit virtual memory stats */
183#define HOST_EXTMOD_INFO64      5       /* External modification stats */
184#define HOST_EXPIRED_TASK_INFO  6       /* Statistics for expired tasks */
185
186
187
188struct host_load_info {
189	integer_t       avenrun[3];     /* scaled by LOAD_SCALE */
190	integer_t       mach_factor[3]; /* scaled by LOAD_SCALE */
191};
192
193typedef struct host_load_info   host_load_info_data_t;
194typedef struct host_load_info   *host_load_info_t;
195#define HOST_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
196	        (sizeof(host_load_info_data_t)/sizeof(integer_t)))
197
198typedef struct vm_purgeable_info        host_purgable_info_data_t;
199typedef struct vm_purgeable_info        *host_purgable_info_t;
200#define HOST_VM_PURGABLE_COUNT ((mach_msg_type_number_t) \
201	        (sizeof(host_purgable_info_data_t)/sizeof(integer_t)))
202
203/* in <mach/vm_statistics.h> */
204/* vm_statistics64 */
205#define HOST_VM_INFO64_COUNT ((mach_msg_type_number_t) \
206	        (sizeof(vm_statistics64_data_t)/sizeof(integer_t)))
207
208/* size of the latest version of the structure */
209#define HOST_VM_INFO64_LATEST_COUNT HOST_VM_INFO64_COUNT
210#define HOST_VM_INFO64_REV2_COUNT HOST_VM_INFO64_COUNT
211#define HOST_VM_INFO64_REV1_COUNT ((mach_msg_type_number_t) \
212	 (offsetof(vm_statistics64_data_t, swapped_count) / sizeof(integer_t)))
213/* previous versions: adjust the size according to what was added each time */
214#define HOST_VM_INFO64_REV0_COUNT ((mach_msg_type_number_t) \
215	 (offsetof(vm_statistics64_data_t, decompressions) / sizeof(integer_t)))
216
217/* in <mach/vm_statistics.h> */
218/* vm_extmod_statistics */
219#define HOST_EXTMOD_INFO64_COUNT ((mach_msg_type_number_t) \
220	    (sizeof(vm_extmod_statistics_data_t)/sizeof(integer_t)))
221
222/* size of the latest version of the structure */
223#define HOST_EXTMOD_INFO64_LATEST_COUNT HOST_EXTMOD_INFO64_COUNT
224
225/* vm_statistics */
226#define HOST_VM_INFO_COUNT ((mach_msg_type_number_t) \
227	        (sizeof(vm_statistics_data_t)/sizeof(integer_t)))
228
229/* size of the latest version of the structure */
230#define HOST_VM_INFO_LATEST_COUNT HOST_VM_INFO_COUNT
231#define HOST_VM_INFO_REV2_COUNT HOST_VM_INFO_LATEST_COUNT
232/* previous versions: adjust the size according to what was added each time */
233#define HOST_VM_INFO_REV1_COUNT /* added "speculative_count" (1 int) */ \
234	((mach_msg_type_number_t) \
235	 (HOST_VM_INFO_REV2_COUNT - 1))
236#define HOST_VM_INFO_REV0_COUNT /* added "purgable" info (2 ints) */    \
237	((mach_msg_type_number_t) \
238	 (HOST_VM_INFO_REV1_COUNT - 2))
239
240struct host_cpu_load_info {             /* number of ticks while running... */
241	natural_t       cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */
242};
243
244typedef struct host_cpu_load_info       host_cpu_load_info_data_t;
245typedef struct host_cpu_load_info       *host_cpu_load_info_t;
246#define HOST_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
247	        (sizeof (host_cpu_load_info_data_t) / sizeof (integer_t)))
248
249struct host_preferred_user_arch {
250	cpu_type_t      cpu_type;       /* Preferred user-space cpu type */
251	cpu_subtype_t   cpu_subtype;    /* Preferred user-space cpu subtype */
252};
253
254typedef struct host_preferred_user_arch host_preferred_user_arch_data_t;
255typedef struct host_preferred_user_arch *host_preferred_user_arch_t;
256#define HOST_PREFERRED_USER_ARCH_COUNT ((mach_msg_type_number_t) \
257	        (sizeof(host_preferred_user_arch_data_t)/sizeof(integer_t)))
258
259
260
261
262#endif  /* _MACH_HOST_INFO_H_ */