]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOStatistics.h
xnu-1699.24.8.tar.gz
[apple/xnu.git] / iokit / IOKit / IOStatistics.h
1 /*
2 * Copyright (c) 2010 Apple Computer, 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 #ifndef _IOKIT_STATISTICS_H
30 #define _IOKIT_STATISTICS_H
31
32 #define IOSTATISTICS_SIG 'IOST'
33 #define IOSTATISTICS_SIG_USERCLIENT 'IOSU'
34 #define IOSTATISTICS_SIG_WORKLOOP 'IOSW'
35
36 /* Update when the binary format changes */
37 #define IOSTATISTICS_VER 0x2
38
39 enum {
40 kIOStatisticsDriverNameLength = 64,
41 kIOStatisticsClassNameLength = 64,
42 kIOStatisticsProcessNameLength = 20
43 };
44
45 enum {
46 kIOStatisticsDerivedEventSourceCounter = 0,
47 kIOStatisticsTimerEventSourceCounter,
48 kIOStatisticsCommandGateCounter,
49 kIOStatisticsCommandQueueCounter,
50 kIOStatisticsInterruptEventSourceCounter,
51 kIOStatisticsFilterInterruptEventSourceCounter
52 };
53
54 typedef uint32_t IOStatisticsCounterType;
55
56 enum {
57 kIOStatisticsGeneral = 0,
58 kIOStatisticsWorkLoop,
59 kIOStatisticsUserClient
60 };
61
62 /* Keep our alignments as intended */
63
64 #pragma pack(4)
65
66 /* Event Counters */
67
68 typedef struct IOStatisticsInterruptEventSources {
69 uint32_t created;
70 uint32_t produced;
71 uint32_t checksForWork;
72 } IOStatisticsInterruptEventSources;
73
74 typedef struct IOStatisticsTimerEventSources {
75 uint32_t created;
76 uint32_t openGateCalls;
77 uint32_t closeGateCalls;
78 uint64_t timeOnGate;
79 uint32_t timeouts;
80 uint32_t checksForWork;
81 } IOStatisticsTimerEventSources;
82
83 typedef struct IOStatisticsDerivedEventSources {
84 uint32_t created;
85 uint32_t openGateCalls;
86 uint32_t closeGateCalls;
87 uint64_t timeOnGate;
88 } IOStatisticsDerivedEventSources;
89
90 typedef struct IOStatisticsCommandGates {
91 uint32_t created;
92 uint32_t openGateCalls;
93 uint32_t closeGateCalls;
94 uint64_t timeOnGate;
95 uint32_t actionCalls;
96 } IOStatisticsCommandGates;
97
98 typedef struct IOStatisticsCommandQueues {
99 uint32_t created;
100 uint32_t actionCalls;
101 } IOStatisticsCommandQueues;
102
103 typedef struct IOStatisticsUserClients {
104 uint32_t created;
105 uint32_t clientCalls;
106 } IOStatisticsUserClients;
107
108 /* General mode */
109
110 typedef struct IOStatisticsHeader {
111 uint32_t sig; /* 'IOST' */
112 uint32_t ver; /* incremented with every data revision */
113
114 uint32_t seq; /* sequence ID */
115
116 uint32_t globalStatsOffset;
117 uint32_t kextStatsOffset;
118 uint32_t memoryStatsOffset;
119 uint32_t classStatsOffset;
120 uint32_t counterStatsOffset;
121 uint32_t kextIdentifiersOffset;
122 uint32_t classNamesOffset;
123
124 /* struct IOStatisticsGlobal */
125 /* struct IOStatisticsKext */
126 /* struct IOStatisticsMemory */
127 /* struct IOStatisticsClass */
128 /* struct IOStatisticsCounter */
129 /* struct IOStatisticsKextIdentifier */
130 /* struct IOStatisticsClassName */
131 } IOStatisticsHeader;
132
133 typedef struct IOStatisticsGlobal {
134 uint32_t kextCount;
135 uint32_t classCount;
136 uint32_t workloops;
137 } IOStatisticsGlobal;
138
139 typedef struct IOStatisticsKext {
140 uint32_t loadTag;
141 uint32_t loadSize;
142 uint32_t wiredSize;
143 uint32_t classes; /* Number of classes owned */
144 uint32_t classIndexes[]; /* Variable length array of owned class indexes */
145 } IOStatisticsKext;
146
147 typedef struct IOStatisticsMemory {
148 uint32_t allocatedSize;
149 uint32_t freedSize;
150 uint32_t allocatedAlignedSize;
151 uint32_t freedAlignedSize;
152 uint32_t allocatedContiguousSize;
153 uint32_t freedContiguousSize;
154 uint32_t allocatedPageableSize;
155 uint32_t freedPageableSize;
156 } IOStatisticsMemory;
157
158 typedef struct IOStatisticsClass {
159 uint32_t classID;
160 uint32_t superClassID;
161 uint32_t classSize;
162 } IOStatisticsClass;
163
164 typedef struct IOStatisticsCounter {
165 uint32_t classID;
166 uint32_t classInstanceCount;
167 struct IOStatisticsUserClients userClientStatistics;
168 struct IOStatisticsInterruptEventSources interruptEventSourceStatistics;
169 struct IOStatisticsInterruptEventSources filterInterruptEventSourceStatistics;
170 struct IOStatisticsTimerEventSources timerEventSourceStatistics;
171 struct IOStatisticsCommandGates commandGateStatistics;
172 struct IOStatisticsCommandQueues commandQueueStatistics;
173 struct IOStatisticsDerivedEventSources derivedEventSourceStatistics;
174 } IOStatisticsCounter;
175
176 typedef struct IOStatisticsKextIdentifier {
177 char identifier[kIOStatisticsDriverNameLength];
178 } IOStatisticsKextIdentifier;
179
180 typedef struct IOStatisticsClassName {
181 char name[kIOStatisticsClassNameLength];
182 } IOStatisticsClassName;
183
184 /* WorkLoop mode */
185
186 typedef struct IOStatisticsWorkLoop {
187 uint32_t attachedEventSources;
188 uint64_t timeOnGate;
189 uint32_t kextLoadTag;
190 uint32_t dependentKexts;
191 uint32_t dependentKextLoadTags[];
192 } IOStatisticsWorkLoop;
193
194 typedef struct IOStatisticsWorkLoopHeader {
195 uint32_t sig; /* 'IOSW */
196 uint32_t ver; /* incremented with every data revision */
197 uint32_t seq; /* sequence ID */
198 uint32_t workloopCount;
199 struct IOStatisticsWorkLoop workLoopStats;
200 } IOStatisticsWorkLoopHeader;
201
202 /* UserClient mode */
203
204 typedef struct IOStatisticsUserClientCall {
205 char processName[kIOStatisticsProcessNameLength];
206 int32_t pid;
207 uint32_t calls;
208 } IOStatisticsUserClientCall;
209
210 typedef struct IOStatisticsUserClientHeader {
211 uint32_t sig; /* 'IOSU */
212 uint32_t ver; /* incremented with every data revision */
213 uint32_t seq; /* sequence ID */
214 uint32_t processes;
215 struct IOStatisticsUserClientCall userClientCalls[];
216 } IOStatisticsUserClientHeader;
217
218 #pragma pack()
219
220 #endif /* _IOKIT_STATISTICS_H */