2 * @APPLE_LICENSE_HEADER_START@
4 * Copyright (c) 2012 Apple Computer, Inc. All Rights Reserved.
6 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. The rights granted to you under the License
12 * may not be used to create, or enable the creation or redistribution of,
13 * unlawful or unlicensed copies of an Apple operating system, or to
14 * circumvent, violate, or enable the circumvention or violation of, any
15 * terms of an Apple operating system software license agreement.
17 * Please obtain a copy of the License at
18 * http://www.opensource.apple.com/apsl/ and read it before using this file.
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
31 #ifndef _IOREPORT_TYPES_H_
32 #define _IOREPORT_TYPES_H_
40 /*! @const kIOReportInvalidValue
41 @const kIOReportInvalidIntValue
42 @abstract cardinal value used to indicate data errors
45 kIOReportInvalidValue and kIOReportInvalidIntValue have the
46 same bit pattern so that clients checking for one or the other
47 don't have to worry about getting the signedness right.
49 #define kIOReportInvalidValue UINT64_MAX
50 #define kIOReportInvalidIntValue (int64_t)kIOReportInvalidValue
52 // IOReportChannelType.categories
53 typedef uint16_t IOReportCategories
;
54 #define kIOReportCategoryPower (1 << 1) // and energy
55 #define kIOReportCategoryTraffic (1 << 2)
56 #define kIOReportCategoryPerformance (1 << 3)
57 #define kIOReportCategoryPeripheral (1 << 4)
58 // future categories TBD
59 #define kIOReportCategoryDebug (1 << 15)
60 #define kIOReportInvalidCategory UINT16_MAX
63 // IOReportChannelType.report_format
64 typedef uint8_t IOReportFormat
;
66 kIOReportInvalidFormat
= 0,
67 kIOReportFormatSimple
= 1,
68 kIOReportFormatState
= 2,
69 kIOReportFormatHistogram
= 3
72 // simple report values
78 } __attribute((packed
)) IOSimpleReportValues
;
80 // state report values
82 uint64_t state_id
; // 0..N-1 or 8-char code (see MAKEID())
83 uint64_t intransitions
; // number of transitions into this state
84 uint64_t upticks
; // ticks spent in state (local timebase)
85 uint64_t last_intransition
; // ticks at last in-transition
86 } __attribute((packed
)) IOStateReportValues
;
88 // histograme report values
94 } __attribute((packed
)) IOHistogramReportValues
;
96 // configuration actions generally change future behavior
97 typedef uint32_t IOReportConfigureAction
;
99 // basics (in common operational order)
100 kIOReportEnable
= 0x01,
101 kIOReportGetDimensions
= 0x02,
102 kIOReportDisable
= 0x00,
104 // Enable/disable modifiers
105 kIOReportNotifyHubOnChange
= 0x10, // triggered polling
107 kIOReportTraceOnChange
= 0x20 // kdebug.h tracing
110 // update actions should not have observable side effects
111 typedef uint32_t IOReportUpdateAction
;
113 kIOReportCopyChannelData
= 1,
114 kIOReportTraceChannelData
= 2
118 uint8_t report_format
; // Histogram, StateResidency, etc.
119 uint8_t reserved
; // must be zero
120 uint16_t categories
; // power, traffic, etc (omnibus obs.)
121 uint16_t nelements
; // internal size of channel
123 // only meaningful in the data pipeline
124 int16_t element_idx
; // 0..nelements-1
125 // -1..-(nelements) = invalid (13127884)
126 } __attribute((packed
)) IOReportChannelType
;
129 @define IOREPORT_MAKECHID
130 @abstract convert up to 8 printable characters into a 64-bit channel ID
131 @param <char0..char7> - printable chars to be packed into a channel ID
132 @result a 64-bit channel ID with an implicit ASCII name
133 @discussion A simple example:
134 IOREPORT_MAKECHID('H', 'i', ' ', 'w', 'o', 'r', 'l', 'd');
135 will evaluate to 0x686920776f726c64. Any NUL bytes are
136 ignored (by libIOReport) for naming purposes, but will
137 appear in the channel ID. Using a non-NUL non-printable
138 character will disable the implicit name. Putting NUL
139 bytes first eliminates trailing zeros when the channel
140 ID is printed as hex. For example:
141 IORERPORT_MAKECHID('\0','\0','n','x','f','e','r','s');
142 To see the text, use xxd -r -p # not -rp; see 12976241
144 #define __IOR_lshiftchr(c, chshift) ((uint64_t)(c) << (8*(chshift)))
145 #define IOREPORT_MAKEID(A, B, C, D, E, F, G, H) \
146 (__IOR_lshiftchr(A, 7) | __IOR_lshiftchr(B, 6) | __IOR_lshiftchr(C, 5) \
147 | __IOR_lshiftchr(D, 4) | __IOR_lshiftchr(E, 3) | __IOR_lshiftchr(F, 2) \
148 | __IOR_lshiftchr(G, 1) | __IOR_lshiftchr(H, 0))
152 IOReportChannelType channel_type
;
157 IOReportChannel channels
[];
158 } IOReportChannelList
;
161 uint64_t provider_id
;
162 IOReportChannel channel
;
167 IOReportInterest interests
[];
168 } IOReportInterestList
;
172 } __attribute((packed
)) IOReportElementValues
;
175 uint64_t provider_id
;
177 IOReportChannelType channel_type
;
178 uint64_t timestamp
; // mach_absolute_time()
179 IOReportElementValues values
;
180 } __attribute((packed
)) IOReportElement
;
186 #endif // _IOREPORT_TYPES_H_