]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/resource_notify.defs
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / mach / resource_notify.defs
CommitLineData
39037602
A
1/*
2 * Copyright (c) 2016 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#include <mach/mach_types.defs> // mach_port_t
30#include <mach/clock_types.defs> // mach_timespec_t
31
32#if KERNEL_USER
33import <mach/resource_monitors.h>;
34import <mach/clock_types.h>;
35#else
36import <System/mach/resource_monitors.h>;
37import <System/mach/clock_types.h>;
38#endif
39
40// match struct proc.p_name / proc_name_t as of January 2016
41#define MAXCOMLEN 16
42type proc_name_t = array [2*MAXCOMLEN+1] of char;
43type posix_path_t = array [512] of char; // ?? can't compile w/1024?
44type resource_notify_flags_t = uint64_t;
45
46/* The kernel sends the message, so we compile with KernelUser when
47 building in the kernel. */
48subsystem
49#if KERNEL_USER
50 KernelUser
51#endif
52 resource_notify 827800; /* 'R''N'00 */
53
54UserPrefix send_;
55ServerPrefix receive_;
56
57
58SimpleRoutine cpu_usage_violation(
59 receiver : mach_port_t;
60
61 /* violator */
62 procname : proc_name_t;
63 pid : int;
64 killed_proc_path : posix_path_t; /* filled in if fatal */
65
66 /* violation */
67 timestamp : mach_timespec_t; /* 32b time, see 25567702 */
68 observed_cpu_nsecs : int64_t;
69 observation_nsecs : int64_t; /* time it took to hit limit */
70
71 /* threshold crossed: calculated from proc_set_cpumon_params() */
72 cpu_nsecs_allowed : int64_t;
73 limit_window_nsecs : int64_t; /* over this period */
74
75 flags : resource_notify_flags_t
76);
77
78SimpleRoutine cpu_wakes_violation(
79 receiver : mach_port_t;
80
81 /* violator */
82 procname : proc_name_t;
83 pid : int;
84 killed_proc_path : posix_path_t; /* filled in if fatal */
85
86 /* violation */
87 timestamp : mach_timespec_t;
88 observed_cpu_wakes : int64_t;
89 observation_nsecs : int64_t; /* time it took to hit limit */
90
91 /* threshold crossed: calculated from proc_set_wakemon_params() */
92 cpu_wakes_allowed : int64_t;
93 limit_window_nsecs : int64_t; /* over this period */
94
95 flags : resource_notify_flags_t
96);
97
98SimpleRoutine disk_writes_violation(
99 receiver : mach_port_t;
100
101 /* violator */
102 procname : proc_name_t;
103 pid : int;
104 killed_proc_path : posix_path_t; /* filled in if fatal */
105
106 /* violation */
107 timestamp : mach_timespec_t;
108 observed_bytes_dirtied : int64_t;
109 observation_nsecs : int64_t; /* time it took to hit limit */
110
111 /* threshold */
112 bytes_dirtied_allowed : int64_t;
113 limit_window_nsecs : int64_t; /* over this period */
114
115 flags : resource_notify_flags_t
116);